[CMake] Rebuild custom command when source file changes

Mike too.cheesy at gmail.com
Fri Apr 6 13:00:27 EDT 2012


Hello,

I have a custom build command which executes an internal resource compiler
and I am having trouble getting it to rebuild whenever one of the files
being packaged is changed. In time I will alter it to scan the input file
for dependencies and build a list automatically, but for now I am manually
specifying the files which are duplicated in the resource file. It's
similar to Qt .qrc system and I based much of this on the Qt macros, yet it
doesn't work for me.

I want it to re-execute the custom command any time any of the files in
${rsm_input_files} changes.

# files also specified in resources.rsm
set(rsm_input_files
   textures/default_blank.png
   scripts/process_images.py
   scripts/misc.py
)

# Make all deps into absolute paths
set(rsm_files_as_deps "")
foreach (_rsm_file ${rsm_input_files})
   list(APPEND rsm_files_as_deps "${CMAKE_CURRENT_SOURCE_DIR}/${_rsm_file}")
endforeach (_rsm_file)

set(rsm_infile "resources.rsm")
set(rsm_outfile "${CMAKE_CURRENT_BINARY_DIR}/resources/resources.rsmc")
add_custom_command(
   OUTPUT ${rsm_outfile}
   DEPENDS ${rsm_infile} ${rsm_files_as_deps}
   COMMANDS ${TOOLS_PATH}/bin/rsmc.exe
   ARGS -i ${rsm_infile} -o ${rsm_outfile} -v 0
   VERBATIM
)

This works when ${rsm_infile} changes, but not when the files in
${rsm_input_files} (or, rather, ${rsm_files_as_deps}) change.

What am I missing?

Thanks,
 Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120406/49ad33b6/attachment.htm>


More information about the CMake mailing list