From b03ca5fcf403e3931981fb39bea5e15f41ab96b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Wed, 24 Dec 2014 18:15:55 -0500 Subject: [PATCH] Include some rather simple CMAKE_TOOLCHAIN_FILE. - Update the build.sh and fix some typos. + Don't add the OSX ones because I have not tested them and it won't even build anyway due to the libaio dependency. Needs to use POSIX AIO or something else. - They are rather simple and all the magic happens in two lines. + First line tells cmake to get ready to compile FOR linux or darwin. It also sets CMAKE_CROSSCOMPILING to true which is the only way to let cmake known that we are using stuff not from the host. + CMAKE_C_COMPILER/CMAKE_CXX_COMPILER are basically used to detect the architecture of the target. Since I used generic cc/c++ the hardcoded -m32 is needed to ensure we get TARGET=i386. Also since I hardcode -m32 and use c++/cc it's to be noted that we can only do i386->i386 (trivial), amd64 -> i386, and x32->i386. . Using something like i586-linux-gnu-{gcc,g++} would also work and enable arm -> i386, etc but it's infeasible and impractical to do all the combinations. File is simple enough that a distro or user can create their own and cross compiling is rather tedious compared to using a chroot to compile it. - I tested it in Debian with "dpkg-buildpackage -ai386" but installing the build dependencies was rather tedious. --- build.sh | 8 +++++--- cmake/darwin-compiler-i386-clang.cmake | 20 ++++++++++++++++++++ cmake/darwin-compiler-i386-generic.cmake | 15 +++++++++++++++ cmake/linux-compiler-i386-multilib.cmake | 16 ++++++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 cmake/darwin-compiler-i386-clang.cmake create mode 100644 cmake/darwin-compiler-i386-generic.cmake create mode 100644 cmake/linux-compiler-i386-multilib.cmake diff --git a/build.sh b/build.sh index 160b6cb30e..6a9c64bb82 100755 --- a/build.sh +++ b/build.sh @@ -42,6 +42,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) ;; -D* ) flags+=($ARG) ;; *) @@ -54,17 +55,18 @@ for ARG in "$@"; do echo "--clean : Do a clean build." echo "--extra : Build all plugins" echo - echo "** Developper option **" + echo "** Developer option **" echo "--clang : Build with Clang/llvm" echo "--asan : Enable Address sanitizer" echo echo "--wx28 : Force wxWidget 2.8" echo "--glsl : Replace CG backend of ZZogl by GLSL" echo "--egl : Replace GLX by EGL (ZZogl plugins only)" - echo "--sdl2 : Build with SDL2 (crash if wx is linked to SDL1)" + echo "--sdl2 : Build with SDL2 (crashes if wx is linked to SDL1.2)" echo "--gles : Replace openGL backend of GSdx by openGLES3.1" + echo "--cross-multilib: Build a 32bit PCSX2 on a 64bit machine using multilib." echo - echo "** Hardcode Developper option **" + echo "** Hardcode Developer option **" echo "--no-simd : Only allow sse2" echo "--gtk3 : replace GTK2 by GTK3" exit 1 diff --git a/cmake/darwin-compiler-i386-clang.cmake b/cmake/darwin-compiler-i386-clang.cmake new file mode 100644 index 0000000000..182a6d4a91 --- /dev/null +++ b/cmake/darwin-compiler-i386-clang.cmake @@ -0,0 +1,20 @@ +# Tell cmake we are cross compiling and targeting darwin +set(CMAKE_SYSTEM_NAME Darwin) +set(CMAKE_SYSTEM_PROCESSOR i686) + +# Use clang and target i686-apple-darwin. +set(CMAKE_C_COMPILER clang -m32) +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. +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/cmake/darwin-compiler-i386-generic.cmake b/cmake/darwin-compiler-i386-generic.cmake new file mode 100644 index 0000000000..b2ac14e6a3 --- /dev/null +++ b/cmake/darwin-compiler-i386-generic.cmake @@ -0,0 +1,15 @@ +# Tell cmake we are cross compiling and targeting darwin +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 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. +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/cmake/linux-compiler-i386-multilib.cmake b/cmake/linux-compiler-i386-multilib.cmake new file mode 100644 index 0000000000..ddf7ceaf5d --- /dev/null +++ b/cmake/linux-compiler-i386-multilib.cmake @@ -0,0 +1,16 @@ +# Tell cmake we are cross compiling and targeting linux +set(CMAKE_SYSTEM_NAME Linux) +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 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. +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)