0

First, there is this answer that describes how to fiddle with FindCUDA.cmake so that we can link with CUDA 9.0+'s renamed NPP libraries correctly, but the default CMake 3.5.1 in Ubuntu 16.04 requires this code to be added manually.

However, if someone forgets to apply that change, or search paths are such that an older FindCUDA.cmake is picked up, I want to report an error. This code almost does that:

find_package(CUDA)
if (CUDA_VERSION VERSION_GREATER_EQUAL "9.0")
    if (NOT CUDA_nppial_LIBRARY)
        message(FATAL_ERROR "CUDA 9.0+ libraries not set in file at ${FINDCUDA_FILE}")
    endif()
    target_link_libraries(foo ${CUDA_nppial_LIBRARY})
endif()

Except that I don't know what to use for ${FINDCUDA_FILE} and searching the code doesn't give me any clues. Is there such a variable or other way to find that file?

Ken Y-N
  • 14,644
  • 21
  • 71
  • 114
  • You can probably use `CUDA_DIR` variable. – arrowd Apr 02 '19 at 07:53
  • @arrowd: According to the [documentation](https://cmake.org/cmake/help/v3.14/command/find_package.html#search-procedure), `XXX_DIR` variable contains the directory with `XXXConfig.cmake`, but not with `FindXXX.cmake` script. – Tsyvarev Apr 02 '19 at 10:17
  • @arrowd `CUDA_DIR` is empty for me. – Ken Y-N Apr 03 '19 at 00:12
  • note: acording to the doc: > The full path to the configuration file is stored in the cmake variable _CONFIG -> BUT there is no _MODULE src: https://gitlab.kitware.com/cmake/cmake/blob/master/Source/cmFindPackageCommand.cxx – Mizux Apr 03 '19 at 07:13

0 Answers0