does cmake scripts execute sequentially?

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

does cmake scripts execute sequentially?

Carlton banks
I seem to have some problems executing one of my submodules cmakelist.

MESSAGE(“In record CMAKELIST”)

# Include externalproject {portaudio} if lib/portaudio don't exist.
MESSAGE(“Download external project”)

INCLUDE(ExternalProject)
ExternalProject_Add(project_portaudio
    GIT_REPOSITORY      https://git.assembla.com/portaudio.git
    PREFIX              lib/portaudio
    CONFIGURE_COMMAND   <SOURCE_DIR>/configure
    BUILD_IN_SOURCE     1
    BUILD_COMMAND       make
    INSTALL_COMMAND     sudo make install
)
ExternalProject_Get_Property(project_portaudio BINARY_DIR)
ExternalProject_Get_Property(project_portaudio SOURCE_DIR)

SET(portaudio_lib_dir "${BINARY_DIR}/lib/.libs")
SET(portaudio_inc_dir "${SOURCE_DIR}/include")

add_library(record STATIC record.cpp record.h)
add_library(libaudio libportaudio.a PATHS ${portaudio_lib_dir})



#
# this makes sure we have compiler flags that allow class::class() = default (>= C++11)
target_compile_features(record PUBLIC cxx_defaulted_functions)




target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${project_portaudio})


It cannot find libportaudio.a as externalproject_add() is not being executed, the command it executes add_library, which fails as the project has not been downloaded…


what is wrong here?
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: does cmake scripts execute sequentially?

Craig Scott-3


On Sun, Oct 29, 2017 at 10:36 AM, Carlton Banks <[hidden email]> wrote:
I seem to have some problems executing one of my submodules cmakelist.

MESSAGE(“In record CMAKELIST”)

# Include externalproject {portaudio} if lib/portaudio don't exist.
MESSAGE(“Download external project”)

INCLUDE(ExternalProject)
ExternalProject_Add(project_portaudio
    GIT_REPOSITORY      https://git.assembla.com/portaudio.git
    PREFIX              lib/portaudio
    CONFIGURE_COMMAND   <SOURCE_DIR>/configure
    BUILD_IN_SOURCE     1
    BUILD_COMMAND       make
    INSTALL_COMMAND     sudo make install
)
ExternalProject_Get_Property(project_portaudio BINARY_DIR)
ExternalProject_Get_Property(project_portaudio SOURCE_DIR)

SET(portaudio_lib_dir "${BINARY_DIR}/lib/.libs")
SET(portaudio_inc_dir "${SOURCE_DIR}/include")

add_library(record STATIC record.cpp record.h)
add_library(libaudio libportaudio.a PATHS ${portaudio_lib_dir})

What is this second add_library() command intended to do? I'm guessing you probably instead want to be doing something like this (untested, but hopefully in the ballpark):

add_library(portaudio STATIC IMPORTED)
set_target_properties(portaudio PROPERTIES
    IMPORTED_LOCATION ${BINARY_DIR}/lib/.libs/libportaudio.a
)
target_include_directories(portaudio INTERFACE
    ${SOURCE_DIR}/include
)
add_dependencies(portaudio project_portaudio)     # Not sure if this is allowed for imported targets though

I don't recall off the top of my head whether STATIC IMPORTED or INTERFACE IMPORTED would be the right way to call add_library() in the above, so try the latter if the former doesn't work for you. 





#
# this makes sure we have compiler flags that allow class::class() = default (>= C++11)
target_compile_features(record PUBLIC cxx_defaulted_functions)




target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${project_portaudio})

You won't need this if you define the portaudio imported library as per my example above.

 


It cannot find libportaudio.a as externalproject_add() is not being executed, the command it executes add_library, which fails as the project has not been downloaded…


what is wrong here?

The reason for this specific problem is that there's no dependency relationship between the project_portaudio target defined by the ExternalProject_Add() call and the record target. Such a relationship is only created through a suitable call to target_link_libraries() or add_dependencies(), or through arguments like DEPENDS for commands that offer such features (e.g. add_custom_target() and add_custom_command()).


--
Craig Scott
Melbourne, Australia

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: does cmake scripts execute sequentially?

Carlton banks
CMake Error at src/include/record/CMakeLists.txt:28 (target_include_directories):
  Cannot specify include directories for imported target "portaudio".


is the problem that externalProject_add only is executed when make is executed and not when cmake is executed’?
what is `portaudio` here referring to?
Den 29. okt. 2017 kl. 02.19 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 10:36 AM, Carlton Banks <[hidden email]> wrote:
I seem to have some problems executing one of my submodules cmakelist.

MESSAGE(“In record CMAKELIST”)

# Include externalproject {portaudio} if lib/portaudio don't exist.
MESSAGE(“Download external project”)

INCLUDE(ExternalProject)
ExternalProject_Add(project_portaudio
    GIT_REPOSITORY      https://git.assembla.com/portaudio.git
    PREFIX              lib/portaudio
    CONFIGURE_COMMAND   <SOURCE_DIR>/configure
    BUILD_IN_SOURCE     1
    BUILD_COMMAND       make
    INSTALL_COMMAND     sudo make install
)
ExternalProject_Get_Property(project_portaudio BINARY_DIR)
ExternalProject_Get_Property(project_portaudio SOURCE_DIR)

SET(portaudio_lib_dir "${BINARY_DIR}/lib/.libs")
SET(portaudio_inc_dir "${SOURCE_DIR}/include")

add_library(record STATIC record.cpp record.h)
add_library(libaudio libportaudio.a PATHS ${portaudio_lib_dir})

What is this second add_library() command intended to do? I'm guessing you probably instead want to be doing something like this (untested, but hopefully in the ballpark):

add_library(portaudio STATIC IMPORTED)
set_target_properties(portaudio PROPERTIES
    IMPORTED_LOCATION ${BINARY_DIR}/lib/.libs/libportaudio.a
)
target_include_directories(portaudio INTERFACE
    ${SOURCE_DIR}/include
)
add_dependencies(portaudio project_portaudio)     # Not sure if this is allowed for imported targets though

I don't recall off the top of my head whether STATIC IMPORTED or INTERFACE IMPORTED would be the right way to call add_library() in the above, so try the latter if the former doesn't work for you. 





#
# this makes sure we have compiler flags that allow class::class() = default (>= C++11)
target_compile_features(record PUBLIC cxx_defaulted_functions)




target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${project_portaudio})

You won't need this if you define the portaudio imported library as per my example above.

 


It cannot find libportaudio.a as externalproject_add() is not being executed, the command it executes add_library, which fails as the project has not been downloaded…


