[CMake] does cmake scripts execute sequentially?

Carlton Banks noflaco at gmail.com
Sat Oct 28 20:26:04 EDT 2017


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 <craig.scott at crascit.com>:
> 
> 
> 
> On Sun, Oct 29, 2017 at 10:36 AM, Carlton Banks <noflaco at gmail.com <mailto:noflaco at gmail.com>> 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 <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
> https://crascit.com <https://crascit.com/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20171029/14eb7ee4/attachment-0001.html>


More information about the CMake mailing list