Hi! In my project, I have a situation where I would like to perform an action as post build step, but only for the Debug configuration. (In the example below I copy a file.)
Unfortunately, it's not possible to apply add_custom_command to a specific configuration (at least when using a multi-configuration generator like the ones for Visual Studio). My current solution is to use something like: add_custom_command(... COMMAND $<$<CONFIG:Debug>:${CMAKE_COMMAND}>$<$<NOT:$<CONFIG:Debug>>:true> -E copy ...) Explanation: In the Debug configuration, this expands to "cmake -E copy ...", in other configurations it expands to "true -E ...". ("true" is a standard UNIX command that accepts any options and always succeeds -- kind of a generic "no-op" command.) This has the drawback that this relies on me having an external command "true". This is a standard UNIX command but isn't installed on standard Windows machine. By having a "cmake -E do_nothing" the command could instead look like: add_custom_command(... COMMAND ${CMAKE_COMMAND} -E $<$<CONFIG:Debug>:copy>$<$<NOT:$<CONFIG:Debug>>:do_nothing> ...) The difference is that this doesn't rely on any system-specific external command. Of course, this would not be needed if add_custom_command could be configuration-specific... In addition, it would be nice if other fields, like COMMENT, could support generator expressions. Sincerely, Anders Lindgren
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake