Allow cross compiling resource file
Needs ReviewPublic

Authored by vpinon on Oct 22 2017, 8:47 PM.



While cross-compiling Kdenlive with MXE, I had to use host's qrcAlias.
I followed the standard pattern, checking CMAKE_CROSSCOMPILING and the defined tool path.

Test Plan

Using it to build Kdenlive for 1 year (several ECM/Qt updates)

Diff Detail

R266 Breeze Icons
Lint Skipped
Unit Tests Skipped
vpinon created this revision.Oct 22 2017, 8:47 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptOct 22 2017, 8:47 PM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript
apol added inline comments.Oct 22 2017, 11:19 PM

Maybe some documentation on how to crosscompile it would be nice.
In fact it feels a bit random. How will the developer get this executable? It's not even installed...

vpinon added a comment.EditedOct 24 2017, 8:07 PM

Thank you Aleix,
You're right!
Before launching cmake for cross compiling, I build the tool for host (this requires to have Qt5 dev files on build host):
I haven't found a way to access the host compiler & libs within cmake (which has a toolchain file to switch to cross-compiling).
My complete cross compiling sequence is (in Makefile syntax for MXE):

cd "$(1)" && $(BUILD_CXX) -std=c++11 qrcAlias.cpp -o $(PREFIX)/bin/qrcAlias -fPIC $(shell pkg-config --cflags Qt5Core --libs Qt5Core)
mkdir "$(1)/build"
cd "$(1)/build" && cmake .. \
    -DCMAKE_BUILD_TYPE=Release \
$(MAKE) -C "$(1)/build" -j $(JOBS) install

Would you have directions for a better approach? Or should I just add in comment the line to build qrcAlias?
I wanted to have a look at how KF5_HOST_TOOLING works, but couldn't find where it is defined in ECM or in the frameworks that use it (kdecoration, kdeclarative)...
Edit: I've found this link, which of course implies building everything twice...
Note: if you want to see the rest of frameworks cross-building for Kdenlive

This comment was removed by vpinon.
apol added a comment.EditedOct 24 2017, 10:09 PM

Hey @vpinon. What's special about qrcAlias is that it's not installed. Usually this kind of tooling (thinking kconfigcompiler) is installed, then there's an easy way to pull it in.

I'd say that the ideal way to treat this is by rewriting the tool in cmake scripts (or python or a scripting language we agree it makes sense). This way this becomes a no-brainer.

As for this patch, I'd suggest adding something in such as:

If you are crosscompiling breeze-icons and need a binary resource, remember to define the following variable -DQRCALIAS_EXECUTABLE.

It isn't straightforward but it's also not a shot in the dark.

apol added a comment.Mar 27 2018, 11:16 PM

Something like this could be done here too D11735.
It's better because it allows the project to self-compile instead of relying on a pre-built version of the tool that isn't even being installed.