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)
endif()
include(CheckCXXCompilerFlag)
foreach(_std gnu++11 gnu++0x)
set(_cxx1x_flag -std=${_std})
check_cxx_compiler_flag(${_cxx1x_flag} CXX_FLAG_-std_${_std})
if(CXX_FLAG_-std_${_std})
include(ExtractValidFlags)
foreach(_cxx1x_flag -std=gnu++11 -std=gnu++0x)
extract_valid_cxx_flags(_cxx1x_flag_supported ${_cxx1x_flag})
if(_cxx1x_flag_supported)
set(CXX1XCXXFLAGS ${_cxx1x_flag})
break()
endif()
@ -381,7 +380,6 @@ if(HAVE_EPOLL AND HAVE_TIMERFD_CREATE)
set(ENABLE_TINY_NGHTTPD 1)
endif()
include(ExtractValidFlags)
if(ENABLE_WERROR)
# For C compiler
extract_valid_c_flags(WARNCFLAGS

View File

@ -7,7 +7,7 @@ include(CheckCXXCompilerFlag)
function(extract_valid_c_flags varname)
set(valid_flags "")
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}")
check_c_compiler_flag("${flag}" "${flag_var}")
if(${flag_var})
@ -20,7 +20,7 @@ endfunction()
function(extract_valid_cxx_flags varname)
set(valid_flags "")
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}")
check_cxx_compiler_flag("${flag}" "${flag_var}")
if(${flag_var})