[CMake] Recommended Multilib Build Approach?

m.hergarden m.hergarden at euphoria-it.nl
Tue Jul 31 01:57:15 EDT 2012


On 07/30/2012 11:28 PM, Xavier Besseron wrote:
> On Mon, Jul 30, 2012 at 9:44 PM, Alexander Neundorf
> <a.neundorf-work at gmx.net> wrote:
>> On Monday 30 July 2012, Xavier Besseron wrote:
>>> To build i386 binaries on my 64-bit system with multilib, I just do
>>> something like this:
>>>
>>> mkdir build-i386
>>> cd build-i386
>>> CFLAGS="-m32" CXXFLAGS="-m32" LDFLAGS="-melf_i386" cmake ../src/
>>>
>>> And to build x86-64 binaries on my 64-bit system, I don't need to
>>> specify anything since it is the default behavior.
>> Is this maybe somewhat similar to the fat binaries on OSX ?
>
> No, I don't think so. You have to use two build directories, one for
> 32-bit code, one for 64-bit code. At the end, you will have two
> different binaries.
>
>
>> How is this handled by CMake ?
>
> This is quite independent of CMake. It works with other build systems
> like autotools/makefile as well.
>
> CFLAGS="-m32" CXXFLAGS="-m32" tells CMake to pass the '-m32' to the C
> and C++ compilers.
> It tells the compiler to generate code that runs on any i386 system
> (cf gcc manpage).
>
> LDFLAGS="-melf_i386" tells CMake to pass the '-melf_i386' to the linker.
> It tells the linker to use the i386 ELF format for the binary (cf ld manpage).
>
> This works for GNU compiler/linker at least. I haven't tried other compilers.
>
>
> Xavier
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
On Linux there is an application called linux32 that changes the way the 
os presents itself to an application. It will help the cmake modules 
make better decisions about the platform they are building on.

Hth,
Micha


More information about the CMake mailing list