Getting the c++ standard if ROOT_CXX_STANDARD is not set

The original topic got closed, but in case anyone else encounters this problem:

If the ROOT_CXX_STANDARD variable is not set in cmake (ROOT versions 6.30.06 and earlier), I found the code can be used to get the c++ standard used to compile the ROOT version in use:

if(NOT ROOT_CXX_VERSION)
   string(REGEX REPLACE ".*-std=.+\\+\\+([0-9][0-9]).*" "\\1" ROOT_CXX_VERSION ${ROOT_CXX_FLAGS})
   if(${CMAKE_MATCH_COUNT} EQUAL "1")
      message("Got ROOT_CXX_VERSION=${ROOT_CXX_VERSION} from \"${ROOT_CXX_FLAGS}\"")
   else()
      message(FATAL_ERROR "The ROOT cxx flags seem to be misformed (${ROOT_CXX_FLAGS}) (CMAKE_MATCH_COUNT=${CMAKE_MATCH_COUNT}), consider providing a cxx version by hand using \"-DROOT_CXX_VERSION=??\"")
   endif()
else()
   message("Got user provided ROOT_CXX_VERSION=${ROOT_CXX_VERSION}")
endif()

Hi @vaubee, thanks for providing your solution.

Original post for future reference: CMake variable ROOT_CXX_STANDARD not set

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.