[CMake] Setting build type

Adam Getchell adam.getchell at gmail.com
Tue Feb 24 14:42:03 EST 2015


Hello all,

I've browsed this thread:

http://www.cmake.org/pipermail/cmake/2008-September/023808.html

But it doesn't work. My project is set to Release regardless, whether I do:

project( CDT-plusplus_ )
set(CMAKE_BUILD_TYPE RelWithDebInfo)

Or:

#
# If the user specifies -DCMAKE_BUILD_TYPE on the command line, take their
definition
# and dump it in the cache along with proper documentation, otherwise set
CMAKE_BUILD_TYPE
# to Debug prior to calling PROJECT()
#
IF(DEFINED CMAKE_BUILD_TYPE)
   SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of
build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug
Release RelWithDebInfo MinSizeRel.")
ELSE()
   SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build,
options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release
RelWithDebInfo MinSizeRel.")
ENDIF()

project( CDT-plusplus_ )

The only way I can change the build type is by going into my build
directory and editing CMakeCache.txt. However, I use an out of source
build, so my build directory is generated automatically by scripts such as:

https://github.com/acgetchell/CDT-plusplus/blob/master/scan-build.sh

What's the correct method for being able to set the type of build via the
command line?

-- 
Adam Getchell
about.me/adamgetchell
"Invincibility is in oneself, vulnerability in the opponent." -- Sun Tzu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150224/7a2831b5/attachment.html>


More information about the CMake mailing list