From 6ba7a6dfe5c0036871ffb5e977f3865e08b7b06e Mon Sep 17 00:00:00 2001
From: Stephen Sorley <Stephen.Sorley@jhuapl.edu>
Date: Thu, 11 Aug 2016 15:20:17 -0400
Subject: [PATCH] Restore default behavior of CUDA_USE_STATIC_CUDA_RUNTIME.

Fixes bug introduced by commit 7229ae7. CUDA_USE_STATIC_CUDA_RUNTIME should
be enabled by default if cudart_static is available, and silently disabled
if it's not.
---
 Modules/FindCUDA.cmake | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index d7c9d8a..972068b 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -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()
 
-- 
1.9.1

