소스 검색

CUDA: Add support for finding nvcc in CUDA_PATH

Previously, nvcc needed to be present in PATH or specified by CUDACXX.
On Windows with vcpkg, the PATH is heavily modified, which lead to
nvcc not being found with the Ninja generator.
Tobias Ribizel 4 년 전
부모
커밋
55233eee42
2개의 변경된 파일12개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      Modules/CMakeDetermineCUDACompiler.cmake
  2. 10 0
      Modules/CMakeDetermineCompiler.cmake

+ 2 - 0
Modules/CMakeDetermineCUDACompiler.cmake

@@ -31,7 +31,9 @@ else()
       set(CMAKE_CUDA_COMPILER_LIST nvcc)
     endif()
 
+    set(_CMAKE_CUDA_COMPILER_PATHS "$ENV{CUDA_PATH}/bin")
     _cmake_find_compiler(CUDA)
+    unset(_CMAKE_CUDA_COMPILER_PATHS)
   else()
     _cmake_find_compiler_path(CUDA)
   endif()

+ 10 - 0
Modules/CMakeDetermineCompiler.cmake

@@ -68,6 +68,16 @@ macro(_cmake_find_compiler lang)
       )
   endif()
   find_program(CMAKE_${lang}_COMPILER NAMES ${CMAKE_${lang}_COMPILER_LIST} DOC "${lang} compiler")
+  if(_CMAKE_${lang}_COMPILER_PATHS)
+    # As a last fall-back, search in language-specific paths
+    find_program(CMAKE_${lang}_COMPILER
+      NAMES ${CMAKE_${lang}_COMPILER_LIST}
+      NAMES_PER_DIR
+      PATHS ${_CMAKE_${lang}_COMPILER_PATHS}
+      DOC "${lang} compiler"
+      NO_DEFAULT_PATH
+      )
+  endif()
   if(CMAKE_${lang}_COMPILER_INIT AND NOT CMAKE_${lang}_COMPILER)
     set_property(CACHE CMAKE_${lang}_COMPILER PROPERTY VALUE "${CMAKE_${lang}_COMPILER_INIT}")
   endif()