[cmake-developers] Passing lists with generator expression through add_custom_command

Raffi Enficiaud raffi.enficiaud at mines-paris.org
Sun Aug 13 11:36:29 EDT 2017


Hi CMake ML,

I have a small issue concerning the way generator expressions are 
resolved when calling another process.

Suppose I have this

set(ALL_DEPENDENCIES_FILES)
foreach(_device IN LISTS ALL_DEVICES)
   list(APPEND ALL_DEPENDENCIES_FILES $<TARGET_FILE:${_device}>)
endforeach()

that creates a list containing generator expressions for locating a 
target, and then I use this list as an argument to execute process:

add_custom_command(
  TARGET my_target
  POST_BUILD
  COMMAND ${CMAKE_COMMAND}
    -DAPPFOLDER=$<TARGET_FILE_DIR:my_target>/../..
    -DBOOST_FOLDER="${BOOST_LIB_PATH}"
    -DQT_BIN_DIR="${QT_BIN_PATH}"
    -DQML_DIR="${CMAKE_SOURCE_DIR}"
    -DDEPLOY_LIB_DIR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
    -DALL_DEPENDENCIES="${ALL_DEPENDENCIES_FILES}"
    -P ${CMAKE_SOURCE_DIR}/cmake/osx_bundle.cmake)

when I trace the content of ALL_DEPENDENCIES_FILES at the location where 
the add_custom_command happens, I have this:

message(STATUS "ALL_DEPENDENCIES_FILES CALL 
'${ALL_DEPENDENCIES_FILES}'") gives

ALL_DEPENDENCIES_FILES CALL 
'$<TARGET_FILE:mock_emotiv>;$<TARGET_FILE:eeg_lsl>'

which indicates that this is a proper list, where each element is 
separated by ";".

However, inside the called script osx_bundle.cmake, I see the target 
location resolved but separated with a space:

message(STATUS "ALL_DEPENDENCIES: '${ALL_DEPENDENCIES}'") gives:

ALL_DEPENDENCIES: 
'/Users/raffi/Code/my_target/build_make/bin/libmock_emotiv.dylib 
/Users/raffi/Code/my_target/build_make/bin/libeeg_lsl.dylib'

Why does the list loose its type when passing to the second cmake script 
through 'add_custom_command' ?

Thanks!
Raffi



More information about the cmake-developers mailing list