[CMake] how to compile as 32bit on a 64bit Linux host ?

Martin Koller martin.koller at etm.at
Fri Feb 15 09:41:59 EST 2013


On Friday 15 February 2013 12:11:27 m. hergarden wrote:
> Can you share a bit more context? I suspect there may be no single
> correct answer, as it depends on your situation what the best way is.

I have a 64bit Linux server (RHEL5), which automatically builds our software every night 
(triggered via a Jenkins job - but that really shouldn't matter).
I'd like to use this server to first build the software for 32bit platforms
and then for 64bit platforms. Our customers should be able to choose their
runtime system being 32 or 64 bit)

> If you are using a toolchain file you will have to put the decision of
> using that file outside of your cmake file.

yes, that would be sufficient.
I'm just not sure if it is enough to change the compiler flags or if
there is more to change (paths etc.)

and what about that wiki page:
> > http://www.vtk.org/Wiki/CMake_Cross_Compiling#Information_how_to_set_up_various_cross_compiling_toolchains
> > => "On mixed 32/64 bit Linux installations cross compilation cannot be used to build for 32/64 bit only."

is it wrong or outdated ?

> You can also opt to put a
> check inside your cmake file and set compiler flags (-m32 / -m64)
> accordingly.
> Using a toolchain file is more flexible when releasing a project, but
> autoconfiguring is nice when running builds on buildservers through
> ctest scripts.
> 
> Regards,
> Micha
> 
> On 02/15/2013 11:46 AM, Martin Koller wrote:
> > Hi all,
> >
> > for the question above I found different answers on the web, so I'm puzzled
> > and wanted to know an authoritative answer from the cmake gurus.
> >
> > What I found:
> > http://www.vtk.org/Wiki/CMake_Cross_Compiling#Information_how_to_set_up_various_cross_compiling_toolchains
> > => "On mixed 32/64 bit Linux installations cross compilation cannot be used to build for 32/64 bit only."
> >
> > but also:
> >
> > http://stackoverflow.com/questions/4131158/how-to-cross-compile-for-linux-x86-with-linux-amd64-cmake-and-g
> > => talking about using a toolchain file ...
> >
> > so please tell me: what is the correct way or is there no way ?
> >
> 
-- 
Best regards/Schöne Grüße

Martin

A: Because it breaks the logical sequence of discussion
Q: Why is top posting bad?

()  ascii ribbon campaign - against html e-mail 
/\  www.asciiribbon.org   - against proprietary attachments

This mail was not scanned before sending.
It was sent from a secure Linux desktop.


More information about the CMake mailing list