diff --git a/CMakeLists.txt b/CMakeLists.txt index 8477d81224df5a62328a4f214489151346f9e86b..14dfd1771f65b2e04b7879531da5deb437184bd4 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 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4c7c3a4683480f17ae4b94fa64f5f759abc0e4d6..f72f53810bbfc50528f29d89790ea56ba2fcfe11 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 3a985cf5baf1c963e28e982bef590e17f3d3f3da..75226f9a71ce9bb47e356d9c1b75541b767c3bdc 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