CUDA 11 still requires -std=c++17
First of all, let me thank you for the rapid progress of CUDA support in CMake! I just tried to compile some C++17 code with CUDA 11.0.182 and CMake 3.18.0. I found that Unless I added -DCMAKE_CUDA_FLAGS=-std=c++17
, nvcc
would fail to compile C++17 constructs. Is this a small thing that can be fixed in CMake so that it knows that nvcc
still needs the -std=c++17
flag? Here is my CMakeLists.txt
for reference:
cmake_minimum_required(VERSION 3.12.0...${CMAKE_VERSION})
project(EXAMPLE VERSION 0.2.0 LANGUAGES CXX)
option(EXAMPLE_ENABLE_CUDA "Build GPU version with CUDA" OFF)
if (EXAMPLE_ENABLE_CUDA)
enable_language(CUDA)
set_source_files_properties(example.cpp PROPERTIES LANGUAGE CUDA)
endif()
add_executable(example example.cpp)
set_property(TARGET example PROPERTY CXX_STANDARD "17")
set_property(TARGET example PROPERTY CXX_STANDARD_REQUIRED ON)
set_property(TARGET example PROPERTY CXX_EXTENSIONS OFF)