[英]How can I override the C++ compiler CMake uses for CUDA?
I'm using a CUDA version which does not support the GCC version installed on my system (my GCC is too new).我使用的是 CUDA 版本,它不支持我系统上安装的 GCC 版本(我的 GCC 太新了)。 I'm trying to build a repository which uses CMake for build configuration.
我正在尝试构建一个使用 CMake 进行构建配置的存储库。
I know how to override the C++ compiler, traditionally:我知道如何传统地覆盖 C++ 编译器:
export CXX=/path/to/other/compiler-binary
and CMake picks this up. CMake 拾取它。 I can also use
cmake -DCMAKE_CXX_COMPILER
.我也可以使用
cmake -DCMAKE_CXX_COMPILER
。 However, neither of these options work when compiling CUDA host-side code: CMake still has CUDA try to use my default GCC version on my system.但是,在编译 CUDA 主机端代码时,这些选项都不起作用: CMake 仍然有 CUDA 尝试在我的系统上使用我的默认 GCC 版本。
How can I tell it to use the alternative C++ compiler for CUDA?我如何告诉它为 CUDA 使用替代的 C++ 编译器?
Additional info:附加信息:
CMake will not (for now) default to using your CMAKE_CXX_COMPILER
as the C++ compiler for CUDA host-side code; CMake不会(目前)默认使用您的
CMAKE_CXX_COMPILER
作为 CUDA 主机端代码的 C++ 编译器; there's a different setting for that.有一个不同的设置。 Run your build configuration like so:
像这样运行你的构建配置:
cmake -DCMAKE_CUDA_HOST_COMPILER=/usr/bin/g++-9
(replace the path with to your chosen C++ compiler of course) (当然,将路径替换为您选择的 C++ 编译器)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.