CMake:有没有办法将选项传递给 g++ 而不是 nvcc
CMake: Is there a way of passing options to g++ but not to nvcc
在CMakeList中.txt我确实想像这样将-std=g++0x
添加到g ++选项中: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x)
但是,所有CMAKE_CXX_FLAGS
也会通过-Xcompiler
标志传递给nvcc(这是自动完成的(。但是,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)
来自 FindCUDA 文档:
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 脚本的开头。
相关文章:
- NVCC 错误:string_view.h:constexpr 函数返回是非常量
- 定义 uint= "unsigned int" 没有像我在 Visual Studio 中使用 nvcc 时预期的那样应用
- 由于缺少类模板,NVCC 编译面向对象代码时出现问题
- 命令提示符下的 NVCC CUDA 不使用 GPU
- CMake还将所有gcc标志传递给nvcc
- 使用nvcc(CUDA-RINSIDE)正确链接对象文件
- C++11 NVCC 不支持函数 iota()?
- 如何将编译器标志从 clang 传递给 nvcc
- CMake:如何在Visual Studio环境中将依赖于模式的编译标志传递给nvcc
- 如何在 Linux 中将 conio.h 添加到 nvcc 中
- NVCC编译了特征库,并在运行时失败的结构中的MatrixxD大小
- CMake:有没有办法将选项传递给 g++ 而不是 nvcc
- 链接QT5库会自动将额外的FPIC标志传递给NVCC编译器,并通过cmake Cause错误
- Cuda NVCC 编译器 - 如何 /showinclude.
- DO NVCC和NVRTC支持尾部呼叫优化
- NVCC 致命:安装 CUDA9.0 时'compute_20'不受支持的 GPU 架构
- 使用Friend Sub类中的私有方法 - NVCC中的编译器错误
- 如何在没有 nvcc 的情况下在编译时获取 CUDA 工具包版本?
- 强制 NVCC 不考虑常量内存的构造函数
- CUDA NVCC 编译器错误