[CMake] Adding cross-compiler support to CMake ... (fwd)

Michael Casadevall sonicmctails at aol.com
Wed Sep 6 17:21:54 EDT 2006


Point taken in regards to the shell, although busybox which is pretty  
standard on embedded devices and that can run configure scripts. I  
was referring to obscure platforms such as a DEC workstation. Anyway,  
in regards to autotools, this is typically how you cross compile  
(this is assuming ideal conditions, which is extremely rare with  
cross-compiling with autotoos):

$> ./configure --build=i686-apple-darwin8.7.0 --host=armeb-unknown-linux
(build on Mac OS X 10.4.7. Intel. Resuting binaries should be for ARM  
big-endian Linux (this is an actual device I own))

Configure will print stuff like this (this is from memory, I don't  
have a cross-compiler installed at the moment since I just reformatted)
check if we are cross-compiling ... no
checking build system type... i686-apple-darwin8.7.1
checking target system type... armeb-unknown-linux
checking host system type... armeb-unknown-linux
...
checking for armeb-linux-gcc... yes
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking if armeb-linux-gcc is a cross-compiler... yes
checking whether we are cross compiling... yes
checking for gcc ... yes
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
(... includes special tests for cross-compiling)
config.status: creating Makefile

$> make
gcc some-tool-needed-during-build.c -o some-tool-needed-during-build
armeb-iinux-gcc -c file-to-be-crossbuilt.c -o file-to-be-crossbuilt
./some-tool-needed-during-build *blah*

You get my point. Unfortunately, it doesn't work like this very  
often, and in fact the only package I've even seen properly generate  
build tools natively and cross-compile the rest is binutils and GCC  
itself. Anyway, the point of cross-compiling is that you don't need  
to run the compile on said device, so autotools in its current form  
fits all three scenarios, the only reason I brought it up was that / 
bin/sh on UNIX-like systems is pretty much a universal standard, and  
configure knows how to handle quite a few obscure compilers.

On Sep 6, 2006, at 5:15 PM, Sean McBride wrote
> I'd just like to mention that the Mac community would dearly love  
> to see
> cross-compilation support in cmake.
>
> Are you familiar with Apple's concept of a "Universal Binary":
> <http://en.wikipedia.org/wiki/Universal_binary>
>
> Basically, it's a kind of cross compilation.  On a PowerPC Mac you can
> compile your executable for both PPC and Intel Macs, and vice versa.
> CMake does support Universal Binaries actually, you may want to see  
> this
> bug for background:
> <http://www.vtk.org/Bug/bug.php?op=show&bugid=2492>

This works fine with CMake. Add C/CXX flags -march ppc -march i386 (I  
think, been awhile, I can look this up), and gcc will spit out a  
university binary. Rosetta works for command line tools, so it will  
work perfectly. I've done this with a few other packages that don't  
use autotoos.
Michael




On Sep 6, 2006, at 4:21 PM, William A. Hoffman wrote:

> At 03:55 PM 9/6/2006, Brandon J. Van Every wrote:
>> Michael Casadevall wrote:
>>>>
>>>> My intent here is not to start a flamewar between autotools and  
>>>> cmake, In some cases, autotools is the proper tool vs cmake due  
>>>> to cross-compiling (which will hopefully fixed) and the fact  
>>>> that you need the cmake executable to build any CMake package.  
>>>> autotools configure script merely needs a shell interpreter,
>>
>> What do you mean "merely" needs a shell interpreter?  For a fair  
>> chunk of embedded devices out there, that's tantamount to saying  
>> that the Titanic "merely" needs to pull into port.  There are 3  
>> cases for embedded devices:
>>
>> - systems with a Bourne shell and ccmake available
>> - systems with a Bourne shell available
>> - systems without any kind of shell, or really any kind of resources
>>
>> Yes, Autoconf has more cross-compilation reach than CMake at  
>> present, but it hardly covers everything.
> Autoconf may need only shell, but CMake only needs a C++ compiler.   
> Which if you are
> building a c++ program, you should already have, but you are not  
> always
> going to have a shell.
>
> As for cross-compilation support, I have never done much with it,  
> what tools does
> autoconf provide to support cross-compiling?  If someone who has  
> used autoconf for
> cross compiling could explain how it works with autoconf, it would  
> be helpful when
> we add support in CMake.
>
> -Bill
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list