[CMake] setting configuration specific options in visual studio

Salvatore Iovene salvatore.iovene+cmake at googlemail.com
Tue Nov 20 01:42:55 EST 2007


On Nov 20, 2007 1:38 AM, Jesse Corrington <jesse.corrington at gmail.com> wrote:
> I searched the archives and couldn't find any good information about this
> task, which I would assume is important to many people. I need to set
> options in visual studio that are different in debug and release modes. For
> example I need to set preprocessor defines, change compiler flags, link with
> different libraries, and other settings.
>
> Is there anyway to do something like this.
>
> IF ( RELEASE )
>     ADD_DEFINITIONS( -DREL1 )
> ELSEIF ( DEBUG )
>     ADD_DEFINITIONS( -DDEB1 )
> ENDIF ()

Look at the CMAKE_BUILD_TYPE variable in
http://www.cmake.org/Wiki/CMake_Useful_Variables
Basically you can have variables like CMAKE_CXX_FLAGS_DEBUG,
CMAKE_CXX_FLAGS_RELEASE, CMAKE_CXX_FLAGS_WHATEVER, and the correct
variable is chosen by cmake according to the value of CMAKE_BUILD_TYPE
(e.g. DEBUG, RELEASE or WHATEVER.

--
Salvatore Iovene
http://www.iovene.com/
Key Fingerprint: 5647 944D D5AD 2E87 00B4  7D54 2864 359D FF20 16D8


More information about the CMake mailing list