if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "Setting default build type to Debug")
  set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE)
  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
    "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif ()

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
  set(DEBUG 1)
  set(RELEASE 0)
  set(MIN_SIZE_REL 0)
  set(REL_WITH_DEB_INFO 0)
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
  set(DEBUG 0)
  set(RELEASE 1)
  set(MIN_SIZE_REL 0)
  set(REL_WITH_DEB_INFO 0)
elseif (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
  set(DEBUG 0)
  set(RELEASE 0)
  set(MIN_SIZE_REL 1)
  set(REL_WITH_DEB_INFO 0)
elseif (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
  set(DEBUG 0)
  set(RELEASE 0)
  set(MIN_SIZE_REL 0)
  set(REL_WITH_DEB_INFO 1)
endif ()

message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
