[CMake] setting configuration specific options in visual studio

Christian Ehrlicher Ch.Ehrlicher at gmx.de
Tue Nov 20 01:58:44 EST 2007


> Von: "Salvatore Iovene"
> CC: cmake at cmake.org
> Betreff: Re: [CMake] setting configuration specific options in visual studio
> 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.
> 
This does not apply to the VisualStudio vcproj generator.
Linking with different libraries can be achieved by using 'debug' and 'release' keyword in you lib definition. See FindQt4.cmake:

SET(QT_${basename}_LIBRARY       optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})


HTH
Christian
-- 
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail


More information about the CMake mailing list