Fix std::regex detection for older gcc

Older gcc versions (e.g. the first one which has usable std::regex: gcc 4.9)
require the --std=c++11 flag to be set. Otherwise std::regex is not made
available. Therefore we need to keep the flag in the loop.
This commit is contained in:
Georg Baum 2016-07-02 12:39:08 +02:00
parent 5ef180842c
commit e49d59dafc

View File

@ -104,12 +104,11 @@ int main()
# check c compiler # check c compiler
set(SAFE_CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET}) set(SAFE_CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET})
set(CMAKE_REQUIRED_QUIET ON) set(CMAKE_REQUIRED_QUIET ON)
SET(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
FOREACH(FLAG ${CXX11_FLAG_CANDIDATES}) FOREACH(FLAG ${CXX11_FLAG_CANDIDATES})
SET(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
SET(CMAKE_REQUIRED_FLAGS "${FLAG}") SET(CMAKE_REQUIRED_FLAGS "${FLAG}")
UNSET(CXX11_FLAG_DETECTED CACHE) UNSET(CXX11_FLAG_DETECTED CACHE)
CHECK_CXX_SOURCE_COMPILES("${CXX11_TEST_SOURCE}" CXX11_FLAG_DETECTED) CHECK_CXX_SOURCE_COMPILES("${CXX11_TEST_SOURCE}" CXX11_FLAG_DETECTED)
SET(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
IF(CXX11_FLAG_DETECTED) IF(CXX11_FLAG_DETECTED)
SET(CXX11_FLAG "${FLAG}") SET(CXX11_FLAG "${FLAG}")
message(STATUS "CXX11_FLAG_DETECTED = \"${FLAG}\"") message(STATUS "CXX11_FLAG_DETECTED = \"${FLAG}\"")
@ -125,6 +124,7 @@ FOREACH(FLAG ${CXX11_FLAG_CANDIDATES})
break() break()
ENDIF() ENDIF()
ENDFOREACH() ENDFOREACH()
SET(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_QUIET ${SAFE_CMAKE_REQUIRED_QUIET}) set(CMAKE_REQUIRED_QUIET ${SAFE_CMAKE_REQUIRED_QUIET})
# handle the standard arguments for find_package # handle the standard arguments for find_package