[CMake] Cross-compilation vs FindQt4.cmake

Andrey. ahippo at yandex.ru
Tue Jun 1 06:05:20 EDT 2010


> > I think, the installation heavily differs depending on cross-compilation
> > environment used (buildroot, scratchbox, etc).
>
> If I remember correctly, scratchbox means running a virtual machine, so from
> this POV building inside scratchbox is not cross compiling, and in that
> regard it shouldn't need anything special from cmake.
Yes, you're right.
And this emphasizes the difference between various cross-compilation environments and techniques.

> Buildroot doesn't do that, right ?
Right, buildroot doesn't use virtual machines.
It compiles cross-toolchain, some tools and then use them to compile packages for target system.

> > Currently, I'm using some
> > hand-written environment, mostly resembling buildroot. It consists of:
> > 1) host system with general native libraries and utilities;
> > 2) cross-compiled libraries and executables for target system placed at
> > some prefix; 3) special tools, required for cross-compilation and related
> > stuff (cross-toolchain, qmake, image/firmware generators go here).
> >
> > Tools at item 3) usually must match specific requirements on version used.
> > In case of Qt, I have statically compiled qmake, moc, uic, lrelease, etc
> > against exactly the same version of Qt used for target system.
>
> So this seems to be the actual crosscompiling case.
Right.

> If you want to use a specific version of Qt, you have to make sure cmake finds
> the qmake for the Qt you want to use.
That's clear.

> This can be done by
> - setting CMAKE_PREFIX_PATH so that it points to the base directory where that
> qmake is installed
> - setting QT_QMAKE_EXECUTABLE directly when running cmake:
> cmake -DQT_QMAKE_EXECUTABLE=/your/qmake
I've already mentioned, that I simply modify PATH variable as it works both for qmake and other tools.
I don't like touching CMAKE_PREFIX_PATH, because then cmake will attempt to look for libraries in "${CMAKE_PREFIX_PATH}/lib" and can pick up libraries, compiled for host system.
Also, I'm not sure, how well CMAKE_PREFIX_PATH would work together with CMAKE_FIND_ROOT_PATH.

> How far do you get with this ?
1) FindQt4 finds my qmake
2) FindQt4 runs "qmake -query" or "qmake CMakeTmpQmake/tmp.pro"
3) FindQt4 gets, i.e. QT_INSTALL_LIBS:/I/configured/qmake/for/this/root/usr/lib/qt4
4) Obtained QT_INSTALL_DIR is wrong, because it may point to host libraries, required for moc, or somewhere else.
5) Qt4-based application fails to build because of incorrect libraries, supplied for linkage.

> > >> Currently, I'm going to use simple FindQt4.cmake with some hardcoded
> > >> paths, that will override system wide one.
> >
> > It's worth mentioning, that I managed to successfully compile a qt4-based
> > application with such a hacked FindQt4.cmake with bunch of set() statements
> > and a couple of include() directives.
>
> Yes, what makes FindQt4.cmake big is all the flexibility to find everything
> for the different versions on the different OSs. It started small...
In addition, there are a great number of Qt components, which magnifies the output by a factor of 20.:)

-- 
Andrey Hippo.


More information about the CMake mailing list