Part of my build process requires passing in a variable to a script to generate some source files. It looks something like this:
add_custom_command(OUTPUT
rebuild_files
COMMAND ${CMAKE_COMMAND} -E echo
COMMENT "Force rebuild of generated files"
)
add_custom_command(OUTPUT "File.c" "File.h"
COMMAND ruby generate_files.rb ${OPTIONS_LIST}
COMMENT "Generate files"
DEPENDS rebuild_files
)
Of course, this runs on every compilation, which isn't needed. The OPTIONS_LIST is set up at configuration time, so it could be cached.
Is there a mechanism to make a custom command dependent on a variable? The ultimate goal is to have this only compile if:
OPTIONS_LISTchanges.File.corFile.hdo not exist.
OPTIONS_LISTvariable is calculated in your case? What are dependencies of such calculation?OPTIONS_LISTis created at the time of CMake's configuration. For example:cmake -G Xcode .. -DOPTIONS_LIST=a,b,c,dWe use those options to generate a C file, which considers the list and the order they are in.