Check CMake build type

If an unsupported CMake build type is used, it is accepted but generate
strange builds for the compiler. This commit adds a check that only one
of the standard build types are used.
This commit is contained in:
Mats Kindahl 2021-03-08 15:13:19 +01:00 committed by Mats Kindahl
parent b6510a063a
commit a36099a686

View File

@ -61,6 +61,11 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel" FORCE)
endif ()
set(SUPPORTED_BUILD_TYPES Debug Release RelWithDebugInfo MinSizeRel)
if (NOT CMAKE_BUILD_TYPE IN_LIST SUPPORTED_BUILD_TYPES)
message(FATAL_ERROR "Bad CMAKE_BUILD_TYPE. Expected one of ${SUPPORTED_BUILD_TYPES}")
endif()
message(STATUS "TimescaleDB version ${PROJECT_VERSION_MOD}. Can be updated from version ${UPDATE_FROM_VERSION}")
message(STATUS "Build type is ${CMAKE_BUILD_TYPE}")