[CMake] Set default build type in CMakeLists.txt

James Bigler jamesbigler at gmail.com
Mon Jun 22 11:56:23 EDT 2009


On Mon, Jun 22, 2009 at 9:54 AM, Tyler Roscoe <tyler at cryptio.net> wrote:
>
> On Mon, Jun 22, 2009 at 11:42:34AM -0400, David Doria wrote:
> > I thought I could set the default build type with the following:
> >
> > SET(CMAKE_BUILD_TYPE debug)
> > PROJECT(Test)
> > ADD_EXECUTABLE(Test Test.cpp)
> >
> > However, when I run ccmake and then press 'c', the CMAKE_BUILD_TYPE field is
> > still empty. Is it set and just not showing up? Or has it not been set
> > properly?
>
> You need to use the form set(... CACHE ...) if you want that value to
> appear in the cache. Look at the docs for set().
>
> tyler
> _______________________________________________

You may also need to use FORCE:

if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE "Release" CACHE STRING
      "Choose the type of build, options are: Debug Release
RelWithDebInfo MinSizeRel."
      FORCE)
endif(NOT CMAKE_BUILD_TYPE)

James


More information about the CMake mailing list