From 58b4946fb93b787d7a28d721fc11ee59c32a9371 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Tue, 5 Sep 2023 20:57:18 +1000 Subject: [PATCH] Build: Switch to C++20 --- CMakeLists.txt | 12 +++++++++--- src/common/common.props | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 55467ecd2..d35c29521 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,9 +142,7 @@ if(ANDROID) endif() -# Detect C++ version support. -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) +# Warning disables. if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") include(CheckCXXFlag) check_cxx_flag(-Wall COMPILER_SUPPORTS_WALL) @@ -229,8 +227,16 @@ if(BUILD_TESTS) enable_testing() endif() +# Use C++17 for building dependencies (some aren't C++20-aware, e.g. reshadefx). +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + # Recursively include the source tree. add_subdirectory(dep) + +# Use C++20 for building the main libraries. +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) add_subdirectory(src) if(ANDROID) diff --git a/src/common/common.props b/src/common/common.props index b8ee70e4b..892e347d1 100644 --- a/src/common/common.props +++ b/src/common/common.props @@ -3,6 +3,7 @@ $(SolutionDir)src;%(AdditionalIncludeDirectories);$(SolutionDir)dep\gsl\include;$(SolutionDir)dep\fast_float\include;$(SolutionDir)dep\fmt\include;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\minizip\include;$(SolutionDir)dep\stb\include + stdcpp20