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

clinton at elemtech.com clinton at elemtech.com
Fri Feb 15 10:33:31 EST 2013


Or simply specify -m32 at the first configure
CFLAGS=-m32 CXXFLAGS=-m32 cmake ../src

find_library() works correctly if you do that, and it automatically detects if the 32 bit libraries are in /usr/lib32 or /usr/lib.

Clint

----- Original Message -----
> Hello,
> 
> On 15/02/13 15:41, Martin Koller wrote:
> > I'm just not sure if it is enough to change the compiler flags or if
> > there is more to change (paths etc.)
> This is why I prefer toolchain files over adding an option inside the
> CMakeLists.txt files. On some systems you probably also want to change
> the search path for libraries in particular (often /usr/lib32 instead of
> /usr/lib), so that the find_package() commands and similar does not find
> the incompatible 64 bit libraries.
> 
> In our system we both have an option to "force 32 bit" (which basically
> just adds -m32 to compile flags), and I have a toolchain file (which
> corresponds to my stackoverflow answer). I find the toolchain file to be
> more accurate/flexible to get correct setup.
> 
> In addition to the three lines you might also want to set paths (I do
> not need that on my system for my projects), something along the lines of:
> 
> set(CMAKE_FIND_ROOT_PATH  /usr/lib32)
> set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
> set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
> set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
> 
> Cheers,
> Yngve
> --
> 
> 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
> 


More information about the CMake mailing list