diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2022-03-17 13:23:48 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-03-18 07:20:15 +0000 |
commit | 48922a3ea24d91b57fa3e9e1817faaca1c491774 (patch) | |
tree | d61b324661460e460622fa18da20797ddef7c3e1 /coin/instructions/cmake_cross_compilation_module_build_instructions.yaml | |
parent | 923db4ec23e0839b15029170ed5cc0effa30e88c (diff) |
CMake: Mitigate moc not finding correct headers in framework builds
When CMake generates compilation rules, it extracts the values from
INTERFACE_INCLUDE_DIRECTORIES and checks if any of the values
are framework paths.
If they are, instead of adding an -I ./lib/My.framework to the
compilation rules, it adds -iframework ./lib or -F ./lib.
The same transformation does not happen when AUTOMOC passes include
paths to moc, nor during a headersclean check. The values there
are passed verbatim, with an -I prepended.
This causes issues when the include file name is the same as the
framework name.
E.g. #include <QtQml> + -I ./lib/QtQml.framework because moc
then ends up silently including the shared library
./lib/QtQml.framework/QtQml
instead of the header
./lib/QtQml.framework/Headers/QtQml
This can lead to a variety of silent issues during moc generation,
because all the definitions of QtQml will be missing.
Unfortunately, there does not seem to be a clean way to fix this in
the build system due to CMake semantics.
See https://gitlab.kitware.com/cmake/cmake/-/issues/23337 for details.
We can mitigate the issue by ensuring that
-I ./lib/QtQml.framework/Headers
comes before
-I ./lib/QtQml.framework
by manipulating the order of values in INTERFACE_INCLUDE_DIRECTORIES.
We might want to consider implementing an additional mitigation in
AUTOMOC, so that it filters out include paths like
-I ./lib/QtQml.framework, thus ensuring that a newer CMake version
will not exhibit the same issue when used with an older Qt.
We could consider doing the same in moc. The advantage of doing it
in moc is that that moc will consider fewer invalid include paths
when searching for headers.
Amends 4b2de41b13eb71c0ce841ef357768a3913b49810
Amends d7efb2a419a88c8f512b98194c8f7bc81dbe942b
Fixes: QTBUG-89545
Fixes: QTBUG-101718
Fixes: QTBUG-101775
Change-Id: Ib2c25b5744bd2b5c9c83813bb04ad88c0179f6ec
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit b858704e1fd5b94349147d2a287b1d89e1799af0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'coin/instructions/cmake_cross_compilation_module_build_instructions.yaml')
0 files changed, 0 insertions, 0 deletions