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

Michael Casadevall sonicmctails at aol.com
Thu Sep 7 18:42:25 EDT 2006


1. Never seen that. autotools should only enter cross-compiling mode  
if --host is set, and its different the current platform, or if both  
build and host are set with different values.

2. In an earlier email which got disconnected from this one stated  
there would be a configuration question CROSS_COMPILE. I'll attach  
that email to the bottom of this one

I am aware of that method of cross-compiling, and its horrible. You  
also need to add lines for RANLIB, AR, and usually some other  
utilities and then remove TRY_RUN. I still won't call that cross- 
compiler support, CMake should undersatnd if its cross-compiling, and  
it should be, in theory, as easy as compiling natively. Also, it  
mucks the filenames and such. Try cross-compiling in CMake from Mac  
OS X to Windows. Do-able with minigw, and autotools, but it would be  
a nightmare for CMake based projects.

Anyway, looking through the source of CMake, this is going to a bit  
messy. Right now, it doesn't have a concept of multiple platforms,  
and the Makefile generator isn't written in a way that it would be  
easy to add it. I'm poking through the Module code now, and seeing  
how it all comes together and see specifically what needs  
modification now. I'm deciding if a new generator is needed, or the  
Unix one can be recycled with a lot of hack and slashing.
Michael

On Sep 7, 2006, at 5:59 PM, William A. Hoffman wrote:

> At 05:38 PM 9/7/2006, Michael Casadevall wrote:
>> I would disagree with that. Your using a cross-compiler, but CMake
>> doesn't know its cross-compiling, and doesn't know how to handle
>> exceptions for a cross-compiler. I cross-compile a LOT of packages -
>> autotools packages are the easiest to compile in general, after you
>> give it all the values for information it doesn't have.
>
> OK, but I am still not clear on the exact functionality that autotools
> provides.  Once you give cmake all the information it needs, it  
> should work as
> well.   So, what could we add to CMake to match what autotools does?
> Here is the list I have so far:
>
> 1. test for cross compile, basically do a try run and if it fails,
> assume you are cross compiling.  (I always hated that about autotools
> in the past because a bad LD_LIBRARY_PATH and it thinks you are  
> cross compiling.)
>
> 2. When you determine cross compile mode (command line option? or  
> automatic),
> Print an error for each try_run that is attempted cmake prints out  
> a message
> saying the following variable must be set in the pre-load cache  
> file for cross
> compiling.
>
> 3. add the notion of host and target properties to cmake library  
> and executable
> targets.
>
>
> Can you describe what autotools does for cross compiling and how?
>
>> Anyway, I'm planning my angle of attack in programming right now on
>> how to do this, but not knowing CMake's guts is making this a little
>> harder.
>
> Basically you need to set a bunch of variables you can use the
> cmake -C initialCachefile.cmake to load all of the variables.
>
> So, something like this:
>
> export CXX=cxx-cross-compiler
> export CC=cc-cross-compiler
> cmake -C buildForHost.cmake
> And buildForHost.cmake would contain a bunch of SET commands that set
> all the variables you need to build for that host.
>



More information about the CMake mailing list