cmake: fix detection of -Werror flag

Do not use minus sign in macro names.
This commit is contained in:
Peter Wu 2016-02-11 22:15:46 +01:00
parent 5b21c39bb2
commit 90d66ea4a9
2 changed files with 6 additions and 8 deletions

View File

@ -106,11 +106,10 @@ else()
add_definitions(-D_U_ -DNGHTTP2_NORETURN) add_definitions(-D_U_ -DNGHTTP2_NORETURN)
endif() endif()
include(CheckCXXCompilerFlag) include(ExtractValidFlags)
foreach(_std gnu++11 gnu++0x) foreach(_cxx1x_flag -std=gnu++11 -std=gnu++0x)
set(_cxx1x_flag -std=${_std}) extract_valid_cxx_flags(_cxx1x_flag_supported ${_cxx1x_flag})
check_cxx_compiler_flag(${_cxx1x_flag} CXX_FLAG_-std_${_std}) if(_cxx1x_flag_supported)
if(CXX_FLAG_-std_${_std})
set(CXX1XCXXFLAGS ${_cxx1x_flag}) set(CXX1XCXXFLAGS ${_cxx1x_flag})
break() break()
endif() endif()
@ -381,7 +380,6 @@ if(HAVE_EPOLL AND HAVE_TIMERFD_CREATE)
set(ENABLE_TINY_NGHTTPD 1) set(ENABLE_TINY_NGHTTPD 1)
endif() endif()
include(ExtractValidFlags)
if(ENABLE_WERROR) if(ENABLE_WERROR)
# For C compiler # For C compiler
extract_valid_c_flags(WARNCFLAGS extract_valid_c_flags(WARNCFLAGS

View File

@ -7,7 +7,7 @@ include(CheckCXXCompilerFlag)
function(extract_valid_c_flags varname) function(extract_valid_c_flags varname)
set(valid_flags "") set(valid_flags "")
foreach(flag IN LISTS ARGN) foreach(flag IN LISTS ARGN)
string(REGEX REPLACE "[^a-zA-Z0-9_-]+" "_" flag_var ${flag}) string(REGEX REPLACE "[^a-zA-Z0-9_]+" "_" flag_var ${flag})
set(flag_var "C_FLAG_${flag_var}") set(flag_var "C_FLAG_${flag_var}")
check_c_compiler_flag("${flag}" "${flag_var}") check_c_compiler_flag("${flag}" "${flag_var}")
if(${flag_var}) if(${flag_var})
@ -20,7 +20,7 @@ endfunction()
function(extract_valid_cxx_flags varname) function(extract_valid_cxx_flags varname)
set(valid_flags "") set(valid_flags "")
foreach(flag IN LISTS ARGN) foreach(flag IN LISTS ARGN)
string(REGEX REPLACE "[^a-zA-Z0-9_-]+" "_" flag_var ${flag}) string(REGEX REPLACE "[^a-zA-Z0-9_]+" "_" flag_var ${flag})
set(flag_var "CXX_FLAG_${flag_var}") set(flag_var "CXX_FLAG_${flag_var}")
check_cxx_compiler_flag("${flag}" "${flag_var}") check_cxx_compiler_flag("${flag}" "${flag_var}")
if(${flag_var}) if(${flag_var})