diff --git a/build.sh b/build.sh index 7f21540b43..e65352edd2 100755 --- a/build.sh +++ b/build.sh @@ -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 - CC=clang CXX=clang++ cmake "${flags[@]}" $root 2>&1 | tee -a $log + 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 diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 8f55fef56c..35781cd053 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -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() #------------------------------------------------------------------------------- diff --git a/cmake/darwin-compiler-i386-generic.cmake b/cmake/darwin-compiler-i386-generic.cmake index b2ac14e6a3..e61a1a54cd 100644 --- a/cmake/darwin-compiler-i386-generic.cmake +++ b/cmake/darwin-compiler-i386-generic.cmake @@ -3,8 +3,10 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR i686) # Leave it generic since it could be clang, gnu, etc. -set(CMAKE_C_COMPILER cc -m32) -set(CMAKE_CXX_COMPILER c++ -m32) +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) diff --git a/cmake/linux-compiler-i386-multilib.cmake b/cmake/linux-compiler-i386-multilib.cmake index 770f38b483..e3cebcc094 100644 --- a/cmake/linux-compiler-i386-multilib.cmake +++ b/cmake/linux-compiler-i386-multilib.cmake @@ -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. -set(CMAKE_C_COMPILER cc -m32) -set(CMAKE_CXX_COMPILER c++ -m32) +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.