[CMake] Suggestion: CMake should support custom commands that can vary by configuration.

Steven Wilson steven.wesley.wilson at gmail.com
Fri Nov 27 19:28:15 EST 2009


The current CMake 2.8.0 system does not allow custom commands created with
add_custom_command() to do different things based on the build
configuration.

I propose adding a new keyword to the add_custom_command CMake directive
called CONFIG:

add_custom_command(OUTPUT output1 [output2 ...]
   COMMAND command1 [ARGS] [args1...]
   [COMMAND command2 [ARGS] [args2...] ...]
   [MAIN_DEPENDENCY depend]
   [DEPENDS [depends...]]
   [IMPLICIT_DEPENDS <lang1> depend1 ...]
   [WORKING_DIRECTORY dir]
   [COMMENT comment] [VERBATIM] [APPEND]
   [CONFIG Debug | MinSizeRel | Release | RelWithDebInfo | ...])

add_custom_command(TARGET target
   PRE_BUILD | PRE_LINK | POST_BUILD
   COMMAND command1 [ARGS] [args1...]
   [COMMAND command2 [ARGS] [args2...] ...]
   [WORKING_DIRECTORY dir]
   [COMMENT comment] [VERBATIM]
   [CONFIG Debug | MinSizeRel | Release | RelWithDebInfo | ...])

The CONFIG option specifies that the custom command(s) should run only when
the given build configuration is active. This option allows custom commands
to have configuration specific behavior.

When the CONFIG option is not present, add_custom_command behaves as before.

I have reported this issue(9974) in the Mantis database and provided patches
that implement this change.

Thanks,

Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091127/c6786fff/attachment.htm>


More information about the CMake mailing list