diff --git a/backends.py b/backends.py index 8860661ea..c92201a3a 100755 --- a/backends.py +++ b/backends.py @@ -183,6 +183,9 @@ class Backend(): commands += compiler.get_pic_flags() for dep in target.get_external_deps(): commands += dep.get_compile_flags() + if isinstance(target, interpreter.Executable): + commands += dep.get_exe_flags() + return commands def build_target_link_arguments(self, deps): diff --git a/dependencies.py b/dependencies.py index 05ff9b397..750174236 100644 --- a/dependencies.py +++ b/dependencies.py @@ -62,6 +62,9 @@ class Dependency(): def get_generate_rules(self): return [] + def get_exe_flags(self): + return [] + class PkgConfigDependency(Dependency): pkgconfig_found = False @@ -356,6 +359,11 @@ class Qt5Dependency(Dependency): 'Compiling @INFILE@ with the ui compiler') return [moc_rule, ui_rule] + def get_exe_flags(self): + # Qt5 seems to require this always. + # Fix this to be more portable, especially to MSVC. + return ['-fPIE'] + def get_dep_identifier(name, kwargs): elements = [name] diff --git a/interpreter.py b/interpreter.py index 8257f2b4d..fe4af4092 100755 --- a/interpreter.py +++ b/interpreter.py @@ -84,6 +84,9 @@ class ExternalLibraryHolder(InterpreterObject): def get_link_flags(self): return self.el.get_link_flags() + + def get_exe_flags(self): + return self.el.get_exe_flags() class Generator(InterpreterObject): diff --git a/test cases/frameworks/4 qt5/main.cpp b/test cases/frameworks/4 qt5/main.cpp index 168b3442a..95cc1f96e 100644 --- a/test cases/frameworks/4 qt5/main.cpp +++ b/test cases/frameworks/4 qt5/main.cpp @@ -4,8 +4,11 @@ int main(int argc, char **argv) { QApplication app(argc, argv); MainWindow *win = new MainWindow(); - win->setWindowTitle("Button demo app"); - win->show(); + win->setWindowTitle("Meson Qt5 build test"); - return app.exec(); + // Don't actually start the GUI so this + // can be run as a unit test. + //win->show(); + //return app.exec(); + return 0; }