From 4747e6e4dfd477518011ed8b509c1262e799111c Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 22 Dec 2020 16:47:29 +0100 Subject: [PATCH] CMake: Fix CMAKE_CONFIGURATION_TYPES not including Coverage Coverage is added based on the value of CMAKE_CXX_COMPILER_ID, which isn't known until after the project() call. This fixes a regression in f26f7d22260b85ea4d0d6044dc2c410ad1da8a20 --- CMakeLists.txt | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 26cf644c17..685586e8d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,24 +32,16 @@ a CMake < 3.9. Making a guess if this is a multi-config generator.") endif() endif() -# Define the type of build we are setting up. -set(_configs Standard Release RelWithDebInfo Debug MinSizeRel) -if(CMAKE_CXX_COMPILER_ID MATCHES "(AppleClang|Clang|GCC)") - list(APPEND _configs Coverage) -endif() - +# Set the default CMAKE_BUILD_TYPE before calling project(). if(IS_MULTICONFIG) message(STATUS "Using multi-configuration generator") - set(CMAKE_CONFIGURATION_TYPES "${_configs}" CACHE STRING "") else() - # Set the default CMAKE_BUILD_TYPE before calling project(). if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Standard CACHE STRING "Choose the type of build." FORCE) message(STATUS "Using default build type ${CMAKE_BUILD_TYPE}") else() message(STATUS "Using build type ${CMAKE_BUILD_TYPE}") endif() - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${_configs}) endif() # Set defaults for macOS, must be before project(). @@ -76,6 +68,20 @@ project(Panda3D VERSION ${_version}) unset(_version) unset(_s) +# Determine the possible build types. Must be *after* calling project(). +set(_configs Standard Release RelWithDebInfo Debug MinSizeRel) +if(CMAKE_CXX_COMPILER_ID MATCHES "(AppleClang|Clang|GCC)") + list(APPEND _configs Coverage) +endif() + +message("available configs are ${_configs}") + +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "${_configs}" CACHE STRING "" FORCE) +else() + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${_configs}) +endif() + enable_testing() string(REPLACE "$(EFFECTIVE_PLATFORM_NAME)" "" PANDA_CFG_INTDIR "${CMAKE_CFG_INTDIR}")