diff --git a/CMakeLists.txt b/CMakeLists.txt index b7fc0c75..a8bb9537 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,13 @@ if(POLICY CMP0105) endif() +# C++ Standard in Superbuilds ################################################# +# +# This is the easiest way to push up a C++17 requirement for AMReX, PICSAR and +# openPMD-api until they increase their requirement. +set_cxx17_superbuild() + + # CCache Support ############################################################## # # this is an optional tool that stores compiled object files; allows fast diff --git a/cmake/pyAMReXFunctions.cmake b/cmake/pyAMReXFunctions.cmake index 353e40b3..c1ea6256 100644 --- a/cmake/pyAMReXFunctions.cmake +++ b/cmake/pyAMReXFunctions.cmake @@ -1,3 +1,31 @@ +# Set C++17 for the whole build if not otherwise requested +# +# This is the easiest way to push up a C++17 requirement for AMReX, PICSAR and +# openPMD-api until they increase their requirement. +# +macro(set_cxx17_superbuild) + if(NOT DEFINED CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) + endif() + if(NOT DEFINED CMAKE_CXX_EXTENSIONS) + set(CMAKE_CXX_EXTENSIONS OFF) + endif() + if(NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + endif() + + if(NOT DEFINED CMAKE_CUDA_STANDARD) + set(CMAKE_CUDA_STANDARD 17) + endif() + if(NOT DEFINED CMAKE_CUDA_EXTENSIONS) + set(CMAKE_CUDA_EXTENSIONS OFF) + endif() + if(NOT DEFINED CMAKE_CUDA_STANDARD_REQUIRED) + set(CMAKE_CUDA_STANDARD_REQUIRED ON) + endif() +endmacro() + + # find the CCache tool and use it if found # macro(set_ccache)