diff options
author | Jason Ekstrand <jason@jlekstrand.net> | 2020-06-20 09:45:22 -0500 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-11-21 07:55:10 -0800 |
commit | 15bbf1ea7581a8a872296435b28d679c7e42a466 (patch) | |
tree | afb7844a63b8406bae87a294bec1e54adad9c73a /mesonbuild/dependencies/base.py | |
parent | 9dab27f814cb3d9abe0a7617b9a7a64efb0938e3 (diff) | |
download | meson-15bbf1ea7581a8a872296435b28d679c7e42a466.zip meson-15bbf1ea7581a8a872296435b28d679c7e42a466.tar.gz meson-15bbf1ea7581a8a872296435b28d679c7e42a466.tar.bz2 |
Handle cmake dependencies which require a specified version
Some CMake packages fail to find at all if no version is specified.
This commit adds a cmake_version parameter to dependency() to allow you
to specify the requested version.
Diffstat (limited to 'mesonbuild/dependencies/base.py')
-rw-r--r-- | mesonbuild/dependencies/base.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 87518e1..11769c0 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -1111,6 +1111,9 @@ class CMakeDependency(ExternalDependency): if self.cmakeinfo is None: raise self._gen_exception('Unable to obtain CMake system information') + package_version = kwargs.get('cmake_package_version', '') + if not isinstance(package_version, str): + raise DependencyException('Keyword "cmake_package_version" must be a string.') components = [(x, True) for x in stringlistify(extract_as_list(kwargs, 'components'))] 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'))] @@ -1121,7 +1124,7 @@ class CMakeDependency(ExternalDependency): if not self._preliminary_find_check(name, cm_path, self.cmakebin.get_cmake_prefix_paths(), environment.machines[self.for_machine]): mlog.debug('Preliminary CMake check failed. Aborting.') return - self._detect_dep(name, modules, components, cm_args) + self._detect_dep(name, package_version, modules, components, cm_args) def __repr__(self): s = '<{0} {1}: {2} {3}>' @@ -1307,7 +1310,7 @@ class CMakeDependency(ExternalDependency): return False - def _detect_dep(self, name: str, modules: T.List[T.Tuple[str, bool]], components: T.List[T.Tuple[str, bool]], args: T.List[str]): + def _detect_dep(self, name: str, package_version: str, modules: T.List[T.Tuple[str, bool]], components: T.List[T.Tuple[str, bool]], args: T.List[str]): # Detect a dependency with CMake using the '--find-package' mode # and the trace output (stderr) # @@ -1337,6 +1340,7 @@ class CMakeDependency(ExternalDependency): cmake_opts = [] cmake_opts += ['-DNAME={}'.format(name)] cmake_opts += ['-DARCHS={}'.format(';'.join(self.cmakeinfo['archs']))] + cmake_opts += ['-DVERSION={}'.format(package_version)] cmake_opts += ['-DCOMPS={}'.format(';'.join([x[0] for x in comp_mapped]))] cmake_opts += args cmake_opts += self.traceparser.trace_args() |