Build breaks with cmake 3.16
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.