Oodini
June 26, 2024, 1:34pm
1
Hello,
When using the ExternalProject_Add(), I try to use a generator expression with the CMAKE_ARGS argument (the … contains actually some variables):
ExternalProject_Add(${APP_NAME}_${module}_${require_module_PLATFORM}
SOURCE_DIR ${ROOT_DIR}/source/modules/${module}
BINARY_DIR ${CMAKE_BINARY_DIR}/${module}_${require_module_PLATFORM}
DOWNLOAD_COMMAND ""
${generator_params}
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DROOT_DIR=${ROOT_DIR}
-DPLATFORM=${PLATFORM}
-DMODE=${MODE}
$<$<BOOL:${OUTPUT_DIR}>:-DOUTPUT_DIR=${OUTPUT_DIR}>
${dependency_cmake_args}
${options_args}
DEPENDS ${dependency_targets}
)
The problem is with the generator expression. When OUTPUT_DIR doesn’t exist, I get the following warning :
Ignoring empty string ("") provided on the command line.
Angew
(Petr Kmoch)
June 27, 2024, 1:21pm
2
Does OUTPUT_DIR contain genexes? If not, you don’t need to use a genex either:
if(OUTPUT_DIR)
set(OUTPUT_DIR_ARG -DOUTPUT_DIR=${OUTPUT_DIR})
else()
set(OUTPUT_DIR_ARG "")
endif()
ExternalProject_Add(${APP_NAME}_${module}_${require_module_PLATFORM}
SOURCE_DIR ${ROOT_DIR}/source/modules/${module}
BINARY_DIR ${CMAKE_BINARY_DIR}/${module}_${require_module_PLATFORM}
DOWNLOAD_COMMAND ""
${generator_params}
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DROOT_DIR=${ROOT_DIR}
-DPLATFORM=${PLATFORM}
-DMODE=${MODE}
${OUTPUT_DIR_ARG} # <--- the only change from the original
${dependency_cmake_args}
${options_args}
DEPENDS ${dependency_targets}
)
Oodini
June 28, 2024, 9:27am
3
No, OUTPUT_DIR is not a generator expression.
I have finally done a variant of what you suggest:
if(OUTPUT_DIR)
set(options_args ${options_args} -DOUTPUT_DIR=${OUTPUT_DIR})
endif()
ExternalProject_Add(${APP_NAME}_${module}_${require_module_PLATFORM}
SOURCE_DIR ${ROOT_DIR}/source/modules/${module}
BINARY_DIR ${CMAKE_BINARY_DIR}/${module}_${require_module_PLATFORM}
DOWNLOAD_COMMAND ""
${generator_params}
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DROOT_DIR=${ROOT_DIR}
-DPLATFORM=${PLATFORM}
-DMODE=${MODE}
${dependency_cmake_args}
${options_args}
DEPENDS ${dependency_targets}
)