From 72cd5c6ccf49fdb9c12448d9b3f8126c147bebee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Gl=C3=B6ckner?= Date: Mon, 22 Jan 2024 09:39:47 +0100 Subject: [PATCH 1/2] Fixed CMP0146 warning with check for CMake version for backwards compatibility. --- test/CMakeLists.txt | 14 ++++++++++++-- unsupported/test/CMakeLists.txt | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4c7c3a468..f72f53810 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -399,8 +399,18 @@ if(EIGEN_TEST_CUDA_CLANG AND NOT CMAKE_CXX_COMPILER MATCHES "clang") message(WARNING "EIGEN_TEST_CUDA_CLANG is set, but CMAKE_CXX_COMPILER does not appear to be clang.") endif() -find_package(CUDA 9.0) -if(CUDA_FOUND AND EIGEN_TEST_CUDA) +if(CMAKE_VERSION VERSION_LESS "3.10") + find_package(CUDA 9.0) +else() + check_language(CUDA) + if(CMAKE_CUDA_COMPILER) + enable_language(CUDA) + else() + message(STATUS "Could NOT find CUDA.") + endif() +endif() + +if((CUDA_FOUND OR CMAKE_CUDA_COMPILER) AND (EIGEN_TEST_CUDA)) # Make sure to compile without the -pedantic, -Wundef, -Wnon-virtual-dtor # and -fno-check-new flags since they trigger thousands of compilation warnings # in the CUDA runtime diff --git a/unsupported/test/CMakeLists.txt b/unsupported/test/CMakeLists.txt index 3a985cf5b..75226f9a7 100644 --- a/unsupported/test/CMakeLists.txt +++ b/unsupported/test/CMakeLists.txt @@ -216,8 +216,18 @@ if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8" AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "MS ei_add_test(cxx11_tensor_uint128) endif() -find_package(CUDA 9.0) -if(CUDA_FOUND AND EIGEN_TEST_CUDA) +if(CMAKE_VERSION VERSION_LESS "3.10") + find_package(CUDA 9.0) +else() + check_language(CUDA) + if(CMAKE_CUDA_COMPILER) + enable_language(CUDA) + else() + message(STATUS "Could NOT find CUDA.") + endif() +endif() + +if((CUDA_FOUND OR CMAKE_CUDA_COMPILER) AND (EIGEN_TEST_CUDA)) # Make sure to compile without the -pedantic, -Wundef, -Wnon-virtual-dtor # and -fno-check-new flags since they trigger thousands of compilation warnings # in the CUDA runtime -- GitLab From c447a4a87f8471fbb862b9c578e4170d4157451a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Gl=C3=B6ckner?= Date: Wed, 24 Jan 2024 12:14:33 +0100 Subject: [PATCH 2/2] Suppresses the CMP0146 warning regarding the CUDA module. --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8477d8122..14dfd1771 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,14 @@ if (POLICY CMP0090) endif (NOT DEFINED CMAKE_EXPORT_PACKAGE_REGISTRY) endif (POLICY CMP0090) +# NOTE Remove setting the policy once a fix with importing CUDA using enable_language() is working with +# clang. Most likely that will only happen once the minimum required version is bumped to at least 3.18. +if (POLICY CMP0146) + # Do not generate a warning if CUDA is loaded using find_package() instead of + # enable_language(). + cmake_policy(SET CMP0146 OLD) +endif () + project(Eigen3) # Remove this block after bumping CMake to v3.21.0 -- GitLab