[CMake] FindCUDA discard any previous value of CUDA_USE_STATIC_CUDA_RUNTIME

Thibaut Neiger thibaut.neiger at gmail.com
Tue Oct 6 13:49:01 EDT 2015


Hello.
I am using cmake 3.3.2.
The following script sets the CUDA_USE_STATIC_CUDA_RUNTIME option, then 
finds the CUDA package.

cmake_minimum_required(VERSION 3.3)
option(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
set(CUDA_TOOLKIT_ROOT_DIR "d:/work/CUDAToolkit")
message(STATUS CUDA_USE_STATIC_CUDA_RUNTIME=${CUDA_USE_STATIC_CUDA_RUNTIME})
find_package(CUDA)
message(STATUS CUDA_USE_STATIC_CUDA_RUNTIME=${CUDA_USE_STATIC_CUDA_RUNTIME})

In the find_package, the variable CUDA_TOOLKIT_ROOT_DIR is compared to 
the variable CUDA_TOOLKIT_ROOT_DIR_INTERNAL (line 556). Since this 
variable is not defined, the cuda_unset_include_and_libraries function 
is called. This function wipes the CUDA_USE_STATIC_CUDA_RUNTIME option 
from the cache.

In order to correctly set this variable, I need to restart change it 
back to OFF, then the FindCUDA script doesn't call 
cuda_unset_include_and_libraries function.
Thibaut.


More information about the CMake mailing list