Cross compiling KDE / Nokia N900

Alexander Neundorf neundorf at kde.org
Wed Dec 23 14:06:18 CET 2009


On Tuesday 22 December 2009, Thiago Macieira wrote:
...
> We've been successful at getting Qt to cross compile for the N900. It works
> much faster and requires no VM. In fact, it works with build farms too, so
> get all the benefits of a normal build.
>
> Any chance we can get an effort started to make KDE cross-compileable?

Yes, it's also on my todo, but it would be really nice if somebody else could 
actually do the work and I would just "guide" throught the necessary steps.

There are mainly three things which lead to problems when cross compiling:
1) try to build and run executable during the configure check
2) running executables during the configure step to find out information
3) running executables during the build step to do something.

1) is the hardest one. If somebody does a try_run (check_c_source_runs()) in a 
cross compile, it will build the executable, but it will not try to run it 
(since it can't, in general). Instead cmake will provide a template cmake 
script file prepared so that the expected values from the try_run() can be 
entered there manually. Also the compiled executable is made available, so 
that the developer can take it, run it on the target and in this way figure 
out the result which have to go into the prepared cmake script file. This 
file than has to be preloaded into cmake using -C on the next cmake run.
Doing this for all try_run()s is actual work.

2) We do this e.g. for Qt (FindQt4.cmake calls qmake), we query kde-config4, 
some find-modules call pkg-config (I'm not sure how to handle pkg-config when 
cross compiling, some env.vars could be set so that it finds only in the 
target root dir, ...). All these steps could be in some way done differently 
when cross compiling (e.g. only try to find qmake and then expect that the 
headers will be in the <qmake_dir>/../include etc. 
This can be guarded in 
if(CMAKE_CROSSCOMPILING)
   ...
endif(CMAKE_CROSSCOMPILING)


3) execute tools build during the build.
This is not a real problem, it's just a bit of work. We already "export" our 
libraries in kdelibs (KDELibs4LibraryTargets.cmake), and also separate from 
this our executable targets (KDELibs4ToolsTargets.cmake).
For cross compiling, these executable targets have to be available from a 
native build, and then this file can be loaded into the cross-compiling 
kdelibs and used there in the add_custom_commands/add_custom_targets().
Again this needs some 
if (CMAKE_CROSSCOMPILING) guards, most probably mainly in KDE4Macros.cmake, 
but then it should work.

> PS: maybe move this discussion to kde-buildsystem? Hereby I give my ok to
> move my part of the thread out of ev-membership.

Done :-)

Alex




More information about the Kde-buildsystem mailing list