Merge pull request #2549 from theirix/feature/detect-cxx-std

Avoid using experimental C++14/17 support in CMake
This commit is contained in:
Egor Pugin 2019-07-08 12:49:24 +03:00 committed by GitHub
commit 62a753ac60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,12 +96,14 @@ else() # minimum required standard
set(CMAKE_CXX_STANDARD 11)
endif()
# workaround for bad info in CMAKE_CXX_KNOWN_FEATURES for g++ 4.8.4
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(CMAKE_CXX_STANDARD 11)
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "6.1.0")
set(CMAKE_CXX_STANDARD 14)
endif()
# Avoid using experimental c++1y (c++1z) standard even if the compiler announces cxx14 (cxx17)
# in CMAKE_CXX_KNOWN_FEATURES and CMAKE_CXX_COMPILE_FEATURES
# It is the case of clang 3.9, 4.0 (announces c++1z) and gcc 4.8 (announces c++1y)
if ("${CMAKE_CXX17_STANDARD_COMPILE_OPTION}" STREQUAL "-std=c++1z")
set(CMAKE_CXX_STANDARD 14)
endif()
if ("${CMAKE_CXX14_STANDARD_COMPILE_OPTION}" STREQUAL "-std=c++1y")
set(CMAKE_CXX_STANDARD 11)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)