From 7fc65e3330cc86e88570067a4f99f6d794992ac1 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Thu, 25 Oct 2018 23:06:40 +0200 Subject: [PATCH] Check for valid CMake build type Fixes #3 --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c03f5d37..a1f32af28 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() #------------------------------------------------------ -- GitLab