From 62ea75453f80ef19b9500d7d3e64c42dde4476cd Mon Sep 17 00:00:00 2001 From: Denis Prokopenko <22414094+denproc@users.noreply.github.com> Date: Wed, 1 Apr 2026 20:39:05 +0100 Subject: [PATCH 1/7] Use ROOT_CXX to define min CXX ver --- CMakeLists.txt | 6 +++--- src/cmake/FindCERN_ROOT.cmake | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f6f6d3c724..226628eac6 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,9 +145,9 @@ if(NOT DISABLE_CERN_ROOT) find_package(CERN_ROOT 6.28.00) # required for C++17 if (CERN_ROOT_FOUND) message(STATUS "ROOT Version: ${CERN_ROOT_VERSION}") - if (${CERN_ROOT_VERSION} VERSION_GREATER 6.29.99) - message(STATUS "ROOT Version is >= 6.30. Setting the minimum CXX version to 20.") - UseCXX(20) + message(STATUS "ROOT Version is ${CERN_ROOT_VERSION}. Required minimum CXX version is ${CERN_ROOT_CXX_STANDARD}.") + if (${CERN_ROOT_CXX_STANDARD} VERSION_GREATER ${CMAKE_CXX_STANDARD}) + UseCXX(${CERN_ROOT_CXX_STANDARD}) endif() endif() endif() diff --git a/src/cmake/FindCERN_ROOT.cmake b/src/cmake/FindCERN_ROOT.cmake index 9aad3924f4..b284389bc9 100644 --- a/src/cmake/FindCERN_ROOT.cmake +++ b/src/cmake/FindCERN_ROOT.cmake @@ -4,6 +4,7 @@ # @Author Kris Thielemans # @Author the ROOT team # @Author Robert Twyman (improved documentation) +# @Author Denis Prokopenko (added auto detection of CXX version from ROOT 6.32+) ## CMAKE ARGS # @@ -63,6 +64,17 @@ if (ROOT_FOUND) set(CERN_ROOT_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}) set(CERN_ROOT_LIBRARIES ${ROOT_LIBRARIES}) + if (${CERN_ROOT_VERSION} VERSION_GREATER 6.31.99) + set(CERN_ROOT_CXX_STANDARD ${ROOT_CXX_STANDARD}) + if (CERN_ROOT_DEBUG) + message(STATUS "ROOT Version is ${CERN_ROOT_VERSION}. Loading minimum C++ from ROOT_CXX_STANDARD.") + endif() + elseif (${CERN_ROOT_VERSION} VERSION_GREATER 6.29.99) + set(CERN_ROOT_CXX_STANDARD 20) + else() + set(CERN_ROOT_CXX_STANDARD 17) + endif() + else() ### Old work-arounds. Should be removed later really From 0bff4f53baa06f5cba49b8275e0dd55ae82b3a8f Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Wed, 1 Apr 2026 23:49:59 +0100 Subject: [PATCH 2/7] simply use UseCXX --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 226628eac6..ad4b658dc0 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,8 +146,7 @@ if(NOT DISABLE_CERN_ROOT) if (CERN_ROOT_FOUND) message(STATUS "ROOT Version: ${CERN_ROOT_VERSION}") message(STATUS "ROOT Version is ${CERN_ROOT_VERSION}. Required minimum CXX version is ${CERN_ROOT_CXX_STANDARD}.") - if (${CERN_ROOT_CXX_STANDARD} VERSION_GREATER ${CMAKE_CXX_STANDARD}) - UseCXX(${CERN_ROOT_CXX_STANDARD}) + UseCXX(${CERN_ROOT_CXX_STANDARD}) endif() endif() endif() From 0529ee66a5a0236f8c76306a28a48a0c1d83314d Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Thu, 2 Apr 2026 00:07:16 +0100 Subject: [PATCH 3/7] fix endif Remove unnecessary endif() for CERN_ROOT_FOUND condition. --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad4b658dc0..fe13bb8394 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,7 +147,6 @@ if(NOT DISABLE_CERN_ROOT) message(STATUS "ROOT Version: ${CERN_ROOT_VERSION}") message(STATUS "ROOT Version is ${CERN_ROOT_VERSION}. Required minimum CXX version is ${CERN_ROOT_CXX_STANDARD}.") UseCXX(${CERN_ROOT_CXX_STANDARD}) - endif() endif() endif() From 56cef56290d8b7dab68275d0b30edb942b48814f Mon Sep 17 00:00:00 2001 From: Denis Prokopenko <22414094+denproc@users.noreply.github.com> Date: Thu, 2 Apr 2026 00:34:58 +0100 Subject: [PATCH 4/7] Add release note --- documentation/release_6.4.htm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/documentation/release_6.4.htm b/documentation/release_6.4.htm index 4e10711977..416fe9c5ae 100644 --- a/documentation/release_6.4.htm +++ b/documentation/release_6.4.htm @@ -134,6 +134,15 @@

