I'm using CMake 3.13, with inherent support for CUDA as a language, to build a project. This project requires the nVIDIA Toolkit Extensions library. On a previous system, I had it under /usr/local/cuda/lib64. I used a find_library() command which I thought should be sufficient, and all was well. But - it isn't, and it wasn't: On a system in which CUDA is installed using OS distribution packages, under /usr directly, my command doesn't work.
To be more specific, I'm using:
find_library(CUDA_NVTX_LIBRARY
NAMES nvToolsExt nvTools nvtoolsext nvtools nvtx NVTX
PATHS ${CUDA_TOOLKIT_ROOT_DIR} ENV LD_LIBRARY_PATH
PATH_SUFFIXES "lib64" "common/lib64" "common/lib" "lib"
DOC "Location of the CUDA Toolkit Extension (NVTX) library"
NO_DEFAULT_PATH
)
and this is missing /usr/lib/x86_64-linux-gnu/libnvToolsExt.so.
Questions:
- How should I alter my find_library command not to miss such target-platform-specific folders?
- Am I looking for the NVTX library the wrong way? Can I somehow rely on what CMake finds internally instead?
Notes:
- I have basically the same issue with
libOpenCL.so, nVIDIA's OpenCL layer.
(This answer regards CMake versions earlier than 3.17; you should really switch to a newer version of CMake, which makes your life much easier.)
CMake does figure out the paths of a lot of other CUDA-related libraries, e.g.:
I think it's actually a bug that it doesn't do so for the NVTX and OpenCL libraries. Still, we can take the paths it finds for other libraries - perhaps the main one,
CUDA_CUDART_LIBRARY, and use it as a search hint.The result is even uglier than what I had before, but it does seems to work: