From cac0283e7d2d77885911025b40c4042a0faebd49 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Thu, 2 Mar 2017 21:18:54 +0000 Subject: [PATCH] [CMake] For single configuration generators only allow `CMAKE_BUILD_TYPE` to be one of the pre-defined build configurations that we support. --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ca94689e..87bd07f31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,6 +112,13 @@ else() set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${available_build_types}) endif() message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") + + # Check the selected build type is valid + list(FIND available_build_types "${CMAKE_BUILD_TYPE}" _build_type_index) + if ("${_build_type_index}" EQUAL "-1") + message(FATAL_ERROR "\"${CMAKE_BUILD_TYPE}\" is an invalid build type.\n" + "Use one of the following build types ${available_build_types}") + endif() endif() # CMAKE_BUILD_TYPE has no meaning for multi-configuration generators