Add CXX dependency generation to custom command for Ninja?

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

Add CXX dependency generation to custom command for Ninja?

Chris Green

We have a custom command for a third-party utility (genreflex, from the
ROOT system) which has a directive:


How would I, either as an extra COMMAND or as a separate custom command,
manually invoke the configured CXX compiler with all the
correctly-configured include directories and other pre-processor and
compiler flags with the expected option (-MMD for GCC, I think) on the
above-mentioned classes.h file so that the resulting file can be used in
a DEPFILE directive for the Ninja generator? I would like to model as
closely as possible exactly what CMake would specify to invoke the
compiler to (e.g.) compile an object with only the necessary changes,
but I'm not sure whence to obtain this information. I'm assuming it's
some combination of automatic variables and properties via generator
expressions, but I'm at a loss, I'm afraid. I also don't know whether I
would need to specify the .d file as an OUTPUT or a BYPRODUCTS if I do
this as a COMMAND, or in DEPENDS in addition to DEPFILE if a separate
custom command, and which choice would be better (assuming both of them
work). The resulting CMake code would need to conditionally support both
Makefile and Ninja generators.

Any advice gratefully accepted.

Current custom command definition:

     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${dictname}_dict.cpp
     -s ${CMAKE_CURRENT_SOURCE_DIR}/classes_def.xml
     -o ${dictname}_dict.cpp
     DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/classes_def.xml
     COMMENT "Generating dictionary files for target ${dictname}"

Many thanks,


Chris Green <[hidden email]>, FNAL CS/SCD/ADSS/SSI/TAC;
'phone (630) 840-2167; Skype:;
IM: [hidden email], chissgreen (AIM), (Google Talk).


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: