[CMake] Adding cross-compiler support to CMake ...
William A. Hoffman
billlist at nycap.rr.com
Fri Sep 8 13:59:32 EDT 2006
At 12:28 PM 9/8/2006, Michael Casadevall wrote:
>Hrm, interesting idea, I admit that it didn't occur to me, although I
>don't see how it really is that different. In your case, you simply
>setting the same variables twice for local and cross-compilation,
>which seems a little kludgy. I mean, you still need to handle all the
>CMAKE_CROSS variables and then have CMake call itself (or at least
>call the code internally twice to build two sets of Makefiles), which
>could be a debugging nightmare. Also, I don't want to think what the
>Makefiles would look like trying to find a native version of a tool
>from the cross-compiling Makefile, and then get that tool to build if
>it isn't. Also, you'd need a lot of code to make sure each instance
>of Makefile generator got the right variables - and to put those
>variables in the first place would require adding them to a .cmake
>file. I'm not discrediting your idea, but it seems its going to
>require more work then it would be at first glance, possibly more
>then my solution.
>
>Anyway, on the notion of compiling, do we have any plans for
>supporting autotools notion of --target. I'm not for it myself,
>because in most apps, --target is more of an alias to set what files
>should be built, and the -D flags (for instance, --target=arm-linux
>in GCC would set -DARM_GCC, and set up the Makefiles to build the arm
>compiler source). If we ever did it, we should replace the notion of
>--target, and maybe support something like Target Profiles, but
>that's for another post, another day.
>Michael
As a CMake developer I think it would be much easier to do it with
two makefiles. As far as I can tell there are two modes of cross compiling.
1. The whole project is being built for some other architecture.
2. The project has some targets that need to be built local and some
that need to be built for some other architecture.
For 1, the makefiles we have are just fine, it is a matter of setting all
the variables correctly.
For 2, two build trees will not be that hard to manage, with of course a top
level makefile that can go into both trees, local first then target. If you
use an executable from the build tree via its cmake target name it will be
easy to tell where to find the correct executable.
From looking at a configure script I don't see CC and CC_CROSS. There is
only CC and cross_compiling=(no|yes). They do not have two sets of variables,
so why should we need two sets?
-Bill
More information about the CMake
mailing list