From 34a8a9302f135495c79160184758d9251e42cb99 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 18 Oct 2020 11:34:39 +0300 Subject: [PATCH] - removed obsolete probing of C++ standard for GCC and Clang CMake try_compile() function still requires explicit command line option --- CMakeLists.txt | 7 +++++++ src/CMakeLists.txt | 24 ------------------------ 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c030d66b..5dabe7bed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,6 +146,13 @@ endif() if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) set( PROFILE 0 CACHE BOOL "Enable profiling with gprof for Debug and RelWithDebInfo build types." ) + + if( CMAKE_CXX_STANDARD ) + # By default, try_compile() invocations ignore CXX_STANDARD value + # CMake 3.8 and newer have CMP0067 policy that fixes the issue, but it should be enabled explicitly + # Older versions require manual specification of the corresponding command line option + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${CMAKE_CXX_STANDARD}" ) + endif() endif() # Fast math flags, required by some subprojects diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aa18ccdfb..f7a399bdb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -330,30 +330,6 @@ if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) set( CMAKE_CXX_FLAGS "-DNO_SSE ${CMAKE_CXX_FLAGS}" ) endif() - # Use the highest C++ standard available since VS2015 compiles with C++14 - # but we only require C++11. The recommended way to do this in CMake is to - # probably to use target_compile_features, but I don't feel like maintaining - # a list of features we use. - CHECK_CXX_COMPILER_FLAG( "-std=gnu++14" CAN_DO_CPP14 ) - if ( CAN_DO_CPP14 ) - set ( CMAKE_CXX_FLAGS "-std=gnu++14 ${CMAKE_CXX_FLAGS}" ) - else () - CHECK_CXX_COMPILER_FLAG( "-std=gnu++1y" CAN_DO_CPP1Y ) - if ( CAN_DO_CPP1Y ) - set ( CMAKE_CXX_FLAGS "-std=gnu++1y ${CMAKE_CXX_FLAGS}" ) - else () - CHECK_CXX_COMPILER_FLAG( "-std=gnu++11" CAN_DO_CPP11 ) - if ( CAN_DO_CPP11 ) - set ( CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}" ) - else () - CHECK_CXX_COMPILER_FLAG( "-std=gnu++0x" CAN_DO_CPP0X ) - if ( CAN_DO_CPP0X ) - set ( CMAKE_CXX_FLAGS "-std=gnu++0x ${CMAKE_CXX_FLAGS}" ) - endif () - endif () - endif () - endif () - # Remove extra warnings when using the official DirectX headers. # Also, TDM-GCC 4.4.0 no longer accepts glibc-style printf formats as valid, # which is a royal pain. The previous version I had been using was fine with them.