diff --git a/cmake/AddCXXCompilerFlag.cmake b/cmake/AddCXXCompilerFlag.cmake index 31a284fe..e52c1848 100644 --- a/cmake/AddCXXCompilerFlag.cmake +++ b/cmake/AddCXXCompilerFlag.cmake @@ -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() diff --git a/cmake/CXXFeatureCheck.cmake b/cmake/CXXFeatureCheck.cmake index 9d809046..7adebcac 100644 --- a/cmake/CXXFeatureCheck.cmake +++ b/cmake/CXXFeatureCheck.cmake @@ -4,19 +4,18 @@ # and adds the corresponding `HAVE_[FILENAME]` flag to the CMake # environment # -# add_cxx_compiler_FLAG( []) +# cxx_feature_check( []) # # - 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)