From cc68f1e2e463b4db68755aeb9123739633b032ba Mon Sep 17 00:00:00 2001 From: Peter Heywood Date: Tue, 9 Jan 2024 15:37:44 +0000 Subject: [PATCH] Adjust cmake_minimim_required upper limit to set all new policies to NEW Includes CMP0152 which in CMake >= 3.28 changes symlink resolution behaviour, relevant to nvhpc workarounds. --- CMakeLists.txt | 2 +- examples/cpp/boids_bruteforce/CMakeLists.txt | 2 +- examples/cpp/boids_spatial3D/CMakeLists.txt | 2 +- .../cpp/circles_bruteforce/CMakeLists.txt | 2 +- examples/cpp/circles_spatial3D/CMakeLists.txt | 2 +- examples/cpp/diffusion/CMakeLists.txt | 2 +- examples/cpp/ensemble/CMakeLists.txt | 2 +- examples/cpp/game_of_life/CMakeLists.txt | 2 +- examples/cpp/host_functions/CMakeLists.txt | 2 +- examples/cpp/sugarscape/CMakeLists.txt | 2 +- .../cpp_rtc/boids_bruteforce/CMakeLists.txt | 2 +- .../cpp_rtc/boids_spatial3D/CMakeLists.txt | 2 +- src/CMakeLists.txt | 34 ++++--------------- swig/CMakeLists.txt | 2 +- swig/python/CMakeLists.txt | 2 +- tests/CMakeLists.txt | 2 +- 16 files changed, 22 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f634809aa..4adb72248 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/examples/cpp/boids_bruteforce/CMakeLists.txt b/examples/cpp/boids_bruteforce/CMakeLists.txt index dc3e7707c..ae6282813 100644 --- a/examples/cpp/boids_bruteforce/CMakeLists.txt +++ b/examples/cpp/boids_bruteforce/CMakeLists.txt @@ -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) diff --git a/examples/cpp/boids_spatial3D/CMakeLists.txt b/examples/cpp/boids_spatial3D/CMakeLists.txt index 7ed05cd29..962330fc8 100644 --- a/examples/cpp/boids_spatial3D/CMakeLists.txt +++ b/examples/cpp/boids_spatial3D/CMakeLists.txt @@ -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) diff --git a/examples/cpp/circles_bruteforce/CMakeLists.txt b/examples/cpp/circles_bruteforce/CMakeLists.txt index c5593370b..41d52723d 100644 --- a/examples/cpp/circles_bruteforce/CMakeLists.txt +++ b/examples/cpp/circles_bruteforce/CMakeLists.txt @@ -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) diff --git a/examples/cpp/circles_spatial3D/CMakeLists.txt b/examples/cpp/circles_spatial3D/CMakeLists.txt index eb1090966..2ffd2f16f 100644 --- a/examples/cpp/circles_spatial3D/CMakeLists.txt +++ b/examples/cpp/circles_spatial3D/CMakeLists.txt @@ -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) diff --git a/examples/cpp/diffusion/CMakeLists.txt b/examples/cpp/diffusion/CMakeLists.txt index 29351386e..c8200ed65 100644 --- a/examples/cpp/diffusion/CMakeLists.txt +++ b/examples/cpp/diffusion/CMakeLists.txt @@ -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) diff --git a/examples/cpp/ensemble/CMakeLists.txt b/examples/cpp/ensemble/CMakeLists.txt index 4cfc9dacd..8d1d7a6ef 100644 --- a/examples/cpp/ensemble/CMakeLists.txt +++ b/examples/cpp/ensemble/CMakeLists.txt @@ -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) diff --git a/examples/cpp/game_of_life/CMakeLists.txt b/examples/cpp/game_of_life/CMakeLists.txt index 1903dfd50..ace58244b 100644 --- a/examples/cpp/game_of_life/CMakeLists.txt +++ b/examples/cpp/game_of_life/CMakeLists.txt @@ -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) diff --git a/examples/cpp/host_functions/CMakeLists.txt b/examples/cpp/host_functions/CMakeLists.txt index 356a372e1..4b0f0c109 100644 --- a/examples/cpp/host_functions/CMakeLists.txt +++ b/examples/cpp/host_functions/CMakeLists.txt @@ -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) diff --git a/examples/cpp/sugarscape/CMakeLists.txt b/examples/cpp/sugarscape/CMakeLists.txt index b12a28fbe..3790e7eb1 100644 --- a/examples/cpp/sugarscape/CMakeLists.txt +++ b/examples/cpp/sugarscape/CMakeLists.txt @@ -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) diff --git a/examples/cpp_rtc/boids_bruteforce/CMakeLists.txt b/examples/cpp_rtc/boids_bruteforce/CMakeLists.txt index 8d2d425a1..79559a997 100644 --- a/examples/cpp_rtc/boids_bruteforce/CMakeLists.txt +++ b/examples/cpp_rtc/boids_bruteforce/CMakeLists.txt @@ -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) diff --git a/examples/cpp_rtc/boids_spatial3D/CMakeLists.txt b/examples/cpp_rtc/boids_spatial3D/CMakeLists.txt index 9c2047a6e..c3090a7d3 100644 --- a/examples/cpp_rtc/boids_spatial3D/CMakeLists.txt +++ b/examples/cpp_rtc/boids_spatial3D/CMakeLists.txt @@ -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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 792b3c3be..af44025fa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) @@ -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 @@ -671,7 +670,7 @@ 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) @@ -679,7 +678,6 @@ if(NOT curand_INCLUDE_DIRS) 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 @@ -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 diff --git a/swig/CMakeLists.txt b/swig/CMakeLists.txt index c261c6097..a52c2c973 100644 --- a/swig/CMakeLists.txt +++ b/swig/CMakeLists.txt @@ -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) diff --git a/swig/python/CMakeLists.txt b/swig/python/CMakeLists.txt index 2db87b5d7..ac36c889a 100644 --- a/swig/python/CMakeLists.txt +++ b/swig/python/CMakeLists.txt @@ -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. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 269db9ffa..97f11c310 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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)