[CMake] FindCUDA discard any previous value of CUDA_USE_STATIC_CUDA_RUNTIME

James Bigler jamesbigler at gmail.com
Mon Oct 12 13:32:17 EDT 2015


Whether you can use the static runtime is based on the toolkit found, so if
you change the toolkit (checked with the CUDA_TOOLKIT_ROOT_DIR_INTERNAL
variable) we need to reset all dependent values.

I don't see a clean way to get this to work in the way you want.  The
script can't tell the difference between you setting the value, and the
value being there from a previous toolkit.

I don't see the problem of this code:


set(CUDA_TOOLKIT_ROOT_DIR "d:/work/CUDAToolkit")
find_package(CUDA)
unset(CUDA_USE_STATIC_CUDA_RUNTIME CACHE)
option(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
find_package(CUDA)

Or you could set the internal version of the CUDA_TOOLKIT_ROOT_DIR_INTERNAL
at the same time you set the CUDA_TOOLKIT_ROOT_DIR:

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

James

On Tue, Oct 6, 2015 at 11:49 AM, Thibaut Neiger <thibaut.neiger at gmail.com>
wrote:

> 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.
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151012/a58322be/attachment.html>


More information about the CMake mailing list