<div dir="ltr"><div><span style="line-height:1.5">Maybe we could make the FindCUDA script check if the caller defined that variable prior to any inclusion. If the user did, then FindCUDA should respect the caller choice.</span><br></div><div>Something like that would make the trick:</div><div><br></div><div><div>if(NOT DEFINED CUDA_USE_STATIC_CUDA_RUNTIME_FORCED)</div><div>  if(DEFINED CUDA_USE_STATIC_CUDA_RUNTIME)</div><div>    set(CUDA_USE_STATIC_CUDA_RUNTIME_FORCED TRUE CACHE INTERNAL "If user forced static cuda runtime variable.")</div><div>  else()</div><div>    set(CUDA_USE_STATIC_CUDA_RUNTIME_FORCED FALSE CACHE INTERNAL "If user forced static cuda runtime variable.")</div><div>  endif()</div><div>endif()</div></div><div>...</div><div>macro(cuda_unset_include_and_libraries)<br></div><div>  ...</div><div>  if(NOT <span style="line-height:21.6667px">CUDA_USE_STATIC_CUDA_RUNTIME_FORCED</span><span style="line-height:21.6667px"> </span><span style="line-height:1.5">)</span></div><div><span style="line-height:1.5">    </span>unset(CUDA_USE_STATIC_CUDA_RUNTIME CACHE)</div><div><span style="line-height:1.5">  endif()</span></div><div>endmacro()</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">Le lun. 12 oct. 2015 à 14:32, James Bigler <<a href="mailto:jamesbigler@gmail.com">jamesbigler@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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.<div><br></div><div>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.</div><div><br></div><div>I don't see the problem of this code:</div><div><br></div><div><br></div><span style="font-size:12.8000001907349px">set(CUDA_TOOLKIT_ROOT_DIR "d:/work/CUDAToolkit")</span><br style="font-size:12.8000001907349px"><div>find_package(CUDA)</div><div>unset(CUDA_USE_STATIC_CUDA_RUNTIME CACHE)<br></div><div><span style="font-size:12.8000001907349px">option(CUDA_USE_STATIC_CUDA_RU</span><span style="font-size:12.8000001907349px">NTIME OFF)</span><br style="font-size:12.8000001907349px"></div><div>find_package(CUDA)</div><div><br></div><div>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:</div><div><br></div><div></div></div><div dir="ltr"><div><span style="font-size:12.8000001907349px">option(CUDA_USE_STATIC_CUDA_RU</span><span style="font-size:12.8000001907349px">NTIME OFF)</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">set(CUDA_TOOLKIT_ROOT_DIR "d:/work/CUDAToolkit")</span><br style="font-size:12.8000001907349px"></div></div><div dir="ltr"><div><span style="font-size:12.8000001907349px">set(CUDA_TOOLKIT_ROOT_DIR_INTERNAL "${CUDA_TOOLKIT_ROOT_DIR}")</span></div></div><div dir="ltr"><div><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">message(STATUS CUDA_USE_STATIC_CUDA_RUNTIME=$</span><span style="font-size:12.8000001907349px">{CUDA_USE_STATIC_CUDA_RUNTIME}</span><span style="font-size:12.8000001907349px">)</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">find_package(CUDA)</span><br style="font-size:12.8000001907349px"></div></div><div dir="ltr"><div></div><div><br></div><div>James</div></div><div class="gmail_extra"><br><div class="gmail_quote"></div></div><div class="gmail_extra"><div class="gmail_quote">On Tue, Oct 6, 2015 at 11:49 AM, Thibaut Neiger <span dir="ltr"><<a href="mailto:thibaut.neiger@gmail.com" target="_blank">thibaut.neiger@gmail.com</a>></span> wrote:<br></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello.<br>
I am using cmake 3.3.2.<br>
The following script sets the CUDA_USE_STATIC_CUDA_RUNTIME option, then finds the CUDA package.<br>
<br>
cmake_minimum_required(VERSION 3.3)<br>
option(CUDA_USE_STATIC_CUDA_RUNTIME OFF)<br>
set(CUDA_TOOLKIT_ROOT_DIR "d:/work/CUDAToolkit")<br>
message(STATUS CUDA_USE_STATIC_CUDA_RUNTIME=${CUDA_USE_STATIC_CUDA_RUNTIME})<br>
find_package(CUDA)<br>
message(STATUS CUDA_USE_STATIC_CUDA_RUNTIME=${CUDA_USE_STATIC_CUDA_RUNTIME})<br>
<br>
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.<br>
<br>
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.<br>
Thibaut.<br></blockquote></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br>
</blockquote></div><br></div>
</blockquote></div>