Fixed the CMake add_cxx_compiler_flag function

This commit is contained in:
Matt Clarkson 2014-08-22 14:36:19 +01:00
parent 0fd0be9789
commit 9593e64076
2 changed files with 9 additions and 11 deletions

View File

@ -25,13 +25,12 @@ function(add_cxx_compiler_flag FLAG)
string(TOLOWER ${VARIANT} VARIANT)
set(VARIANT " ${VARIANT}")
endif()
message("-- Check compiler${VARIANT} flag ${FLAG}")
string(TOUPPER ${FLAG} SANITIZED_FLAG)
string(REGEX REPLACE "[^A-Za-z_0-9]" "_" ${SANITIZED_FLAG} SANITIZED_FLAG)
string(TOUPPER "HAVE_${FLAG}" SANITIZED_FLAG)
string(REGEX REPLACE "[^A-Za-z_0-9]" "_" SANITIZED_FLAG ${SANITIZED_FLAG})
string(REGEX REPLACE "_+" "_" SANITIZED_FLAG ${SANITIZED_FLAG})
check_cxx_compiler_flag(${FLAG} ${SANITIZED_FLAG})
if(${SANITIZED_FLAG})
message("-- Check compiler${VARIANT} flag ${FLAG} -- works")
string(REGEX REPLACE "[^A-Za-z_0-9]" "_" "${VARIANT}" VARIANT)
string(REGEX REPLACE "[^A-Za-z_0-9]" "_" VARIANT "${VARIANT}")
string(TOUPPER "${VARIANT}" VARIANT)
set(CMAKE_CXX_FLAGS${VARIANT} "${CMAKE_CXX_FLAGS}${VARIANT} ${FLAG}" PARENT_SCOPE)
endif()

View File

@ -4,19 +4,18 @@
# and adds the corresponding `HAVE_[FILENAME]` flag to the CMake
# environment
#
# add_cxx_compiler_FLAG(<FLAG> [<VARIANT>])
# cxx_feature_check(<FLAG> [<VARIANT>])
#
# - Example
#
# include(AddCXXCompilerFlag)
# add_cxx_compiler_FLAG(-Wall)
# add_cxx_compiler_FLAG(-no-strict-aliasing RELEASE)
# include(CXXFeatureCheck)
# cxx_feature_check(STD_REGEX)
# Requires CMake 2.6+
if(__cxx_feature_check_FLAG)
if(__cxx_feature_check)
return()
endif()
set(__cxx_feature_check_FLAG INCLUDED)
set(__cxx_feature_check INCLUDED)
function(cxx_feature_check FILE)
string(TOLOWER ${FILE} FILE)