what is wrong here?

The reason for this specific problem is that there's no dependency relationship between the project_portaudio target defined by the ExternalProject_Add() call and the record target. Such a relationship is only created through a suitable call to target_link_libraries() or add_dependencies(), or through arguments like DEPENDS for commands that offer such features (e.g. add_custom_target() and add_custom_command()).


--
Craig Scott
Melbourne, Australia


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: does cmake scripts execute sequentially?

Craig Scott-3


On Sun, Oct 29, 2017 at 11:26 AM, Carlton Banks <[hidden email]> wrote:
CMake Error at src/include/record/CMakeLists.txt:28 (target_include_directories):
  Cannot specify include directories for imported target "portaudio".


is the problem that externalProject_add only is executed when make is executed and not when cmake is executed’?
what is `portaudio` here referring to?

The name "portaudio" is the target defined by the add_library() call in my example (the imported target that represents what the ExternalProject_Add() is going to create at build time). Did you also try the INTERFACE IMPORTED alternative? It would be more useful if you showed the full CMakeLists.txt rather than just the error message.


 
Den 29. okt. 2017 kl. 02.19 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 10:36 AM, Carlton Banks <[hidden email]> wrote:
I seem to have some problems executing one of my submodules cmakelist.

MESSAGE(“In record CMAKELIST”)

# Include externalproject {portaudio} if lib/portaudio don't exist.
MESSAGE(“Download external project”)

INCLUDE(ExternalProject)
ExternalProject_Add(project_portaudio
    GIT_REPOSITORY      https://git.assembla.com/portaudio.git
    PREFIX              lib/portaudio
    CONFIGURE_COMMAND   <SOURCE_DIR>/configure
    BUILD_IN_SOURCE     1
    BUILD_COMMAND       make
    INSTALL_COMMAND     sudo make install
)
ExternalProject_Get_Property(project_portaudio BINARY_DIR)
ExternalProject_Get_Property(project_portaudio SOURCE_DIR)

SET(portaudio_lib_dir "${BINARY_DIR}/lib/.libs")
SET(portaudio_inc_dir "${SOURCE_DIR}/include")

add_library(record STATIC record.cpp record.h)
add_library(libaudio libportaudio.a PATHS ${portaudio_lib_dir})

What is this second add_library() command intended to do? I'm guessing you probably instead want to be doing something like this (untested, but hopefully in the ballpark):

add_library(portaudio STATIC IMPORTED)
set_target_properties(portaudio PROPERTIES
    IMPORTED_LOCATION ${BINARY_DIR}/lib/.libs/libportaudio.a
)
target_include_directories(portaudio INTERFACE
    ${SOURCE_DIR}/include
)
add_dependencies(portaudio project_portaudio)     # Not sure if this is allowed for imported targets though

I don't recall off the top of my head whether STATIC IMPORTED or INTERFACE IMPORTED would be the right way to call add_library() in the above, so try the latter if the former doesn't work for you. 





#
# this makes sure we have compiler flags that allow class::class() = default (>= C++11)
target_compile_features(record PUBLIC cxx_defaulted_functions)




target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${project_portaudio})

You won't need this if you define the portaudio imported library as per my example above.

 


It cannot find libportaudio.a as externalproject_add() is not being executed, the command it executes add_library, which fails as the project has not been downloaded…


what is wrong here?

The reason for this specific problem is that there's no dependency relationship between the project_portaudio target defined by the ExternalProject_Add() call and the record target. Such a relationship is only created through a suitable call to target_link_libraries() or add_dependencies(), or through arguments like DEPENDS for commands that offer such features (e.g. add_custom_target() and add_custom_command()).


--
Craig Scott
Melbourne, Australia




--
Craig Scott
Melbourne, Australia

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: does cmake scripts execute sequentially?

Carlton banks

Den 29. okt. 2017 kl. 02.29 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 11:26 AM, Carlton Banks <[hidden email]> wrote:
CMake Error at src/include/record/CMakeLists.txt:28 (target_include_directories):
  Cannot specify include directories for imported target "portaudio".


is the problem that externalProject_add only is executed when make is executed and not when cmake is executed’?
what is `portaudio` here referring to?

The name "portaudio" is the target defined by the add_library() call in my example (the imported target that represents what the ExternalProject_Add() is going to create at build time).
ok.

Did you also try the INTERFACE IMPORTED alternative?
Still the same.. 

It would be more useful if you showed the full CMakeLists.txt rather than just the error message.


The submodule cmakelist: 


tree structure


The outer cmakelist includes the inner directories. 


 
Den 29. okt. 2017 kl. 02.19 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 10:36 AM, Carlton Banks <[hidden email]> wrote:
I seem to have some problems executing one of my submodules cmakelist.

MESSAGE(“In record CMAKELIST”)

# Include externalproject {portaudio} if lib/portaudio don't exist.
MESSAGE(“Download external project”)

INCLUDE(ExternalProject)
ExternalProject_Add(project_portaudio
    GIT_REPOSITORY      https://git.assembla.com/portaudio.git
    PREFIX              lib/portaudio
    CONFIGURE_COMMAND   <SOURCE_DIR>/configure
    BUILD_IN_SOURCE     1
    BUILD_COMMAND       make
    INSTALL_COMMAND     sudo make install
)
ExternalProject_Get_Property(project_portaudio BINARY_DIR)
ExternalProject_Get_Property(project_portaudio SOURCE_DIR)

SET(portaudio_lib_dir "${BINARY_DIR}/lib/.libs")
SET(portaudio_inc_dir "${SOURCE_DIR}/include")

add_library(record STATIC record.cpp record.h)
add_library(libaudio libportaudio.a PATHS ${portaudio_lib_dir})

What is this second add_library() command intended to do? I'm guessing you probably instead want to be doing something like this (untested, but hopefully in the ballpark):

add_library(portaudio STATIC IMPORTED)
set_target_properties(portaudio PROPERTIES
    IMPORTED_LOCATION ${BINARY_DIR}/lib/.libs/libportaudio.a
)
target_include_directories(portaudio INTERFACE
    ${SOURCE_DIR}/include
)
add_dependencies(portaudio project_portaudio)     # Not sure if this is allowed for imported targets though

I don't recall off the top of my head whether STATIC IMPORTED or INTERFACE IMPORTED would be the right way to call add_library() in the above, so try the latter if the former doesn't work for you. 





#
# this makes sure we have compiler flags that allow class::class() = default (>= C++11)
target_compile_features(record PUBLIC cxx_defaulted_functions)




