CUDA: Please add a variable to select shared/static CUDA runtime
Currently it is possible to select which CUDA runtime is used by adding `` to the CMake invocation.
This is fine for simple test programs, but it has its issues.
For example, it is hard to set this variable programmatically:
- Using
string(APPEND CMAKE_CUDA_FLAGS " --cudart shared")
has simply no effect. The workaround is to make sure that CMAKE_CUDA_FLAGS already is a Cache variable by creating it first:set(CMAKE_CUDA_FLAGS "" CACHE STRING "")
- Setting
CMAKE_CUDA_FLAGS
after aproject(name LANGUAGES CUDA)
orenable_language(CUDA)
has no effect. It must be set before the project or enable_language call. - Assume I set this variable in a script (for example as a default value), but want to allow the user to override this. There is no easy way without parsing/regexing/stripping the CMAKE_CUDA_FLAGS to override it, since specifying it twice is forbidden by NVCC.
I believe there should be a simple variable called CMAKE_CUDA_USE_STATIC_CUDA_RUNTIME
or similar, that allows a simple way to switch between a dynamic and static runtimes.