FindCUDAToolkit: Fails to define CUDA::nvrtc on On Ubuntu bionic
I have a project with uses NVRTC, the CUDA run-time compilation library. This is its main
CMakeLists.txt, with the key lines being:
PROJECT(cuda-api-wrappers LANGUAGES CUDA CXX) find_package(CUDAToolkit REQUIRED) target_link_libraries(nvrtc INTERFACE CUDA::nvrtc)
and in a subdirectory I have:
Now, I'm using Travis CI to build that project. I've upped the CMake version in there to 3.21.0-rc2 using the .travis.yml to make sure I'm filing this issue against the latest and greatest (but am also seeing this with 3.17.5 for example).
When the Travis machine comes up, this is what happens; and the key lines are:
-- The CUDA compiler identification is NVIDIA 10.2.89 ...snip... -- Found CUDAToolkit: /usr/local/cuda-10.2/include (found version "10.2.89") -- Configuring done CMake Error at examples/CMakeLists.txt:48 (add_executable): Target "vectorAdd_nvrtc" links to target "CUDA::nvrtc" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?
Now, on my machine, the project builds fine and CUDA::nvrtc is found.
I'm pretty certain it should be found on the Travis CI machine as well. I was scratching my head trying to understand if I got something wrong, and I don't think I did, so it may be a bug.