ubports / crossbuilder

A debian package cross building tool using LXD
13 stars 17 forks source link

crossbuilder: fix missing moc tool for cmake #51

Closed mardy closed 3 years ago

mardy commented 3 years ago

It's not clear how cmake finds the moc tool, but for some reason it expects to find it in /usr/lib/$HOST_FARCH/qt5/bin/. So, let's put it there.

Also, rework a bit the way that qmake is setup, by using a more robust approach that does not require the QT_SELECT=qt5 trick: we simply install qmake in /usr/local/bin/, just like clickable is doing.

Last but not least, correct the value of the HOST_FARCH variable, which was computed wrong (it is used in this part of crossbuilder anyway, so changing it should not bring any side-effects).

peat-psuwit commented 3 years ago

Regarding moc's path, there's some clue in /usr/share/cmake-3.5/Modules/AutogenInfo.cmake.in:

set(AM_QT_MOC_EXECUTABLE "@_qt_moc_executable@")
[...]
if(DEFINED ENV{DEB_BUILD_MULTIARCH} AND DEFINED ENV{DEB_HOST_MULTIARCH} AND "@_qt_moc_executable@" MATCHES "/usr/lib/$ENV{DEB_HOST_MULTIARCH}/qt5/bin/moc")
  set(AM_QT_MOC_EXECUTABLE "/usr/lib/$ENV{DEB_BUILD_MULTIARCH}/qt5/bin/moc")
endif()

@_qt_moc_executable@ is filled in by CMake itself using the value from Qt5::moc, which in turn defined by MultiArchCross.cmake. Curiously the part after [...] is added by Ubuntu and might be wrong. Maybe it's because we've backported newer Qt.

Other than that, I used this to cross-build trust-store for armhf, which also failed previously with moc error, successfully. I haven't tried using qmake, but from my past experience, and given that support for cross-building qmake project with debhelper doesn't arrive until debhelper level 11, I've given up trying to cross-build qmake project entirely.