summaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies/dev.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2024-04-10 10:32:15 -0700
committerDylan Baker <dylan@pnwbakers.com>2024-04-11 09:55:04 -0700
commitb6d7a7a5b72e708a0f6480bb6f143c95cdbe3cde (patch)
treebf617fe411d42f7d073f27067220ab273bd64396 /mesonbuild/dependencies/dev.py
parentbcb82b390a382e10b6dd5a8e27727b31ada811b1 (diff)
downloadmeson-b6d7a7a5b72e708a0f6480bb6f143c95cdbe3cde.tar.gz
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.
Diffstat (limited to 'mesonbuild/dependencies/dev.py')
-rw-r--r--mesonbuild/dependencies/dev.py27
1 files changed, 24 insertions, 3 deletions
diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py
index 72dbb4522..89761f24f 100644
--- a/mesonbuild/dependencies/dev.py
+++ b/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)