From 0ab009e162124936a1743759ea2fcca7fc9d0eb2 Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Tue, 13 Jul 2021 19:50:43 +0200
Subject: [PATCH] BUILD: Use target_compile_features to pass C++ needed
 features

---
 CMakeLists.txt | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 33b762ed..3159722c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,10 +10,6 @@ set(CMAKE_AUTOUIC ON)
 set(CMAKE_AUTOMOC ON)
 set(CMAKE_AUTORCC ON)
 
-# C++20, at least we try
-set(CMAKE_CXX_STANDARD 20)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-
 # Pthread ftw
 set(THREADS_PREFER_PTHREAD_FLAG ON)
 
@@ -76,6 +72,23 @@ target_precompile_headers(Vivy PRIVATE
     <QIcon>
 )
 
+# Set Vivy's needed C++ features
+target_compile_features(Vivy PRIVATE
+    cxx_std_20
+    cxx_auto_type
+    cxx_deleted_functions
+    cxx_explicit_conversions
+    cxx_final
+    cxx_inline_namespaces
+    cxx_lambdas
+    cxx_noexcept
+    cxx_nonstatic_member_init
+    cxx_nullptr
+    cxx_override
+    cxx_range_for
+    cxx_strong_enums
+)
+
 # More options and warnings
 target_compile_options(Vivy PRIVATE
     -Wall -Wextra -Wshadow -pedantic
@@ -91,7 +104,9 @@ if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
         -Wno-unused-private-field   # Skip the unused private fields for now
         -fopenmp                    # We do OpenMP here
     )
-    target_link_libraries(Vivy PRIVATE -fopenmp)
+    target_link_libraries(Vivy PRIVATE
+        -fopenmp
+    )
 elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
     target_compile_options(Vivy PRIVATE -fopenmp)
     target_link_libraries(Vivy PRIVATE -fopenmp)
-- 
GitLab