diff --git a/CMakeLists.txt b/CMakeLists.txt index 40bcc6f95..9dec1c90b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,26 +109,16 @@ function(add_c_compiler_flag_if_supported VARIABLE FLAG) endif() endfunction() -function(add_cxx_compiler_flag_if_supported VARIABLE FLAG) - if(ARGC GREATER 2) - set(CHECKED_FLAG "${ARGV2}") - else() - set(CHECKED_FLAG "${FLAG}") - endif() - string(REGEX REPLACE "[^A-Za-z0-9]" "_" CONFIG_VARIABLE "FLAG_SUPPORTED${CHECKED_FLAG}") - check_cxx_compiler_flag("${CHECKED_FLAG}" ${CONFIG_VARIABLE}) - if(${CONFIG_VARIABLE}) - if(${VARIABLE}) - set("${VARIABLE}" "${${VARIABLE}};${FLAG}" PARENT_SCOPE) - else() - set("${VARIABLE}" "${FLAG}" PARENT_SCOPE) - endif() - endif() -endfunction() - if(NOT MSVC) if(CMAKE_VERSION VERSION_LESS 3.1 OR TARGET_OS STREQUAL "mac") - add_cxx_compiler_flag_if_supported(CMAKE_CXX_FLAGS -std=gnu++11) + check_cxx_compiler_flag(-std=gnu++11 FLAG_SUPPORTED_std_gnu__11) + if(FLAG_SUPPORTED_std_gnu__11) + if(CMAKE_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") + else() + set(CMAKE_CXX_FLAGS -std=gnu++11) + endif() + endif() endif() # Protect the stack pointer.