Preventing add_custom_command from removing output

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Preventing add_custom_command from removing output

Alain Miniussi

I have a source file (version.cpp) I need to generate trough a script.

What the script does is

- generate a file
- if version.cpp does not exists or is different from,
copy into version.cpp


add_custom_command(OUTPUT version.cpp always
   bash -x ${CMAKE_SOURCE_DIR}/tools/dev/
${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 ?


Alain Miniussi
DSI, Pôles Calcul et Genie Log.
Tél. : +33492003009 (Mont-Gros)
Tél. : +33483618544 (Sophia Antipolis)


Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: