[CMake] Adding cross-compiler support to CMake ...

William A. Hoffman billlist at nycap.rr.com
Fri Sep 8 15:19:35 EDT 2006


At 03:02 PM 9/8/2006, Alan W. Irwin wrote:
>On 2006-09-08 13:59-0400 William A. Hoffman wrote:
>
>>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 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.
>
>I have no expertise in cross-compiling, but I am trying to follow this thread
>anyway to learn something.
>
>Your last paragraph that I quoted above seems to imply a single cmake
>invocation would prepare both a build tree for the local architecture and a
>build tree for the different architecture. If that interpretation of what
>you said is correct, then that seems over-complicated to me.  Instead, I
>would think that if somebody wants to build for both a local and different
>architecture, why not simply have two completely independent build trees
>with two completely independent invocations of cmake?  One invocation would
>have appropriate options for the local architecture (as for cmake now), and
>one would have appropriate options for the different architecture (as in 1).
>Neither invocation would know about the other.

The trouble is that in the case of 2, when you build
some sort of code generation executable as part of the build and run it during
the build, it has to be built for the host or local machine.   

For example:

add_executable(generate generate.c)
set_target_properties(generate PROPERTIES HOST_ONLY 1)
add_custom_command(COMMAND generate  ....)

The makefiles need to have access to the generate command.   Having it managed by
one cmake invocation is just to make it easier for the end user. 
We could require two separate runs of cmake, but also have some way of pointing to
a host or local build tree build.

-Bill



More information about the CMake mailing list