From: Guy Harris Date: Fri, 9 Aug 2019 20:41:06 +0000 (-0700) Subject: Always define check_and_add_compiler_option(). X-Git-Tag: tcpdump-4.99-bp~710 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/675f67a20b0a94eef8288b0016f959a1597615cc Always define check_and_add_compiler_option(). --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 85ff0382..79763aa6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,27 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) project(tcpdump) +# +# For checking if a compiler flag works and adding it if it does. +# +include(CheckCCompilerFlag) +macro(check_and_add_compiler_option _option) + message(STATUS "Checking C compiler flag ${_option}") + string(REPLACE "=" "-" _temp_option_variable ${_option}) + string(REGEX REPLACE "^-" "" _option_variable ${_temp_option_variable}) + check_c_compiler_flag("${_option}" ${_option_variable}) + if(${${_option_variable}}) + set(C_ADDITIONAL_FLAGS "${C_ADDITIONAL_FLAGS} ${_option}") + endif() +endmacro() + # # If we're building with Visual Studio, we require Visual Studio 2015, # in order to get sufficient C99 compatibility. Check for that. # +# If not, try the appropriate flag for the compiler to enable C99 +# features. +# if(MSVC) if(MSVC_VERSION LESS 1900) message(FATAL_ERROR "Visual Studio 2015 or later is required") @@ -53,17 +70,6 @@ else(MSVC) # that can't be made to support those features, we can add a test to make # sure we actually *have* C99 support. # - include(CheckCCompilerFlag) - macro(check_and_add_compiler_option _option) - message(STATUS "Checking C compiler flag ${_option}") - string(REPLACE "=" "-" _temp_option_variable ${_option}) - string(REGEX REPLACE "^-" "" _option_variable ${_temp_option_variable}) - check_c_compiler_flag("${_option}" ${_option_variable}) - if(${${_option_variable}}) - set(C_ADDITIONAL_FLAGS "${C_ADDITIONAL_FLAGS} ${_option}") - endif() - endmacro() - set(C_ADDITIONAL_FLAGS "") if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")