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)