[CMake] Specifying different flags for debug/release mode

Pau Garcia i Quiles pgquiles at elpauer.org
Mon Dec 10 09:11:52 EST 2007


Quoting Christian Ehrlicher <Ch.Ehrlicher at gmx.de>:

> Hi,
>
> ist there something like target_link_libraries(debug fooD.lib   
> release foo.lib) possible for flags?
> It's needed to make Qt plugins work (yes, you can't properly build   
> Qt plugins on windows with cmake).

 From http://www.cmake.org/Wiki/CMake_Useful_Variables

CMAKE_BUILD_TYPE
  Choose the type of build. CMake has default flags for these:
None (CMAKE_C_FLAGS or CMAKE_CXX_FLAGS used)
Debug (CMAKE_C_FLAGS_DEBUG or CMAKE_CXX_FLAGS_DEBUG)
Release (CMAKE_C_FLAGS_RELEASE or CMAKE_CXX_FLAGS_RELEASE)
RelWithDebInfo (CMAKE_C_FLAGS_RELWITHDEBINFO or CMAKE_CXX_FLAGS_RELWITHDEBINFO
MinSizeRel (CMAKE_C_FLAGS_MINSIZEREL or CMAKE_CXX_FLAGS_MINSIZEREL)
Example: SET(CMAKE_BUILD_TYPE Debug)
You can create your own build type like this:
  SET(CMAKE_BUILD_TYPE distribution)
  SET(CMAKE_CXX_FLAGS_DISTRIBUTION "-O3")
  SET(CMAKE_C_FLAGS_DISTRIBUTION "-O3")
Note that CMAKE_BUILD_TYPE is not initialized with a readable value at  
configuration time. This is because the user is free to select a build  
type at build time. Use CMAKE_CFG_INTDIR if you need a variable that  
evaluates to the correct build time directory.


-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)



More information about the CMake mailing list