FindCUDA: Restore default behavior of CUDA_USE_STATIC_CUDA_RUNTIME

Fix bug introduced by commit 7229ae72 (FindCUDA: Refactor Android(Tegra)
support, 2016-04-19).  `CUDA_USE_STATIC_CUDA_RUNTIME` should be enabled
by default if `cudart_static` is available, and silently disabled if
it is not.
This commit is contained in:
Stephen Sorley 2016-08-11 15:20:17 -04:00 committed by Brad King
parent f203694bb8
commit aab1f6e984
1 changed files with 4 additions and 3 deletions

View File

@ -779,18 +779,19 @@ if(CUDA_VERSION VERSION_EQUAL "3.0")
)
endif()
if(CUDA_USE_STATIC_CUDA_RUNTIME AND NOT CUDA_VERSION VERSION_LESS "5.5")
if(NOT CUDA_VERSION VERSION_LESS "5.5")
cuda_find_library_local_first(CUDA_cudart_static_LIBRARY cudart_static "static CUDA runtime library")
mark_as_advanced(CUDA_cudart_static_LIBRARY)
endif()
if(CUDA_cudart_static_LIBRARY)
# Set whether to use the static cuda runtime.
# If static cudart available, use it by default, but provide a user-visible option to disable it.
option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" ON)
set(CUDA_CUDART_LIBRARY_VAR CUDA_cudart_static_LIBRARY)
else()
option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" OFF)
# If not available, silently disable the option.
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF CACHE INTERNAL "")
set(CUDA_CUDART_LIBRARY_VAR CUDA_CUDART_LIBRARY)
endif()