[CMake] Preventing add_custom_command from removing output
Alain Miniussi
Alain.Miniussi at oca.eu
Fri Dec 14 04:44:58 EST 2018
Hi,
I have a source file (version.cpp) I need to generate trough a script.
What the script does is
- generate a version.cpp.new file
- if version.cpp does not exists or is different from version.cpp.new,
copy version.cpp.new into version.cpp
-------------------
add_custom_command(OUTPUT version.cpp always
COMMAND
bash -x ${CMAKE_SOURCE_DIR}/tools/dev/gen_version.sh
${CMAKE_CURRENT_BINARY_DIR}/version.cpp )
set_source_files_properties(version.cpp PROPERTIES GENERATED TRUE)
-----------------
the 'always' target is here to make sure the script is alway called (in
case the version changed).
Unfortunately, it seems that add_custom_command will delete its output
before calling the command. As a result the version.cpp's dependancies
are always bult.
Is there a way to prevent that deletion ?
Thanks
--
-----
Alain Miniussi
DSI, Pôles Calcul et Genie Log.
Tél. : +33492003009 (Mont-Gros)
Tél. : +33483618544 (Sophia Antipolis)
More information about the CMake
mailing list