Add support for cross-compilation
osrf-migration opened this issue · 6 comments
Original report (archived issue) by Silvio Traversaro (Bitbucket: traversaro).
Summary
It would be great to be able to compile the C++ library ignition-msgs, to compile it for target platform different from the one in which the project is being built (see https://cmake.org/cmake/help/v3.12/manual/cmake-toolchains.7.html#cross-compiling and https://en.wikipedia.org/wiki/Cross_compiler for some background on cross compilation). As ignition-msgs require code generation with tools that are compiled as part of the project itself, this is not trivial.
Motivation
Cross compilation is quite common, for example it is used when targeting embedded targets or WebAssembly.
Describe alternatives you've considered
A typical approach for cross-compilation of projects that require code generation as this one, is to have a parallel installation of the code generator for the host machine, and use that for code generation. An alternative is just to use the host project build system to generate the necessary C++ files, and use them directly in the cross compilation.
Based on this, I think there are two main alternatives to tackle this:
- One is to install the
ign_msgs_gen
protobuf plugin and install it in the host project, and then add options to manually specify an externalprotoc
compiler and an externalign_msgs_gen
protobuf plugin, that will be used in the cross-compiled project to use the host code generators. - An alternative is to add an option to install or export in some form the generate C++ code (that will be used in the host project), and add an option to avoid generation of the C++ code, and just use it externally (this option will be used in the cross-compiled project).
Additional context
The main motivation for tackling this issue is to be able to support all officially supported vcpkg triplets, see microsoft/vcpkg#8044 .
Original comment by Silvio Traversaro (Bitbucket: traversaro).
The problem discuss in this isssue and the first solution proposed are described in https://youtu.be/sBP17HQAQjk?t=773 .
Given that #60 has been merged I think we can close this issue.