target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${project_portaudio})

You won't need this if you define the portaudio imported library as per my example above.

 


It cannot find libportaudio.a as externalproject_add() is not being executed, the command it executes add_library, which fails as the project has not been downloaded…


what is wrong here?

The reason for this specific problem is that there's no dependency relationship between the project_portaudio target defined by the ExternalProject_Add() call and the record target. Such a relationship is only created through a suitable call to target_link_libraries() or add_dependencies(), or through arguments like DEPENDS for commands that offer such features (e.g. add_custom_target() and add_custom_command()).


--
Craig Scott
Melbourne, Australia




--
Craig Scott
Melbourne, Australia


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: does cmake scripts execute sequentially?

Craig Scott-3
Ah, sorry. This particular problem has been fixed on CMake master, but it won't be in the 3.10 release (in release candidate stage), so that isn't going to help you right now. Possibly you might be able to modify the relevant target property directly rather than using target_include_directories() - again this is untested, but worth a try:

set_property(TARGET portaudio APPEND PROPERTY
    INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR}/include
)

If that doesn't work, then I guess modifying your original method to use the correct path may be an alternative workaround:

target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${SOURCE_DIR}/include)




On Sun, Oct 29, 2017 at 11:47 AM, Carlton Banks <[hidden email]> wrote:

Den 29. okt. 2017 kl. 02.29 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 11:26 AM, Carlton Banks <[hidden email]> wrote:
CMake Error at src/include/record/CMakeLists.txt:28 (target_include_directories):
  Cannot specify include directories for imported target "portaudio".


is the problem that externalProject_add only is executed when make is executed and not when cmake is executed’?
what is `portaudio` here referring to?

The name "portaudio" is the target defined by the add_library() call in my example (the imported target that represents what the ExternalProject_Add() is going to create at build time).
ok.

Did you also try the INTERFACE IMPORTED alternative?
Still the same.. 

It would be more useful if you showed the full CMakeLists.txt rather than just the error message.


The submodule cmakelist: 


tree structure


The outer cmakelist includes the inner directories. 


 
Den 29. okt. 2017 kl. 02.19 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 10:36 AM, Carlton Banks <[hidden email]> wrote:
I seem to have some problems executing one of my submodules cmakelist.

MESSAGE(“In record CMAKELIST”)

# Include externalproject {portaudio} if lib/portaudio don't exist.
MESSAGE(“Download external project”)

INCLUDE(ExternalProject)
ExternalProject_Add(project_portaudio
    GIT_REPOSITORY      https://git.assembla.com/portaudio.git
    PREFIX              lib/portaudio
    CONFIGURE_COMMAND   <SOURCE_DIR>/configure
    BUILD_IN_SOURCE     1
    BUILD_COMMAND       make
    INSTALL_COMMAND     sudo make install
)
ExternalProject_Get_Property(project_portaudio BINARY_DIR)
ExternalProject_Get_Property(project_portaudio SOURCE_DIR)

SET(portaudio_lib_dir "${BINARY_DIR}/lib/.libs")
SET(portaudio_inc_dir "${SOURCE_DIR}/include")

add_library(record STATIC record.cpp record.h)
add_library(libaudio libportaudio.a PATHS ${portaudio_lib_dir})

What is this second add_library() command intended to do? I'm guessing you probably instead want to be doing something like this (untested, but hopefully in the ballpark):

add_library(portaudio STATIC IMPORTED)
set_target_properties(portaudio PROPERTIES
    IMPORTED_LOCATION ${BINARY_DIR}/lib/.libs/libportaudio.a
)
target_include_directories(portaudio INTERFACE
    ${SOURCE_DIR}/include
)
add_dependencies(portaudio project_portaudio)     # Not sure if this is allowed for imported targets though

I don't recall off the top of my head whether STATIC IMPORTED or INTERFACE IMPORTED would be the right way to call add_library() in the above, so try the latter if the former doesn't work for you. 





#
# this makes sure we have compiler flags that allow class::class() = default (>= C++11)
target_compile_features(record PUBLIC cxx_defaulted_functions)




target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${project_portaudio})

You won't need this if you define the portaudio imported library as per my example above.

 


It cannot find libportaudio.a as externalproject_add() is not being executed, the command it executes add_library, which fails as the project has not been downloaded…


what is wrong here?

The reason for this specific problem is that there's no dependency relationship between the project_portaudio target defined by the ExternalProject_Add() call and the record target. Such a relationship is only created through a suitable call to target_link_libraries() or add_dependencies(), or through arguments like DEPENDS for commands that offer such features (e.g. add_custom_target() and add_custom_command()).


--
Craig Scott
Melbourne, Australia




--
Craig Scott
Melbourne, Australia




--
Craig Scott
Melbourne, Australia

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: does cmake scripts execute sequentially?

J Decker
I recently added externaproject_add() to download a library, but since it doesn't do the download until build, I had to put a conditional around the second part of the cmake that used the libraries it produced so it would do a cmake configure/generate, cmake build, cmake configure/generate and a final build and all was good... 


but I coudln't reference any directories that didn't exist yet in include_directories, or link_directories...until the project had been at least partially built.

On Sat, Oct 28, 2017 at 6:00 PM, Craig Scott <[hidden email]> wrote:
Ah, sorry. This particular problem has been fixed on CMake master, but it won't be in the 3.10 release (in release candidate stage), so that isn't going to help you right now. Possibly you might be able to modify the relevant target property directly rather than using target_include_directories() - again this is untested, but worth a try:

set_property(TARGET portaudio APPEND PROPERTY
    INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR}/include
)

If that doesn't work, then I guess modifying your original method to use the correct path may be an alternative workaround:

target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${SOURCE_DIR}/include)




On Sun, Oct 29, 2017 at 11:47 AM, Carlton Banks <[hidden email]> wrote:

Den 29. okt. 2017 kl. 02.29 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 11:26 AM, Carlton Banks <[hidden email]> wrote:
CMake Error at src/include/record/CMakeLists.txt:28 (target_include_directories):
  Cannot specify include directories for imported target "portaudio".


is the problem that externalProject_add only is executed when make is executed and not when cmake is executed’?
what is `portaudio` here referring to?

The name "portaudio" is the target defined by the add_library() call in my example (the imported target that represents what the ExternalProject_Add() is going to create at build time).
ok.

Did you also try the INTERFACE IMPORTED alternative?
Still the same.. 

It would be more useful if you showed the full CMakeLists.txt rather than just the error message.


The submodule cmakelist: 


tree structure


