[CMake] configuration based add_custom_command

David Cole david.cole at kitware.com
Wed Aug 24 08:34:18 EDT 2011


On Wed, Aug 24, 2011 at 7:47 AM, Robert Bielik <robert.bielik at xponaut.se> wrote:
> Robert Bielik skrev 2011-08-24 13:43:
>>
>> Michael Hertling skrev 2011-08-24 13:13:
>>>
>>> Suppose
>>>
>>> ADD_CUSTOM_COMMAND(OUTPUT source.c CONFIGURATION Release COMMAND ...)
>>> ADD_EXECUTABLE(main ... source.c)
>>>
>>> and then:
>>>
>>> cmake -DCMAKE_BUILD_TYPE=Debug<path/to/source>
>>>
>>> How would you like this case to be handled by CMake? Note that with
>>> multi-config generators, the build type aka configuration is chosen
>>> at build time, and the user is free to define custom build types.
>>
>> I'd expect the obvious, i.e. the ADD_CUSTOM_COMMAND shall not be included
>> in the build if CMAKE_BUILD_TYPE==Debug. I see no conflict with
>> multi-config generators either.
>
> Sorry, I didn't look to closely. Hmm.. yup, that would be a problem. Maybe
> CMake would fail when it detects dependencies that must be available
> in all configurations ? In this case it would say:
>
> "Failure: Target 'main' has dependencies that are not available in all
> configurations"
>
> /Rob
> _______________________________________________
> 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
>


Please see notes and details in the following bug reports (some
already resolved/fixed) regarding "generator expressions" in
add_custom_command and more:

  http://public.kitware.com/Bug/view.php?id=11209
  http://public.kitware.com/Bug/view.php?id=9974
  http://public.kitware.com/Bug/view.php?id=6269
  http://public.kitware.com/Bug/view.php?id=6242

To find these, I simply searched the bug database for "per
configuration add_custom_command"


HTH,
David


More information about the CMake mailing list