diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py index a08dfd00fc74..c76973e84d42 100644 --- a/mesonbuild/compilers/cuda.py +++ b/mesonbuild/compilers/cuda.py @@ -616,8 +616,18 @@ def get_options(self) -> 'KeyedOptionDictType': return opts def _to_host_compiler_options(self, options: 'KeyedOptionDictType') -> 'KeyedOptionDictType': + """ + Convert an NVCC Option set to a host compiler's option set. + """ + + # We must strip the -std option from the host compiler option set, as NVCC has + # its own -std flag that may not agree with the host compiler's. overrides = {name: opt.value for name, opt in options.items()} - return OptionOverrideProxy(overrides, self.host_compiler.get_options()) + overrides.pop(OptionKey('std', machine=self.for_machine, + lang=self.host_compiler.language), None) + host_options = self.host_compiler.get_options().copy() + host_options.pop('std', None) + return OptionOverrideProxy(overrides, host_options) def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: args = self.get_ccbin_args(options) diff --git a/test cases/cuda/16 multistd/main.cu b/test cases/cuda/16 multistd/main.cu new file mode 100644 index 000000000000..a2ffba4896c3 --- /dev/null +++ b/test cases/cuda/16 multistd/main.cu @@ -0,0 +1,20 @@ +#include +#include + +auto cuda_devices(void) { + int result = 0; + cudaGetDeviceCount(&result); + return result; +} + + +int main(void) { + int n = cuda_devices(); + if (n == 0) { + std::cout << "No Cuda hardware found. Exiting.\n"; + return 0; + } + + std::cout << "Found " << n << "Cuda devices.\n"; + return 0; +} diff --git a/test cases/cuda/16 multistd/meson.build b/test cases/cuda/16 multistd/meson.build new file mode 100644 index 000000000000..4769a87dddd1 --- /dev/null +++ b/test cases/cuda/16 multistd/meson.build @@ -0,0 +1,4 @@ +project('C++-CUDA multi-std', 'cpp', 'cuda', version : '1.0.0', default_options : ['cpp_std=c++17', 'cuda_std=c++14']) + +exe = executable('prog', 'main.cu') +test('cudatest', exe)