Skip to content

Commit

Permalink
Adjust cmake_minimim_required upper limit to set all new policies to NEW
Browse files Browse the repository at this point in the history
Includes CMP0152 which in CMake >= 3.28 changes symlink resolution behaviour, relevant to nvhpc workarounds.
  • Loading branch information
ptheywood committed Jan 9, 2024
1 parent 0a45326 commit cc68f1e
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 42 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Minimum CMake version 3.18 for CUDA --std=c++17
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18...3.28 FATAL_ERROR)

# Include and call some CMake to record initial state of CMAKE_CUDA_ARCHITECTURES for later use
include(${CMAKE_CURRENT_LIST_DIR}/cmake/CUDAArchitectures.cmake)
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/boids_bruteforce/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Minimum CMake version 3.18 for CUDA --std=c++17
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18...3.28 FATAL_ERROR)

# Set the location of the ROOT flame gpu project relative to this CMakeList.txt
get_filename_component(FLAMEGPU_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/boids_spatial3D/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Minimum CMake version 3.18 for CUDA --std=c++17
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18...3.28 FATAL_ERROR)

# Set the location of the ROOT flame gpu project relative to this CMakeList.txt
get_filename_component(FLAMEGPU_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/circles_bruteforce/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Minimum CMake version 3.18 for CUDA --std=c++17
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18...3.28 FATAL_ERROR)

# Set the location of the ROOT flame gpu project relative to this CMakeList.txt
get_filename_component(FLAMEGPU_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/circles_spatial3D/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Minimum CMake version 3.18 for CUDA --std=c++17
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18...3.28 FATAL_ERROR)

# Set the location of the ROOT flame gpu project relative to this CMakeList.txt
get_filename_component(FLAMEGPU_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/diffusion/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Set the minimum cmake version to that which supports cuda natively.
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18...3.28 FATAL_ERROR)

# Set the location of the ROOT flame gpu project relative to this CMakeList.txt
get_filename_component(FLAMEGPU_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/ensemble/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Set the minimum cmake version to that which supports cuda natively.
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18...3.28 FATAL_ERROR)

# Set the location of the ROOT flame gpu project relative to this CMakeList.txt
get_filename_component(FLAMEGPU_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/game_of_life/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Minimum CMake version 3.18 for CUDA --std=c++17
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18...3.28 FATAL_ERROR)

# Set the location of the ROOT flame gpu project relative to this CMakeList.txt
get_filename_component(FLAMEGPU_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/host_functions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Minimum CMake version 3.18 for CUDA --std=c++17
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18...3.28 FATAL_ERROR)

# Set the location of the ROOT flame gpu project relative to this CMakeList.txt
get_filename_component(FLAMEGPU_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/sugarscape/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Set the minimum cmake version to that which supports cuda natively.
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18...3.28 FATAL_ERROR)

# Set the location of the ROOT flame gpu project relative to this CMakeList.txt
get_filename_component(FLAMEGPU_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp_rtc/boids_bruteforce/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Minimum CMake version 3.18 for CUDA --std=c++17
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18...3.28 FATAL_ERROR)

# Set the location of the ROOT flame gpu project relative to this CMakeList.txt
get_filename_component(FLAMEGPU_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp_rtc/boids_spatial3D/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Minimum CMake version 3.18 for CUDA --std=c++17
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18...3.28 FATAL_ERROR)

# Set the location of the ROOT flame gpu project relative to this CMakeList.txt
get_filename_component(FLAMEGPU_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
Expand Down
34 changes: 7 additions & 27 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Minimum CMake version 3.18 for CUDA --std=c++17
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18...3.28 FATAL_ERROR)

# Set the location of the ROOT flame gpu project relative to this CMakeList.txt
get_filename_component(FLAMEGPU_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/.. REALPATH)
Expand Down Expand Up @@ -659,8 +659,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC CUDA::cuda_driver)
# If using cuda installed with older nvhpc, the location of curand won't implicitly be on the include directory path, so we must explicitly specify it.

