From 471662f7c94b881821803b4d1379deee5e6d59ae Mon Sep 17 00:00:00 2001 From: Michael Dusan Date: Wed, 12 Feb 2020 17:23:48 -0500 Subject: [PATCH] stage1: limit cmake checks on build type Various maintainers pass custom build types and we don't need to check those. We are interested only in checking and diagnosing common errors for Zig project supported types. Check is now limited to look for case-mismatch only on the well-known values { Debug, Release, RelWithDebInfo, MinSizeRel }. --- CMakeLists.txt | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a8ec226e004ecc25250e546b8fdb450a6877373..a6d5a9e810ed08472d8a8fc2d2bee317ca211391 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,16 +5,21 @@ if(NOT CMAKE_BUILD_TYPE) "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) endif() -set(_list "None;Debug;Release;RelWithDebInfo;MinSizeRel") -list(FIND _list ${CMAKE_BUILD_TYPE} _index) -if(${_index} EQUAL -1) - string(REPLACE ";" ", " _list_pretty "${_list}") - message("::") - message(":: ERROR: Invalid build type: ${CMAKE_BUILD_TYPE}") - message("::") - message(":: valid types: { ${_list_pretty} }") - message("::") - message(FATAL_ERROR) +set(_list "Debug;Release;RelWithDebInfo;MinSizeRel") +string(TOLOWER "${_list}" _list_lower) +string(TOLOWER ${CMAKE_BUILD_TYPE} _build_type_lower) +list(FIND _list_lower "${_build_type_lower}" _index) +if(NOT ${_index} EQUAL -1) + list(FIND _list "${CMAKE_BUILD_TYPE}" _index) + if(${_index} EQUAL -1) + string(REPLACE ";" ", " _list_pretty "${_list}") + message("::") + message(":: ERROR: build type case-mismatch: ${CMAKE_BUILD_TYPE}") + message("::") + message(":: valid types: { ${_list_pretty} }") + message("::") + message(FATAL_ERROR) + endif() endif() if(NOT CMAKE_INSTALL_PREFIX) -- 2.54.0