using CMake add_custom_command, we cannot automatically find the output files. the script generate many cpp/h files but it is base on some templates. Of course the template change from time to time.
so we have:
set(THE_SCRIPT "/x/y/z/theScript")
set(GENERATED_FILES "file1.cpp" "file1.h" "file2.cpp" "file2.hpp" ...)
set (TPL_FILE "Template.ert")
add_custom_command(
OUTPUT ${GENERATED_FILES}
COMMAND ${THE_SCRIPT} -t ${TPL_FILE} -D ${CMAKE_CURRENT_BINARY_DIR}
MAIN_DEPENDENCY ${TPL_FILE}
DEPENDS ${GENERATED_FILES}
)
target_sources(myTarget PRIVATE ${GENERATED_FILES})
The GENERATED_FILES variable is made by the developer each time he/she changes the template file. the dev runs the command, grab all the files created and update the variable.
I was trying to think of a way to use file(GLOB GENERATED_FILES ...)
to get the list of files. But I am not sure how to go about it!