From b5612ec622ba99c5fda1ab33dbcdf0f8023e7f0e Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sun, 22 Feb 2015 22:14:26 +0100 Subject: [PATCH] cmake: always set -m32 for 32 bits build It fixes cross-compilition issue when users/env set CC/CXX variables --- cmake/linux-compiler-i386-multilib.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/linux-compiler-i386-multilib.cmake b/cmake/linux-compiler-i386-multilib.cmake index e3cebcc094..2a6ba10290 100644 --- a/cmake/linux-compiler-i386-multilib.cmake +++ b/cmake/linux-compiler-i386-multilib.cmake @@ -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.