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

James Bigler jamesbigler at gmail.com
Sun Nov 29 15:59:33 EST 2009


On Fri, Nov 27, 2009 at 5:28 PM, Steven Wilson <
steven.wesley.wilson at gmail.com> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091129/2891c8b5/attachment.htm>


More information about the CMake mailing list