2017-05-24 20 views
0

在CMakeList.txt的一种方法,我也想给-std=g++0x添加到G ++选项是这样的:但是所有的CMAKE_CXX_FLAGS都上过 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x)CMake的:有传球选择到g ++但不NVCC

nvcc以及通过-Xcompiler标志(这是自动完成的)。但是nvcc不符合gnu++0x标准。

是否有合格标志的方式到g ++但不NVCC

if(CUDA_NVCC_HOST_COMPILER) 
    list(APPEND CUDA_NVCC_FLAGS "--compiler-bindir=${CUDA_NVCC_HOST_COMPILER}") 
endif(CUDA_NVCC_HOST_COMPILER) 
+1

你有什么CUDA版本?自CUDA 7以来,支持Afaik C++ 11. – Shadow

+1

检查此https://stackoverflow.com/a/23995391/1418828 – xiaobing

+0

@Shadow nvcc:NVIDIA®Cuda编译器驱动程序 版权所有(c)2005-2013 NVIDIA公司 建立在Wed_Jul_17_18:36:13_PDT_2013 Cuda编译工具,版本5.5,V5.5.0 – Michael

回答

2

指定的编译器从FindCUDA documentation

CUDA_PROPAGATE_HOST_FLAGS (Default ON) 
-- Set to ON to propagate CMAKE_{C,CXX}_FLAGS and their configuration 
    dependent counterparts (e.g. CMAKE_C_FLAGS_DEBUG) automatically to the 
    host compiler through nvcc's -Xcompiler flag. This helps make the 
    generated host code match the rest of the system better. Sometimes 
    certain flags give nvcc problems, and this will help you turn the flag 
    propagation off. This does not affect the flags supplied directly to nvcc 
    via CUDA_NVCC_FLAGS or through the OPTION flags specified through 
    CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for 
    shared library compilation are not affected by this flag. 

因此,要解决您的问题,只要把

set(CUDA_PROPAGATE_HOST_FLAGS FALSE) 

接近您的CMake脚本的开始。

+0

@MultipleMonmials你的答案是有用的,但它并没有解决问题。我确实使用target_compile_options( PUBLIC -std = C++ 11)在目标基础上设置了目标上的'-std'开关' – Michael