Qt5 moc regression in cmake 3.16
Hi, I've been bisecting a build failure of a piece of software which builds fine with cmake 3.15 but fails to compile with cmake 3.16 (and later, the bisect was between origin/master and v3.15.0).
The git bisect result is the following:
d018d27c101869e4e2449f938df89d4f97c5b73c is the first bad commit commit d018d27c101869e4e2449f938df89d4f97c5b73c Author: Sebastian Holtermann <email@example.com> Date: Fri Sep 13 15:17:24 2019 +0200 Autogen: Add moc path prefix generation (AUTOMOC_PATH_PREFIX) The new `AUTOMOC_PATH_PREFIX` boolean target property enables automatic generation of the path prefix `-p` option for `moc`. `AUTOMOC_PATH_PREFIX` is initialized from the variable `CMAKE_AUTOMOC_PATH_PREFIX`, which is ON by default. When `AUTOMOC_PATH_PREFIX` is enabled, CMake tests if a `moc`ed header file is in one of the include directories. If so, then the `-p` option, with the relative path of the header parent directory to the respective include directory, is added to the `moc` command. If the header file is not in an include directory, the `-p` option is omitted. Closes: #18815 "AUTOMOC: generated files include full relative path, breaking certain reproducible builds" Modules/CMakeGenericSystem.cmake | 1 + Source/cmQtAutoGenInitializer.cxx | 2 + Source/cmQtAutoMocUic.cxx | 110 ++++++++++++++++++++++++++------------ Source/cmQtAutoMocUic.h | 7 +-- Source/cmTarget.cxx | 1 + 5 files changed, 84 insertions(+), 37 deletions(-) bisect run success
The compile error can be found at https://github.com/ubports/system-settings/issues/217 (I can also copy-paste it here if you want).
From what I can tell,
#include "plugin.h" in the moc file doesn't get resolved to
plugins/system-update/plugin.h but to a different
plugin.h somewhere in the tree (tested with
#warning statements in
plugins/system-update/plugin.h) which causes
Backend plugin to not get defined.
As you can see in the sources of "system-settings" there are a lot of
plugin.h files in the tree so I'm guessing that's how it breaks with the cmake commit from above.
I unfortunately don't have a minimal sample for this issue and this piece of software needs a lot of weird dependencies so it's not simple to compile, but I'm hoping the information here is enough :)