aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/coredata.py8
-rw-r--r--mesonbuild/dependencies/base.py22
2 files changed, 26 insertions, 4 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index ac620d7..e1dd74b 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -235,6 +235,7 @@ class DependencyCacheType(enum.Enum):
OTHER = 0
PKG_CONFIG = 1
+ CMAKE = 2
@classmethod
def from_type(cls, dep: 'dependencies.Dependency') -> 'DependencyCacheType':
@@ -242,6 +243,8 @@ class DependencyCacheType(enum.Enum):
# As more types gain search overrides they'll need to be added here
if isinstance(dep, dependencies.PkgConfigDependency):
return cls.PKG_CONFIG
+ if isinstance(dep, dependencies.CMakeDependency):
+ return cls.CMAKE
return cls.OTHER
@@ -282,6 +285,10 @@ class DependencyCache:
if self.__is_cross:
return tuple(self.__builtins['cross_pkg_config_path'].value)
return tuple(self.__builtins['pkg_config_path'].value)
+ elif type_ is DependencyCacheType.CMAKE:
+ if self.__is_cross:
+ return tuple(self.__builtins['cross_cmake_prefix_path'].value)
+ return tuple(self.__builtins['cmake_prefix_path'].value)
assert type_ is DependencyCacheType.OTHER, 'Someone forgot to update subkey calculations for a new type'
return tuple()
@@ -923,6 +930,7 @@ builtin_options = OrderedDict([
('install_umask', BuiltinOption(UserUmaskOption, 'Default umask to apply on permissions of installed files', '022')),
('layout', BuiltinOption(UserComboOption, 'Build directory layout', 'mirror', choices=['mirror', 'flat'])),
('pkg_config_path', BuiltinOption(UserArrayOption, 'List of additional paths for pkg-config to search', [], separate_cross=True)),
+ ('cmake_prefix_path', BuiltinOption(UserArrayOption, 'List of additional prefixes for cmake to search', [], separate_cross=True)),
('optimization', BuiltinOption(UserComboOption, 'Optimization level', '0', choices=['0', 'g', '1', '2', '3', 's'])),
('stdsplit', BuiltinOption(UserBooleanOption, 'Split stdout and stderr in test logs', True)),
('strip', BuiltinOption(UserBooleanOption, 'Strip targets on install', False)),
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 37a8847..1ccbf6f 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -1129,11 +1129,19 @@ class CMakeDependency(ExternalDependency):
modules = [(x, True) for x in stringlistify(extract_as_list(kwargs, 'modules'))]
modules += [(x, False) for x in stringlistify(extract_as_list(kwargs, 'optional_modules'))]
cm_path = stringlistify(extract_as_list(kwargs, 'cmake_module_path'))
- cm_args = stringlistify(extract_as_list(kwargs, 'cmake_args'))
cm_path = [x if os.path.isabs(x) else os.path.join(environment.get_source_dir(), x) for x in cm_path]
+ cm_args = stringlistify(extract_as_list(kwargs, 'cmake_args'))
if cm_path:
- cm_args += ['-DCMAKE_MODULE_PATH={}'.format(';'.join(cm_path))]
- if not self._preliminary_find_check(name, cm_path, environment.machines[for_machine]):
+ cm_args.append('-DCMAKE_MODULE_PATH=' + ';'.join(cm_path))
+
+ if environment.is_cross_build() and self.want_cross:
+ pref_path = self.env.coredata.builtins['cross_cmake_prefix_path'].value
+ else:
+ pref_path = self.env.coredata.builtins['cmake_prefix_path'].value
+ if pref_path:
+ cm_args.append('-DCMAKE_PREFIX_PATH={}'.format(';'.join(pref_path)))
+
+ if not self._preliminary_find_check(name, cm_path, pref_path, environment.machines[for_machine]):
return
self._detect_dep(name, modules, cm_args)
@@ -1229,7 +1237,7 @@ class CMakeDependency(ExternalDependency):
except OSError:
return False
- def _preliminary_find_check(self, name: str, module_path: List[str], machine: MachineInfo) -> bool:
+ def _preliminary_find_check(self, name: str, module_path: List[str], prefix_path: List[str], machine: MachineInfo) -> bool:
lname = str(name).lower()
# Checks <path>, <path>/cmake, <path>/CMake
@@ -1273,6 +1281,12 @@ class CMakeDependency(ExternalDependency):
if find_module(i):
return True
+ # Check the user provided prefix paths
+ for i in prefix_path:
+ if search_lib_dirs(i):
+ return True
+
+
# Check the system paths
for i in self.cmakeinfo['module_paths']:
if find_module(i):