From f09457a1e8878598eaf3862e1b759e53429b2528 Mon Sep 17 00:00:00 2001 From: Carlos Bederian Date: Wed, 14 Oct 2020 16:50:43 -0300 Subject: [PATCH] compilers/cuda: Fix has_header_symbol check --- mesonbuild/compilers/cuda.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py index bf46a7d4d..4dd9c36ca 100644 --- a/mesonbuild/compilers/cuda.py +++ b/mesonbuild/compilers/cuda.py @@ -170,16 +170,29 @@ class CudaCompiler(Compiler): env: 'Environment', *, extra_args: T.Optional[T.List[str]] = None, dependencies: T.Optional[T.List['Dependency']] = None) -> T.Tuple[bool, bool]: - result, cached = super().has_header_symbol(hname, symbol, prefix, env, extra_args=extra_args, dependencies=dependencies) - if result: - return True, cached if extra_args is None: extra_args = [] fargs = {'prefix': prefix, 'header': hname, 'symbol': symbol} + # Check if it's a C-like symbol + t = '''{prefix} + #include <{header}> + int main(void) {{ + /* If it's not defined as a macro, try to use as a symbol */ + #ifndef {symbol} + {symbol}; + #endif + return 0; + }}''' + found, cached = self.compiles(t.format(**fargs), env, extra_args=extra_args, dependencies=dependencies) + if found: + return True, cached + # Check if it's a class or a template t = '''{prefix} #include <{header}> using {symbol}; - int main(void) {{ return 0; }}''' + int main(void) {{ + return 0; + }}''' return self.compiles(t.format(**fargs), env, extra_args=extra_args, dependencies=dependencies) def get_options(self) -> 'OptionDictType':