From 31ac1ec2384f3a4ab00091b4f3945b30847e9e78 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Thu, 29 Aug 2024 17:08:26 -0700 Subject: [PATCH 1/2] CMake: Replace `FetchContent_Populate` In CMake superbuilds, `FetchContent_Populate` is now deprecated. Use `FetchContent_MakeAvailable` instead. --- ExampleCodes/CMakeLists.txt | 24 +++++++------------ .../HeatEquation/Exec/CMakeLists.txt | 6 +---- .../HeatEquation_Simple/CMakeLists.txt | 6 +---- GuidedTutorials/HelloWorld/CMakeLists.txt | 6 +---- GuidedTutorials/MultiFab/CMakeLists.txt | 6 +---- 5 files changed, 12 insertions(+), 36 deletions(-) diff --git a/ExampleCodes/CMakeLists.txt b/ExampleCodes/CMakeLists.txt index be729404..736d93e9 100644 --- a/ExampleCodes/CMakeLists.txt +++ b/ExampleCodes/CMakeLists.txt @@ -59,14 +59,14 @@ if( NOT DEFINED AMReX_DIR ) GIT_TAG ${AMReX_GIT_BRANCH} ) - if(NOT ${amrex}_POPULATED) - FetchContent_Populate(amrex) +if(NOT ${amrex}_POPULATED) + FetchContent_MakeAvailable(amrex) - list(APPEND CMAKE_MODULE_PATH ${amrex_SOURCE_DIR}/Tools/CMake) + list(APPEND CMAKE_MODULE_PATH ${amrex_SOURCE_DIR}/Tools/CMake) - # Load amrex options here so that they are - # available to the entire project - include(AMReXOptions) + # Load amrex options here so that they are + # available to the entire project + include(AMReXOptions) if( AMReX_SUNDIALS ) if( NOT DEFINED SUNDIALS_DIR ) @@ -86,7 +86,7 @@ if( NOT DEFINED SUNDIALS_DIR ) ) if(NOT ${sundials}_POPULATED) - FetchContent_Populate(sundials) + FetchContent_MakeAvailable(sundials) # set(SUNDIALS_DIR ${sundials_SOURCE_DIR}) # Set build options for subproject set(EXAMPLES_ENABLE_C OFF CACHE INTERNAL "" ) @@ -122,9 +122,6 @@ if( NOT DEFINED SUNDIALS_DIR ) endif () list(APPEND CMAKE_MODULE_PATH ${sundials_SOURCE_DIR}) -# Add SUNDIALS sources to the build - add_subdirectory(${sundials_SOURCE_DIR}) - # This is to use the same target name uses by the sundials exported targets add_library(SUNDIALS::cvode ALIAS sundials_cvode_static) add_library(SUNDIALS::arkode ALIAS sundials_arkode_static) @@ -172,9 +169,6 @@ endif () include(AMReX_SetupCUDA) endif() endif() - - # Bring the populated content into the build - add_subdirectory(${amrex_SOURCE_DIR} ${amrex_BINARY_DIR}) endif() else() message(STATUS "Using existing AMReX library") @@ -210,10 +204,8 @@ if(TUTORIAL_PYTHON) GIT_REPOSITORY ${pyAMReX_GIT_REPO} GIT_TAG ${pyAMReX_GIT_BRANCH} ) - if(NOT fetchedpyamrex_POPULATED) - FetchContent_Populate(fetchedpyamrex) - add_subdirectory(${fetchedpyamrex_SOURCE_DIR} ${fetchedpyamrex_BINARY_DIR}) + FetchContent_MakeAvailable(fetchedpyamrex) endif() endif() endif() diff --git a/GuidedTutorials/HeatEquation/Exec/CMakeLists.txt b/GuidedTutorials/HeatEquation/Exec/CMakeLists.txt index 33706d03..578f8df5 100644 --- a/GuidedTutorials/HeatEquation/Exec/CMakeLists.txt +++ b/GuidedTutorials/HeatEquation/Exec/CMakeLists.txt @@ -57,11 +57,7 @@ if(NOT DEFINED AMReX_ROOT) GIT_TAG origin/development ) - FetchContent_Populate(amrex_code) - - # CMake will read the files in these directories and configure, build - # and install AMReX. - add_subdirectory(${amrex_code_SOURCE_DIR} ${amrex_code_BINARY_DIR}) + FetchContent_MakeAvailable(amrex_code) else() diff --git a/GuidedTutorials/HeatEquation_Simple/CMakeLists.txt b/GuidedTutorials/HeatEquation_Simple/CMakeLists.txt index 0aee75e7..fb5c2d43 100644 --- a/GuidedTutorials/HeatEquation_Simple/CMakeLists.txt +++ b/GuidedTutorials/HeatEquation_Simple/CMakeLists.txt @@ -49,11 +49,7 @@ if(NOT DEFINED AMReX_ROOT) GIT_TAG origin/development ) - FetchContent_Populate(amrex_code) - - # CMake will read the files in these directories to configure, build - # and install AMReX. - add_subdirectory(${amrex_code_SOURCE_DIR} ${amrex_code_BINARY_DIR}) + FetchContent_MakeAvailable(amrex_code) else() diff --git a/GuidedTutorials/HelloWorld/CMakeLists.txt b/GuidedTutorials/HelloWorld/CMakeLists.txt index 3a4c8849..68fe3b4e 100644 --- a/GuidedTutorials/HelloWorld/CMakeLists.txt +++ b/GuidedTutorials/HelloWorld/CMakeLists.txt @@ -53,11 +53,7 @@ if(NOT DEFINED AMReX_ROOT) GIT_TAG origin/development ) - FetchContent_Populate(amrex_code) - - # CMake will read the files in these directories and configure, build - # and install AMReX. - add_subdirectory(${amrex_code_SOURCE_DIR} ${amrex_code_BINARY_DIR}) + FetchContent_MakeAvailable(amrex_code) else() diff --git a/GuidedTutorials/MultiFab/CMakeLists.txt b/GuidedTutorials/MultiFab/CMakeLists.txt index b5b3cbf8..e54b1295 100644 --- a/GuidedTutorials/MultiFab/CMakeLists.txt +++ b/GuidedTutorials/MultiFab/CMakeLists.txt @@ -53,11 +53,7 @@ if(NOT DEFINED AMReX_ROOT) GIT_TAG origin/development ) - FetchContent_Populate(amrex_code) - - # CMake will read the files in these directories and configure, build - # and install AMReX. - add_subdirectory(${amrex_code_SOURCE_DIR} ${amrex_code_BINARY_DIR}) + FetchContent_MakeAvailable(amrex_code) else() From d9a73e30cb3386f6226c2c7c65eb36cfb2eb0691 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Thu, 29 Aug 2024 20:44:18 -0700 Subject: [PATCH 2/2] CMake: 3.24+ --- ExampleCodes/CMakeLists.txt | 18 +++++++++--------- .../HeatEquation/Exec/CMakeLists.txt | 2 +- .../HeatEquation_Simple/CMakeLists.txt | 2 +- GuidedTutorials/HelloWorld/CMakeLists.txt | 2 +- GuidedTutorials/MultiFab/CMakeLists.txt | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ExampleCodes/CMakeLists.txt b/ExampleCodes/CMakeLists.txt index 736d93e9..ae0df66e 100644 --- a/ExampleCodes/CMakeLists.txt +++ b/ExampleCodes/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.24) project( AMReX-Tutorials DESCRIPTION "Tutorials for the AMReX adaptive mesh refinement framework" @@ -51,6 +51,14 @@ if( NOT DEFINED AMReX_DIR ) set(AMReX_GIT_BRANCH "development" CACHE STRING "The AMReX branch to checkout") set(AMReX_INSTALL "NO" CACHE INTERNAL "Disable install target for amrex") + if(AMReX_FORTRAN) + enable_language(Fortran) + endif () + + if(AMReX_GPU_BACKEND STREQUAL "CUDA") + enable_language(CUDA) + endif() + include(FetchContent) set(FETCHCONTENT_QUIET OFF) # Verbose ON @@ -164,10 +172,6 @@ endif () if(AMReX_GPU_BACKEND STREQUAL "CUDA") enable_language(CUDA) - # AMReX 21.06+ supports CUDA_ARCHITECTURES - if(CMAKE_VERSION VERSION_LESS 3.20) - include(AMReX_SetupCUDA) - endif() endif() endif() else() @@ -178,10 +182,6 @@ else() if(AMReX_GPU_BACKEND STREQUAL "CUDA") enable_language(CUDA) - # AMReX 21.06+ supports CUDA_ARCHITECTURES - if(CMAKE_VERSION VERSION_LESS 3.20) - include(AMReX_SetupCUDA) - endif() endif() endif() diff --git a/GuidedTutorials/HeatEquation/Exec/CMakeLists.txt b/GuidedTutorials/HeatEquation/Exec/CMakeLists.txt index 578f8df5..df317516 100644 --- a/GuidedTutorials/HeatEquation/Exec/CMakeLists.txt +++ b/GuidedTutorials/HeatEquation/Exec/CMakeLists.txt @@ -28,7 +28,7 @@ # For additional CMake compile options see # https://amrex-codes.github.io/amrex/docs_html/BuildingAMReX.html#building-with-cmake -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.24) ## Project name and source file languages project(HeatEquation_EX0 diff --git a/GuidedTutorials/HeatEquation_Simple/CMakeLists.txt b/GuidedTutorials/HeatEquation_Simple/CMakeLists.txt index fb5c2d43..02e65312 100644 --- a/GuidedTutorials/HeatEquation_Simple/CMakeLists.txt +++ b/GuidedTutorials/HeatEquation_Simple/CMakeLists.txt @@ -24,7 +24,7 @@ # For additional CMake compile options see # https://amrex-codes.github.io/amrex/docs_html/BuildingAMReX.html#building-with-cmake -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.24) # Project name and source file languages project(HeatEquation_Simple diff --git a/GuidedTutorials/HelloWorld/CMakeLists.txt b/GuidedTutorials/HelloWorld/CMakeLists.txt index 68fe3b4e..533c7f10 100644 --- a/GuidedTutorials/HelloWorld/CMakeLists.txt +++ b/GuidedTutorials/HelloWorld/CMakeLists.txt @@ -26,7 +26,7 @@ -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.24) # Project name and source file language project(HelloWorld diff --git a/GuidedTutorials/MultiFab/CMakeLists.txt b/GuidedTutorials/MultiFab/CMakeLists.txt index e54b1295..2626db12 100644 --- a/GuidedTutorials/MultiFab/CMakeLists.txt +++ b/GuidedTutorials/MultiFab/CMakeLists.txt @@ -26,7 +26,7 @@ -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.24) # Project name and source file language project(MultiFab