From 6834a0024610caf39021ebcc877b0754f2de3feb Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 4 Sep 2024 17:04:27 -0700 Subject: [PATCH] CMake: Replace `FetchContent_Populate` (#5179) * CMake: Replace `FetchContent_Populate` In CMake superbuilds, `FetchContent_Populate` is now deprecated. Use `FetchContent_MakeAvailable` instead. * CI: Catalyst Image Update (CMake) Update the Catalyst CI image to `kitware/paraview:ci-catalyst-amrex-warpx-20240828` to pull in a newer CMake version with it. * CI: SENSEI Hack CMake Update Hack into container image. * Doc: CMake 3.24+ - dependencies/requirements - system docs * HPC3: CMake via `pipx` for now Ticket still pending completion. --- .github/workflows/insitu.yml | 8 ++++++-- CMakeLists.txt | 9 +-------- Docs/source/install/dependencies.rst | 2 +- .../frontier_warpx.profile.example | 3 ++- .../hpc3-uci/hpc3_gpu_warpx.profile.example | 2 +- .../hpc3-uci/install_gpu_dependencies.sh | 2 ++ .../lassen_v100_warpx_toss3.profile.example | 2 +- .../ookami-sbu/ookami_warpx.profile.example | 2 +- .../polaris_gpu_warpx.profile.example | 18 +++++++++++------- .../taurus-zih/taurus_warpx.profile.example | 2 +- cmake/dependencies/AMReX.cmake | 17 ++++++----------- cmake/dependencies/PICSAR.cmake | 14 ++++---------- cmake/dependencies/openPMD.cmake | 7 +------ cmake/dependencies/pyAMReX.cmake | 7 +------ cmake/dependencies/pybind11.cmake | 7 +------ pyproject.toml | 2 +- setup.py | 6 +++--- 17 files changed, 44 insertions(+), 66 deletions(-) diff --git a/.github/workflows/insitu.yml b/.github/workflows/insitu.yml index c36900cbb7d..d6184e64d28 100644 --- a/.github/workflows/insitu.yml +++ b/.github/workflows/insitu.yml @@ -22,6 +22,8 @@ jobs: image: senseiinsitu/ci:fedora35-amrex-20220613 steps: - uses: actions/checkout@v4 + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v2 - name: Configure run: | cmake -S . -B build \ @@ -73,7 +75,7 @@ jobs: catalyst: name: Catalyst - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 if: github.event.pull_request.draft == false env: CXX: g++ @@ -83,8 +85,10 @@ jobs: CATALYST_IMPLEMENTATION_PATHS: /opt/paraview/lib/catalyst OMP_NUM_THREADS: 1 + # Container build scripts: + # https://gitlab.kitware.com/christos.tsolakis/catalyst-amrex-docker-images container: - image: kitware/paraview:ci-catalyst-amrex-warpx-20240701 + image: kitware/paraview:ci-catalyst-amrex-warpx-20240828 steps: - uses: actions/checkout@v4 - name: Configure diff --git a/CMakeLists.txt b/CMakeLists.txt index d94b684f3a4..9bbfba70c27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # Preamble #################################################################### # -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.24.0) project(WarpX VERSION 24.08) include(${WarpX_SOURCE_DIR}/cmake/WarpXFunctions.cmake) @@ -29,13 +29,6 @@ if(POLICY CMP0104) cmake_policy(SET CMP0104 OLD) endif() -# We use simple syntax in cmake_dependent_option, so we are compatible with the -# extended syntax in CMake 3.22+ -# https://cmake.org/cmake/help/v3.22/policy/CMP0127.html -if(POLICY CMP0127) - cmake_policy(SET CMP0127 NEW) -endif() - # C++ Standard in Superbuilds ################################################# # diff --git a/Docs/source/install/dependencies.rst b/Docs/source/install/dependencies.rst index 34150e42b5a..f46dc3d1640 100644 --- a/Docs/source/install/dependencies.rst +++ b/Docs/source/install/dependencies.rst @@ -7,7 +7,7 @@ WarpX depends on the following popular third party software. Please see installation instructions below. - a mature `C++17 `__ compiler, e.g., GCC 8.4+, Clang 7, NVCC 11.0, MSVC 19.15 or newer -- `CMake 3.20.0+ `__ +- `CMake 3.24.0+ `__ - `Git 2.18+ `__ - `AMReX `__: we automatically download and compile a copy of AMReX - `PICSAR `__: we automatically download and compile a copy of PICSAR diff --git a/Tools/machines/frontier-olcf/frontier_warpx.profile.example b/Tools/machines/frontier-olcf/frontier_warpx.profile.example index f59f2d3d058..5ca6e1e1622 100644 --- a/Tools/machines/frontier-olcf/frontier_warpx.profile.example +++ b/Tools/machines/frontier-olcf/frontier_warpx.profile.example @@ -6,7 +6,8 @@ export MY_PROFILE=$(cd $(dirname $BASH_SOURCE) && pwd)"/"$(basename $BASH_SOURCE if [ -z ${proj-} ]; then echo "WARNING: The 'proj' variable is not yet set in your $MY_PROFILE file! Please edit its line 2 to continue!"; return; fi # required dependencies -module load cmake/3.23.2 +module switch Core Core/24.07 +module load cmake/3.27.9 module load craype-accel-amd-gfx90a module load rocm/5.7.1 module load cray-mpich/8.1.28 diff --git a/Tools/machines/hpc3-uci/hpc3_gpu_warpx.profile.example b/Tools/machines/hpc3-uci/hpc3_gpu_warpx.profile.example index 017613f9d60..27b6a59592e 100644 --- a/Tools/machines/hpc3-uci/hpc3_gpu_warpx.profile.example +++ b/Tools/machines/hpc3-uci/hpc3_gpu_warpx.profile.example @@ -6,7 +6,7 @@ export MY_PROFILE=$(cd $(dirname $BASH_SOURCE) && pwd)"/"$(basename $BASH_SOURCE if [ -z ${proj-} ]; then echo "WARNING: The 'proj' variable is not yet set in your $MY_PROFILE file! Please edit its line 2 to continue!"; return; fi # required dependencies -module load cmake/3.22.1 +module load cmake/3.22.1 # we need 3.24+ - installing via pipx until module is available module load gcc/11.2.0 module load cuda/11.7.1 module load openmpi/4.1.2/gcc.11.2.0 diff --git a/Tools/machines/hpc3-uci/install_gpu_dependencies.sh b/Tools/machines/hpc3-uci/install_gpu_dependencies.sh index b585c2702b6..56f2bff4025 100755 --- a/Tools/machines/hpc3-uci/install_gpu_dependencies.sh +++ b/Tools/machines/hpc3-uci/install_gpu_dependencies.sh @@ -118,6 +118,8 @@ python3 -m pip install --upgrade build python3 -m pip install --upgrade packaging python3 -m pip install --upgrade wheel python3 -m pip install --upgrade setuptools +python3 -m pip install --upgrade pipx +python3 -m pipx install --upgrade cmake python3 -m pip install --upgrade cython python3 -m pip install --upgrade numpy python3 -m pip install --upgrade pandas diff --git a/Tools/machines/lassen-llnl/lassen_v100_warpx_toss3.profile.example b/Tools/machines/lassen-llnl/lassen_v100_warpx_toss3.profile.example index 98e8d6410b3..99e61a2fbf6 100644 --- a/Tools/machines/lassen-llnl/lassen_v100_warpx_toss3.profile.example +++ b/Tools/machines/lassen-llnl/lassen_v100_warpx_toss3.profile.example @@ -2,7 +2,7 @@ #export proj="" # edit this and comment in # required dependencies -module load cmake/3.23.1 +module load cmake/3.29.2 module load gcc/11.2.1 module load cuda/12.0.0 diff --git a/Tools/machines/ookami-sbu/ookami_warpx.profile.example b/Tools/machines/ookami-sbu/ookami_warpx.profile.example index 321e3ce1d59..dc8c7ac6639 100644 --- a/Tools/machines/ookami-sbu/ookami_warpx.profile.example +++ b/Tools/machines/ookami-sbu/ookami_warpx.profile.example @@ -2,7 +2,7 @@ #export proj= # required dependencies -module load cmake/3.19.0 +module load cmake/3.19.0 # please check for a 3.24+ module and report back module load gcc/10.3.0 module load openmpi/gcc10/4.1.0 diff --git a/Tools/machines/polaris-alcf/polaris_gpu_warpx.profile.example b/Tools/machines/polaris-alcf/polaris_gpu_warpx.profile.example index 333434c1b97..d5cb1ec7a07 100644 --- a/Tools/machines/polaris-alcf/polaris_gpu_warpx.profile.example +++ b/Tools/machines/polaris-alcf/polaris_gpu_warpx.profile.example @@ -3,20 +3,24 @@ export proj="" # change me! # swap to GNU programming environment (with gcc 11.2) module swap PrgEnv-nvhpc PrgEnv-gnu -module swap gcc/12.2.0 gcc/11.2.0 -module load nvhpc-mixed/22.11 +module load gcc-native/12.3 +module load nvhpc-mixed/23.9 # swap to the Milan cray package -module swap craype-x86-rome craype-x86-milan +module load craype-x86-milan + +# extra modules +module use /soft/modulefiles +module load spack-pe-gnu # required dependencies -module load cmake/3.23.2 +module load cmake/3.27.7 # optional: for QED support with detailed tables -# module load boost/1.81.0 +module load boost # optional: for openPMD and PSATD+RZ support -module load cray-hdf5-parallel/1.12.2.3 +module load cray-hdf5-parallel/1.12.2.9 export CMAKE_PREFIX_PATH=/home/${USER}/sw/polaris/gpu/c-blosc-1.21.1:$CMAKE_PREFIX_PATH export CMAKE_PREFIX_PATH=/home/${USER}/sw/polaris/gpu/adios2-2.8.3:$CMAKE_PREFIX_PATH export CMAKE_PREFIX_PATH=/home/${USER}/sw/polaris/gpu/blaspp-2024.05.31:$CMAKE_PREFIX_PATH @@ -30,7 +34,7 @@ export LD_LIBRARY_PATH=/home/${USER}/sw/polaris/gpu/lapackpp-2024.05.31/lib64:$L export PATH=/home/${USER}/sw/polaris/gpu/adios2-2.8.3/bin:${PATH} # optional: for Python bindings or libEnsemble -module load cray-python/3.9.13.1 +module load python/3.10.9 if [ -d "/home/${USER}/sw/polaris/gpu/venvs/warpx" ] then diff --git a/Tools/machines/taurus-zih/taurus_warpx.profile.example b/Tools/machines/taurus-zih/taurus_warpx.profile.example index f564f696c4a..434d773067b 100644 --- a/Tools/machines/taurus-zih/taurus_warpx.profile.example +++ b/Tools/machines/taurus-zih/taurus_warpx.profile.example @@ -5,7 +5,7 @@ module load modenv/hiera module load foss/2021b module load CUDA/11.8.0 -module load CMake/3.22.1 +module load CMake/3.27.6 # optional: for QED support with detailed tables #module load Boost # TODO diff --git a/cmake/dependencies/AMReX.cmake b/cmake/dependencies/AMReX.cmake index 605ca2d3fa6..91d3542008b 100644 --- a/cmake/dependencies/AMReX.cmake +++ b/cmake/dependencies/AMReX.cmake @@ -145,22 +145,17 @@ macro(find_amrex) endif() add_subdirectory(${WarpX_amrex_src} _deps/localamrex-build/) else() + if(WarpX_COMPUTE STREQUAL CUDA) + enable_language(CUDA) + # AMReX 21.06+ supports CUDA_ARCHITECTURES + endif() FetchContent_Declare(fetchedamrex GIT_REPOSITORY ${WarpX_amrex_repo} GIT_TAG ${WarpX_amrex_branch} BUILD_IN_SOURCE 0 ) - FetchContent_GetProperties(fetchedamrex) - - if(NOT fetchedamrex_POPULATED) - FetchContent_Populate(fetchedamrex) - list(APPEND CMAKE_MODULE_PATH "${fetchedamrex_SOURCE_DIR}/Tools/CMake") - if(WarpX_COMPUTE STREQUAL CUDA) - enable_language(CUDA) - # AMReX 21.06+ supports CUDA_ARCHITECTURES - endif() - add_subdirectory(${fetchedamrex_SOURCE_DIR} ${fetchedamrex_BINARY_DIR}) - endif() + FetchContent_MakeAvailable(fetchedamrex) + list(APPEND CMAKE_MODULE_PATH "${fetchedamrex_SOURCE_DIR}/Tools/CMake") # advanced fetch options mark_as_advanced(FETCHCONTENT_BASE_DIR) diff --git a/cmake/dependencies/PICSAR.cmake b/cmake/dependencies/PICSAR.cmake index 6f2fb4f0137..ca06cf42315 100644 --- a/cmake/dependencies/PICSAR.cmake +++ b/cmake/dependencies/PICSAR.cmake @@ -53,19 +53,13 @@ function(find_picsar) get_source_version(PXRMP_QED ${WarpX_picsar_src}) else() FetchContent_Declare(fetchedpicsar - GIT_REPOSITORY ${WarpX_picsar_repo} - GIT_TAG ${WarpX_picsar_branch} + GIT_REPOSITORY ${WarpX_picsar_repo} + GIT_TAG ${WarpX_picsar_branch} BUILD_IN_SOURCE 0 + SOURCE_SUBDIR multi_physics/QED ) - FetchContent_GetProperties(fetchedpicsar) + FetchContent_MakeAvailable(fetchedpicsar) - if(NOT fetchedpicsar_POPULATED) - FetchContent_Populate(fetchedpicsar) - add_subdirectory( - ${fetchedpicsar_SOURCE_DIR}/multi_physics/QED - ${fetchedpicsar_BINARY_DIR} - ) - endif() get_source_version(PXRMP_QED ${fetchedpicsar_SOURCE_DIR}) if(NOT PXRMP_QED_GIT_VERSION) set(PXRMP_QED_GIT_VERSION "${WarpX_picsar_branch}" CACHE INTERNAL "") diff --git a/cmake/dependencies/openPMD.cmake b/cmake/dependencies/openPMD.cmake index f58d37ee92e..ce6ec4d0967 100644 --- a/cmake/dependencies/openPMD.cmake +++ b/cmake/dependencies/openPMD.cmake @@ -32,12 +32,7 @@ function(find_openpmd) GIT_TAG ${WarpX_openpmd_branch} BUILD_IN_SOURCE 0 ) - FetchContent_GetProperties(fetchedopenpmd) - - if(NOT fetchedopenpmd_POPULATED) - FetchContent_Populate(fetchedopenpmd) - add_subdirectory(${fetchedopenpmd_SOURCE_DIR} ${fetchedopenpmd_BINARY_DIR}) - endif() + FetchContent_MakeAvailable(fetchedopenpmd) # advanced fetch options mark_as_advanced(FETCHCONTENT_BASE_DIR) diff --git a/cmake/dependencies/pyAMReX.cmake b/cmake/dependencies/pyAMReX.cmake index 793c7cfe598..a803e47eb2f 100644 --- a/cmake/dependencies/pyAMReX.cmake +++ b/cmake/dependencies/pyAMReX.cmake @@ -47,12 +47,7 @@ function(find_pyamrex) GIT_TAG ${WarpX_pyamrex_branch} BUILD_IN_SOURCE 0 ) - FetchContent_GetProperties(fetchedpyamrex) - - if(NOT fetchedpyamrex_POPULATED) - FetchContent_Populate(fetchedpyamrex) - add_subdirectory(${fetchedpyamrex_SOURCE_DIR} ${fetchedpyamrex_BINARY_DIR}) - endif() + FetchContent_MakeAvailable(fetchedpyamrex) # advanced fetch options mark_as_advanced(FETCHCONTENT_BASE_DIR) diff --git a/cmake/dependencies/pybind11.cmake b/cmake/dependencies/pybind11.cmake index 0a7ec260493..94d38e69112 100644 --- a/cmake/dependencies/pybind11.cmake +++ b/cmake/dependencies/pybind11.cmake @@ -21,12 +21,7 @@ function(find_pybind11) GIT_TAG ${WarpX_pybind11_branch} BUILD_IN_SOURCE 0 ) - FetchContent_GetProperties(fetchedpybind11) - - if(NOT fetchedpybind11_POPULATED) - FetchContent_Populate(fetchedpybind11) - add_subdirectory(${fetchedpybind11_SOURCE_DIR} ${fetchedpybind11_BINARY_DIR}) - endif() + FetchContent_MakeAvailable(fetchedpybind11) # advanced fetch options mark_as_advanced(FETCHCONTENT_BASE_DIR) diff --git a/pyproject.toml b/pyproject.toml index 9d5e78a6cc4..6210388f6e0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ requires = [ "setuptools>=42", "wheel", - "cmake>=3.20.0,<4.0.0", + "cmake>=3.24.0,<4.0.0", "packaging>=23", ] build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index acf61165e98..713fb788319 100644 --- a/setup.py +++ b/setup.py @@ -63,14 +63,14 @@ def run(self): out = subprocess.check_output(["cmake", "--version"]) except OSError: raise RuntimeError( - "CMake 3.20.0+ must be installed to build the following " + "CMake 3.24.0+ must be installed to build the following " + "extensions: " + ", ".join(e.name for e in self.extensions) ) cmake_version = parse(re.search(r"version\s*([\d.]+)", out.decode()).group(1)) - if cmake_version < parse("3.20.0"): - raise RuntimeError("CMake >= 3.20.0 is required") + if cmake_version < parse("3.24.0"): + raise RuntimeError("CMake >= 3.24.0 is required") for ext in self.extensions: self.build_extension(ext)