MantisBT - CMake
View Issue Details
0006242CMakeCMakepublic2008-01-14 17:522012-09-03 16:00
Luke K 
Brad King 
normalfeaturealways
closedduplicate 
 
 
0006242: ADD_CUSTOM_COMMAND needs CONFIGURATIONS keyword for Visual Studio post-builds
Hi,

Our whole software team has just recently decided to move to CMake for our unified build system. We are encountering an annoying problem in Visual Studio 7.1 .NET 2003 where we want to have a different post-build command run depending on the project configuration, specifically to copy our newly built executable from the build area to the runtime location. We would like to have a separate runtime location for Debug and Release configurations, since each have different runtime dependencies (notably Debug configuration uses DLLs with 'd' suffix, among other files), and the executable name should also be different for Debug and Release (Debug executable has 'd' indicator).

Here is basically the CMake command we are using now:

        Add_Custom_Command(TARGET "${PROJECT}"
                           POST_BUILD
                           COMMAND "${command}" ARGS ${argumentList})

It would be AWESOME if we could use a command like this:

        Add_Custom_Command(TARGET "${PROJECT}"
                           POST_BUILD
                           CONFIGURATIONS ${configuration}
                           COMMAND "${command}" ARGS ${argumentList})

which would be similar to the Install command.

This is not a problem for our NMake or Codeblocks/Unix-based makefiles, because those makefiles are target-based, not based on project configuration.

Your help and contributions are greatly appreciated :-D

Luke
We appreciate all the hard work you have contributed to keep CMake updated and the users of CMake satisfied. Keep up the good work!

Luke
Columbus, Ohio
Go bucks!
No tags attached.
duplicate of 0009974closed Brad King CMake should support custom commands that can vary by configuration. 
Issue History
2008-01-14 17:52Luke KNew Issue
2008-01-14 19:21Alex NeundorfCategoryCCMake => CMake
2008-01-14 21:19Bill HoffmanStatusnew => assigned
2008-01-14 21:19Bill HoffmanAssigned To => David Cole
2009-12-28 15:38David ColeAssigned ToDavid Cole => Brad King
2010-01-04 10:28Brad KingNote Added: 0019020
2012-03-09 14:41Brad KingNote Added: 0028883
2012-03-09 14:41Brad KingRelationship addedduplicate of 0009974
2012-03-09 14:41Brad KingStatusassigned => resolved
2012-03-09 14:41Brad KingResolutionopen => duplicate
2012-09-03 16:00David ColeNote Added: 0030832
2012-09-03 16:00David ColeStatusresolved => closed

Notes
(0019020)
Brad King   
2010-01-04 10:28   
Currently add_custom_command is one of the remaining places where we do not support per-configuration rules. This has been on my back burner for years but I do not know when I'll have time to finally do it.

It is possible to work around the limitation in some cases like this:

  add_custom_command(OUTPUT ... DEPENDS ...
    COMMAND ${CMAKE_COMMAND} -Dconfig=${CMAKE_CFG_INTDIR} -P myscript.cmake
    )

where myscript.cmake inspects the value of "config" to determine the configuration being built.

FYI, you can solve the original problem using the RUNTIME_OUTPUT_DIRECTORY target property. This will cause the build system to link the executable directly in the destination directory.
(0028883)
Brad King   
2012-03-09 14:41   
Resolving as duplicate of 0009974. Even though that one came later more discussion and updates have occurred there.
(0030832)
David Cole   
2012-09-03 16:00   
Closing resolved issues that have not been updated in more than 4 months.