The outer cmakelist includes the inner directories. 


 
Den 29. okt. 2017 kl. 02.19 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 10:36 AM, Carlton Banks <[hidden email]> wrote:
I seem to have some problems executing one of my submodules cmakelist.

MESSAGE(“In record CMAKELIST”)

# Include externalproject {portaudio} if lib/portaudio don't exist.
MESSAGE(“Download external project”)

INCLUDE(ExternalProject)
ExternalProject_Add(project_portaudio
    GIT_REPOSITORY      https://git.assembla.com/portaudio.git
    PREFIX              lib/portaudio
    CONFIGURE_COMMAND   <SOURCE_DIR>/configure
    BUILD_IN_SOURCE     1
    BUILD_COMMAND       make
    INSTALL_COMMAND     sudo make install
)
ExternalProject_Get_Property(project_portaudio BINARY_DIR)
ExternalProject_Get_Property(project_portaudio SOURCE_DIR)

SET(portaudio_lib_dir "${BINARY_DIR}/lib/.libs")
SET(portaudio_inc_dir "${SOURCE_DIR}/include")

add_library(record STATIC record.cpp record.h)
add_library(libaudio libportaudio.a PATHS ${portaudio_lib_dir})

What is this second add_library() command intended to do? I'm guessing you probably instead want to be doing something like this (untested, but hopefully in the ballpark):

add_library(portaudio STATIC IMPORTED)
set_target_properties(portaudio PROPERTIES
    IMPORTED_LOCATION ${BINARY_DIR}/lib/.libs/libportaudio.a
)
target_include_directories(portaudio INTERFACE
    ${SOURCE_DIR}/include
)
add_dependencies(portaudio project_portaudio)     # Not sure if this is allowed for imported targets though

I don't recall off the top of my head whether STATIC IMPORTED or INTERFACE IMPORTED would be the right way to call add_library() in the above, so try the latter if the former doesn't work for you. 





#
# this makes sure we have compiler flags that allow class::class() = default (>= C++11)
target_compile_features(record PUBLIC cxx_defaulted_functions)




target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${project_portaudio})

You won't need this if you define the portaudio imported library as per my example above.

 


It cannot find libportaudio.a as externalproject_add() is not being executed, the command it executes add_library, which fails as the project has not been downloaded…


what is wrong here?

The reason for this specific problem is that there's no dependency relationship between the project_portaudio target defined by the ExternalProject_Add() call and the record target. Such a relationship is only created through a suitable call to target_link_libraries() or add_dependencies(), or through arguments like DEPENDS for commands that offer such features (e.g. add_custom_target() and add_custom_command()).


--
Craig Scott
Melbourne, Australia




--
Craig Scott
Melbourne, Australia




--
Craig Scott
Melbourne, Australia

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: does cmake scripts execute sequentially?

Carlton banks

Den 29. okt. 2017 kl. 02.06 skrev J Decker <[hidden email]>:

I recently added externaproject_add() to download a library, but since it doesn't do the download until build, I had to put a conditional around the second part of the cmake that used the libraries it produced so it would do a cmake configure/generate, cmake build, cmake configure/generate and a final build and all was good... 

Yes… that sound exactly like the problem I am currently facing..
I am not sure I understand how your if statement fixes this?.. when does it download?

but I coudln't reference any directories that didn't exist yet in include_directories, or link_directories...until the project had been at least partially built.

On Sat, Oct 28, 2017 at 6:00 PM, Craig Scott <[hidden email]> wrote:
it still doesn’t work… 

I am bit unsure of what is being done here..  I need to include the libraryportaudio.a to include portaudio into the project. 

which causes an error as the download only occurs during build (make) and not during cmake. 

Ah, sorry. This particular problem has been fixed on CMake master, but it won't be in the 3.10 release (in release candidate stage), so that isn't going to help you right now. Possibly you might be able to modify the relevant target property directly rather than using target_include_directories() - again this is untested, but worth a try:

set_property(TARGET portaudio APPEND PROPERTY
    INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR}/include
)

If that doesn't work, then I guess modifying your original method to use the correct path may be an alternative workaround:

target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${SOURCE_DIR}/include)




On Sun, Oct 29, 2017 at 11:47 AM, Carlton Banks <[hidden email]> wrote:

Den 29. okt. 2017 kl. 02.29 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 11:26 AM, Carlton Banks <[hidden email]> wrote:
CMake Error at src/include/record/CMakeLists.txt:28 (target_include_directories):
  Cannot specify include directories for imported target "portaudio".


is the problem that externalProject_add only is executed when make is executed and not when cmake is executed’?
what is `portaudio` here referring to?

The name "portaudio" is the target defined by the add_library() call in my example (the imported target that represents what the ExternalProject_Add() is going to create at build time).
ok.

Did you also try the INTERFACE IMPORTED alternative?
Still the same.. 

It would be more useful if you showed the full CMakeLists.txt rather than just the error message.


The submodule cmakelist: 


tree structure


The outer cmakelist includes the inner directories. 


 
Den 29. okt. 2017 kl. 02.19 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 10:36 AM, Carlton Banks <[hidden email]> wrote:
I seem to have some problems executing one of my submodules cmakelist.

MESSAGE(“In record CMAKELIST”)

# Include externalproject {portaudio} if lib/portaudio don't exist.
MESSAGE(“Download external project”)

INCLUDE(ExternalProject)
ExternalProject_Add(project_portaudio
    GIT_REPOSITORY      https://git.assembla.com/portaudio.git
    PREFIX              lib/portaudio
    CONFIGURE_COMMAND   <SOURCE_DIR>/configure
    BUILD_IN_SOURCE     1
    BUILD_COMMAND       make
    INSTALL_COMMAND     sudo make install
)
ExternalProject_Get_Property(project_portaudio BINARY_DIR)
ExternalProject_Get_Property(project_portaudio SOURCE_DIR)

SET(portaudio_lib_dir "${BINARY_DIR}/lib/.libs")
SET(portaudio_inc_dir "${SOURCE_DIR}/include")

add_library(record STATIC record.cpp record.h)
add_library(libaudio libportaudio.a PATHS ${portaudio_lib_dir})

What is this second add_library() command intended to do? I'm guessing you probably instead want to be doing something like this (untested, but hopefully in the ballpark):

add_library(portaudio STATIC IMPORTED)
set_target_properties(portaudio PROPERTIES
    IMPORTED_LOCATION ${BINARY_DIR}/lib/.libs/libportaudio.a
)
target_include_directories(portaudio INTERFACE
    ${SOURCE_DIR}/include
)
add_dependencies(portaudio project_portaudio)     # Not sure if this is allowed for imported targets though

I don't recall off the top of my head whether STATIC IMPORTED or INTERFACE IMPORTED would be the right way to call add_library() in the above, so try the latter if the former doesn't work for you. 





#
# this makes sure we have compiler flags that allow class::class() = default (>= C++11)
target_compile_features(record PUBLIC cxx_defaulted_functions)




target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${project_portaudio})

You won't need this if you define the portaudio imported library as per my example above.

 


It cannot find libportaudio.a as externalproject_add() is not being executed, the command it executes add_library, which fails as the project has not been downloaded…


what is wrong here?

The reason for this specific problem is that there's no dependency relationship between the project_portaudio target defined by the ExternalProject_Add() call and the record target. Such a relationship is only created through a suitable call to target_link_libraries() or add_dependencies(), or through arguments like DEPENDS for commands that offer such features (e.g. add_custom_target() and add_custom_command()).


--
Craig Scott
Melbourne, Australia




--
Craig Scott
Melbourne, Australia




--
Craig Scott
Melbourne, Australia

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: does cmake scripts execute sequentially?

Craig Scott-3
In reply to this post by J Decker


On Sun, Oct 29, 2017 at 12:06 PM, J Decker <[hidden email]> wrote:
I recently added externaproject_add() to download a library, but since it doesn't do the download until build, I had to put a conditional around the second part of the cmake that used the libraries it produced so it would do a cmake configure/generate, cmake build, cmake configure/generate and a final build and all was good... 


but I coudln't reference any directories that didn't exist yet in include_directories, or link_directories...until the project had been at least partially built.

For the "directory must exist" problem, using file(MAKE_DIRECTORY) to force it to exist first is sometimes a viable workaround.


 

On Sat, Oct 28, 2017 at 6:00 PM, Craig Scott <[hidden email]> wrote:
Ah, sorry. This particular problem has been fixed on CMake master, but it won't be in the 3.10 release (in release candidate stage), so that isn't going to help you right now. Possibly you might be able to modify the relevant target property directly rather than using target_include_directories() - again this is untested, but worth a try:

set_property(TARGET portaudio APPEND PROPERTY
    INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR}/include
)

If that doesn't work, then I guess modifying your original method to use the correct path may be an alternative workaround:

target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${SOURCE_DIR}/include)




On Sun, Oct 29, 2017 at 11:47 AM, Carlton Banks <[hidden email]> wrote:

Den 29. okt. 2017 kl. 02.29 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 11:26 AM, Carlton Banks <[hidden email]> wrote:
CMake Error at src/include/record/CMakeLists.txt:28 (target_include_directories):
  Cannot specify include directories for imported target "portaudio".


is the problem that externalProject_add only is executed when make is executed and not when cmake is executed’?
what is `portaudio` here referring to?

The name "portaudio" is the target defined by the add_library() call in my example (the imported target that represents what the ExternalProject_Add() is going to create at build time).
ok.

Did you also try the INTERFACE IMPORTED alternative?
Still the same.. 

It would be more useful if you showed the full CMakeLists.txt rather than just the error message.


The submodule cmakelist: 


tree structure


The outer cmakelist includes the inner directories. 


 
Den 29. okt. 2017 kl. 02.19 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 10:36 AM, Carlton Banks <[hidden email]> wrote:
I seem to have some problems executing one of my submodules cmakelist.

MESSAGE(“In record CMAKELIST”)

# Include externalproject {portaudio} if lib/portaudio don't exist.
MESSAGE(“Download external project”)

INCLUDE(ExternalProject)
ExternalProject_Add(project_portaudio
    GIT_REPOSITORY      https://git.assembla.com/portaudio.git
    PREFIX              lib/portaudio
    CONFIGURE_COMMAND   <SOURCE_DIR>/configure
    BUILD_IN_SOURCE     1
    BUILD_COMMAND       make
    INSTALL_COMMAND     sudo make install
)
ExternalProject_Get_Property(project_portaudio BINARY_DIR)
ExternalProject_Get_Property(project_portaudio SOURCE_DIR)

SET(portaudio_lib_dir "${BINARY_DIR}/lib/.libs")
SET(portaudio_inc_dir "${SOURCE_DIR}/include")

add_library(record STATIC record.cpp record.h)
add_library(libaudio libportaudio.a PATHS ${portaudio_lib_dir})

What is this second add_library() command intended to do? I'm guessing you probably instead want to be doing something like this (untested, but hopefully in the ballpark):

add_library(portaudio STATIC IMPORTED)
set_target_properties(portaudio PROPERTIES
    IMPORTED_LOCATION ${BINARY_DIR}/lib/.libs/libportaudio.a
)
target_include_directories(portaudio INTERFACE
    ${SOURCE_DIR}/include
)
add_dependencies(portaudio project_portaudio)     # Not sure if this is allowed for imported targets though

I don't recall off the top of my head whether STATIC IMPORTED or INTERFACE IMPORTED would be the right way to call add_library() in the above, so try the latter if the former doesn't work for you. 





#
# this makes sure we have compiler flags that allow class::class() = default (>= C++11)
target_compile_features(record PUBLIC cxx_defaulted_functions)




target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${project_portaudio})

You won't need this if you define the portaudio imported library as per my example above.

 


It cannot find libportaudio.a as externalproject_add() is not being executed, the command it executes add_library, which fails as the project has not been downloaded…


what is wrong here?

The reason for this specific problem is that there's no dependency relationship between the project_portaudio target defined by the ExternalProject_Add() call and the record target. Such a relationship is only created through a suitable call to target_link_libraries() or add_dependencies(), or through arguments like DEPENDS for commands that offer such features (e.g. add_custom_target() and add_custom_command()).


--
Craig Scott
Melbourne, Australia

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: does cmake scripts execute sequentially?

Carlton banks

Den 29. okt. 2017 kl. 02.15 skrev Craig Scott <[hidden email]>:

 file(MAKE_DIRECTORY)
Not sure about the workaround.. the problem here is that cmake does not download, and make does. 
So adding a workaround like that, would require to add a condition that differentiates between cmake and make.. 

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: does cmake scripts execute sequentially?

Craig Scott-3


On Sun, Oct 29, 2017 at 12:18 PM, Carlton Banks <[hidden email]> wrote:

Den 29. okt. 2017 kl. 02.15 skrev Craig Scott <[hidden email]>:

 file(MAKE_DIRECTORY)
Not sure about the workaround.. the problem here is that cmake does not download, and make does. 
So adding a workaround like that, would require to add a condition that differentiates between cmake and make.. 

