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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Steven Wilson-2
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

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

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

James Bigler
On Fri, Nov 27, 2009 at 5:28 PM, Steven Wilson <[hidden email]> wrote:
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


That would be a welcome feature.  I've gotten around this issue, by generating a build time invoked script that takes the configuration as a parameter and behaves differently based on the value.

James

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake