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
This commit is contained in:
rdb 2020-12-22 16:47:29 +01:00
parent 131ae98bfd
commit 4747e6e4df

View File

@ -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}")