From aa86e978469e75691bd8f83e4a9fedd07aec283c Mon Sep 17 00:00:00 2001 From: Mathias Preiner Date: Wed, 12 Sep 2018 13:58:41 -0700 Subject: [PATCH] cmake: Simplify build type configuration. --- CMakeLists.txt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4120e5984..a1d137232 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -273,11 +273,14 @@ option(BUILD_BINDINGS_PYTHON "Build Python bindings") set(OPTIMIZATION_LEVEL 3) set(GPL_LIBS "") -set(BUILD_TYPES Production Debug Testing Competition) - #-----------------------------------------------------------------------------# # Build types + +# Note: Module CodeCoverage requires the name of the debug build to conform +# to cmake standards (first letter uppercase). +set(BUILD_TYPES Production Debug Testing Competition) + if(ENABLE_ASAN) set(CMAKE_BUILD_TYPE Debug) endif() @@ -289,20 +292,17 @@ if(NOT CMAKE_BUILD_TYPE) # Provide drop down menu options in cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${BUILD_TYPES}) endif() -message(STATUS "Building ${CMAKE_BUILD_TYPE} build") -# Note: Module CodeCoverage requires the name of the debug build to conform -# to cmake standards (first letter uppercase). -if(CMAKE_BUILD_TYPE STREQUAL "Debug") - include(ConfigDebug) -elseif(CMAKE_BUILD_TYPE STREQUAL "Production") - include(ConfigProduction) -elseif(CMAKE_BUILD_TYPE STREQUAL "Testing") - include(ConfigTesting) -elseif(CMAKE_BUILD_TYPE STREQUAL "Competition") - include(ConfigCompetition) +list(FIND BUILD_TYPES ${CMAKE_BUILD_TYPE} FOUND_BUILD_TYPE) +if(${FOUND_BUILD_TYPE} EQUAL -1) + message(FATAL_ERROR + "'${CMAKE_BUILD_TYPE}' is not a valid build type. " + "Available builds are: ${BUILD_TYPES}") endif() +message(STATUS "Building ${CMAKE_BUILD_TYPE} build") +include(Config${CMAKE_BUILD_TYPE}) + #-----------------------------------------------------------------------------# # Compiler flags -- 2.30.2