[CMake] Cross-compilation vs FindQt4.cmake

Andrey. ahippo at yandex.ru
Mon May 31 08:29:29 EDT 2010


>> I would like to know whether there is some progress on making FindQt4.cmake
>> friends with cross-compilation.
> Not much, unfortunately.
Not a piece of good news.

>> Writing to you, as you seems to be a maintainer of FindQt4.cmake in both
>> Cmake and KDE repositories.
> Well, Clinton Stimpson is the maintainer of FindQt4.cmake in CMake, and I 
> mostly merge the fixes there to the version in KDE.
> So actually he's the maintainer, but I'm also not the completely wrong person 
> here :-)
Sorry, I misunderstood the commit history a little.

>> Also, I'm interested to know, why FindQt4.cmake doesn't utilize pkg-config
>> for most introspection of Qt. Qt4 provides nice .pc files.
>> pkg-config has some built-in support for cross-compilation through
>> PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_LIBDIR while qmake doesn't. Simply
>> compiling qmake to be used during cross-compilation and compiling qmake to
>> return correct include/library paths are two different tasks. In first
>> case, qmake can be used for multiple cross-compilation environments.
> In general, CMake tries not to rely on any additional external tools, and 
> pkg-config is one of those tools.
Instead of blindly relying on pkg-config, it may be used as a hint in some complex situations like cross-compiling.
And anyway, in case of Qt, CMake relies on an external qmake, which is not itself required to be present at compile time (in contrast to moc/uic).

> I have (until now) never cross compiled anything with Qt.
> How does a typical Qt installation for cross compiling look like ?
> I guess it has native tools (qmake, moc, uic), etc.
I think, the installation heavily differs depending on cross-compilation environment used (buildroot, scratchbox, etc).
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.

> When FindQt4.cmake is executed, it queries qmake for information. 
> Does this also work for a cross-compilation installation of Qt ?
> What are the results of a FindQt4.cmake with a cross-compiling qmake ?
If no special care is taken, FindQt4 finds qmake from host system that returns information about host library ignoring CMAKE_FIND_ROOT_PATH (and that's wrong).
If PATH variable is modified appropriately, FindQt4 finds specially compiled qmake with good version.
It's possible to compile qmake to return information, suitable for cross-compilation.
But it's then required to recompile qmake if a change prefix somewhere.

>> 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.

> CC'ing the cmake -list.
OK.

-- 
Andrey Hippo.


More information about the CMake mailing list