[CMake] Adding a buildstep to all targets

Alexander Neundorf a.neundorf-work at gmx.net
Sun Oct 11 08:38:41 EDT 2009


On Friday 09 October 2009, Hendrik Sattler wrote:
> Zitat von jens persson <jens at persson.cx>:
> > 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
>
> [...]
>
> > Is there a way to do this that I haven't found yet?
>
> Use the RelWithDebInfo build type and install once using the install
> target and once using the install/strip target. No need to do anything
> in your CMakeLists.txt, then. Maybe the CMAKE_INSTALL_PREFIX (or some
> custom own variable) should differ between both install calls.

Yes.
Another solution would be that you write your own custom foo_add_executable() 
macro, which you then always use instead of the plain add_executable():

macro(FOO_ADD_EXECUTABLE _target ...args)
   add_executable(${_target} ...)
   add_custom_command(TARGET ${_targets} ... }
endmacro(FOO_ADD_EXECUTABLE ...args)

Alex


More information about the CMake mailing list