[CMake] CMake, QT5 and cross compilation

Dave Flogeras dflogeras2 at gmail.com
Sat Dec 19 13:27:10 EST 2015


On Thu, Dec 17,
>
> So, here is my question: How can I overwrite the moc-executable (and uic
> etc) path to use another moc version than the one found by the
> find_package mechanism? If I use the moc which is part of my Linux host
> PC rather than the arm compiled moc in the Raspberry file system, the
> code generation should be fine, and afterwards, I will link against the
> Raspberry Pi Qt5 libraries.
>

Hi Hauke,

In the past, I have done this (wth Qt4) by generating, then hand
editing the CMakeCache.txt to change the location of the moc
executable to the native one.  Now that reading your post made me
re-visit this it seems to have two problems.  First, with Qt5 finder,
it doesn't seem to expose the moc location in the cache.  Also I
recall doing it the way I described works only if your native version
is exactly the same as the arm version, otherwise you get errors like
"this header was generated with a different version of Qt"....  It
always seemed pretty brittle.

Another way that I do this, is by generating a toolchain file, which
forces cmake to look only inside the RPi root directory.  This means
it will find the cross compiled moc executable.  Then I have qemu set
up with the Linux binfmt driver so that I can execute arm binaries
'natively'..  This is not trivial, and requires setting up a wrapper
so that qemu can find the arm linker-loader etc. but you may be able
to use this as a solution.  I (loosely) followed this guide, modifying
the wrapper to my system.

https://gentoo-handbook.lugons.org/proj/en/base/embedded/handbook/index.xml?style=printable&part=1&chap=5

Good luck.

I'd also like to hear if there is a different solution to this problem.


More information about the CMake mailing list