[CMake] How to build for 32bit using multiarch?

Kishore kitts.mailinglists at gmail.com
Tue Nov 29 09:39:59 EST 2011


On Tuesday 29 Nov 2011 10:50:13 AM Mathias Gaunard wrote:
> On 11/28/2011 05:58 PM, Kishore Jonnalagadda wrote:
> > I have recently moved to using 64bit Kubuntu Oneiric when supports
> > multiarch. I understand that building 32 bit from my 64 install is as
> > simple as adding the "-m32" option to gcc. Asking cmake to add that
> > flag is easy but i don't know how to ask cmake to only look for 32 bit
> > libraries in FindPackage() class. I have all the 32bit library (Qt)
> > dependencies installed and they are in /usr/lib/i386-linux-gnu. By
> > adding the "-m32" option compilation succeeds but as expected linking
> > fails complaining that i am trying to link to 64 bit libraries.
> > 
> > So, how do i ask cmake to look for 32bit libs?
> 
> I personally haven't found a good solution for this either.
> 
> What I currently do is the following
> set(CMAKE_SYSTEM_PROCESSOR i386)
> set(CMAKE_SYSTEM_LIBRARY_PATH /lib32 /usr/lib32 /usr/local/lib32)
> set(FIND_LIBRARY_USE_LIB64_PATHS OFF)
> set(CMAKE_IGNORE_PATH /lib /usr/lib /usr/local/lib)
> 
> Unfortunately the CMAKE_IGNORE_PATH is required. I created a bug about this.

Thanks for the input. In the meanwhile I tried to work past this by setting it 
up as a cross build using a toolchain files. However, i hit a road block when i 
discovered that not all libraries are multiarch friendly. In my case, 
qtmobility packages install to /usr/lib directly. I'm not ready yet to take 
the road of building/packaging qtmobility as well.

So i guess, i will now have to setup a VM for 32 bit builds. But thanks for 
the tip! :)
-- 
Cheers!
Kishore


More information about the CMake mailing list