From 3c56e7c0eb8d1d00b5783a11e69cff50e1e53790 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sat, 2 Jul 2016 18:26:08 +0200 Subject: [PATCH] Fix MSVC C++11 detection The old version with empty flag did not enter the loop at all, so we have to use a workaround. Thanks Uwe for testing. --- development/cmake/modules/FindCXX11Compiler.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/development/cmake/modules/FindCXX11Compiler.cmake b/development/cmake/modules/FindCXX11Compiler.cmake index c7045d1fd2..5c7b69866e 100644 --- a/development/cmake/modules/FindCXX11Compiler.cmake +++ b/development/cmake/modules/FindCXX11Compiler.cmake @@ -44,7 +44,7 @@ else() # MSVC does not have a general C++11 flag, one can only switch off # MS extensions with /Za in general or by extension with /Zc. # Use an empty flag to ensure that CXX11_STD_REGEX is correctly set. - set(CXX11_FLAG_CANDIDATES "") + set(CXX11_FLAG_CANDIDATES "noflagneeded") else() set(CXX11_FLAG_CANDIDATES "--std=c++14" @@ -113,7 +113,9 @@ set(SAFE_CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET}) set(CMAKE_REQUIRED_QUIET ON) SET(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") FOREACH(FLAG ${CXX11_FLAG_CANDIDATES}) - SET(CMAKE_REQUIRED_FLAGS "${FLAG}") + IF(NOT "${FLAG}" STREQUAL "noflagneeded") + SET(CMAKE_REQUIRED_FLAGS "${FLAG}") + ENDIF() UNSET(CXX11_FLAG_DETECTED CACHE) CHECK_CXX_SOURCE_COMPILES("${CXX11_TEST_SOURCE}" CXX11_FLAG_DETECTED) IF(CXX11_FLAG_DETECTED) @@ -136,5 +138,8 @@ set(CMAKE_REQUIRED_QUIET ${SAFE_CMAKE_REQUIRED_QUIET}) # handle the standard arguments for find_package FIND_PACKAGE_HANDLE_STANDARD_ARGS(CXX11Compiler DEFAULT_MSG CXX11_FLAG) +IF("${CXX11_FLAG}" STREQUAL "noflagneeded") + SET(CXX11_FLAG "") +ENDIF() MARK_AS_ADVANCED(CXX11_FLAG CXX11_STD_REGEX)