From b17e3d8734608f159d7c171a9da09ab0a7dcf5cb Mon Sep 17 00:00:00 2001 From: Ben Morgan <ben.morgan@warwick.ac.uk> Date: Fri, 21 Apr 2023 15:12:35 +0100 Subject: [PATCH] Simplify use of COLOR_DEFS output Color variables will be empty strings if color isn't available, so message() calls can use them directly and not worry about this. --- cmake/BuildType.cmake | 12 +++--------- cmake/PrintBuildInfo.cmake | 15 ++++----------- cmake/SetupCoin3D.cmake | 6 +----- cmake/SetupJSON.cmake | 6 +----- cmake/SetupXercesC.cmake | 8 ++------ cmake/configure_cpp_options.cmake | 4 +--- 6 files changed, 12 insertions(+), 39 deletions(-) diff --git a/cmake/BuildType.cmake b/cmake/BuildType.cmake index 14a12a8cc..ac66a37a7 100644 --- a/cmake/BuildType.cmake +++ b/cmake/BuildType.cmake @@ -14,15 +14,9 @@ set(default_build_type "Release") # endif() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - if( COLOR_DEFS ) - message(STATUS "${Blue}INFO: Setting build type to '${default_build_type}' as none was specified.${ColourReset}") - else() - message(STATUS "INFO: Setting build type to '${default_build_type}' as none was specified.") - endif() - set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE - STRING "Choose the type of build." FORCE) + message(STATUS "${Blue}INFO: Setting build type to '${default_build_type}' as none was specified.${ColourReset}") + set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Release" "MinSizeRel" "RelWithDebInfo") + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() diff --git a/cmake/PrintBuildInfo.cmake b/cmake/PrintBuildInfo.cmake index 862a34b45..68d6ac021 100644 --- a/cmake/PrintBuildInfo.cmake +++ b/cmake/PrintBuildInfo.cmake @@ -1,13 +1,6 @@ # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -if( COLOR_DEFS ) - message(STATUS "-----") - message(STATUS "${BoldYellow}Building with type: ${CMAKE_BUILD_TYPE}${ColourReset}") - message(STATUS "${BoldYellow}Using C++ standard: ${CMAKE_CXX_STANDARD}${ColourReset}") - message(STATUS "-----") -else() - message(STATUS "-----") - message(STATUS "Building with type: ${CMAKE_BUILD_TYPE}") - message(STATUS "Using C++ standard: ${CMAKE_CXX_STANDARD}") - message(STATUS "-----") -endif() +message(STATUS "-----") +message(STATUS "${BoldYellow}Building with type: ${CMAKE_BUILD_TYPE}${ColourReset}") +message(STATUS "${BoldYellow}Using C++ standard: ${CMAKE_CXX_STANDARD}${ColourReset}") +message(STATUS "-----") diff --git a/cmake/SetupCoin3D.cmake b/cmake/SetupCoin3D.cmake index d8372de2a..98d818f55 100644 --- a/cmake/SetupCoin3D.cmake +++ b/cmake/SetupCoin3D.cmake @@ -20,11 +20,7 @@ option( GEOMODEL_USE_BUILTIN_COIN3D if( GEOMODEL_USE_BUILTIN_COIN3D ) # Tell the user what's happening. - if( COLOR_DEFS ) - message( STATUS "${BoldMagenta}'GEOMODEL_USE_BUILTIN_COIN3D' was set to 'true' ==> Building Coin and SoQt as part of the project${ColourReset}" ) - else() - message( STATUS "'GEOMODEL_USE_BUILTIN_COIN3D' was set to 'true' ==> Building Coin and SoQt as part of the project" ) - endif() + message( STATUS "${BoldMagenta}'GEOMODEL_USE_BUILTIN_COIN3D' was set to 'true' ==> Building Coin and SoQt as part of the project${ColourReset}" ) # External(s) required for the build. find_package( Boost REQUIRED ) diff --git a/cmake/SetupJSON.cmake b/cmake/SetupJSON.cmake index 3e6312b0d..a516cde54 100644 --- a/cmake/SetupJSON.cmake +++ b/cmake/SetupJSON.cmake @@ -21,11 +21,7 @@ option( GEOMODEL_USE_BUILTIN_JSON if( GEOMODEL_USE_BUILTIN_JSON ) # Tell the user what's happening. - if( COLOR_DEFS ) - message( STATUS "${BoldMagenta}'GEOMODEL_USE_BUILTIN_JSON' was set to 'true' ==> Building nlohmann_json as part of the project${ColourReset}" ) - else() - message( STATUS "'GEOMODEL_USE_BUILTIN_JSON' was set to 'true' ==> Building nlohmann_json as part of the project" ) - endif() + message( STATUS "${BoldMagenta}'GEOMODEL_USE_BUILTIN_JSON' was set to 'true' ==> Building nlohmann_json as part of the project${ColourReset}" ) # The include directory and library that will be produced. set( nlohmann_json_INCLUDE_DIR diff --git a/cmake/SetupXercesC.cmake b/cmake/SetupXercesC.cmake index da6ec6fda..e42cb94c0 100644 --- a/cmake/SetupXercesC.cmake +++ b/cmake/SetupXercesC.cmake @@ -20,16 +20,12 @@ option( GEOMODEL_USE_BUILTIN_XERCESC if( GEOMODEL_USE_BUILTIN_XERCESC ) # Tell the user what's happening. - if( COLOR_DEFS ) - message( STATUS "${BoldMagenta}'GEOMODEL_USE_BUILTIN_XERCESC' was set to 'true' ==> Building XercesC as part of the project${ColourReset}" ) - else() - message( STATUS "'GEOMODEL_USE_BUILTIN_XERCESC' was set to 'true' ==> Building XercesC as part of the project" ) - endif() + message( STATUS "${BoldMagenta}'GEOMODEL_USE_BUILTIN_XERCESC' was set to 'true' ==> Building XercesC as part of the project${ColourReset}" ) # The include directory and library that will be produced. set( XercesC_INCLUDE_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCInstall/${CMAKE_INSTALL_INCLUDEDIR}" CACHE PATH "Path to the Xerces-C include directory" FORCE ) - set( XercesC_INCLUDE_DIRS "${XercesC_INCLUDE_DIR}" ) + set( XercesC_INCLUDE_DIRS "${XercesC_INCLUDE_DIR}" ) set( XercesC_LIBRARY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCInstall/lib/${CMAKE_SHARED_LIBRARY_PREFIX}xerces-c${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE PATH "Path to the Xerces-C library file" FORCE ) set( XercesC_LIBRARIES "${XercesC_LIBRARY}" ) diff --git a/cmake/configure_cpp_options.cmake b/cmake/configure_cpp_options.cmake index 9a6cc8a79..4b7db9d28 100644 --- a/cmake/configure_cpp_options.cmake +++ b/cmake/configure_cpp_options.cmake @@ -18,8 +18,7 @@ set( CMAKE_BUILD_TYPE "Release" CACHE STRING "CMake build mode to use" ) set( CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard used for the build" ) set( CMAKE_CXX_EXTENSIONS FALSE CACHE BOOL "(Dis)allow using GNU extensions" ) -set( CMAKE_CXX_STANDARD_REQUIRED TRUE CACHE BOOL - "Require the specified C++ standard for the build" ) +set( CMAKE_CXX_STANDARD_REQUIRED TRUE CACHE BOOL "Require the specified C++ standard for the build" ) # Setting CMAKE_CXX_FLAGS to avoid "deprecated" warnings set(CMAKE_CXX_FLAGS "-Wno-deprecated-declarations" ) # very basic @@ -28,7 +27,6 @@ set(CMAKE_CXX_FLAGS "-Wno-deprecated-declarations" ) # very basic #set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror -pedantic-errors" ) # better for an even more severe check #set(CMAKE_CXX_FLAGS "-Weverything -Werror -pedantic-errors" ) # not recommended, it warns for really EVERYTHING! - # TODO: for Debug and with GCC, do we want to set the flags below by default? # set( CMAKE_BUILD_TYPE DEBUG ) # set(CMAKE_CXX_FLAGS "-fPIC -O0 -g -gdwarf-2" ) -- GitLab