add_custom_command(
OUTPUT my_output.out
COMMAND ${MY_TOOL} ${PARAMETERS}
DEPENDS ${MY_OBJECT_FILES}
VERBATIM)
I have the above add_custom_command in my cmake that DEPENDS on filenames (MY_OBJECT_FILES) that are generated from a list as:
set(MY_OBJECT_FILES "")
foreach(config ${CONFIGURATIONS})
set(MY_OBJECT_FILES "${MY_OBJECT_FILES} ${CMAKE_CURRENT_BINARY_DIR}/generated-file-${config}.o")
endforeach()
The above foreach loop generates a string that contains the names of all the object files separated by whitespace. But when the cmake built the built.make it puts extra \ in the beginning and before each whitespace and it messes up with the build.
It looks like this:
my_output.out: \ /home/user/project/build/generated-file-config1.o\ /home/user/project/build/generated-file-config2.o\ /home/user/project/build/generated-file-config3.o\
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold --progress-dir=/home/user/project/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Generating my_output.out"
/opt/bin/my_tool -parameter1=5 -parameter2=4
How do I resolve this and provide the DEPENDS with proper whitespace separated list of files?