[CMake] configuration specific ADD_CUSTOM_COMMAND (was: Target properties LOCATION and DEBUG_POSTFIX)

Martin Lutken mlu at danware.dk
Tue Mar 11 11:43:32 EDT 2008


Yes just use something like:

IF ( ${CMAKE_BUILD_TYPE} STREQUAL "Debug" )

ENDIF ( ${CMAKE_BUILD_TYPE} STREQUAL "Debug" )

IF ( ${CMAKE_BUILD_TYPE} STREQUAL "Release" )

ENDIF ( ${CMAKE_BUILD_TYPE} STREQUAL "Release" )


-Martin Lutken

On Tuesday 11 March 2008 10:16:32 Zschocke, Florian wrote:
> Hi!
>
> I'm trying this again from a different angle:
>
> Is it possible to add a custom command only for a specific
> configuration, i.e. build type? So I could add a certain command only
> for DEBUG and a different one for RELEASE?
>
> Thanks,
> Florian Zschocke
>
> > -----Original Message-----
> > From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On
> > Behalf Of Zschocke, Florian
> > Sent: Tuesday, March 04, 2008 11:22 AM
> > To: cmake at cmake.org
> > Subject: [CMake] Target properties LOCATION and DEBUG_POSTFIX
> >
> > Hi!
> >
> > I have some trouble using a target's LOCATION property in order to
> > build
> > a custom command. Maybe someone can tell me if this is by design and
> > whether I can do what I intend to.
> >
> > I have a target that has a changed name as well as an added postfix
>
> for
>
> > the Debug configuration.
> >
> > ADD_EXECUTABLE( test test.c )
> > SET_TARGET_PROPERTIES( test PROPERTIES OUPUT_NAME hello )
> > SET_TARGET_PROPERTIES( test PROPERTIES DEBUG_POSTFIX d )
> >
> > So now I expect the resulting executable to be called "hello"
> > respectively "hellod" when building in Debug configuration. So far
>
> this
>
> > is working.
> >
> > Now I want to add a custom command which acts on the executable. Let's
> > say I want to copy it someplace else. My problem is, how can I address
> > the executable in the custom command? Consider the following example
> > custom command.
> >
> > ADD_CUSTOM_COMMAND( TARGET test POST_BUILD COMMAND cp ${PROGRAM}
> > someplace )
> >
> > The thing is, how can I set the PROGRAM variable to the correct name
> > and
> > path of the executable built? Because simply using the LOCATION
> > property
> > won't work for the Debug configuration as it will use the standard
>
> name
>
> > "hello". The DEBUG_LOCATION gives the correct name, with the 'd'
> > appended. But that means that I would have to actually check for the
> > BUILD_TYPE and set the PROGRAM variable using the correct LOCATION
> > type.
> > Which begs the question (as I haven't tested that yet) if that
>
> actually
>
> > works for building MSVS8 project files, too.
> >
> > Isn't there some way to get "just the right" value of LOCATION for the
> > current BUILD_TYPE without having to explicitely checking every
> > possible
> > build type?
> >
> > Thanks,
> > Florian
> >
> > _______________________________________________
> > CMake mailing list
> > CMake at cmake.org
> > http://www.cmake.org/mailman/listinfo/cmake
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake




More information about the CMake mailing list