[CMake] providing host binary and target library cmake-package when cross compiling

Pascal Bach pascal.bach at siemens.com
Mon Oct 19 10:11:57 EDT 2015


Hello

I'm working on CMake support for Apache Thrift [1].
It is currently already buildable using CMake. However while trying to add support for generating a ThriftConfig.cmake I ran into some issues
related to cross compilation.

Thrift has the following components relevant to the problem:

C++ library (.so library)
Thrift compiler (binary)

End users/developers usually us thrift in the following way:
Thrift IDL ==[Thrift compiler]==> C++ files ==[GCC + Link with thrift.so]==> final.so

My idea for the resulting ThriftConfig.cmake was to provide two imported targets Thrift::libthrift and Thrift::compiler.
Thrift::compiler can be used to generate C++ files from Thrift IDLs and Thrift::libthrift is what the resulting binary should link against.
This works well if no cross compilation is involved.


Now for the cross compilation case. I'm using OpenEmbedded [2] which provides two sysroot directories:
1. sysroot_x86 containing binaries and libraries for the host: libthrift.so (x86 library), thrift (x86 executable)
2. sysroot_arm containing binaries and libraries for the target: libthrift.so (arm library), thrift (arm executable)

In the cross compiling case the Thrift::compiler target must be executable on the HOST and Thrift::libthrift must be a target library.
This means the library should be from sysroot_arm but the binary from sysroot_x86.
I'm not able express this an a good way.

Does anyone know how to do this? Is there an example how this could be done?

Thanks for your help.

Regards
Pascal


[1] http://thrift.apache.org/
[2] http://www.openembedded.org/wiki/Main_Page


More information about the CMake mailing list