Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,8 @@ 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}")
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)
endif()
message(STATUS "ROOT Version: ${CERN_ROOT_VERSION}. CXX version: ${CERN_ROOT_CXX_STANDARD}.")
UseCXX(${CERN_ROOT_CXX_STANDARD})
endif()
endif()

Expand Down
9 changes: 9 additions & 0 deletions documentation/release_6.4.htm
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ <h3>Build system</h3>
<br>
<a href=https://github.com/UCL/STIR/pull/1665>PR #1665</a>
</li>
<li>
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 <code>ROOT_CXX_STANDARD</code> 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).<br>
Note that for ROOT versions below v6.32, the C++ standard is not exposed.
In this case, STIR's <tt>FindROOT.cmake</tt> sets <code>ROOT_CXX_STANDARD = 17</code>, 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 <code>CMAKE_CXX_STANDARD</code>.
<br>
<a href=https://github.com/UCL/STIR/pull/1700>PR #1700</a>
</li>
</ul>

<h3>Known problems</h3>
Expand Down
72 changes: 43 additions & 29 deletions src/cmake/FindCERN_ROOT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down Expand Up @@ -62,46 +63,53 @@ if (ROOT_FOUND)
set(CERN_ROOT_VERSION ${ROOT_VERSION})
set(CERN_ROOT_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS})
set(CERN_ROOT_LIBRARIES ${ROOT_LIBRARIES})
set(CERN_ROOT_CXX_STANDARD ${ROOT_CXX_STANDARD})

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)
execute_process(
COMMAND ${CERN_ROOT_CONFIG} --cxxstandard
OUTPUT_VARIABLE CERN_ROOT_CXX_STANDARD
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()

else()
else()

# no root-config
if (CERN_ROOT_DEBUG)
Expand Down Expand Up @@ -154,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)
Expand Down