Decouple C++ standard and CUDA_STANDARD
Use case: You want to develop a library with some parts in CUDA and some in C++. Since nvcc
only supports old C++ standards you want to keep the amount of CUDA files at a minimum and do everything else in C++ files with the newest available C++ standard.
Current possible solution: You create two library targets in CMake. For the CUDA library you set CUDA_STANDARD
to 14
and for the C++ library you set a PRIVATE
cxx_std_17
compile feature. Afterwards you link both library targets.
Desirable solution: You can set C++ standard and CUDA_STANDARD indepentently, e.g.:
add_library(main main.cpp foo.cu)
target_compile_options(main PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-arch sm_61>)
set_target_properties(main PROPERTIES $<$<COMPILE_LANGUAGE:CUDA>:CUDA_STANDARD 14>)
target_compile_features(main PRIVATE $<$<COMPILE_LANGUAGE:CXX>:cxx_std_17>)
This is currently not possible, because setting the C++ standard overwrites the CUDA_STANDARD
.
What do you think about this?