Skip to content

Adding CUDAUtilities.cmake

Henry Schreiner requested to merge henryiii/cmake:cuda-language into master

This is the beginning of a CUDAUtilities module, with one function: cmake_cuda_arch_detect. The changes are as follows:

  • Moved select_compute_arch from FindCUDA/ to CUDA/. The other three files in FindCUDA are distinctly FindCUDA only files (they aren't even includeable), whereas this one is general.
  • Modernised CUDA_SELECT_NVCC_ARCH_FLAGS with keyword parsing and renamed to CMAKE_CUDA_ARCH_SELECT. READABLE output is now requestable, and an adapter to the old name and syntax is provided when FindCUDA uses the function. The new function also provides a QUIET toggle. FLAGS is used to get the flag list.
  • Added TARGETS, along with INTERFACE, PUBLIC, and PRIVATE keywords, to set an interface or compile target flags, property protected with COMPILE_LANGUAGE. (This will only work with the CUDA as a language mode)
  • Uses the --genenerate-code syntax rather than -gencode, avoiding needing the new SHELL: feature; CUDA_SELECT_NVCC_ARCH_FLAGS converts back to the old syntax for maximum backward compatibility. Caching improved a bit to ensure 1 run per configure even if the detection fails.
  • User-facing access to the new function is provided in a new CUDAUtilities module, mimicking the name of the CSharpUtilitiess module already in CMake. A future pull request with a new function (convert CXX to CUDA flags) in CUDAUtilities is planned.
  • A test has been added, CudaOnly.ArchFlags.

See issues: #16586 (closed), #17408.

Followup to !1856 (merged) .

Edited by Henry Schreiner

Merge request reports