FindCUDAToolkit: Configuration failure with minimum-required CMake version 3.25
If I require my CMake version to be at least 3.25 and try to find the CUDA Toolkit, the configuration fails with the error message
CMake Error at C:/Program Files/CMake/share/cmake-3.25/Modules/FindCUDAToolkit.cmake:1088 (set_property):
set_property could not find TARGET CUDA::nvToolsExt. Perhaps it has not yet been created.
A minimal CMakeLists.txt
hitting this issue would be
cmake_minimum_required(VERSION 3.25)
project(test_project CUDA CXX)
find_package(CUDAToolkit REQUIRED)
This happens on Windows 11 with CMake 3.25.1 and CUDA 12.0.
This looks similar to issue #22893, but is distinct. I ran into this error without having any intention of using the CUDA::nvToolsExt
target.
It's clear from the code surrounding FindCUDAToolkit.cmake:1088 that the offending line is only hit in the presence of the cmake_minimum_required(VERSION 3.25)
call. A possible temporary workaround is to require a lower CMake version.
I suspect CUDA 12 may have actually removed the previously deprecated nvToolsExt
library. Either way, the issue could, and I think should, be resolved by appending AND TARGET CUDA::nvToolsExt
to the condition of the if clause on line 1087.