From e725f57995eef5b27f3e59eabeb3377901a28a46 Mon Sep 17 00:00:00 2001 From: tmadlener Date: Fri, 5 Jul 2024 09:19:08 +0200 Subject: [PATCH 1/4] Detect more c++ standards and make sure useful message actually appears --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index efcffb9f5..15dfb8bff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,8 +93,12 @@ if(NOT DEFINED ROOT_CXX_STANDARD) set(ROOT_CXX_STANDARD 17) elseif("cxx_std_20" IN_LIST ROOT_COMPILE_FEATURES) set(ROOT_CXX_STANDARD 20) + elseif("cxx_std_14" IN_LIST ROOT_COMPILE_FEATURES) + set(ROOT_CXX_STANDARD 14) + elseif("cxx_std_11" IN_LIST ROOT_COMPILE_FEATURES) + set(ROOT_CXX_STANDARD 11) else() - message(FATAL_ERROR "ROOT C++ could not be detected") + message(WARNING "ROOT c++ standard could not be detected") endif() endif() From f9eb666693212ca8d8f8187b25c852d541116e96 Mon Sep 17 00:00:00 2001 From: tmadlener Date: Fri, 5 Jul 2024 10:04:53 +0200 Subject: [PATCH 2/4] Order c++ standards numerically --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15dfb8bff..d452e2a1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,14 +89,14 @@ endif() # before that it's an empty variable so we check if it's any number > 0 if(NOT DEFINED ROOT_CXX_STANDARD) get_target_property(ROOT_COMPILE_FEATURES ROOT::Core INTERFACE_COMPILE_FEATURES) - if("cxx_std_17" IN_LIST ROOT_COMPILE_FEATURES) + if("cxx_std_11" IN_LIST ROOT_COMPILE_FEATURES) + set(ROOT_CXX_STANDARD 11) + elseif("cxx_std_14" IN_LIST ROOT_COMPILE_FEATURES) + set(ROOT_CXX_STANDARD 14) + elseif("cxx_std_17" IN_LIST ROOT_COMPILE_FEATURES) set(ROOT_CXX_STANDARD 17) elseif("cxx_std_20" IN_LIST ROOT_COMPILE_FEATURES) set(ROOT_CXX_STANDARD 20) - elseif("cxx_std_14" IN_LIST ROOT_COMPILE_FEATURES) - set(ROOT_CXX_STANDARD 14) - elseif("cxx_std_11" IN_LIST ROOT_COMPILE_FEATURES) - set(ROOT_CXX_STANDARD 11) else() message(WARNING "ROOT c++ standard could not be detected") endif() From c8a0d77d7bfe5ec21d0d4f0a01095e52ba3638d2 Mon Sep 17 00:00:00 2001 From: tmadlener Date: Fri, 5 Jul 2024 10:22:58 +0200 Subject: [PATCH 3/4] Use a for loop to detect ROOT c++ standard --- CMakeLists.txt | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d452e2a1d..2c38eac23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,17 +89,16 @@ endif() # before that it's an empty variable so we check if it's any number > 0 if(NOT DEFINED ROOT_CXX_STANDARD) get_target_property(ROOT_COMPILE_FEATURES ROOT::Core INTERFACE_COMPILE_FEATURES) - if("cxx_std_11" IN_LIST ROOT_COMPILE_FEATURES) - set(ROOT_CXX_STANDARD 11) - elseif("cxx_std_14" IN_LIST ROOT_COMPILE_FEATURES) - set(ROOT_CXX_STANDARD 14) - elseif("cxx_std_17" IN_LIST ROOT_COMPILE_FEATURES) - set(ROOT_CXX_STANDARD 17) - elseif("cxx_std_20" IN_LIST ROOT_COMPILE_FEATURES) - set(ROOT_CXX_STANDARD 20) - else() - message(WARNING "ROOT c++ standard could not be detected") - endif() + foreach(cxxstd IN ITEMS 20;17;14;11) + if ("cxx_std_${cxxstd}" IN_LIST ROOT_COMPILE_FEATURES) + set(ROOT_CXX_STANDARD ${cxxstd}) + break() + endif() + endforeach() +endif() + +if(NOT DEFINED ROOT_CXX_STANDARD) + message(WARNING "ROOT c++ standard could not be detected") endif() if(ROOT_CXX_STANDARD VERSION_LESS 17) From e95aeb1a37dc62ea35d75a659f71d89c7bb34a7d Mon Sep 17 00:00:00 2001 From: tmadlener Date: Fri, 5 Jul 2024 10:26:22 +0200 Subject: [PATCH 4/4] Add a bit more logging --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c38eac23..dfd6f98db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,7 @@ endif() # ROOT_CXX_STANDARD was introduced in https://github.com/root-project/root/pull/6466 # before that it's an empty variable so we check if it's any number > 0 if(NOT DEFINED ROOT_CXX_STANDARD) + message(STATUS "ROOT c++ standard not yet available. Determining from compile features") get_target_property(ROOT_COMPILE_FEATURES ROOT::Core INTERFACE_COMPILE_FEATURES) foreach(cxxstd IN ITEMS 20;17;14;11) if ("cxx_std_${cxxstd}" IN_LIST ROOT_COMPILE_FEATURES) @@ -99,6 +100,8 @@ endif() if(NOT DEFINED ROOT_CXX_STANDARD) message(WARNING "ROOT c++ standard could not be detected") +else() + message(STATUS "Determined ROOT c++ standard: " ${ROOT_CXX_STANDARD}) endif() if(ROOT_CXX_STANDARD VERSION_LESS 17)