Is there a CMake command that can be used to set the Cuda runtime library (in visual studio under Cuda C/C++ -> Host -> Runtime Library)? For instance I would need to set it to MTd rather than MDd in debug mode, and MT rather than MD in release mode. I can do this manually in visual studio after building, but it would be great to have this be automatic using my CMakeLists.txt file. Thanks!
P.S. I know how to set this for the normal runtime library (not Cuda); this question is specific to the Cuda runtime library.
UPDATE 2022-01-24: The helpful input has lead me to the CMake variable CMAKE_CUDA_FLAGS_RELEASE which seems to control this. I need to set it like so: set(CMAKE_CUDA_FLAGS_RELEASE " -Xcompiler=\"-MT -O2 -Ob2\" -DNDEBUG")
But unfortunately it seems to get overwritten for some reason, back to -MD.
UPDATE 2022-01-25: Example code:
cmake_minimum_required(VERSION 3.8)
#set(CMAKE_CUDA_RUNTIME_LIBRARY Shared)
#string(APPEND CMAKE_CUDA_FLAGS_RELEASE_INIT " -Xcompiler=\"-MT -O2 -Ob2\" -DNDEBUG")
#set(CMAKE_CUDA_FLAGS_RELEASE_INIT " -Xcompiler=\"-MT -O2 -Ob2\" -DNDEBUG")
set(CMAKE_CUDA_FLAGS_RELEASE " -Xcompiler=\"-MT -O2 -Ob2\" -DNDEBUG")
project(cuda_test_integrated LANGUAGES CUDA CXX)
# multi-threaded
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
find_package(CUDAToolkit REQUIRED)
set(CMAKE_CUDA_ARCHITECTURES OFF)
set(CMAKE_CUDA_FLAGS_RELEASE " -Xcompiler=\"-MT -O2 -Ob2\" -DNDEBUG")
# modules
include_directories("../cuda_module_example")
add_subdirectory("../cuda_module_example" "${CMAKE_CURRENT_BINARY_DIR}/cuda_module_example")
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
add_executable(cuda_test_integrated main.cxx)
set(CMAKE_CUDA_FLAGS_RELEASE " -Xcompiler=\"-MT -O2 -Ob2\" -DNDEBUG")
set_target_properties(cuda_test_integrated PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_link_libraries(cuda_test_integrated CUDA::cudart)
target_link_libraries(cuda_test_integrated cuda_module_example)
set(CMAKE_CUDA_FLAGS_RELEASE " -Xcompiler=\"-MT -O2 -Ob2\" -DNDEBUG")