I am running Ubuntu 15.10 with CUDA 7.5. CMmake v3.2.2, NVCC - release 7.5, v7.5.17; GCC - Ubuntu 5.2.1-22ubuntu2 v5.2.1
Starting C ++ 11 in regular projects is easy:
project(foo CXX) set(TARGET foo CMAKE_CXX_STANDARD 11)
I define my CUDA project with:
find_package(CUDA REQUIRED) CUDA_ADD_EXECUTABLE(foo ${foo_src} ${foo_hdr} ${foo_cu})
But C ++ 11 support does not apply to NVCC. I have to add:
list(APPEND CUDA_NVCC_FLAGS "-std=c++11")
It looks like shreds. Obviously, this has been done recently for this task , but I could not find the results.
How do I get CMake to automatically set C ++ 11 flags when declaring a project as C ++ 11?
EDIT: I reinstalled this question using CUDA 8.0 and CMake 3.5.1.
From the documentation , set(CUDA_PROPAGATE_HOST_FLAGS ON) will distribute the contents of CMAKE_CXX_FLAGS , so the following C ++ 11 triggers for both cpp and NVCC:
set (CMAKE_CXX_FLAGS "--std=c++11") set (CUDA_PROPAGATE_HOST_FLAGS ON)
However, set(CMAKE_CXX_STANDARD 11) does not affect CMAKE_CXX_FLAGS , therefore, below are the compiler errors for C ++ 11 device code, since there is nothing to distribute:
set (CMAKE_CXX_STANDARD 11) set (CUDA_PROPAGATE_HOST_FLAGS ON)
I cannot find a CMake command combination that allows explicitly setting --std=c++11 in the CXX or CUDA flags.
c ++ 11 cmake cuda
Andreas Yankopolus
source share