dependencies/llvm: Try to make warning about CMake better

We have seen a number of bugs from people confused by warning that the
need both a C and C++ compiler to use the CMake method. This attempts
to provide a more helpful error message.
pull/13076/head
Dylan Baker 8 months ago
parent bcb82b390a
commit b6d7a7a5b7
  1. 27
      mesonbuild/dependencies/dev.py

@ -393,7 +393,7 @@ class LLVMDependencyCMake(CMakeDependency):
compilers = env.coredata.compilers.build
else:
compilers = env.coredata.compilers.host
if not compilers or not all(x in compilers for x in ('c', 'cpp')):
if not compilers or not {'c', 'cpp'}.issubset(compilers):
# Initialize basic variables
ExternalDependency.__init__(self, DependencyTypeName('cmake'), env, kwargs)
@ -401,8 +401,29 @@ class LLVMDependencyCMake(CMakeDependency):
self.found_modules: T.List[str] = []
self.name = name
# Warn and return
mlog.warning('The LLVM dependency was not found via CMake since both a C and C++ compiler are required.')
langs: T.List[str] = []
if not compilers:
langs = ['c', 'cpp']
else:
if 'c' not in compilers:
langs.append('c')
if 'cpp' not in compilers:
langs.append('cpp')
mlog.warning(
'The LLVM dependency was not found via CMake, as this method requires',
'both a C and C++ compiler to be enabled, but',
'only' if langs else 'neither',
'a',
" nor ".join(l.upper() for l in langs),
'compiler is enabled for the',
f"{self.for_machine}.",
"Consider adding {0} to your project() call or using add_languages({0}, native : {1})".format(
', '.join(f"'{l}'" for l in langs),
'true' if self.for_machine is mesonlib.MachineChoice.BUILD else 'false',
),
'before the LLVM dependency lookup.'
)
return
super().__init__(name, env, kwargs, language='cpp', force_use_global_compilers=True)

Loading…
Cancel
Save