[CMake] Building a tool to run on the host when cross-compiling

Christopher Lansing c.lansing at gmail.com
Thu Jan 17 15:53:40 EST 2013


Hi,

I'm trying to use CMake to build a set of libraries with the intention of
being able to build the library on a few different systems, and also
cross-compile. Some of the source code for the library is generated from
description files using a tool included (as source) with the library code.
I want to be able to build the tool, use it to generate the sources, then
build the library. That part works.

When trying to compile for a system different from the host, it generates
the tool for the target, which the host can't run. If I understand the
wiki, the suggested approach to deal with this is two separate builds - one
configured to build for the host, and one configured to build for the
target, importing the tool generated by the host build (
http://www.cmake.org/Wiki/CMake_Cross_Compiling#Using_executables_in_the_build_created_during_the_build
).

I'm trying to find a way to do this without requiring a second build. I
suppose I could have each CMakeLists.txt set up custom target properties
for the compiler flags depending on whether I'm cross compiling or not for
- but that seems like a lot of extra junk to stick in every file.

Is there a way to do this - or will I need to find some way to make the
dual build approach work for me?

Thanks,
Christopher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130117/7afe1ced/attachment.htm>


More information about the CMake mailing list