From a43b0522e7c4dde227dee30d475e97a1f65058af Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sun, 27 Feb 2022 23:08:55 -0800 Subject: [PATCH] C++17 build ``` In file included from /home/runner/work/pyamrex/pyamrex/build/temp.linux-x86_64-3.6/3/_deps/fetchedamrex-src/Src/Base/AMReX_FabArray.H:13: /home/runner/work/pyamrex/pyamrex/build/temp.linux-x86_64-3.6/3/_deps/fetchedamrex-src/Src/Base/AMReX_FabFactory.H:52:5: error: use of the 'nodiscard' attribute is a C++17 extension [-Werror,-Wc++17-extensions] AMREX_NODISCARD ^ /home/runner/work/pyamrex/pyamrex/build/temp.linux-x86_64-3.6/3/_deps/fetchedamrex-src/Src/Base/AMReX_Extension.H:185:30: note: expanded from macro 'AMREX_NODISCARD' # define AMREX_NODISCARD [[nodiscard]] ^ ``` --- CMakeLists.txt | 7 +++++++ cmake/pyAMReXFunctions.cmake | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) 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)