Build system


PR #1665 +
  • + Use the CMake CMAKE_ROOT_CXX_STANDARD to configure the minimum C++ version for the ROOT dependency. + Starting with ROOT v6.32, ROOT_CXX_STANDARD defines the minimum C++ version required by ROOT, + and CMake will automatically set the C++ version for the target that links to ROOT to at least that version. + For ROOT v6.30, we set CMAKE_ROOT_CXX_STANDARD = 20. + For ROOT v6.28, we set CMAKE_ROOT_CXX_STANDARD = 17. +
    + PR #1700 +
  • Known problems

    From 6af5cdd12a111ed3b4b82f6de93dcac2cc326343 Mon Sep 17 00:00:00 2001 From: Denis Prokopenko <22414094+denproc@users.noreply.github.com> Date: Thu, 2 Apr 2026 00:56:48 +0100 Subject: [PATCH 5/7] add processing for standalone root --- src/cmake/FindCERN_ROOT.cmake | 68 ++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/src/cmake/FindCERN_ROOT.cmake b/src/cmake/FindCERN_ROOT.cmake index b284389bc9..3a215d99e2 100644 --- a/src/cmake/FindCERN_ROOT.cmake +++ b/src/cmake/FindCERN_ROOT.cmake @@ -79,41 +79,51 @@ else() ### Old work-arounds. Should be removed later really - if (CERN_ROOT_DEBUG) - message(STATUS "Did not find ROOTConfig.cmake, so trying via root-config") - endif() - find_program(CERN_ROOT_CONFIG "root-config" HINTS "${ROOTSYS}" ) + if (CERN_ROOT_DEBUG) + message(STATUS "Did not find ROOTConfig.cmake, so trying via root-config") + endif() + find_program(CERN_ROOT_CONFIG "root-config" HINTS "${ROOTSYS}" ) - if (CERN_ROOT_CONFIG) + if (CERN_ROOT_CONFIG) - if (CERN_ROOT_DEBUG) - message(STATUS "Finding ROOT location etc via ${CERN_ROOT_CONFIG}") - endif() + if (CERN_ROOT_DEBUG) + message(STATUS "Finding ROOT location etc via ${CERN_ROOT_CONFIG}") + endif() - execute_process(COMMAND ${CERN_ROOT_CONFIG} --incdir OUTPUT_VARIABLE - CERN_ROOT_INCLUDE_DIRS - OUTPUT_STRIP_TRAILING_WHITESPACE) - - # Attempt fo find libraries from root-config. However, this doesn't work if - # not all libraries are installed (as root-config lists them anyway). - # set (root_lib_arg "--libs") - # execute_process(COMMAND ${CERN_ROOT_CONFIG} ${root_lib_arg} OUTPUT_VARIABLE - # TCERN_ROOT_LIBRARIES) - # string (STRIP "${TCERN_ROOT_LIBRARIES}" CERN_ROOT_LIBRARIES) - - # Do an explicit search - # Lines copied from FindROOT.cmake distributed with ROOT v6.08/06 - execute_process( - COMMAND ${CERN_ROOT_CONFIG} --libdir - OUTPUT_VARIABLE CERN_ROOT_LIBRARY_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( + execute_process(COMMAND ${CERN_ROOT_CONFIG} --incdir OUTPUT_VARIABLE + CERN_ROOT_INCLUDE_DIRS + OUTPUT_STRIP_TRAILING_WHITESPACE) + + # Attempt fo find libraries from root-config. However, this doesn't work if + # not all libraries are installed (as root-config lists them anyway). + # set (root_lib_arg "--libs") + # execute_process(COMMAND ${CERN_ROOT_CONFIG} ${root_lib_arg} OUTPUT_VARIABLE + # TCERN_ROOT_LIBRARIES) + # string (STRIP "${TCERN_ROOT_LIBRARIES}" CERN_ROOT_LIBRARIES) + + # Do an explicit search + # Lines copied from FindROOT.cmake distributed with ROOT v6.08/06 + execute_process( + COMMAND ${CERN_ROOT_CONFIG} --libdir + OUTPUT_VARIABLE CERN_ROOT_LIBRARY_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( COMMAND ${CERN_ROOT_CONFIG} --version OUTPUT_VARIABLE CERN_ROOT_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) - + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (${CERN_ROOT_VERSION} VERSION_GREATER 6.31.99) + set(CERN_ROOT_CXX_STANDARD ${ROOT_CXX_STANDARD}) + if (CERN_ROOT_DEBUG) + message(STATUS "ROOT Version is ${CERN_ROOT_VERSION}. Loading minimum C++ from ROOT_CXX_STANDARD.") + endif() + elseif (${CERN_ROOT_VERSION} VERSION_GREATER 6.29.99) + set(CERN_ROOT_CXX_STANDARD 20) else() + set(CERN_ROOT_CXX_STANDARD 17) + endif() + + else() # no root-config if (CERN_ROOT_DEBUG) From bf1e9e6ad0ccd3d6f0aae6bf80d259b85c78d0d6 Mon Sep 17 00:00:00 2001 From: Denis Prokopenko <22414094+denproc@users.noreply.github.com> Date: Thu, 16 Apr 2026 14:17:09 +0100 Subject: [PATCH 6/7] Refactor ROOT C++ standard handling in CMake configuration --- CMakeLists.txt | 3 +-- documentation/release_6.4.htm | 12 +++++++----- src/cmake/FindCERN_ROOT.cmake | 30 +++++++++++------------------- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe13bb8394..8efb6aad31 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,8 +144,7 @@ endif() if(NOT DISABLE_CERN_ROOT) find_package(CERN_ROOT 6.28.00) # required for C++17 if (CERN_ROOT_FOUND) - message(STATUS "ROOT Version: ${CERN_ROOT_VERSION}") - message(STATUS "ROOT Version is ${CERN_ROOT_VERSION}. Required minimum CXX version is ${CERN_ROOT_CXX_STANDARD}.") + message(STATUS "ROOT Version: ${CERN_ROOT_VERSION}. CXX version: ${CERN_ROOT_CXX_STANDARD}.") UseCXX(${CERN_ROOT_CXX_STANDARD}) endif() endif() diff --git a/documentation/release_6.4.htm b/documentation/release_6.4.htm index 416fe9c5ae..70a0ee689e 100644 --- a/documentation/release_6.4.htm +++ b/documentation/release_6.4.htm @@ -135,11 +135,13 @@

    Build system

    PR #1665
  • - Use the CMake CMAKE_ROOT_CXX_STANDARD to configure the minimum C++ version for the ROOT dependency. - Starting with ROOT v6.32, ROOT_CXX_STANDARD defines the minimum C++ version required by ROOT, - and CMake will automatically set the C++ version for the target that links to ROOT to at least that version. - For ROOT v6.30, we set CMAKE_ROOT_CXX_STANDARD = 20. - For ROOT v6.28, we set CMAKE_ROOT_CXX_STANDARD = 17. + For builds with CERN ROOT, the C++ standard is now automatically set to match the one used to build ROOT. + New CMake variable CMAKE_ROOT_CXX_STANDARD is used to configure the minimum C++ standard for the project. + Starting from ROOT v6.32, the variable ROOT_CXX_STANDARD specifies the C++ standard used to build ROOT. + CMake will automatically ensure that the project uses the same C++ standard. + For ROOT versions below v6.32, the C++ standard is not exposed. + In this case, the default is set to CMAKE_CXX_STANDARD = 17, matching pre-built releases and conda packages. + For custom builds of ROOT below v6.32 that use a different C++ standard, the user must specify the C++ standard manually during configuration.
    PR #1700
  • diff --git a/src/cmake/FindCERN_ROOT.cmake b/src/cmake/FindCERN_ROOT.cmake index 3a215d99e2..bd4f204ea1 100644 --- a/src/cmake/FindCERN_ROOT.cmake +++ b/src/cmake/FindCERN_ROOT.cmake @@ -63,17 +63,7 @@ if (ROOT_FOUND) set(CERN_ROOT_VERSION ${ROOT_VERSION}) set(CERN_ROOT_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}) set(CERN_ROOT_LIBRARIES ${ROOT_LIBRARIES}) - - if (${CERN_ROOT_VERSION} VERSION_GREATER 6.31.99) - set(CERN_ROOT_CXX_STANDARD ${ROOT_CXX_STANDARD}) - if (CERN_ROOT_DEBUG) - message(STATUS "ROOT Version is ${CERN_ROOT_VERSION}. Loading minimum C++ from ROOT_CXX_STANDARD.") - endif() - elseif (${CERN_ROOT_VERSION} VERSION_GREATER 6.29.99) - set(CERN_ROOT_CXX_STANDARD 20) - else() - set(CERN_ROOT_CXX_STANDARD 17) - endif() + set(CERN_ROOT_CXX_STANDARD ${ROOT_CXX_STANDARD}) else() @@ -113,14 +103,10 @@ else() OUTPUT_VARIABLE CERN_ROOT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) if (${CERN_ROOT_VERSION} VERSION_GREATER 6.31.99) - set(CERN_ROOT_CXX_STANDARD ${ROOT_CXX_STANDARD}) - if (CERN_ROOT_DEBUG) - message(STATUS "ROOT Version is ${CERN_ROOT_VERSION}. Loading minimum C++ from ROOT_CXX_STANDARD.") - endif() - elseif (${CERN_ROOT_VERSION} VERSION_GREATER 6.29.99) - set(CERN_ROOT_CXX_STANDARD 20) - else() - set(CERN_ROOT_CXX_STANDARD 17) + execute_process( + COMMAND ${CERN_ROOT_CONFIG} --cxxstandard + OUTPUT_VARIABLE CERN_ROOT_CXX_STANDARD + OUTPUT_STRIP_TRAILING_WHITESPACE) endif() else() @@ -176,11 +162,17 @@ else() endif() +# Fall back to minimum C++ version required by ROOT. +if (NOT (CERN_ROOT_CXX_STANDARD)) + set(CERN_ROOT_CXX_STANDARD 17) +endif() + # root-config reports version as 6.26/10. This might also happen in other cases. Convert it to 6.26.10 string(REPLACE "/" "." CERN_ROOT_VERSION "${CERN_ROOT_VERSION}") if (CERN_ROOT_DEBUG) message(STATUS "CERN_ROOT_VERSION: ${CERN_ROOT_VERSION}") + message(STATUS "CERN_ROOT_CXX_STANDARD: ${CERN_ROOT_CXX_STANDARD}") message(STATUS "CERN_ROOT_INCLUDE_DIRS: ${CERN_ROOT_INCLUDE_DIRS}") message(STATUS "AVAILABLE ROOT LIBRARIES: ${CERN_ROOT_LIBRARIES}") if (TARGET ROOT::Tree) From 7bec3e953e6a1e68e1332a8f21c27f9d61375144 Mon Sep 17 00:00:00 2001 From: Denis Prokopenko <22414094+denproc@users.noreply.github.com> Date: Fri, 17 Apr 2026 10:38:23 +0100 Subject: [PATCH 7/7] [ci skip] Apply suggestions from code review Co-authored-by: Kris Thielemans --- documentation/release_6.4.htm | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/documentation/release_6.4.htm b/documentation/release_6.4.htm index 70a0ee689e..f812b5bb63 100644 --- a/documentation/release_6.4.htm +++ b/documentation/release_6.4.htm @@ -135,13 +135,11 @@

    Build system

    PR #1665
  • - For builds with CERN ROOT, the C++ standard is now automatically set to match the one used to build ROOT. - New CMake variable CMAKE_ROOT_CXX_STANDARD is used to configure the minimum C++ standard for the project. - Starting from ROOT v6.32, the variable ROOT_CXX_STANDARD specifies the C++ standard used to build ROOT. - CMake will automatically ensure that the project uses the same C++ standard. - For ROOT versions below v6.32, the C++ standard is not exposed. - In this case, the default is set to CMAKE_CXX_STANDARD = 17, matching pre-built releases and conda packages. - For custom builds of ROOT below v6.32 that use a different C++ standard, the user must specify the C++ standard manually during configuration. + For builds with CERN ROOT, the minimum C++ standard is now automatically set to the one used to build ROOT. + Starting from ROOT v6.32, the CMake variable ROOT_CXX_STANDARD specifies the C++ standard used to build ROOT, so STIR now uses this as (minimum) C++ version. (From ROOT 6.34, CMake will automatically ensure that ROOT dependencies (such as STIR) use the same C++ standard).
    + Note that for ROOT versions below v6.32, the C++ standard is not exposed. + In this case, STIR's FindROOT.cmake sets ROOT_CXX_STANDARD = 17, matching pre-built releases and conda packages. + For custom builds of ROOT below v6.32 that use a more recent C++ standard, the STIR user must specify the appropriate C++ standard manually during configuration by specifying CMAKE_CXX_STANDARD.
    PR #1700