Skip to content

Commit

Permalink
Add support for CMake 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Feb 24, 2025
1 parent 776e868 commit 7ccf207
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 35 deletions.
45 changes: 23 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@

cmake_minimum_required(VERSION 3.25.1)
cmake_policy(VERSION 3.25.1)
if(POLICY CMP0167)
# use BoostConfig.cmake shipped with Boost 1.70+ instead of the one in CMake
cmake_policy(SET CMP0167 NEW)
endif()
if(POLICY CMP0169)
# use deprecated FetchContent_Populate function for h5xx dependency
cmake_policy(SET CMP0169 OLD)
endif()
message(STATUS "CMake version: ${CMAKE_VERSION}")
# CMake modules/macros are in a subdirectory to keep this file cleaner
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
Expand Down Expand Up @@ -64,6 +56,7 @@ endif()

include(FeatureSummary)
include(GNUInstallDirs)
include(ExternalProject)
include(FetchContent)
include(espresso_option_enum)
include(espresso_enable_avx2_support)
Expand Down Expand Up @@ -114,11 +107,6 @@ FetchContent_Declare(
GIT_REPOSITORY https://github.com/hmenke/espresso-stokesian-dynamics.git
GIT_TAG 90f6de70d1c0ac9cf468f2fc90f9c601139e4c88
)
FetchContent_Declare(
h5xx
GIT_REPOSITORY https://github.com/h5md/h5xx.git
GIT_TAG 0.9.1
)
FetchContent_Declare(
caliper
GIT_REPOSITORY https://github.com/LLNL/Caliper.git
Expand Down Expand Up @@ -509,19 +497,27 @@ if(ESPRESSO_BUILD_WITH_HDF5)
)
endif()
endif()
# We need to define our own h5xx target, since the project version we depend
# on is not fully compatible with modern CMake.
FetchContent_GetProperties(h5xx)
if(NOT h5xx_POPULATED)
FetchContent_Populate(h5xx)
endif()
add_library(h5xx INTERFACE)
add_library(hdf5 INTERFACE)
target_link_libraries(hdf5 INTERFACE $<BUILD_INTERFACE:${HDF5_LIBRARIES}>)
target_include_directories(hdf5
INTERFACE $<BUILD_INTERFACE:${HDF5_INCLUDE_DIRS}>)
target_include_directories(h5xx
INTERFACE $<BUILD_INTERFACE:${h5xx_SOURCE_DIR}>)
# We need to define our own h5xx target, since the project version we depend
# on is not fully compatible with modern CMake.
add_library(h5xx INTERFACE)
# cmake-format: off
ExternalProject_Add(
h5xx_library
GIT_REPOSITORY https://github.com/h5md/h5xx.git
GIT_TAG 0.9.1
PREFIX lib_h5xx
# header-only library: disable configuration/build/install steps
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
# cmake-format: on
ExternalProject_Get_Property(h5xx_library SOURCE_DIR)
target_include_directories(h5xx INTERFACE $<BUILD_INTERFACE:${SOURCE_DIR}>)
target_compile_features(h5xx INTERFACE cxx_std_11)
target_compile_definitions(h5xx INTERFACE H5XX_USE_MPI)
add_library(espresso_h5xx_cpp_flags INTERFACE)
Expand Down Expand Up @@ -670,6 +666,11 @@ endif()
# Boost
#

if(POLICY CMP0167)
# use BoostConfig.cmake shipped with Boost 1.70+ instead of the one in CMake
cmake_policy(SET CMP0167 NEW)
endif()

list(APPEND BOOST_COMPONENTS mpi serialization filesystem system)

if(ESPRESSO_BUILD_TESTS)
Expand Down
13 changes: 0 additions & 13 deletions cmake/FindCUDACompilerNVCC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# Verify the NVCC compiler matches the NVIDIA toolkit,
# include the toolkit libraries and declare a custom
# `add_library()` wrapper function named `espresso_add_gpu_library()`.

file(REAL_PATH "${CUDAToolkit_ROOT}/bin/nvcc" ESPRESO_CUDAToolkit_ROOT_RESOLVED)
file(REAL_PATH "${CMAKE_CUDA_COMPILER}" ESPRESO_CMAKE_CUDA_COMPILER_RESOLVED)
if(NOT "${ESPRESO_CUDAToolkit_ROOT_RESOLVED}" STREQUAL "${ESPRESO_CMAKE_CUDA_COMPILER_RESOLVED}"
AND NOT ESPRESSO_INSIDE_DOCKER)
cmake_path(GET CMAKE_CUDA_COMPILER PARENT_PATH ESPRESSO_NVCC_EXECUTABLE_DIRNAME)
cmake_path(GET ESPRESSO_NVCC_EXECUTABLE_DIRNAME PARENT_PATH ESPRESSO_NVCC_EXECUTABLE_DIRNAME)
message(
WARNING
"Your nvcc compiler (${CMAKE_CUDA_COMPILER}) does not appear to match your CUDA toolkit installation (${CUDAToolkit_ROOT}). While ESPResSo will still compile, you might get unexpected crashes. Try hinting it with '-D CUDAToolkit_ROOT=\"${ESPRESSO_NVCC_EXECUTABLE_DIRNAME}\"'."
)
endif()

set(CUDA_LINK_LIBRARIES_KEYWORD PUBLIC)
set(CUDA_PROPAGATE_HOST_FLAGS OFF)

Expand Down
6 changes: 6 additions & 0 deletions cmake/walberla.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ https://i10git.cs.fau.de/walberla/walberla/-/merge_requests/709
@@ -700 +700 @@
- begin_ = new T[0];
+ begin_ = nullptr;
support for CMake 4.0
--- cmake/FindOpenMesh.cmake
+++ cmake/FindOpenMesh.cmake
@@ -56 +56 @@
-cmake_minimum_required(VERSION 3.5.0)
+cmake_minimum_required(VERSION 3.10.0)

0 comments on commit 7ccf207

Please sign in to comment.