From 1fc075df881f1b4c58f7e85b53aecb14fcba1e24 Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Mon, 8 Jul 2024 14:34:51 +0200 Subject: [PATCH] Detect more c++ standards and make sure useful message actually appears (#635) * Detect more c++ standards and make sure useful message actually appears * Order c++ standards numerically * Use a for loop to detect ROOT c++ standard * Add a bit more logging --- CMakeLists.txt | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index efcffb9f5..dfd6f98db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,14 +88,20 @@ 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) - if("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(FATAL_ERROR "ROOT C++ 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") +else() + message(STATUS "Determined ROOT c++ standard: " ${ROOT_CXX_STANDARD}) endif() if(ROOT_CXX_STANDARD VERSION_LESS 17)