No condition should be needed, simply add it to CMakeLists.txt before the command that adds the directory to the include path. The external make build shouldn't complain if the path already exists, it will just go ahead and populate it. At least, that's been my experience when I've used this workaround before for this very problem.


--
Craig Scott
Melbourne, Australia

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: does cmake scripts execute sequentially?

Carlton banks

Den 29. okt. 2017 kl. 02.20 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 12:18 PM, Carlton Banks <[hidden email]> wrote:

Den 29. okt. 2017 kl. 02.15 skrev Craig Scott <[hidden email]>:

 file(MAKE_DIRECTORY)
Not sure about the workaround.. the problem here is that cmake does not download, and make does. 
So adding a workaround like that, would require to add a condition that differentiates between cmake and make.. 

No condition should be needed, simply add it to CMakeLists.txt before the command that adds the directory to the include path. The external make build shouldn't complain if the path already exists, it will just go ahead and populate it. At least, that's been my experience when I've used this workaround before for this very problem.

It somehow still causes some problems.. 



Gives me this error: 

cmake ..
“InsrcCMAKELIST”
“InincludeCMAKELIST”
“IndatabaseCMAKELIST”
“InmatchCMAKELIST”
“InrecordCMAKELIST”
“Downloadexternalproject”
CMake Error at src/include/record/CMakeLists.txt:25 (file):
  file must be called with at least two arguments.


CMake Error at src/include/record/CMakeLists.txt:32 (target_include_directories):
  Cannot specify include directories for imported target "portaudio".


“InspectogramCMAKELIST”
-- Configuring incomplete, errors occurred!
See also "/Users/keerthikanratnarajah/soundcloud/build/CMakeFiles/CMakeOutput.log".


--
Craig Scott
Melbourne, Australia


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: does cmake scripts execute sequentially?

Craig Scott-3
Your line 25 is incorrect, you left out the MAKE_DIRECTORY part and the path you specified doesn't seem to be right. It should be something more like:

file(MAKE_DIRECTORY ${SOURCE_DIR}/include)


You also seem to have missed one of my other emails. Replace this:

target_include_directories(portaudio INTERFACE
    ${portaudio_inc_dir}
)

with this:

set_property(TARGET portaudio APPEND PROPERTY
    INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR}/include
)

If that doesn't work, still get rid of the target_include_directories() call above and also replace this:

target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${project_portaudio})

with this (as a last resort workaround):

target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${SOURCE_DIR}/include)


I'm going to have to leave it at that, gotta focus on other work now. Hopefully the above gets you further along. Otherwise, I'll have to leave it to others to continue to help you from here.
 

On Sun, Oct 29, 2017 at 12:27 PM, Carlton Banks <[hidden email]> wrote:

Den 29. okt. 2017 kl. 02.20 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 12:18 PM, Carlton Banks <[hidden email]> wrote:

Den 29. okt. 2017 kl. 02.15 skrev Craig Scott <[hidden email]>:

 file(MAKE_DIRECTORY)
Not sure about the workaround.. the problem here is that cmake does not download, and make does. 
So adding a workaround like that, would require to add a condition that differentiates between cmake and make.. 

No condition should be needed, simply add it to CMakeLists.txt before the command that adds the directory to the include path. The external make build shouldn't complain if the path already exists, it will just go ahead and populate it. At least, that's been my experience when I've used this workaround before for this very problem.

It somehow still causes some problems.. 



Gives me this error: 

cmake ..
“InsrcCMAKELIST”
“InincludeCMAKELIST”
“IndatabaseCMAKELIST”
“InmatchCMAKELIST”
“InrecordCMAKELIST”
“Downloadexternalproject”
CMake Error at src/include/record/CMakeLists.txt:25 (file):
  file must be called with at least two arguments.


CMake Error at src/include/record/CMakeLists.txt:32 (target_include_directories):
  Cannot specify include directories for imported target "portaudio".


“InspectogramCMAKELIST”
-- Configuring incomplete, errors occurred!
See also "/Users/keerthikanratnarajah/soundcloud/build/CMakeFiles/CMakeOutput.log".


--
Craig Scott
Melbourne, Australia




--
Craig Scott
Melbourne, Australia

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: does cmake scripts execute sequentially?

Carlton banks
I might have been a tat too fast there.. 

It doesn’t seem to able to find the /configure script.. and I can’t seem to print the path it looking in.. 

[  5%] Building CXX object src/include/spectogram/CMakeFiles/spectogram.dir/spectogram.cpp.o
[ 11%] Linking CXX static library libspectogram.a
[ 11%] Built target spectogram
[ 16%] Building CXX object src/include/database/CMakeFiles/database.dir/database.cpp.o
[ 22%] Linking CXX static library libdatabase.a
[ 22%] Built target database
[ 27%] Building CXX object src/include/match/CMakeFiles/match.dir/match.cpp.o
[ 33%] Linking CXX static library libmatch.a
[ 33%] Built target match
[ 38%] Building CXX object src/include/record/CMakeFiles/record.dir/record.cpp.o
[ 44%] Linking CXX static library librecord.a
[ 44%] Built target record
[ 50%] Building CXX object src/CMakeFiles/cmakeDemo.dir/main.cpp.o
[ 55%] Linking CXX executable cmakeDemo
[ 55%] Built target cmakeDemo
[ 61%] Creating directories for 'project_portaudio'
[ 66%] Performing download step (git clone) for 'project_portaudio'
-- Avoiding repeated git clone, stamp file is up to date: '/Users/keerthikanratnarajah/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio-stamp/project_portaudio-gitclone-lastrun.txt'
[ 72%] No patch step for 'project_portaudio'
[ 77%] Performing update step for 'project_portaudio'
Current branch master is up to date.
[ 83%] Performing configure step for 'project_portaudio'
/bin/sh: /configure: No such file or directory
make[2]: *** [src/include/record/lib/portaudio/src/project_portaudio-stamp/project_portaudio-configure] Error 127
make[1]: *** [src/include/record/CMakeFiles/project_portaudio.dir/all] Error 2
make: *** [all] Error 2
Den 29. okt. 2017 kl. 02.37 skrev Carlton Banks <[hidden email]>:


Den 29. okt. 2017 kl. 02.34 skrev Craig Scott <[hidden email]>:

Your line 25 is incorrect, you left out the MAKE_DIRECTORY part and the path you specified doesn't seem to be right. It should be something more like:

file(MAKE_DIRECTORY ${SOURCE_DIR}/include)


You also seem to have missed one of my other emails. Replace this:

