[CMake] Problem with cross-compiling and external projects

David Cole DLRdave at aol.com
Sat Mar 7 08:29:18 EST 2015


It does not happen automatically, but it is not hard to pass down the tool
chain as an additional parameter to the configure step of your external
projects. There may be other adjustments necessary, too. I'm not sure, I
still haven't done a lot of cross-compiling myself with CMake yet.

Cross-compiling came after ExternalProject, took a long time to stabilize
into something useful, and only works with certain generators... I guess it
makes sense that you'd mostly want to use the toolchain for
ExternalProjects. Perhaps it's time for a patch. ;-)

The focus with ExternalProject when it was first built was actually to
enable building any project, even ones that don't use CMake to drive their
builds. The decision was made early on NOT to pass down most CMake
settings, so the developer writing the ExternalProject_Add call is the one
deciding what needs to be passed down. (Consider, for example, the case of
building a set of libraries, both Debug and Release, both Static and
Shared, for many architectures, all as part of one overarching superbuild.
Passing all those settings down from the parent might make that sort of
thing difficult or confusing.)

Anyhow, the short answer was, no, CMake doesn't do it automatically. You'll
have to do it yourself. I'd recommend having a top level "extra CMake
parameters" variable that gets passed to all your ExternalProject_Add calls.


HTH,
David C.


On Friday, March 6, 2015, Richard Shaw <hobbes1069 at gmail.com> wrote:

> I've got a cmake based project that can optionally build static versions
> of most of its dependencies and it works fine on Linux and MSYS2+MinGW.
>
> The problem is when I try to cross compile using MinGW on Linux. I would
> expect cmake would be smart enough to know if the parent project is being
> built with a particular toolchain that the external projects (also cmake
> based) would use the same toolchain but that doesn't appear to be what's
> happening.
>
> Is there some setting I'm missing here?
>
> I'm currently running 3.0.2 on Fedora linux but this has been happening on
> 2.8.X as well.
>
> Thanks,
> Richard
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150307/dbc7eb67/attachment.html>


More information about the CMake mailing list