Respect the CC and CXX environment variables when cross building.

This commit is contained in:
Miguel A. Colón Vélez 2015-01-04 00:56:47 -05:00
parent e23e2ac327
commit 8440d263cd
4 changed files with 17 additions and 6 deletions

View File

@ -20,6 +20,8 @@ flags=(-DCMAKE_BUILD_PO=FALSE)
cleanBuild=0
useClang=0
# 0 => no, 1 => yes, 2 => force yes
useCross=0
for ARG in "$@"; do
case "$ARG" in
@ -38,7 +40,7 @@ for ARG in "$@"; do
--wx28 ) flags+=(-DWX28_API=TRUE) ;;
--gtk3 ) flags+=(-DGTK3_API=TRUE) ;;
--no-simd ) flags+=(-DDISABLE_ADVANCE_SIMD=TRUE) ;;
--cross-multilib ) flags+=(-DCMAKE_TOOLCHAIN_FILE=cmake/linux-compiler-i386-multilib.cmake) ;;
--cross-multilib ) flags+=(-DCMAKE_TOOLCHAIN_FILE=cmake/linux-compiler-i386-multilib.cmake); useCross=1; ;;
-D* ) flags+=($ARG) ;;
*)
@ -92,7 +94,11 @@ mkdir -p $build
cd $build
if [[ "$useClang" -eq 1 ]]; then
if [[ "$useCross" -eq 0 ]]; then
CC=clang CXX=clang++ cmake "${flags[@]}" $root 2>&1 | tee -a $log
else
CC="clang -m32" CXX="clang++ -m32" cmake "${flags[@]}" $root 2>&1 | tee -a $log
fi
else
cmake "${flags[@]}" $root 2>&1 | tee -a $log
fi

View File

@ -64,6 +64,7 @@ option(USE_ASAN "Enable address sanitizer")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(USE_CLANG TRUE)
message(STATUS "Building with Clang/LLVM.")
endif()
#-------------------------------------------------------------------------------

View File

@ -3,8 +3,10 @@ set(CMAKE_SYSTEM_NAME Darwin)
set(CMAKE_SYSTEM_PROCESSOR i686)
# Leave it generic since it could be clang, gnu, etc.
if("$ENV{CC}" STREQUAL "" OR "$ENV{CXX}" STREQUAL "")
set(CMAKE_C_COMPILER cc -m32)
set(CMAKE_CXX_COMPILER c++ -m32)
endif()
# If given a CMAKE_FIND_ROOT_PATH then
# FIND_PROGRAM ignores CMAKE_FIND_ROOT_PATH (probably can't run)

View File

@ -4,8 +4,10 @@ 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 "")
set(CMAKE_C_COMPILER cc -m32)
set(CMAKE_CXX_COMPILER c++ -m32)
endif()
# cmake 2.8.5 correctly sets CMAKE_LIBRARY_ARCHITECTURE for Debian multiarch.
# Be really strict about what gets used.