[CMake] Adding a buildstep to all targets

jens persson jens at persson.cx
Fri Oct 9 05:28:40 EDT 2009


Hello,

I'm trying to convert an old home grown buildsystem based on make to
cmake and one of the requisites[1] is that I need to build each
executable in two versions, one with debug symbols and one without. I
have solved it now with a add_custom_command call for every target
like this

add_custom_command(TARGET test
  COMMAND cp ../../bin/test ../../bin/test_debug
  COMMAND strip ../../bin/test
)

but it feels a bit repetitive and it would be nice to do something like

add_custom_command(TARGET *
  COMMAND cp $(CMAKE_TARGET) $CMAKE_TARGET)_debug
  COMMAND strip $(CMAKE_TARGET)
)

Is there a way to do this that I haven't found yet?

Best regards
/jp


[1] don't get me started on why, but it is needed...
-- 
jens persson
<jens at persson.cx>
Mäster Olofsväg 24
S-224 66 LUND;SWEDEN


More information about the CMake mailing list