diff options
-rw-r--r-- | docs/markdown/Qt5-module.md | 10 | ||||
-rw-r--r-- | docs/markdown/snippets/qt5-moc_extra_arguments.md | 8 | ||||
-rw-r--r-- | mesonbuild/modules/qt.py | 19 |
3 files changed, 27 insertions, 10 deletions
diff --git a/docs/markdown/Qt5-module.md b/docs/markdown/Qt5-module.md index a8ad73d..613e5c1 100644 --- a/docs/markdown/Qt5-module.md +++ b/docs/markdown/Qt5-module.md @@ -5,11 +5,11 @@ tools and steps required for Qt. The module has one method. ## preprocess -This method takes five keyword arguments, `moc_headers`, -`moc_sources`, `ui_files` and `qresources` which define the files that -require preprocessing with `moc`, `uic` and `rcc` and 'include_directories' which might be needed by moc. It returns an -opaque object that should be passed to a main build target. A simple -example would look like this: +This method takes six keyword arguments, `moc_headers`, `moc_sources`, `ui_files`, `qresources` +and `moc_extra_arguments` which define the files that require preprocessing with `moc`, `uic` +and `rcc` and 'include_directories' which might be needed by moc as well as (optional) +additional arguments. It returns an opaque object that should be passed to a main build target. +A simple example would look like this: ```meson qt5 = import('qt5') diff --git a/docs/markdown/snippets/qt5-moc_extra_arguments.md b/docs/markdown/snippets/qt5-moc_extra_arguments.md new file mode 100644 index 0000000..957c3c7 --- /dev/null +++ b/docs/markdown/snippets/qt5-moc_extra_arguments.md @@ -0,0 +1,8 @@ +# Adds support for additional Qt5-Module keyword `moc_extra_arguments` + +When `moc`-ing sources, the `moc` tool does not know about any +preprocessor macros. The generated code might not match the input +files when the linking with the moc input sources happens. + +This amendment allows to specify a a list of additional arguments +passed to the `moc` tool. They are called `moc_extra_arguments`.
\ No newline at end of file diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py index 2f24740..1ff30ef 100644 --- a/mesonbuild/modules/qt.py +++ b/mesonbuild/modules/qt.py @@ -84,10 +84,10 @@ class QtBaseModule: except Exception: return [] - @permittedKwargs({'moc_headers', 'moc_sources', 'include_directories', 'ui_files', 'qresources', 'method'}) + @permittedKwargs({'moc_headers', 'moc_sources', 'moc_extra_arguments', 'include_directories', 'ui_files', 'qresources', 'method'}) def preprocess(self, state, args, kwargs): - rcc_files, ui_files, moc_headers, moc_sources, sources, include_directories \ - = extract_as_list(kwargs, 'qresources', 'ui_files', 'moc_headers', 'moc_sources', 'sources', 'include_directories', pop = True) + rcc_files, ui_files, moc_headers, moc_sources, moc_extra_arguments, sources, include_directories \ + = extract_as_list(kwargs, 'qresources', 'ui_files', 'moc_headers', 'moc_sources', 'moc_extra_arguments', 'sources', 'include_directories', pop = True) sources += args[1:] method = kwargs.get('method', 'auto') self._detect_tools(state.environment, method) @@ -122,14 +122,23 @@ class QtBaseModule: sources.append(ui_output) inc = get_include_args(include_dirs=include_directories) if len(moc_headers) > 0: + if len(moc_extra_arguments) > 0: + arguments = moc_extra_arguments + inc + ['@INPUT@', '-o', '@OUTPUT@'] + else: + arguments = inc + ['@INPUT@', '-o', '@OUTPUT@'] moc_kwargs = {'output': 'moc_@BASENAME@.cpp', - 'arguments': inc + ['@INPUT@', '-o', '@OUTPUT@']} + 'arguments': arguments} moc_gen = build.Generator([self.moc], moc_kwargs) moc_output = moc_gen.process_files('Qt{} moc header'.format(self.qt_version), moc_headers, state) sources.append(moc_output) if len(moc_sources) > 0: + if len(moc_extra_arguments) > 0: + concatinated_moc_extra_arguments = ' '.join(moc_extra_arguments) + arguments = [concatinated_moc_extra_arguments, '@INPUT@', '-o', '@OUTPUT@'] + else: + arguments = ['@INPUT@', '-o', '@OUTPUT@'] moc_kwargs = {'output': '@BASENAME@.moc', - 'arguments': ['@INPUT@', '-o', '@OUTPUT@']} + 'arguments': arguments} moc_gen = build.Generator([self.moc], moc_kwargs) moc_output = moc_gen.process_files('Qt{} moc source'.format(self.qt_version), moc_sources, state) sources.append(moc_output) |