1 # Derived from Marcus D. Hanwell's suggestion
2 # https://blog.kitware.com/cmake-and-the-default-build-type/
4 # Set a default build type if none was specified
5 set(default_build_type "Release")
7 # For builds from Git, default to Debug
8 if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
9 set(default_build_type "Debug")
12 # Multi-config generators (such as the VS one) will set the config types
13 if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
14 message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
15 set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
16 STRING "Choose the type of build." FORCE)
17 # Set the possible values of build type for cmake-gui
18 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
20 message(STATUS "CMake build type: ${CMAKE_BUILD_TYPE}")