Allow a random name for the build type. If not recognized, it is set to None

This commit is contained in:
Carles Fernandez 2020-06-27 19:51:22 +02:00
parent 23e13a7002
commit a5aa0d2549
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
3 changed files with 15 additions and 5 deletions

View File

@ -245,13 +245,17 @@ if((${CMAKE_SYSTEM_NAME} MATCHES "Linux|kFreeBSD|GNU") AND (CMAKE_CXX_COMPILER_I
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Fix for Debug mode in macOS
# Fix for Debug and None modes in macOS
# without this, get get a runtime error
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-fstandalone-debug HAVE_STANDALONE_DEBUG)
check_cxx_compiler_flag(-Og HAVE_OG_FLAG)
if(HAVE_STANDALONE_DEBUG AND HAVE_OG_FLAG)
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g -fstandalone-debug")
set(CMAKE_C_FLAGS_DEBUG "-Og -g -fstandalone-debug")
if(CMAKE_BUILD_TYPE STREQUAL "None")
add_compile_options(-Og -fstandalone-debug)
endif()
endif()
endif()
endif()

View File

@ -38,8 +38,8 @@ list(APPEND AVAIL_BUILDTYPES
# checks the value set in the cmake interface against the list of
# known build types in AVAIL_BUILDTYPES. If the build type is found,
# the function exits immediately. If nothing is found by the end of
# checking all available build types, we exit with an error and list
# the available build types.
# checking all available build types, we exit with a soft warning, listing
# the available build types, and setting the build type to None.
########################################################################
function(GNSSSDR_CHECK_BUILD_TYPE settype)
string(TOUPPER ${settype} _settype)
@ -49,8 +49,10 @@ function(GNSSSDR_CHECK_BUILD_TYPE settype)
return() # found it; exit cleanly
endif()
endforeach()
# Build type not found; error out
message(FATAL_ERROR "Build type '${settype}' not valid, must be one of: ${AVAIL_BUILDTYPES}")
# Build type not found; warn out at set it to None
message(STATUS "Warning: Build type '${settype}' not valid, must be one of: ${AVAIL_BUILDTYPES}.")
message(STATUS "Setting the build type to 'None'")
set(CMAKE_BUILD_TYPE "None" PARENT_SCOPE)
endfunction()

View File

@ -49,6 +49,10 @@ SPDX-FileCopyrightText: 2011-2020 Carles Fernandez-Prades <carles.fernandez@cttc
fallback. The latter has been updated to version
[0.37.0](https://github.com/gsl-lite/gsl-lite/releases/tag/0.37.0).
- Improved finding of libgfortran in openSUSE and Fedora distributions.
- Allow a random name for the build type. If not recognized, it is set to
`None`. This allows packaging in some distributions that pass an arbitrary
name as the build type (e.g., Gentoo) to avoid unexpected compiler flags. The
building option `ENABLE_PACKAGING` must set to `ON` when packaging.
### Improvements in Reliability: