[CMake] multiple add_custom_command solution
Micha Renner
Micha.Renner at t-online.de
Thu Jul 2 05:10:04 EDT 2009
I have a program prog filename, that generates an output to stdout. To
collect data in a file one uses
prog filename > result.txt
In a CMake-script I have list of 5 files which should processed by the
program
SET(_moduleList name1 name2 name3 name4 name5)
FOREACH(_module ${_moduleList})
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_module}.dummy
COMMAND cmake -E touch {CMAKE_CURRENT_BINARY_DIR}/${_module}.dummy
COMMAND prog ${_module}.txt >> tm16.txt
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}
COMMENT "-- done")
LIST(APPEND _result ${CMAKE_CURRENT_BINARY_DIR}/${_module}.dummy)
ENDFOREACH(_module ${_moduleList})
ADD_CUSTOM_TARGET(tProcess ALL DEPENDS ${_result})
The main disadvantage of this is
- The target works correct only if tm16.txt does not exist before it
runs.
Does someone knows a better solution.
Micha
More information about the CMake
mailing list