По возможности использовать C++14, иначе С++11

This commit is contained in:
Andrei Astafev 2020-06-25 09:20:23 +03:00
parent a6bb734f49
commit f2ee747a38

View File

@ -31,12 +31,23 @@ else()
endif()
endif()
# Выбор стандарта по умолчанию (можно переопределить в проекте)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
check_cxx_compiler_flag(-std=c++14 HAVE_FLAG_STD_CXX14)
if(HAVE_FLAG_STD_CXX14)
set(CMAKE_CXX_STANDARD 14)
check_cxx_compiler_flag(-std=gnu++14 HAVE_FLAG_STD_GNUXX14)
if(HAVE_FLAG_STD_GNUXX14)
set(CMAKE_CXX_EXTENSIONS YES)
endif()
else()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS YES)
endif()
# Common configuration for GCC, clang and Intel.
if(CMAKE_CXX_COMPILER_IS_CLANG OR CMAKE_CXX_COMPILER_IS_INTEL OR CMAKE_CXX_COMPILER_IS_GCC)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS YES)
if(CMLIB_WARNING_FLAGS AND CMAKE_BUILD_TYPE STREQUAL "Debug")
check_enable_cxx_flag(-Wall)
check_enable_cxx_flag(-Wextra)