[CMake] Eliminating spurious dependencies
Tom Birch
tbirch at apple.com
Fri Jun 25 19:09:11 EDT 2010
I'm using add_excecutable to generate a .s file which I then parse to generate a header file. This all works fine and all the dependencies seem to be working, but it gets built every time, even if nothing has changed.
I have a function to generate the asm file:
function (make_asm_file source dest defs flags)
set_source_files_properties(
${source}
PROPERTIES
COMPILE_DEFINITIONS "${${defs}}"
COMPILE_FLAGS "${${flags}} -S"
)
add_executable (
${dest}
EXCLUDE_FROM_ALL
${source}
)
set_target_properties(
${dest}
PROPERTIES
OUTPUT_NAME ${dest}
RULE_LAUNCH_LINK "sh build_tools/copier.sh ${CMAKE_BINARY_DIR} <OBJECTS> --"
)
endfunction(make_asm_file)
and I invoke that, and then add a custom command to convert the .s into a .h like this:
make_asm_file(${input_c} ${output_s} c_defs c_flags)
add_custom_command (
OUTPUT ${header_path}
COMMAND ./make_header ${header_path} ${dest}
DEPENDS ${output_s}
)
and then I use set_source_file_properties(OBJECT_DEPENDS) to make the sources depend on this generated header.
Every time I get type make (even on incremental builds) I get
[ 0%] Built target genassym.c.s
but I only see the custom command on a build when the header hasn't previously been generated, i.e.
[ 1%] Generating assym.h
So my question is, what is it about this invocation of add_excecutable that makes it always run? Shouldn't EXCLUDE_FROM_ALL get rid of that?
cheers,
Tom
More information about the CMake
mailing list