diff options
author | Hong Xu <hong@topbug.net> | 2019-11-04 19:18:05 (GMT) |
---|---|---|
committer | Hong Xu <hong@topbug.net> | 2019-11-04 22:17:20 (GMT) |
commit | 2e9feddf68a15e9f8909aedbd8b0f3e916273b94 (patch) | |
tree | d0756a165a1789a12af2935cab43469ff58ac007 /Modules/FindCUDA.cmake | |
parent | 2654a2e999c1271c6730c1fb7d4582a3fff47ee8 (diff) | |
download | CMake-2e9feddf68a15e9f8909aedbd8b0f3e916273b94.zip CMake-2e9feddf68a15e9f8909aedbd8b0f3e916273b94.tar.gz CMake-2e9feddf68a15e9f8909aedbd8b0f3e916273b94.tar.bz2 |
FindCUDA: Use find_program instead of find_path when searching for nvcc.
Before this commit, nvcc would not be found if it is in env PATH but a
non-standard location. This commit fixes this issue.
Diffstat (limited to 'Modules/FindCUDA.cmake')
-rw-r--r-- | Modules/FindCUDA.cmake | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index b6859aa..85d705c 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -676,7 +676,7 @@ endif() # Search for the cuda distribution. if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING) # Search in the CUDA_BIN_PATH first. - find_path(CUDA_TOOLKIT_ROOT_DIR + find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC NAMES nvcc nvcc.exe PATHS ENV CUDA_TOOLKIT_ROOT @@ -688,19 +688,22 @@ if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING) ) # Now search default paths - find_path(CUDA_TOOLKIT_ROOT_DIR + find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC NAMES nvcc nvcc.exe PATHS /opt/cuda/bin PATH_SUFFIXES cuda/bin DOC "Toolkit location." ) - if (CUDA_TOOLKIT_ROOT_DIR) + if (CUDA_TOOLKIT_ROOT_DIR_NVCC) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR "${CUDA_TOOLKIT_ROOT_DIR_NVCC}" DIRECTORY) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR "${CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR}" DIRECTORY CACHE) string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR}) # We need to force this back into the cache. set(CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR} CACHE PATH "Toolkit location." FORCE) set(CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) endif() + unset(CUDA_TOOLKIT_ROOT_DIR_NVCC CACHE) if (NOT EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) if(CUDA_FIND_REQUIRED) |