cmake: always set -m32 for 32 bits build

It fixes cross-compilition issue when users/env set CC/CXX variables
This commit is contained in:
Gregory Hainaut 2015-02-22 22:14:26 +01:00
parent 6b48784709
commit b5612ec622
1 changed files with 7 additions and 1 deletions

View File

@ -4,9 +4,15 @@ set(CMAKE_SYSTEM_PROCESSOR i686)
# It could be i?86-*linux-gnu, x86_64-*linux-gnu, x86_64-*linux-gnux32, etc.
# Leave it generic to only support amd64 or x32 to i386 with any compiler.
if("$ENV{CC}" STREQUAL "" OR "$ENV{CXX}" STREQUAL "")
if ("$ENV{CC}" STREQUAL "")
set(CMAKE_C_COMPILER cc -m32)
else()
set(CMAKE_C_COMPILER $ENV{CC} -m32)
endif()
if ("$ENV{CXX}" STREQUAL "")
set(CMAKE_CXX_COMPILER c++ -m32)
else()
set(CMAKE_CXX_COMPILER $ENV{CXX} -m32)
endif()
# cmake 2.8.5 correctly sets CMAKE_LIBRARY_ARCHITECTURE for Debian multiarch.