diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2017-04-11 16:41:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-11 16:41:56 +0300 |
commit | 42d1661bd9d4a29d8780e77127542120624d3729 (patch) | |
tree | f40d39bf9418499d2296e8c227c00f015bc9bf2b | |
parent | 371e3d3e87bff5413554bbfc01250a899288400c (diff) | |
parent | 1fbf6300c5d38b12a4347a9327e54a9a315ef8de (diff) | |
download | meson-42d1661bd9d4a29d8780e77127542120624d3729.zip meson-42d1661bd9d4a29d8780e77127542120624d3729.tar.gz meson-42d1661bd9d4a29d8780e77127542120624d3729.tar.bz2 |
Merge pull request #1588 from absmall/method
Add an option to dependencies called 'method'.
-rw-r--r-- | mesonbuild/dependencies.py | 271 | ||||
-rw-r--r-- | mesonbuild/mlog.py | 13 | ||||
-rw-r--r-- | mesonbuild/modules/qt4.py | 7 | ||||
-rw-r--r-- | mesonbuild/modules/qt5.py | 7 | ||||
-rwxr-xr-x | run_unittests.py | 6 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/meson.build | 14 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/meson_options.txt | 1 |
7 files changed, 202 insertions, 117 deletions
diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py index 2b110bb..25ca411 100644 --- a/mesonbuild/dependencies.py +++ b/mesonbuild/dependencies.py @@ -24,6 +24,7 @@ import sys import os, stat, glob, shutil import subprocess import sysconfig +from enum import Enum from collections import OrderedDict from . mesonlib import MesonException, version_compare, version_compare_many, Popen_safe from . import mlog @@ -33,11 +34,35 @@ from .environment import detect_cpu_family, for_windows class DependencyException(MesonException): '''Exceptions raised while trying to find dependencies''' +class DependencyMethods(Enum): + # Auto means to use whatever dependency checking mechanisms in whatever order meson thinks is best. + AUTO = 'auto' + PKGCONFIG = 'pkg-config' + QMAKE = 'qmake' + # Just specify the standard link arguments, assuming the operating system provides the library. + SYSTEM = 'system' + # Detect using sdl2-config + SDLCONFIG = 'sdlconfig' + # This is only supported on OSX - search the frameworks directory by name. + EXTRAFRAMEWORK = 'extraframework' + # Detect using the sysconfig module. + SYSCONFIG = 'sysconfig' + class Dependency: - def __init__(self, type_name='unknown'): + def __init__(self, type_name, kwargs): self.name = "null" self.is_found = False self.type_name = type_name + method = DependencyMethods(kwargs.get('method', 'auto')) + + # Set the detection method. If the method is set to auto, use any available method. + # If method is set to a specific string, allow only that detection method. + if method == DependencyMethods.AUTO: + self.methods = self.get_methods() + elif method in self.get_methods(): + self.methods = [method] + else: + raise MesonException('Unsupported detection method: {}, allowed methods are {}'.format(method.value, mlog.format_list(map(lambda x: x.value, [DependencyMethods.AUTO] + self.get_methods())))) def __repr__(self): s = '<{0} {1}: {2}>' @@ -57,6 +82,9 @@ class Dependency: As an example, gtest-all.cc when using GTest.""" return [] + def get_methods(self): + return [DependencyMethods.AUTO] + def get_name(self): return self.name @@ -71,7 +99,7 @@ class Dependency: class InternalDependency(Dependency): def __init__(self, version, incdirs, compile_args, link_args, libraries, sources, ext_deps): - super().__init__('internal') + super().__init__('internal', {}) self.version = version self.include_directories = incdirs self.compile_args = compile_args @@ -95,7 +123,7 @@ class PkgConfigDependency(Dependency): class_pkgbin = None def __init__(self, name, environment, kwargs): - Dependency.__init__(self, 'pkgconfig') + Dependency.__init__(self, 'pkgconfig', kwargs) self.is_libtool = False self.required = kwargs.get('required', True) self.static = kwargs.get('static', False) @@ -254,6 +282,9 @@ class PkgConfigDependency(Dependency): def get_link_args(self): return self.libs + def get_methods(self): + return [DependencyMethods.PKGCONFIG] + def check_pkgconfig(self): evar = 'PKG_CONFIG' if evar in os.environ: @@ -322,7 +353,7 @@ class WxDependency(Dependency): wx_found = None def __init__(self, environment, kwargs): - Dependency.__init__(self, 'wx') + Dependency.__init__(self, 'wx', kwargs) self.is_found = False self.modversion = 'none' if WxDependency.wx_found is None: @@ -542,7 +573,7 @@ class ExternalLibrary(Dependency): # TODO: Add `lang` to the parent Dependency object so that dependencies can # be expressed for languages other than C-like def __init__(self, name, link_args=None, language=None, silent=False): - super().__init__('external') + super().__init__('external', {}) self.name = name self.is_found = False self.link_args = [] @@ -582,7 +613,7 @@ class BoostDependency(Dependency): name2lib = {'test': 'unit_test_framework'} def __init__(self, environment, kwargs): - Dependency.__init__(self, 'boost') + Dependency.__init__(self, 'boost', kwargs) self.name = 'boost' self.environment = environment self.libdir = '' @@ -805,7 +836,7 @@ class BoostDependency(Dependency): class GTestDependency(Dependency): def __init__(self, environment, kwargs): - Dependency.__init__(self, 'gtest') + Dependency.__init__(self, 'gtest', kwargs) self.main = kwargs.get('main', False) self.name = 'gtest' self.libname = 'libgtest.so' @@ -882,7 +913,7 @@ class GTestDependency(Dependency): class GMockDependency(Dependency): def __init__(self, environment, kwargs): - Dependency.__init__(self, 'gmock') + Dependency.__init__(self, 'gmock', kwargs) # GMock may be a library or just source. # Work with both. self.name = 'gmock' @@ -937,7 +968,7 @@ class GMockDependency(Dependency): class QtBaseDependency(Dependency): def __init__(self, name, env, kwargs): - Dependency.__init__(self, name) + Dependency.__init__(self, name, kwargs) self.name = name self.qtname = name.capitalize() self.qtver = name[-1] @@ -964,26 +995,32 @@ class QtBaseDependency(Dependency): type_text = 'cross' if env.is_cross_build() else 'native' found_msg = '{} {} {{}} dependency (modules: {}) found:' \ ''.format(self.qtname, type_text, ', '.join(mods)) - from_text = '`pkg-config`' + from_text = 'pkg-config' + + # Keep track of the detection methods used, for logging purposes. + methods = [] # Prefer pkg-config, then fallback to `qmake -query` - self._pkgconfig_detect(mods, env, kwargs) - if not self.is_found: + if DependencyMethods.PKGCONFIG in self.methods: + self._pkgconfig_detect(mods, env, kwargs) + methods.append('pkgconfig') + if not self.is_found and DependencyMethods.QMAKE in self.methods: from_text = self._qmake_detect(mods, env, kwargs) - if not self.is_found: - # Reset compile args and link args - self.cargs = [] - self.largs = [] - from_text = '(checked pkg-config, qmake-{}, and qmake)' \ - ''.format(self.name) - self.version = 'none' - if self.required: - err_msg = '{} {} dependency not found {}' \ - ''.format(self.qtname, type_text, from_text) - raise DependencyException(err_msg) - if not self.silent: - mlog.log(found_msg.format(from_text), mlog.red('NO')) - return - from_text = '`{}`'.format(from_text) + methods.append('qmake-' + self.name) + methods.append('qmake') + if not self.is_found: + # Reset compile args and link args + self.cargs = [] + self.largs = [] + from_text = '(checked {})'.format(mlog.format_list(methods)) + self.version = 'none' + if self.required: + err_msg = '{} {} dependency not found {}' \ + ''.format(self.qtname, type_text, from_text) + raise DependencyException(err_msg) + if not self.silent: + mlog.log(found_msg.format(from_text), mlog.red('NO')) + return + from_text = '`{}`'.format(from_text) if not self.silent: mlog.log(found_msg.format(from_text), mlog.green('YES')) @@ -1053,6 +1090,7 @@ class QtBaseDependency(Dependency): return self.version = re.search(self.qtver + '(\.\d+)+', stdo).group(0) # Query library path, header path, and binary path + mlog.log("Found qmake:", mlog.bold(self.qmake.get_name()), '(%s)' % self.version) stdo = Popen_safe(self.qmake.get_command() + ['-query'])[1] qvars = {} for line in stdo.split('\n'): @@ -1092,7 +1130,7 @@ class QtBaseDependency(Dependency): libdir = qvars['QT_INSTALL_LIBS'] for m in modules: fname = 'Qt' + m - fwdep = ExtraFrameworkDependency(fname, kwargs.get('required', True), libdir) + fwdep = ExtraFrameworkDependency(fname, kwargs.get('required', True), libdir, kwargs) self.cargs.append('-F' + libdir) if fwdep.found(): self.is_found = True @@ -1113,6 +1151,9 @@ class QtBaseDependency(Dependency): def get_link_args(self): return self.largs + def get_methods(self): + return [DependencyMethods.PKGCONFIG, DependencyMethods.QMAKE] + def found(self): return self.is_found @@ -1150,7 +1191,7 @@ class Qt4Dependency(QtBaseDependency): class GnuStepDependency(Dependency): def __init__(self, environment, kwargs): - Dependency.__init__(self, 'gnustep') + Dependency.__init__(self, 'gnustep', kwargs) self.required = kwargs.get('required', True) self.modules = kwargs.get('modules', []) self.detect() @@ -1248,7 +1289,7 @@ why. As a hack filter out everything that is not a flag.""" class AppleFrameworks(Dependency): def __init__(self, environment, kwargs): - Dependency.__init__(self, 'appleframeworks') + Dependency.__init__(self, 'appleframeworks', kwargs) modules = kwargs.get('modules', []) if isinstance(modules, str): modules = [modules] @@ -1271,31 +1312,33 @@ class AppleFrameworks(Dependency): class GLDependency(Dependency): def __init__(self, environment, kwargs): - Dependency.__init__(self, 'gl') + Dependency.__init__(self, 'gl', kwargs) self.is_found = False self.cargs = [] self.linkargs = [] - try: - pcdep = PkgConfigDependency('gl', environment, kwargs) - if pcdep.found(): - self.type_name = 'pkgconfig' + if DependencyMethods.PKGCONFIG in self.methods: + try: + pcdep = PkgConfigDependency('gl', environment, kwargs) + if pcdep.found(): + self.type_name = 'pkgconfig' + self.is_found = True + self.cargs = pcdep.get_compile_args() + self.linkargs = pcdep.get_link_args() + self.version = pcdep.get_version() + return + except Exception: + pass + if DependencyMethods.SYSTEM in self.methods: + if mesonlib.is_osx(): self.is_found = True - self.cargs = pcdep.get_compile_args() - self.linkargs = pcdep.get_link_args() - self.version = pcdep.get_version() + self.linkargs = ['-framework', 'OpenGL'] + self.version = '1' # FIXME + return + if mesonlib.is_windows(): + self.is_found = True + self.linkargs = ['-lopengl32'] + self.version = '1' # FIXME: unfixable? return - except Exception: - pass - if mesonlib.is_osx(): - self.is_found = True - self.linkargs = ['-framework', 'OpenGL'] - self.version = '1' # FIXME - return - if mesonlib.is_windows(): - self.is_found = True - self.linkargs = ['-lopengl32'] - self.version = '1' # FIXME: unfixable? - return def get_link_args(self): return self.linkargs @@ -1303,48 +1346,57 @@ class GLDependency(Dependency): def get_version(self): return self.version + def get_methods(self): + if mesonlib.is_osx() or mesonlib.is_windows(): + return [DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM] + else: + return [DependencyMethods.PKGCONFIG] + # There are three different ways of depending on SDL2: # sdl2-config, pkg-config and OSX framework class SDL2Dependency(Dependency): def __init__(self, environment, kwargs): - Dependency.__init__(self, 'sdl2') + Dependency.__init__(self, 'sdl2', kwargs) self.is_found = False self.cargs = [] self.linkargs = [] - try: - pcdep = PkgConfigDependency('sdl2', environment, kwargs) - if pcdep.found(): - self.type_name = 'pkgconfig' - self.is_found = True - self.cargs = pcdep.get_compile_args() - self.linkargs = pcdep.get_link_args() - self.version = pcdep.get_version() - return - except Exception as e: - mlog.debug('SDL 2 not found via pkgconfig. Trying next, error was:', str(e)) - pass - sdlconf = shutil.which('sdl2-config') - if sdlconf: - stdo = Popen_safe(['sdl2-config', '--cflags'])[1] - self.cargs = stdo.strip().split() - stdo = Popen_safe(['sdl2-config', '--libs'])[1] - self.linkargs = stdo.strip().split() - stdo = Popen_safe(['sdl2-config', '--version'])[1] - self.version = stdo.strip() - self.is_found = True - mlog.log('Dependency', mlog.bold('sdl2'), 'found:', mlog.green('YES'), - self.version, '(%s)' % sdlconf) - return - mlog.debug('Could not find sdl2-config binary, trying next.') - if mesonlib.is_osx(): - fwdep = ExtraFrameworkDependency('sdl2', kwargs.get('required', True)) - if fwdep.found(): + if DependencyMethods.PKGCONFIG in self.methods: + try: + pcdep = PkgConfigDependency('sdl2', environment, kwargs) + if pcdep.found(): + self.type_name = 'pkgconfig' + self.is_found = True + self.cargs = pcdep.get_compile_args() + self.linkargs = pcdep.get_link_args() + self.version = pcdep.get_version() + return + except Exception as e: + mlog.debug('SDL 2 not found via pkgconfig. Trying next, error was:', str(e)) + pass + if DependencyMethods.SDLCONFIG in self.methods: + sdlconf = shutil.which('sdl2-config') + if sdlconf: + stdo = Popen_safe(['sdl2-config', '--cflags'])[1] + self.cargs = stdo.strip().split() + stdo = Popen_safe(['sdl2-config', '--libs'])[1] + self.linkargs = stdo.strip().split() + stdo = Popen_safe(['sdl2-config', '--version'])[1] + self.version = stdo.strip() self.is_found = True - self.cargs = fwdep.get_compile_args() - self.linkargs = fwdep.get_link_args() - self.version = '2' # FIXME + mlog.log('Dependency', mlog.bold('sdl2'), 'found:', mlog.green('YES'), + self.version, '(%s)' % sdlconf) return - mlog.log('Dependency', mlog.bold('sdl2'), 'found:', mlog.red('NO')) + mlog.debug('Could not find sdl2-config binary, trying next.') + if DependencyMethods.EXTRAFRAMEWORK in self.methods: + if mesonlib.is_osx(): + fwdep = ExtraFrameworkDependency('sdl2', kwargs.get('required', True), None, kwargs) + if fwdep.found(): + self.is_found = True + self.cargs = fwdep.get_compile_args() + self.linkargs = fwdep.get_link_args() + self.version = '2' # FIXME + return + mlog.log('Dependency', mlog.bold('sdl2'), 'found:', mlog.red('NO')) def get_compile_args(self): return self.cargs @@ -1358,9 +1410,15 @@ class SDL2Dependency(Dependency): def get_version(self): return self.version + def get_methods(self): + if mesonlib.is_osx(): + return [DependencyMethods.PKGCONFIG, DependencyMethods.SDLCONFIG, DependencyMethods.EXTRAFRAMEWORK] + else: + return [DependencyMethods.PKGCONFIG, DependencyMethods.SDLCONFIG] + class ExtraFrameworkDependency(Dependency): - def __init__(self, name, required, path=None): - Dependency.__init__(self, 'extraframeworks') + def __init__(self, name, required, path, kwargs): + Dependency.__init__(self, 'extraframeworks', kwargs) self.name = None self.detect(name, path) if self.found(): @@ -1404,7 +1462,7 @@ class ExtraFrameworkDependency(Dependency): class ThreadDependency(Dependency): def __init__(self, environment, kwargs): - super().__init__('threads') + super().__init__('threads', {}) self.name = 'threads' self.is_found = True mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.green('YES')) @@ -1417,28 +1475,29 @@ class ThreadDependency(Dependency): class Python3Dependency(Dependency): def __init__(self, environment, kwargs): - super().__init__('python3') + super().__init__('python3', kwargs) self.name = 'python3' self.is_found = False # We can only be sure that it is Python 3 at this point self.version = '3' - try: - pkgdep = PkgConfigDependency('python3', environment, kwargs) - if pkgdep.found(): - self.cargs = pkgdep.cargs - self.libs = pkgdep.libs - self.version = pkgdep.get_version() - self.is_found = True - return - except Exception: - pass + if DependencyMethods.PKGCONFIG in self.methods: + try: + pkgdep = PkgConfigDependency('python3', environment, kwargs) + if pkgdep.found(): + self.cargs = pkgdep.cargs + self.libs = pkgdep.libs + self.version = pkgdep.get_version() + self.is_found = True + return + except Exception: + pass if not self.is_found: - if mesonlib.is_windows(): + if mesonlib.is_windows() and DependencyMethods.SYSCONFIG in self.methods: self._find_libpy3_windows(environment) - elif mesonlib.is_osx(): + elif mesonlib.is_osx() and DependencyMethods.EXTRAFRAMEWORK in self.methods: # In OSX the Python 3 framework does not have a version # number in its name. - fw = ExtraFrameworkDependency('python', False) + fw = ExtraFrameworkDependency('python', False, None, kwargs) if fw.found(): self.cargs = fw.get_compile_args() self.libs = fw.get_link_args() @@ -1490,6 +1549,14 @@ class Python3Dependency(Dependency): def get_link_args(self): return self.libs + def get_methods(self): + if mesonlib.is_windows(): + return [DependencyMethods.PKGCONFIG, DependencyMethods.SYSCONFIG] + elif mesonlib.is_osx(): + return [DependencyMethods.PKGCONFIG, DependencyMethods.EXTRAFRAMEWORK] + else: + return [DependencyMethods.PKGCONFIG] + def get_version(self): return self.version @@ -1522,6 +1589,8 @@ def find_external_dependency(name, environment, kwargs): required = kwargs.get('required', True) if not isinstance(required, bool): raise DependencyException('Keyword "required" must be a boolean.') + if not isinstance(kwargs.get('method', ''), str): + raise DependencyException('Keyword "method" must be a string.') lname = name.lower() if lname in packages: dep = packages[lname](environment, kwargs) @@ -1537,7 +1606,7 @@ def find_external_dependency(name, environment, kwargs): except Exception as e: pkg_exc = e if mesonlib.is_osx(): - fwdep = ExtraFrameworkDependency(name, required) + fwdep = ExtraFrameworkDependency(name, required, None, kwargs) if required and not fwdep.found(): m = 'Dependency {!r} not found, tried Extra Frameworks ' \ 'and Pkg-Config:\n\n' + str(pkg_exc) diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index bad756a..82ee6ba 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -99,3 +99,16 @@ def log(*args, **kwargs): def warning(*args, **kwargs): log(yellow('WARNING:'), *args, **kwargs) + +# Format a list for logging purposes as a string. It separates +# all but the last item with commas, and the last with 'and'. +def format_list(list): + l = len(list) + if l > 2: + return ' and '.join([', '.join(list[:-1]), list[-1]]) + elif l == 2: + return ' and '.join(list) + elif l == 1: + return list[0] + else: + return '' diff --git a/mesonbuild/modules/qt4.py b/mesonbuild/modules/qt4.py index 7146739..0386291 100644 --- a/mesonbuild/modules/qt4.py +++ b/mesonbuild/modules/qt4.py @@ -24,14 +24,14 @@ from . import ModuleReturnValue class Qt4Module(ExtensionModule): tools_detected = False - def _detect_tools(self, env): + def _detect_tools(self, env, method): if self.tools_detected: return mlog.log('Detecting Qt4 tools') # FIXME: We currently require Qt4 to exist while importing the module. # We should make it gracefully degrade and not create any targets if # the import is marked as 'optional' (not implemented yet) - kwargs = {'required': 'true', 'modules': 'Core', 'silent': 'true'} + kwargs = {'required': 'true', 'modules': 'Core', 'silent': 'true', 'method': method} qt4 = Qt4Dependency(env, kwargs) # Get all tools and then make sure that they are the right version self.moc, self.uic, self.rcc = qt4.compilers_detect() @@ -113,7 +113,8 @@ class Qt4Module(ExtensionModule): if not isinstance(sources, list): sources = [sources] sources += args[1:] - self._detect_tools(state.environment) + method = kwargs.get('method', 'auto') + self._detect_tools(state.environment, method) err_msg = "{0} sources specified and couldn't find {1}, " \ "please check your qt4 installation" if len(moc_headers) + len(moc_sources) > 0 and not self.moc.found(): diff --git a/mesonbuild/modules/qt5.py b/mesonbuild/modules/qt5.py index 2a87a80..6497694 100644 --- a/mesonbuild/modules/qt5.py +++ b/mesonbuild/modules/qt5.py @@ -24,14 +24,14 @@ from . import ModuleReturnValue class Qt5Module(ExtensionModule): tools_detected = False - def _detect_tools(self, env): + def _detect_tools(self, env, method): if self.tools_detected: return mlog.log('Detecting Qt5 tools') # FIXME: We currently require Qt5 to exist while importing the module. # We should make it gracefully degrade and not create any targets if # the import is marked as 'optional' (not implemented yet) - kwargs = {'required': 'true', 'modules': 'Core', 'silent': 'true'} + kwargs = {'required': 'true', 'modules': 'Core', 'silent': 'true', 'method': method} qt5 = Qt5Dependency(env, kwargs) # Get all tools and then make sure that they are the right version self.moc, self.uic, self.rcc = qt5.compilers_detect() @@ -119,7 +119,8 @@ class Qt5Module(ExtensionModule): if not isinstance(sources, list): sources = [sources] sources += args[1:] - self._detect_tools(state.environment) + method = kwargs.get('method', 'auto') + self._detect_tools(state.environment, method) err_msg = "{0} sources specified and couldn't find {1}, " \ "please check your qt5 installation" if len(moc_headers) + len(moc_sources) > 0 and not self.moc.found(): diff --git a/run_unittests.py b/run_unittests.py index 4599b2b..6ea1d41 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -1134,7 +1134,7 @@ class LinuxlikeTests(BasePlatformTests): if qt4 != 0 or qt5 != 0: raise unittest.SkipTest('Qt not found with pkg-config') testdir = os.path.join(self.framework_test_dir, '4 qt') - self.init(testdir) + self.init(testdir, ['-Dmethod=pkg-config']) # Confirm that the dependency was found with qmake msg = 'Qt4 native `pkg-config` dependency (modules: Core, Gui) found: YES\n' msg2 = 'Qt5 native `pkg-config` dependency (modules: Core, Gui) found: YES\n' @@ -1157,10 +1157,8 @@ class LinuxlikeTests(BasePlatformTests): if 'Qt version 5' not in output and 'qt5' not in output: raise unittest.SkipTest('Qmake found, but it is not for Qt 5.') # Disable pkg-config codepath and force searching with qmake/qmake-qt5 - os.environ['PKG_CONFIG_LIBDIR'] = self.builddir - os.environ['PKG_CONFIG_PATH'] = self.builddir testdir = os.path.join(self.framework_test_dir, '4 qt') - self.init(testdir) + self.init(testdir, ['-Dmethod=qmake']) # Confirm that the dependency was found with qmake msg = 'Qt5 native `qmake-qt5` dependency (modules: Core) found: YES\n' msg2 = 'Qt5 native `qmake` dependency (modules: Core) found: YES\n' diff --git a/test cases/frameworks/4 qt/meson.build b/test cases/frameworks/4 qt/meson.build index fec5959..468b9c9 100644 --- a/test cases/frameworks/4 qt/meson.build +++ b/test cases/frameworks/4 qt/meson.build @@ -9,17 +9,17 @@ foreach qt : ['qt4', 'qt5'] qt_modules += qt5_modules endif # Test that invalid modules are indeed not found - fakeqtdep = dependency(qt, modules : ['DefinitelyNotFound'], required : false) + fakeqtdep = dependency(qt, modules : ['DefinitelyNotFound'], required : false, method : get_option('method')) if fakeqtdep.found() error('Invalid qt dep incorrectly found!') endif # Test that partially-invalid modules are indeed not found - fakeqtdep = dependency(qt, modules : ['Core', 'DefinitelyNotFound'], required : false) + fakeqtdep = dependency(qt, modules : ['Core', 'DefinitelyNotFound'], required : false, method : get_option('method')) if fakeqtdep.found() error('Invalid qt dep incorrectly found!') endif # If qt4 modules are found, test that. qt5 is required. - qtdep = dependency(qt, modules : qt_modules, required : qt == 'qt5') + qtdep = dependency(qt, modules : qt_modules, required : qt == 'qt5', method : get_option('method')) if qtdep.found() qtmodule = import(qt) @@ -30,10 +30,11 @@ foreach qt : ['qt4', 'qt5'] moc_headers : ['mainWindow.h'], # These need to be fed through the moc tool before use. ui_files : 'mainWindow.ui', # XML files that need to be compiled with the uic tol. qresources : ['stuff.qrc', 'stuff2.qrc'], # Resource file for rcc compiler. + method : get_option('method') ) # Test that setting a unique name with a positional argument works - qtmodule.preprocess(qt + 'teststuff', qresources : ['stuff.qrc']) + qtmodule.preprocess(qt + 'teststuff', qresources : ['stuff.qrc'], method : get_option('method')) qexe = executable(qt + 'app', sources : ['main.cpp', 'mainWindow.cpp', # Sources that don't need preprocessing. @@ -43,7 +44,7 @@ foreach qt : ['qt4', 'qt5'] # We need a console test application because some test environments # do not have an X server. - qtcore = dependency(qt, modules : 'Core') + qtcore = dependency(qt, modules : 'Core', method : get_option('method')) qtcoreapp = executable(qt + 'core', 'q5core.cpp', dependencies : qtcore) @@ -55,7 +56,8 @@ foreach qt : ['qt4', 'qt5'] # files from sources. manpreprocessed = qtmodule.preprocess( moc_sources : 'manualinclude.cpp', - moc_headers : 'manualinclude.h') + moc_headers : 'manualinclude.h', + method : get_option('method')) qtmaninclude = executable(qt + 'maninclude', sources : ['manualinclude.cpp', manpreprocessed], diff --git a/test cases/frameworks/4 qt/meson_options.txt b/test cases/frameworks/4 qt/meson_options.txt new file mode 100644 index 0000000..bc1069e --- /dev/null +++ b/test cases/frameworks/4 qt/meson_options.txt @@ -0,0 +1 @@ +option('method', type : 'string', value : 'auto', description : 'The method to use to find Qt') |