From 1f0b280dcae14c9b4422e2cf5f8f4bf7d7c0f92e Mon Sep 17 00:00:00 2001 From: Lukas Nellen <lukas@nucleares.unam.mx> Date: Thu, 16 May 2019 14:57:30 -0500 Subject: [PATCH] Simplify: use "IN_LIST" condition --- CMakeLists.txt | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 114048b8..dcca8cad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,15 +49,9 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) STRING "Choose the type of build." FORCE) else (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) # Ignore capitalization when build type is selected manually and check for valid setting - string(TOLOWER ${CMAKE_BUILD_TYPE} selected_lower) - foreach(build ${allowed_build_types}) - string(TOLOWER ${build} build_lower) - if (build_lower STREQUAL selected_lower) - set (CMAKE_BUILD_TYPE ${build}) - set (build_type_found True) - endif() - endforeach() - if (NOT build_type_found) + string (TOLOWER ${CMAKE_BUILD_TYPE} selected_lower) + string (TOLOWER "${allowed_build_types}" build_types_lower) + if (NOT selected_lower IN_LIST build_types_lower) message (FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE} [allowed: ${allowed_build_types}]") endif () message (STATUS "Build type is: ${CMAKE_BUILD_TYPE}") -- GitLab