target_include_directories(portaudio INTERFACE
    ${portaudio_inc_dir}
)

with this:

set_property(TARGET portaudio APPEND PROPERTY
    INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR}/include
)


Those fixes made it work.. thanks :)

If that doesn't work, still get rid of the target_include_directories() call above and also replace this:

target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${project_portaudio})

with this (as a last resort workaround):

target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${SOURCE_DIR}/include)


I'm going to have to leave it at that, gotta focus on other work now. Hopefully the above gets you further along. Otherwise, I'll have to leave it to others to continue to help you from here.
 

On Sun, Oct 29, 2017 at 12:27 PM, Carlton Banks <[hidden email]> wrote:

Den 29. okt. 2017 kl. 02.20 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 12:18 PM, Carlton Banks <[hidden email]> wrote:

Den 29. okt. 2017 kl. 02.15 skrev Craig Scott <[hidden email]>:

 file(MAKE_DIRECTORY)
Not sure about the workaround.. the problem here is that cmake does not download, and make does. 
So adding a workaround like that, would require to add a condition that differentiates between cmake and make.. 

No condition should be needed, simply add it to CMakeLists.txt before the command that adds the directory to the include path. The external make build shouldn't complain if the path already exists, it will just go ahead and populate it. At least, that's been my experience when I've used this workaround before for this very problem.

It somehow still causes some problems.. 



Gives me this error: 

cmake ..
“InsrcCMAKELIST”
“InincludeCMAKELIST”
“IndatabaseCMAKELIST”
“InmatchCMAKELIST”
“InrecordCMAKELIST”
“Downloadexternalproject”
CMake Error at src/include/record/CMakeLists.txt:25 (file):
  file must be called with at least two arguments.


CMake Error at src/include/record/CMakeLists.txt:32 (target_include_directories):
  Cannot specify include directories for imported target "portaudio".


“InspectogramCMAKELIST”
-- Configuring incomplete, errors occurred!
See also "/Users/keerthikanratnarajah/soundcloud/build/CMakeFiles/CMakeOutput.log".


-- 
Craig Scott
Melbourne, Australia




-- 
Craig Scott
Melbourne, Australia


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: does cmake scripts execute sequentially?

J Decker
In reply to this post by Craig Scott-3


On Sat, Oct 28, 2017 at 6:15 PM, Craig Scott <[hidden email]> wrote:


On Sun, Oct 29, 2017 at 12:06 PM, J Decker <[hidden email]> wrote:
I recently added externaproject_add() to download a library, but since it doesn't do the download until build, I had to put a conditional around the second part of the cmake that used the libraries it produced so it would do a cmake configure/generate, cmake build, cmake configure/generate and a final build and all was good... 


but I coudln't reference any directories that didn't exist yet in include_directories, or link_directories...until the project had been at least partially built.

For the "directory must exist" problem, using file(MAKE_DIRECTORY) to force it to exist first is sometimes a viable workaround.



(third time's the charm :) kept missing reply-all )
That would cause the git checkout to fail with 'directory already has content' or something like that.
There is a second external project that builds another sub-project from the same source tree... it probably would work for expected install locations for a simpler project though.
 
 

On Sat, Oct 28, 2017 at 6:00 PM, Craig Scott <[hidden email]> wrote:
Ah, sorry. This particular problem has been fixed on CMake master, but it won't be in the 3.10 release (in release candidate stage), so that isn't going to help you right now. Possibly you might be able to modify the relevant target property directly rather than using target_include_directories() - again this is untested, but worth a try:

set_property(TARGET portaudio APPEND PROPERTY
    INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR}/include
)

If that doesn't work, then I guess modifying your original method to use the correct path may be an alternative workaround:

target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${SOURCE_DIR}/include)




On Sun, Oct 29, 2017 at 11:47 AM, Carlton Banks <[hidden email]> wrote:

Den 29. okt. 2017 kl. 02.29 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 11:26 AM, Carlton Banks <[hidden email]> wrote:
CMake Error at src/include/record/CMakeLists.txt:28 (target_include_directories):
  Cannot specify include directories for imported target "portaudio".


is the problem that externalProject_add only is executed when make is executed and not when cmake is executed’?
what is `portaudio` here referring to?

The name "portaudio" is the target defined by the add_library() call in my example (the imported target that represents what the ExternalProject_Add() is going to create at build time).
ok.

Did you also try the INTERFACE IMPORTED alternative?
Still the same.. 

It would be more useful if you showed the full CMakeLists.txt rather than just the error message.


The submodule cmakelist: 


tree structure


The outer cmakelist includes the inner directories. 


 
Den 29. okt. 2017 kl. 02.19 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 10:36 AM, Carlton Banks <[hidden email]> wrote:
I seem to have some problems executing one of my submodules cmakelist.

MESSAGE(“In record CMAKELIST”)

# Include externalproject {portaudio} if lib/portaudio don't exist.
MESSAGE(“Download external project”)

INCLUDE(ExternalProject)
ExternalProject_Add(project_portaudio
    GIT_REPOSITORY      https://git.assembla.com/portaudio.git
    PREFIX              lib/portaudio
    CONFIGURE_COMMAND   <SOURCE_DIR>/configure
    BUILD_IN_SOURCE     1
    BUILD_COMMAND       make
    INSTALL_COMMAND     sudo make install
)
ExternalProject_Get_Property(project_portaudio BINARY_DIR)
ExternalProject_Get_Property(project_portaudio SOURCE_DIR)

SET(portaudio_lib_dir "${BINARY_DIR}/lib/.libs")
SET(portaudio_inc_dir "${SOURCE_DIR}/include")

add_library(record STATIC record.cpp record.h)
add_library(libaudio libportaudio.a PATHS ${portaudio_lib_dir})

What is this second add_library() command intended to do? I'm guessing you probably instead want to be doing something like this (untested, but hopefully in the ballpark):

add_library(portaudio STATIC IMPORTED)
set_target_properties(portaudio PROPERTIES
    IMPORTED_LOCATION ${BINARY_DIR}/lib/.libs/libportaudio.a
)
target_include_directories(portaudio INTERFACE
    ${SOURCE_DIR}/include
)
add_dependencies(portaudio project_portaudio)     # Not sure if this is allowed for imported targets though

I don't recall off the top of my head whether STATIC IMPORTED or INTERFACE IMPORTED would be the right way to call add_library() in the above, so try the latter if the former doesn't work for you. 





#
# this makes sure we have compiler flags that allow class::class() = default (>= C++11)
target_compile_features(record PUBLIC cxx_defaulted_functions)




