einpoklum
einpoklum

Reputation: 131544

How do I override the (host-side) C++ compiler CMake uses for CUDA targets?

I'm using a CUDA version which does not support the GCC version installed on my system (my GCC is too new). I'm trying to build a repository which uses CMake for build configuration.

I know how to override the C++ compiler, traditionally:

export CXX=/path/to/other/compiler-binary

and CMake picks this up. I can also use 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.

How can I tell it to use the alternative C++ compiler for CUDA?

Additional info:

Upvotes: 2

Views: 1183

Answers (1)

einpoklum
einpoklum

Reputation: 131544

use CMAKE_CUDA_HOST_COMPILER:

CMake will not (for now) default to using your CMAKE_CXX_COMPILER as the C++ compiler for CUDA host-side code; 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)

Upvotes: 3

Related Questions