Merge pull request #415 from micove/build-cleanup

Improve build system.
This commit is contained in:
Gregory Hainaut 2015-01-06 21:36:24 +01:00
commit a0d54df522
6 changed files with 52 additions and 18 deletions

View File

@ -20,12 +20,13 @@ flags=(-DCMAKE_BUILD_PO=FALSE)
cleanBuild=0
useClang=0
Build64=0
# 0 => no, 1 => yes, 2 => force yes
useCross=2
for ARG in "$@"; do
case "$ARG" in
--clean ) cleanBuild=1 ;;
--clang ) flags+=(-DUSE_CLANG=TRUE); useClang=1; ;;
--clang ) useClang=1; ;;
--dev|--devel ) flags+=(-DCMAKE_BUILD_TYPE=Devel) ;;
--dbg|--debug ) flags+=(-DCMAKE_BUILD_TYPE=Debug) ;;
--strip ) flags+=(-DCMAKE_BUILD_STRIP=TRUE) ;;
@ -39,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) ;;
*)
@ -70,10 +71,6 @@ for ARG in "$@"; do
esac
done
if [[ (-f /usr/bin/wx-config32-2.8 && -f /usr/bin/wxrc32-2.8) && "$Build64" -eq 0 ]]; then
#add flags for archlinux, wx 3 is not yet in main repositories, wx2.8 need to be used for now
flags+=(-DwxWidgets_CONFIG_EXECUTABLE='/usr/bin/wx-config32-2.8' -DwxWidgets_wxrc_EXECUTABLE='/usr/bin/wxrc32-2.8' -DWX28_API=TRUE)
fi
root=$PWD/$(dirname "$0")
log=$root/install_log.txt
build=$root/build
@ -84,6 +81,13 @@ if [[ "$cleanBuild" -eq 1 ]]; then
rm -fr $build/*
fi
if [[ "$useCross" -eq 2 ]] && [[ "$(getconf LONG_BIT 2> /dev/null)" != 32 ]]; then
echo "Forcing cross compilation."
flags+=(-DCMAKE_TOOLCHAIN_FILE=cmake/linux-compiler-i386-multilib.cmake)
elif [[ "$useCross" -ne 1 ]]; then
useCross=0
fi
echo "Building pcsx2 with ${flags[*]}" | tee $log
# Resolve the symlink otherwise cmake is lost
@ -97,7 +101,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

View File

@ -60,12 +60,11 @@ endif()
#-------------------------------------------------------------------------------
# Compiler extra
#-------------------------------------------------------------------------------
option(USE_CLANG "Use llvm/clang to build PCSX2 (developer option)")
option(USE_ASAN "Enable address sanitizer")
# It's probably better to autodetect the USE_CLANG. Remove the option?
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT USE_CLANG)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(USE_CLANG TRUE)
message(STATUS "Building with Clang/LLVM.")
endif()
#-------------------------------------------------------------------------------

View File

@ -22,6 +22,32 @@ if(Fedora AND CMAKE_CROSSCOMPILING)
else()
set(wxWidgets_CONFIG_OPTIONS --unicode=yes)
endif()
# Temprorary help for Arch-based distros.
# They have wx2.8, lib32-wx2.8 and wx3.0 but no lib32-wx3.0.
# wx2.8 => /usr/bin/wx-config-2.8, /usr/bin/wxrc-2.8
# lib32-wx2.8 => /usr/bin/wx-config32-2.8, /usr/bin/wxrc32-2.8
# wx3.0 => /usr/bin/wx-config, /usr/bin/wxrc -> /usr/bin/wxrc-3.0
# I'm going to take a wild guess and predict this:
# lib32-wx3.0 => /usr/bin/wx-config32-3.0, /usr/bin/wxrc32-3.0
# FindwxWidgets only searches for wxrc and wx-config. Therefore only native
# wx3.0 works since everything else has non-standard naming.
if(CMAKE_CROSSCOMPILING)
# May need to fix the filenames for lib32-wx3.0.
if(NOT WX28_API AND ${PCSX2_TARGET_ARCHITECTURES} MATCHES "i386" AND EXISTS "/usr/bin/wx-config32-3.0" AND EXISTS "/usr/bin/wxrc32-3.0")
set(wxWidgets_CONFIG_EXECUTABLE "/usr/bin/wx-config32-3.0")
set(wxWidgets_wxrc_EXECUTABLE "/usr/bin/wxrc32-3.0")
elseif(WX28_API AND ${PCSX2_TARGET_ARCHITECTURES} MATCHES "i386" AND EXISTS "/usr/bin/wx-config32-2.8" AND EXISTS "/usr/bin/wxrc32-2.8")
set(wxWidgets_CONFIG_EXECUTABLE "/usr/bin/wx-config32-2.8")
set(wxWidgets_wxrc_EXECUTABLE "/usr/bin/wxrc32-2.8")
endif()
else()
if(WX28_API AND EXISTS "/usr/bin/wx-config-2.8" AND EXISTS "/usr/bin/wxrc-2.8")
set(wxWidgets_CONFIG_EXECUTABLE "/usr/bin/wx-config-2.8")
set(wxWidgets_wxrc_EXECUTABLE "/usr/bin/wxrc-2.8")
endif()
endif()
find_package(wxWidgets COMPONENTS base core adv)
find_package(ZLIB)

View File

@ -8,9 +8,6 @@ set(CMAKE_C_COMPILER_TARGET i686-apple-darwin)
set(CMAKE_CXX_COMPILER clang++ -m32)
set(CMAKE_CXX_COMPILER_TARGET i686-apple-darwin)
# Enable clang
set(USE_CLANG TRUE)
# If given a CMAKE_FIND_ROOT_PATH then
# FIND_PROGRAM ignores CMAKE_FIND_ROOT_PATH (probably can't run)
# FIND_{LIBRARY,INCLUDE,PACKAGE} only uses the files in CMAKE_FIND_ROOT_PATH.

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.
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)

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.
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.