# do a find path for curand.h at the expected nvcc location. If it does not exist there, then try again where nvhpc places it, and if found add that to the include directories. Potentially this is not required for new enough nvhpc with gcc as the host compiler.
# Could also detect if this is neccesary via try compile, set a cache var, and if the cache var exists use that?
message("CUDAToolkit_INCLUDE_DIRS ${CUDAToolkit_INCLUDE_DIRS}")
# Could also detect if this is necessary via try compile, set a cache var, and if the cache var exists use that?
find_path(curand_INCLUDE_DIRS
NAMES
curand.h
Expand All @@ -671,15 +670,14 @@ find_path(curand_INCLUDE_DIRS
# if not found, probably an nvhpc install (or curand is not installed)
if(NOT curand_INCLUDE_DIRS)
# search for the (expected) split math library location
message(WARNING "curand not found at expected location, must be an nvhpc install.")
# message(WARNING "curand not found at expected location, must be an nvhpc install.")
# if using nvhpc as the host compiler
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.19")
file(REAL_PATH "${CUDAToolkit_LIBRARY_DIR}/../../../math_libs/${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR}" curand_split_search_dir)
else()
message(FATAL_ERROR "@todo - use get filename component isntead.")
get_filename_component(curand_split_search_dir "@todo" REALPATH)
endif()
message("curand_split_search_dir ${curand_split_search_dir}")
find_file(curand_header_abspath
NAMES
curand.h
Expand All @@ -692,40 +690,22 @@ if(NOT curand_INCLUDE_DIRS)
if(NOT curand_header_abspath)
message(FATAL_ERROR "${curand_header_abspath} not found @todo")
else()
# if we found curand at the exepcted nvhpc installation location, we might have to resolve symlinks again, and return the parent directory
# if we found curand at the expected nvhpc installation location, we might have to resolve symlinks again, and return the parent directory. This could be simplified for 3.28+
# @todo - do we need to support the 3.18/3.19 path here? nvhpc is only supported for 3.20+, and we might add a lower minimum if it fixes things.
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.19")
message("curand_header_abspath ${curand_header_abspath}")
message("curand_header_abspath ${curand_header_abspath}")
file(REAL_PATH "${curand_header_abspath}" curand_header_abspath)
cmake_path(GET curand_header_abspath PARENT_PATH curand_INCLUDE_DIRS)
else()
message(FATAL_ERROR "@todo - use get filename component isntead.")
get_filename_component(curand_split_search_dir "@todo" REALPATH)
endif()

# message(FATAL_ERROR "curand_INCLUDE_DIRS ${curand_INCLUDE_DIRS}")

endif()
target_include_directories(${PROJECT_NAME} PUBLIC ${curand_INCLUDE_DIRS})
unset(curand_header_abspath)
endif()
endif()
unset(curand_INCLUDE_DIRS)

# @todo - correctly detect where nvcc came from, but when nvhpc is not the host compiler.
# @todo - if using nvhpc and version is older, or using an nvcc install from within nvhpc?
# if(CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "22.3")
# target_link_libraries(${PROJECT_NAME} PUBLIC CUDA::curand)
# message(FATAL_ERROR "older nvhpc, doi curand manually")
# # else()
# # message(FATAL_ERROR "${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
# endif()

# If using cuda installed with older nvhpc, and nvhpc as the host compiler, need to ensure that curands repackaged include directory is on the include path. the CUDA::curand target does not do this.
# if(CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC")
# target_link_libraries(${PROJECT_NAME} PUBLIC CUDA::curand)
# message(FATAL_ERROR "CUDAToolkit_INCLUDE_DIRS ${CUDAToolkit_INCLUDE_DIRS}")
# target_include_directories(${PROJECT_NAME} PUBLIC ${})
# endif()

if(FLAMEGPU_ENABLE_NVTX AND TARGET NVTX::nvtx)
target_link_libraries(${PROJECT_NAME} PUBLIC NVTX::nvtx)
# Get the version to set a definition value
Expand Down
2 changes: 1 addition & 1 deletion swig/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Minimum CMake version 3.18 for CUDA --std=c++17
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18...3.28 FATAL_ERROR)
include(FetchContent)


Expand Down
2 changes: 1 addition & 1 deletion swig/python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Minimum CMake version 3.18 for CUDA --std=c++17
# for multi-config generators, CMake must be >= 3.20 for python bindings due to use of generator expressions in outputs/byproducts
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18...3.28 FATAL_ERROR)

# Defines multiple CMake targets and custom commands to build swig bindings, create a python wheel and (optionally) install it into a venv.
# defines `pyflamegpu` - the user-facing target which creates the wheel.
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Minimum CMake version 3.18 for CUDA --std=c++17
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18...3.28 FATAL_ERROR)

# Option to enable GTEST_DISCOVER if tests or tests_dev are enabled. Defaults to off due to runtime increase
cmake_dependent_option(FLAMEGPU_ENABLE_GTEST_DISCOVER "Enable GTEST_DISCOVER for more detailed ctest output without -VV. This dramatically increases test suite runtime to CUDA context initialisation." OFF "FLAMEGPU_BUILD_TESTS OR FLAMEGPU_BUILD_TESTS_DEV" OFF)
Expand Down

0 comments on commit cc68f1e

Please sign in to comment.