|
|
@ -27,13 +27,14 @@ import textwrap |
|
|
|
import platform |
|
|
|
import platform |
|
|
|
import itertools |
|
|
|
import itertools |
|
|
|
import ctypes |
|
|
|
import ctypes |
|
|
|
|
|
|
|
from typing import List |
|
|
|
from enum import Enum |
|
|
|
from enum import Enum |
|
|
|
from pathlib import Path, PurePath |
|
|
|
from pathlib import Path, PurePath |
|
|
|
|
|
|
|
|
|
|
|
from .. import mlog |
|
|
|
from .. import mlog |
|
|
|
from .. import mesonlib |
|
|
|
from .. import mesonlib |
|
|
|
from ..compilers import clib_langs |
|
|
|
from ..compilers import clib_langs |
|
|
|
from ..environment import BinaryTable |
|
|
|
from ..environment import BinaryTable, Environment |
|
|
|
from ..mesonlib import MachineChoice, MesonException, OrderedSet, PerMachine |
|
|
|
from ..mesonlib import MachineChoice, MesonException, OrderedSet, PerMachine |
|
|
|
from ..mesonlib import Popen_safe, version_compare_many, version_compare, listify |
|
|
|
from ..mesonlib import Popen_safe, version_compare_many, version_compare, listify |
|
|
|
from ..mesonlib import Version |
|
|
|
from ..mesonlib import Version |
|
|
@ -926,7 +927,7 @@ class CMakeDependency(ExternalDependency): |
|
|
|
def _gen_exception(self, msg): |
|
|
|
def _gen_exception(self, msg): |
|
|
|
return DependencyException('Dependency {} not found: {}'.format(self.name, msg)) |
|
|
|
return DependencyException('Dependency {} not found: {}'.format(self.name, msg)) |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, name, environment, kwargs, language=None): |
|
|
|
def __init__(self, name: str, environment: Environment, kwargs, language=None): |
|
|
|
super().__init__('cmake', environment, language, kwargs) |
|
|
|
super().__init__('cmake', environment, language, kwargs) |
|
|
|
self.name = name |
|
|
|
self.name = name |
|
|
|
self.is_libtool = False |
|
|
|
self.is_libtool = False |
|
|
@ -1010,16 +1011,25 @@ class CMakeDependency(ExternalDependency): |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
modules = kwargs.get('modules', []) |
|
|
|
modules = kwargs.get('modules', []) |
|
|
|
|
|
|
|
cm_path = kwargs.get('cmake_module_path', []) |
|
|
|
|
|
|
|
cm_args = kwargs.get('cmake_args', []) |
|
|
|
if not isinstance(modules, list): |
|
|
|
if not isinstance(modules, list): |
|
|
|
modules = [modules] |
|
|
|
modules = [modules] |
|
|
|
self._detect_dep(name, modules) |
|
|
|
if not isinstance(cm_path, list): |
|
|
|
|
|
|
|
cm_path = [cm_path] |
|
|
|
|
|
|
|
if not isinstance(cm_args, list): |
|
|
|
|
|
|
|
cm_args = [cm_args] |
|
|
|
|
|
|
|
cm_path = [x if os.path.isabs(x) else os.path.join(environment.get_source_dir(), x) for x in cm_path] |
|
|
|
|
|
|
|
if cm_path: |
|
|
|
|
|
|
|
cm_args += ['-DCMAKE_MODULE_PATH={}'.format(';'.join(cm_path))] |
|
|
|
|
|
|
|
self._detect_dep(name, modules, cm_args) |
|
|
|
|
|
|
|
|
|
|
|
def __repr__(self): |
|
|
|
def __repr__(self): |
|
|
|
s = '<{0} {1}: {2} {3}>' |
|
|
|
s = '<{0} {1}: {2} {3}>' |
|
|
|
return s.format(self.__class__.__name__, self.name, self.is_found, |
|
|
|
return s.format(self.__class__.__name__, self.name, self.is_found, |
|
|
|
self.version_reqs) |
|
|
|
self.version_reqs) |
|
|
|
|
|
|
|
|
|
|
|
def _detect_dep(self, name, modules): |
|
|
|
def _detect_dep(self, name: str, modules: List[str], args: List[str]): |
|
|
|
# Detect a dependency with CMake using the '--find-package' mode |
|
|
|
# Detect a dependency with CMake using the '--find-package' mode |
|
|
|
# and the trace output (stderr) |
|
|
|
# and the trace output (stderr) |
|
|
|
# |
|
|
|
# |
|
|
@ -1035,7 +1045,7 @@ class CMakeDependency(ExternalDependency): |
|
|
|
mlog.debug('Try CMake generator: {}'.format(i if len(i) > 0 else 'auto')) |
|
|
|
mlog.debug('Try CMake generator: {}'.format(i if len(i) > 0 else 'auto')) |
|
|
|
|
|
|
|
|
|
|
|
# Prepare options |
|
|
|
# Prepare options |
|
|
|
cmake_opts = ['--trace-expand', '-DNAME={}'.format(name), '.'] |
|
|
|
cmake_opts = ['--trace-expand', '-DNAME={}'.format(name)] + args + ['.'] |
|
|
|
if len(i) > 0: |
|
|
|
if len(i) > 0: |
|
|
|
cmake_opts = ['-G', i] + cmake_opts |
|
|
|
cmake_opts = ['-G', i] + cmake_opts |
|
|
|
|
|
|
|
|
|
|
|