[CMake] Header only targets, solution folders and shared settings?

Eric Noulard eric.noulard at gmail.com
Mon May 21 05:22:01 EDT 2007


2007/5/21, Kenny Erleben <kenny at diku.dk>:
> Eric Noulard skrev:
> > 2007/5/20, Kenny Erleben <kenny at diku.dk>:
> >
> >> iii) How to make several executables share the same compiler- and
> >> linker- flags?
> >
> > you may define a CMake variable
> > SET(MYCFLAGS "jkdlfjlj")
> > SET(MYLDFLAGS "ljjl")
> >
> > then you may use
> > SET_TARGET_PROPERTIES(target1 target2
> >                                           PROPERTIES
> >                                           COMPILE_FLAGS ${MYCFLAGS}
> >                                           LINK_FLAGS ${MYLDFLAGS})
> How can I use different flags for debug and optimized versions?

I would test the value of CMAKE_BUILD_TYPE
and SET your MYxxxFLAGS accordingly.
something like:

IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
   SET ...
ELSE (CMAKE_BUILD_TYPE STREQUAL "Debug")
   SET ...
ENDIF (CMAKE_BUILD_TYPE STREQUAL "Debug")

as a side note you should look at the wiki
http://www.cmake.org/Wiki/CMake_Useful_Variables

and look for
"You can create your own build type"

you may search ML archive for this kind of subject too
may be it is another suitable way to do what you want
with your "custom" FLAGS

-- 
Erk


More information about the CMake mailing list