[CMake] Dependency problem

pjtr hahn pjtr.hahn at googlemail.com
Fri Jun 19 12:10:16 EDT 2009


Hello,

I have a question concerning the order in that transitiv dependencies
are resolved.

My target depends on a source file. This source file is generated by
an external tool by ADD_CUSTOM_COMMAND.
To to ensure the file is always up to date I used ADD_CUSTOM_COMMAND
with a phony target.

Example:

# generate source file
add_custom_command( OUTPUT __phony_target_name
     COMMAND some_command_to_generate
     ARGS -o __my_outfile.cpp
     ....
)

set_source_files_properties( __phony_target_name PROPERTIES SYMBOLIC TRUE )	

set_source_files_properties( __my_outfile.cpp PROPERTIES GENERATED TRUE )

set_source_files_properties( __my_outfile.cpp PROPERTIES
OBJECT_DEPENDS ${__phony_target} )

add_executable( __my_target  __my_outfile.cpp  )



The problem is that it needs 2 compile runs to bring __my_outfile.cpp
up to date. In the first pass the file is generated but not compiled.
In the second run it gets compiled. As far as I understand the
dependencies I created are transitve and should work in a single
compile run.

target --> depends on
__my_outfile.obj --> depends on
__my_outfile.cpp --> depends on
__phony_target_name

Any idea why it isn't working?

regards


More information about the CMake mailing list