diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c03f5d37b5566b21e6aa3503ef1a19cdce1ebd6..a1f32af2807940a9be738a1391372db2a925768a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,12 +46,19 @@ MARK_AS_ADVANCED( CMAKE_EXE_LINKER_FLAGS_COVERAGE CMAKE_SHARED_LINKER_FLAGS_COVERAGE ) +if(CMAKE_BUILD_TYPE) + string(REGEX MATCH "(Debug|Release|RelWithDebInfo|MinSizeRel|Coverage)" VALID_BUILD_TYPE "${CMAKE_BUILD_TYPE}") + if(NOT VALID_BUILD_TYPE) + message(FATAL_ERROR "Invalid CMAKE_BUILD_TYPE: '${CMAKE_BUILD_TYPE}'") + endif() +endif() + # Default build type is RelWIthDebInfo if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build: Debug Release RelWithDebInfo MinSizeRel Coverage." FORCE) -endif(NOT CMAKE_BUILD_TYPE) +endif() #------------------------------------------------------