[CMake] Default value for CMAKE_BUILD_TYPE

Jean-Christophe Fillion-Robin jchris.fillionr at kitware.com
Fri May 11 11:30:10 EDT 2012


Hi Eric,

In our different projects, we use an approach similar to this one:

# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "Setting build type to 'Debug' as none was specified.")
  set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
  # Set the possible values of build type for cmake-gui
  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
    "MinSizeRel" "RelWithDebInfo")
endif()



See
http://vtk.org/gitweb?p=VTK.git;a=blob;f=CMakeLists.txt;h=a57fd66ef333fc26bf74fe658c88c3c634f54c3a;hb=HEAD#l12


Hth
Jc

On Fri, May 11, 2012 at 11:21 AM, pellegrini <pellegrini at ill.fr> wrote:

> Hi all,
>
> when cmake is run without specifying the build type using -D
> CMAKE_BUILD_TYPE, it is the Debug mode that is selected as
> the default. I would like to find a way to use Release as the default
> value when the user does not specify any build
> type in the cmake command line.
>
> From one of my previous post concerning CMAKE_INSTALL_PREFIX variable, I
> was thinking to use a similar approach i.e.:
>
> project(Foo)
>
> if (CMAKE_BUILD_TYPE_INITIALIZED_**TO_DEFAULT)
>    set(CMAKE_BUILD_TYPE Release)
> endif
>
> but cmake still sets CMAKE_BUILD_TYPE to Debug in the CMakeCache.txt file.
>
> Would you have any idea about what is wrong with my implementation ?
>
> thanks a lot.
>
> Eric
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/**
> opensource/opensource.html<http://www.kitware.com/opensource/opensource.html>
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/**CMake_FAQ<http://www.cmake.org/Wiki/CMake_FAQ>
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/**listinfo/cmake<http://www.cmake.org/mailman/listinfo/cmake>
>



-- 
+1 919 869 8849
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120511/0d941a8c/attachment.htm>


More information about the CMake mailing list