diff --git a/cmake/Modules/LHCbSettings.cmake b/cmake/Modules/LHCbSettings.cmake
index b1564276204db809416a69f67c30cacec79695d4..d182604847e0046c5c5ea294ba25de8edab9f692 100644
--- a/cmake/Modules/LHCbSettings.cmake
+++ b/cmake/Modules/LHCbSettings.cmake
@@ -1,5 +1,5 @@
 ###############################################################################
-# (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration           #
+# (c) Copyright 2021-2024 CERN for the benefit of the LHCb Collaboration      #
 #                                                                             #
 # This software is distributed under the terms of the GNU General Public      #
 # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
@@ -19,7 +19,13 @@ find_data_package(Geant4Files ${Geant4_VERSION_MAJOR}${Geant4_VERSION_MINOR}.0)
 
 
 # FIXME: this should match the version used by ROOT (LCG version + compiler version)
-set(GEANT4_BUILD_CXXSTD 17 CACHE STRING "C++ Standard")
+if( (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "13.0")
+    OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "16.0") )
+    set(LHCB_DEFAULT_CXXSTD 17)
+else()
+    set(LHCB_DEFAULT_CXXSTD 20)
+endif()
+set(GEANT4_BUILD_CXXSTD ${LHCB_DEFAULT_CXXSTD} CACHE STRING "C++ Standard")
 
 set(OpenGL_GL_PREFERENCE "GLVND" CACHE STRING
     "Preferred GL library to use (see https://cmake.org/cmake/help/v3.12/policy/CMP0072.html)")