Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Build breaks with cmake 3.16 #217

Closed
z3ntu opened this issue Feb 8, 2020 · 3 comments
Closed

Build breaks with cmake 3.16 #217

z3ntu opened this issue Feb 8, 2020 · 3 comments

Comments

@z3ntu
Copy link
Contributor

z3ntu commented Feb 8, 2020

Tested on Arch Linux with with cmake 3.14.6, 3.15.5 & 3.16.4 (and on Alpine Linux with cmake 3.16.4). Compilation works fine with cmake 3.14.6 and 3.15.5 but breaks with cmake 3.16.4 with the error:

[ 51%] Building CXX object plugins/system-update/CMakeFiles/UbuntuUpdatePanel.dir/UbuntuUpdatePanel_autogen/mocs_compilation.cpp.o
In file included from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/mocs_compilation.cpp:2:
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:59:6: error: ‘BackendPlugin’ has not been declared
   59 | void BackendPlugin::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
      |      ^~~~~~~~~~~~~
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:67:38: error: ‘BackendPlugin’ has not been declared
   67 | QT_INIT_METAOBJECT const QMetaObject BackendPlugin::staticMetaObject = { {
      |                                      ^~~~~~~~~~~~~
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:68:34: error: ‘QQmlExtensionPlugin’ was not declared in this scope
   68 |     QMetaObject::SuperData::link<QQmlExtensionPlugin::staticMetaObject>(),
      |                                  ^~~~~~~~~~~~~~~~~~~
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:68:29: error: parse error in template argument list
   68 |     QMetaObject::SuperData::link<QQmlExtensionPlugin::staticMetaObject>(),
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:68:73: error: no matching function for call to ‘QMetaObject::SuperData::link<<expression error> >()’
   68 |     QMetaObject::SuperData::link<QQmlExtensionPlugin::staticMetaObject>(),
      |                                                                         ^
In file included from /usr/include/qt/QtCore/qobject.h:46,
                 from /usr/include/qt/QtCore/QObject:1,
                 from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/src/plugin.h:24,
                 from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:10,
                 from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/mocs_compilation.cpp:2:
/usr/include/qt/QtCore/qobjectdefs.h:599:69: note: candidate: ‘template<const QMetaObject& MO> static constexpr QMetaObject::SuperData QMetaObject::SuperData::link()’
  599 |         template <const QMetaObject &MO> static constexpr SuperData link()
      |                                                                     ^~~~
/usr/include/qt/QtCore/qobjectdefs.h:599:69: note:   template argument deduction/substitution failed:
In file included from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/mocs_compilation.cpp:2:
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:68:73: error: template argument 1 is invalid
   68 |     QMetaObject::SuperData::link<QQmlExtensionPlugin::staticMetaObject>(),
      |                                                                         ^
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:77:20: error: ‘BackendPlugin’ has not been declared
   77 | const QMetaObject *BackendPlugin::metaObject() const
      |                    ^~~~~~~~~~~~~
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:77:48: error: non-member function ‘const QMetaObject* metaObject()’ cannot have cv-qualifier
   77 | const QMetaObject *BackendPlugin::metaObject() const
      |                                                ^~~~~
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp: In function ‘const QMetaObject* metaObject()’:
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:79:21: error: ‘QScopedPointer<QObjectData> QObject::d_ptr’ is protected within this context
   79 |     return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
      |                     ^~~~~
In file included from /usr/include/qt/QtCore/QObject:1,
                 from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/src/plugin.h:24,
                 from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:10,
                 from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/mocs_compilation.cpp:2:
/usr/include/qt/QtCore/qobject.h:450:33: note: declared protected here
  450 |     QScopedPointer<QObjectData> d_ptr;
      |                                 ^~~~~
In file included from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/mocs_compilation.cpp:2:
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:79:21: error: invalid use of non-static data member ‘QObject::d_ptr’
   79 |     return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
      |                     ^~~~~
In file included from /usr/include/qt/QtCore/QObject:1,
                 from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/src/plugin.h:24,
                 from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:10,
                 from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/mocs_compilation.cpp:2:
/usr/include/qt/QtCore/qobject.h:450:33: note: declared here
  450 |     QScopedPointer<QObjectData> d_ptr;
      |                                 ^~~~~
In file included from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/mocs_compilation.cpp:2:
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:79:50: error: ‘QScopedPointer<QObjectData> QObject::d_ptr’ is protected within this context
   79 |     return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
      |                                                  ^~~~~
In file included from /usr/include/qt/QtCore/QObject:1,
                 from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/src/plugin.h:24,
                 from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:10,
                 from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/mocs_compilation.cpp:2:
/usr/include/qt/QtCore/qobject.h:450:33: note: declared protected here
  450 |     QScopedPointer<QObjectData> d_ptr;
      |                                 ^~~~~
In file included from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/mocs_compilation.cpp:2:
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:79:50: error: invalid use of non-static data member ‘QObject::d_ptr’
   79 |     return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
      |                                                  ^~~~~
In file included from /usr/include/qt/QtCore/QObject:1,
                 from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/src/plugin.h:24,
                 from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:10,
                 from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/mocs_compilation.cpp:2:
/usr/include/qt/QtCore/qobject.h:450:33: note: declared here
  450 |     QScopedPointer<QObjectData> d_ptr;
      |                                 ^~~~~
In file included from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/mocs_compilation.cpp:2:
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp: At global scope:
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:82:7: error: ‘BackendPlugin’ has not been declared
   82 | void *BackendPlugin::qt_metacast(const char *_clname)
      |       ^~~~~~~~~~~~~
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp: In function ‘void* qt_metacast(const char*)’:
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:86:35: error: invalid use of ‘this’ in non-member function
   86 |         return static_cast<void*>(this);
      |                                   ^~~~
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:87:12: error: ‘QQmlExtensionPlugin’ has not been declared
   87 |     return QQmlExtensionPlugin::qt_metacast(_clname);
      |            ^~~~~~~~~~~~~~~~~~~
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp: At global scope:
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:90:5: error: ‘BackendPlugin’ has not been declared
   90 | int BackendPlugin::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
      |     ^~~~~~~~~~~~~
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp: In function ‘int qt_metacall(QMetaObject::Call, int, void**)’:
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:92:11: error: ‘QQmlExtensionPlugin’ has not been declared
   92 |     _id = QQmlExtensionPlugin::qt_metacall(_c, _id, _a);
      |           ^~~~~~~~~~~~~~~~~~~
In file included from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:13,
                 from /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/mocs_compilation.cpp:2:
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp: In function ‘QObject* qt_plugin_instance()’:
/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/EWIEGA46WW/moc_plugin.cpp:114:22: error: ‘BackendPlugin’ does not name a type
  114 | QT_MOC_EXPORT_PLUGIN(BackendPlugin, BackendPlugin)
      |                      ^~~~~~~~~~~~~
make[2]: *** [plugins/system-update/CMakeFiles/UbuntuUpdatePanel.dir/build.make:63: plugins/system-update/CMakeFiles/UbuntuUpdatePanel.dir/UbuntuUpdatePanel_autogen/mocs_compilation.cpp.o] Error 1

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.

I've also checked the exact build command that cmake executes by passing VERBOSE=1 to make which resulted in the following commands for the different cmake versions:

--- cmake 3.16.4

cd /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update && /usr/bin/c++  -DQT_CORE_LIB -DQT_DBUS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_QUICK_LIB -DQT_SQL_LIB -DUbuntuUpdatePanel_EXPORTS -I/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/include -I/home/luca/dev/postmarketOS/unity8-stuff/system-settings/lib -I/home/luca/dev/postmarketOS/unity8-stuff/system-settings/src -I/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update -I/home/luca/dev/postmarketOS/unity8-stuff/system-settings/plugins/system-update -isystem /usr/include/qt -isystem /usr/include/qt/QtQml -isystem /usr/include/qt/QtNetwork -isystem /usr/include/qt/QtCore -isystem /usr/lib/qt/mkspecs/linux-g++ -isystem /usr/include/qt/QtQuick -isystem /usr/include/qt/QtQmlModels -isystem /usr/include/qt/QtGui -isystem /usr/include/qt/QtDBus -isystem /usr/include/qt/QtSql  -std=c++0x -fno-permissive -pedantic -Wall -Wextra -fPIC   -fPIC -o CMakeFiles/UbuntuUpdatePanel.dir/UbuntuUpdatePanel_autogen/mocs_compilation.cpp.o -c /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/mocs_compilation.cpp

--- cmake 3.14.6

cd /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update && /usr/bin/c++  -DQT_CORE_LIB -DQT_DBUS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_QUICK_LIB -DQT_SQL_LIB -DUbuntuUpdatePanel_EXPORTS -I/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/include -I/home/luca/dev/postmarketOS/unity8-stuff/system-settings/lib -I/home/luca/dev/postmarketOS/unity8-stuff/system-settings/src -I/home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update -I/home/luca/dev/postmarketOS/unity8-stuff/system-settings/plugins/system-update -isystem /usr/include/qt -isystem /usr/include/qt/QtQml -isystem /usr/include/qt/QtNetwork -isystem /usr/include/qt/QtCore -isystem /usr/lib/qt/mkspecs/linux-g++ -isystem /usr/include/qt/QtQuick -isystem /usr/include/qt/QtQmlModels -isystem /usr/include/qt/QtGui -isystem /usr/include/qt/QtDBus -isystem /usr/include/qt/QtSql  -std=c++0x -fno-permissive -pedantic -Wall -Wextra -fPIC   -fPIC -std=gnu++11 -o CMakeFiles/UbuntuUpdatePanel.dir/UbuntuUpdatePanel_autogen/mocs_compilation.cpp.o -c /home/luca/dev/postmarketOS/unity8-stuff/system-settings/build/plugins/system-update/UbuntuUpdatePanel_autogen/mocs_compilation.cpp

Ignoring the fact that cmake 3.14.6 puts -std=gnu++11 into the command, they're otherwise identical and both produce an error in a build tree with cmake 3.16.4; so the problem seems to happen earlier in the build process.

@z3ntu
Copy link
Contributor Author

z3ntu commented Apr 17, 2020

I did bisect cmake today and this was the result:

d018d27c101869e4e2449f938df89d4f97c5b73c is the first bad commit
commit d018d27c101869e4e2449f938df89d4f97c5b73c
Author: Sebastian Holtermann <sebholt@xwmw.org>
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

@z3ntu
Copy link
Contributor Author

z3ntu commented Apr 17, 2020

Reported in the CMake repository: https://gitlab.kitware.com/cmake/cmake/-/issues/20598

@UniversalSuperBox
Copy link
Member

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants