Build CUDA 11 with C++17, MSVC, NVCC, CMake

Trying to build a C++17 project with CUDA 11, CMake using NVCC and MSVC host compiler. This is supposed to be supported in CUDA 11, right? I don’t want to build CUDA code with C++14 while host code is using C++17 features.

Tried variations on:

target_compile_options({TEST_EXE} PRIVATE <$<COMPILE_LANGUAGE:CUDA>:–std=c++17>)

get an error in CMake:

[CMake] Target “…” requires the language dialect “CUDA17” (with compiler extensions), but CMake does not know the compile flags to use to enable it.

Any help, please?

I’m having the exact same issue.

Found the following…

Looks like CUDA_STANDARD 17 and above is only supported on CMAKE 18 and above.

I can confirm after I updated my cmake from 17 to 19 my build worked with cuda 17 enabled.

That’s great. I’m gonna upgrade then. I did have a workaround but since it’s moot now, not gonna post. Thanks for answering this.

1 Like