From: Aina Niemetz Date: Mon, 13 Aug 2018 22:22:07 +0000 (-0700) Subject: cmake: Fixed compiler flag macros. X-Git-Tag: cvc5-1.0.0~4609 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=37cdc26762e4f5436c3e1403c92d4bc825eeced2;p=cvc5.git cmake: Fixed compiler flag macros. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index c54ddfd87..26aa10f89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,36 +49,61 @@ include(CheckCXXCompilerFlag) macro(add_c_flag flag) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") + message(STATUS "Configuring with C flag '${flag}'") +endmacro() + +macro(add_cxx_flag flag) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") + message(STATUS "Configuring with CXX flag '${flag}'") +endmacro() + +macro(add_c_cxx_flag flag) + add_c_flag(${flag}) + add_cxx_flag(${flag}) endmacro() macro(add_check_c_flag flag) - check_c_compiler_flag("${flag}" HAVE_FLAG_${flag}) - if(HAVE_FLAG_${flag}) + string(REGEX REPLACE "[-=]" "_" flagname ${flag}) + check_c_compiler_flag("${flag}" HAVE_FLAG${flagname}) + if(HAVE_FLAG${flagname}) add_c_flag(${flag}) endif() endmacro() -macro(add_cxx_flag flag) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") -endmacro() - macro(add_check_cxx_flag flag) - check_cxx_compiler_flag("${flag}" HAVE_FLAG_${flag}) - if(HAVE_FLAG_${flag}) + string(REGEX REPLACE "[-=]" "_" flagname ${flag}) + check_cxx_compiler_flag("${flag}" HAVE_FLAG${flagname}) + if(HAVE_FLAG${flagname}) add_cxx_flag(${flag}) endif() endmacro() -macro(add_c_cxx_flag flag) - add_c_flag(${flag}) - add_cxx_flag(${flag}) - message(STATUS "Configure with flag '${flag}'") -endmacro() - macro(add_check_c_cxx_flag flag) add_check_c_flag(${flag}) add_check_cxx_flag(${flag}) - message(STATUS "Configure with flag '${flag}'") +endmacro() + +macro(add_required_cxx_flag flag) + string(REGEX REPLACE "[-=]" "_" flagnamename ${flag}) + check_cxx_compiler_flag("${flag}" HAVE_FLAG${flagname}) + if (NOT HAVE_FLAG${flagname}) + message(FATAL_ERROR "Required compiler flag ${flag} not supported") + endif() + add_cxx_flag(${flag}) +endmacro() + +macro(add_required_c_flag flag) + string(REGEX REPLACE "[-=]" "_" flagname ${flag}) + check_c_compiler_flag("${flag}" HAVE_FLAG${flagname}) + if (NOT HAVE_FLAG${flagname}) + message(FATAL_ERROR "Required compiler flag ${flag} not supported") + endif() + add_c_flag(${flag}) +endmacro() + +macro(add_required_c_cxx_flag flag) + add_required_c_flag(${flag}) + add_required_cxx_flag(${flag}) endmacro() macro(cvc4_link_library library)