target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${project_portaudio})

You won't need this if you define the portaudio imported library as per my example above.

 


It cannot find libportaudio.a as externalproject_add() is not being executed, the command it executes add_library, which fails as the project has not been downloaded…


what is wrong here?

The reason for this specific problem is that there's no dependency relationship between the project_portaudio target defined by the ExternalProject_Add() call and the record target. Such a relationship is only created through a suitable call to target_link_libraries() or add_dependencies(), or through arguments like DEPENDS for commands that offer such features (e.g. add_custom_target() and add_custom_command()).


--
Craig Scott
Melbourne, Australia


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: does cmake scripts execute sequentially?

J Decker
In reply to this post by Carlton banks


On Sat, Oct 28, 2017 at 6:10 PM, Carlton Banks <[hidden email]> wrote:

Den 29. okt. 2017 kl. 02.06 skrev J Decker <[hidden email]>:

I recently added externaproject_add() to download a library, but since it doesn't do the download until build, I had to put a conditional around the second part of the cmake that used the libraries it produced so it would do a cmake configure/generate, cmake build, cmake configure/generate and a final build and all was good... 

Yes… that sound exactly like the problem I am currently facing..
I am not sure I understand how your if statement fixes this?.. when does it download?

Sorry it's not a very simple  project....
the second is immediately after the if that was fore-mentioned.  and that first if( exists) linked goes from there until the end of the file....

And it's not just native cmake, it's actually a node module, that uses npm...

build_gui : npm run build-gui-config #cmake-js --CDMAKE_GUI=1 configure
&& npm run build-gui-run1 #cmake-js build
&& npm run build-gui-config # cmake-js --CDMAKE_GUI=1 configure
&& npm run build-gui-run2 #cmake-js build

so I can just do 'num run build-gui'  and it runs a sequence of steps...
Yes, I hate including build scripts in simpler projects... should just be buildable with cmake.
Make if you make your library also an externalproject_add() step, with just a SOURCE_DIR specified (or something) then you could probably do it all in one step.


but I coudln't reference any directories that didn't exist yet in include_directories, or link_directories...until the project had been at least partially built.

On Sat, Oct 28, 2017 at 6:00 PM, Craig Scott <[hidden email]> wrote:
it still doesn’t work… 

I am bit unsure of what is being done here..  I need to include the libraryportaudio.a to include portaudio into the project. 

which causes an error as the download only occurs during build (make) and not during cmake. 

Ah, sorry. This particular problem has been fixed on CMake master, but it won't be in the 3.10 release (in release candidate stage), so that isn't going to help you right now. Possibly you might be able to modify the relevant target property directly rather than using target_include_directories() - again this is untested, but worth a try:

set_property(TARGET portaudio APPEND PROPERTY
    INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR}/include
)

If that doesn't work, then I guess modifying your original method to use the correct path may be an alternative workaround:

target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${SOURCE_DIR}/include)




On Sun, Oct 29, 2017 at 11:47 AM, Carlton Banks <[hidden email]> wrote:

Den 29. okt. 2017 kl. 02.29 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 11:26 AM, Carlton Banks <[hidden email]> wrote:
CMake Error at src/include/record/CMakeLists.txt:28 (target_include_directories):
  Cannot specify include directories for imported target "portaudio".


is the problem that externalProject_add only is executed when make is executed and not when cmake is executed’?
what is `portaudio` here referring to?

The name "portaudio" is the target defined by the add_library() call in my example (the imported target that represents what the ExternalProject_Add() is going to create at build time).
ok.

Did you also try the INTERFACE IMPORTED alternative?
Still the same.. 

It would be more useful if you showed the full CMakeLists.txt rather than just the error message.


The submodule cmakelist: 


tree structure


The outer cmakelist includes the inner directories. 


 
Den 29. okt. 2017 kl. 02.19 skrev Craig Scott <[hidden email]>:



On Sun, Oct 29, 2017 at 10:36 AM, Carlton Banks <[hidden email]> wrote:
I seem to have some problems executing one of my submodules cmakelist.

MESSAGE(“In record CMAKELIST”)

# Include externalproject {portaudio} if lib/portaudio don't exist.
MESSAGE(“Download external project”)

INCLUDE(ExternalProject)
ExternalProject_Add(project_portaudio
    GIT_REPOSITORY      https://git.assembla.com/portaudio.git
    PREFIX              lib/portaudio
    CONFIGURE_COMMAND   <SOURCE_DIR>/configure
    BUILD_IN_SOURCE     1
    BUILD_COMMAND       make
    INSTALL_COMMAND     sudo make install
)
ExternalProject_Get_Property(project_portaudio BINARY_DIR)
ExternalProject_Get_Property(project_portaudio SOURCE_DIR)

SET(portaudio_lib_dir "${BINARY_DIR}/lib/.libs")
SET(portaudio_inc_dir "${SOURCE_DIR}/include")

add_library(record STATIC record.cpp record.h)
add_library(libaudio libportaudio.a PATHS ${portaudio_lib_dir})

What is this second add_library() command intended to do? I'm guessing you probably instead want to be doing something like this (untested, but hopefully in the ballpark):

add_library(portaudio STATIC IMPORTED)
set_target_properties(portaudio PROPERTIES
    IMPORTED_LOCATION ${BINARY_DIR}/lib/.libs/libportaudio.a
)
target_include_directories(portaudio INTERFACE
    ${SOURCE_DIR}/include
)
add_dependencies(portaudio project_portaudio)     # Not sure if this is allowed for imported targets though

I don't recall off the top of my head whether STATIC IMPORTED or INTERFACE IMPORTED would be the right way to call add_library() in the above, so try the latter if the former doesn't work for you. 





#
# this makes sure we have compiler flags that allow class::class() = default (>= C++11)
target_compile_features(record PUBLIC cxx_defaulted_functions)




target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${project_portaudio})

You won't need this if you define the portaudio imported library as per my example above.

 


It cannot find libportaudio.a as externalproject_add() is not being executed, the command it executes add_library, which fails as the project has not been downloaded…


what is wrong here?

The reason for this specific problem is that there's no dependency relationship between the project_portaudio target defined by the ExternalProject_Add() call and the record target. Such a relationship is only created through a suitable call to target_link_libraries() or add_dependencies(), or through arguments like DEPENDS for commands that offer such features (e.g. add_custom_target() and add_custom_command()).


--
Craig Scott
Melbourne, Australia




--
Craig Scott
Melbourne, Australia




--
Craig Scott
Melbourne, Australia

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake




--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake