From 59b3d68b3324037ab4a74d48dc4699c5ce272f26 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Mon, 24 Nov 2014 02:10:25 +0100 Subject: [PATCH] Enabling cross compiling if supported by the current system. --- CMakeLists.txt | 17 ++++++++++++----- build.sh | 11 +++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b34054..221221e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,11 +118,18 @@ FILE(GLOB_RECURSE HEADER_FILES_BULLET ${CMAKE_SOURCE_DIR}/extern/bullet/src/*.h) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/extern/bullet/src) SET(HEADER_FILES ${HEADER_FILES} ${HEADER_FILES_BULLET}) - -SET (LIBRARIES ${LIBRARIES} ${CMAKE_SOURCE_DIR}/extern/bullet/build/src/BulletDynamics/libBulletDynamics.a) -SET (LIBRARIES ${LIBRARIES} ${CMAKE_SOURCE_DIR}/extern/bullet/build/src/BulletCollision/libBulletCollision.a) -SET (LIBRARIES ${LIBRARIES} ${CMAKE_SOURCE_DIR}/extern/bullet/build/src/LinearMath/libLinearMath.a) -SET (LIBRARIES ${LIBRARIES} ${CMAKE_SOURCE_DIR}/extern/bullet/build/src/BulletSoftBody/libBulletSoftBody.a) +if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + SET (LIBRARIES ${LIBRARIES} ${CMAKE_SOURCE_DIR}/extern/bullet/build/lib/libBulletDynamics.a) + SET (LIBRARIES ${LIBRARIES} ${CMAKE_SOURCE_DIR}/extern/bullet/build/lib/libBulletCollision.a) + SET (LIBRARIES ${LIBRARIES} ${CMAKE_SOURCE_DIR}/extern/bullet/build/lib/libLinearMath.a) + SET (LIBRARIES ${LIBRARIES} ${CMAKE_SOURCE_DIR}/extern/bullet/build/lib/libBulletSoftBody.a) + SET (LIBRARIES -static ${LIBRARIES} -static-libgcc -static-libstdc++) +else() + SET (LIBRARIES ${LIBRARIES} ${CMAKE_SOURCE_DIR}/extern/bullet/build/src/BulletDynamics/libBulletDynamics.a) + SET (LIBRARIES ${LIBRARIES} ${CMAKE_SOURCE_DIR}/extern/bullet/build/src/BulletCollision/libBulletCollision.a) + SET (LIBRARIES ${LIBRARIES} ${CMAKE_SOURCE_DIR}/extern/bullet/build/src/LinearMath/libLinearMath.a) + SET (LIBRARIES ${LIBRARIES} ${CMAKE_SOURCE_DIR}/extern/bullet/build/src/BulletSoftBody/libBulletSoftBody.a) +endif() ADD_EXECUTABLE(${CMAKE_PROJECT_NAME} ${SOURCE_FILES} ${HEADER_FILES} ${SHADER_FILES} ${README_FILES}) diff --git a/build.sh b/build.sh index 0758a4e..0109ee3 100755 --- a/build.sh +++ b/build.sh @@ -8,6 +8,13 @@ then exit fi +cmake="cmake" + +if [[ $1 == "windows" ]] +then + cmake=x86_64-w64-mingw32-cmake +fi + currentDir=$(pwd) threads=$(($(nproc)+1)) @@ -16,7 +23,7 @@ threads=$(($(nproc)+1)) cd extern/bullet/ mkdir -p build cd build -cmake -DBUILD_DEMOS=0 -DBUILD_EXTRAS=0 -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=0 .. +$cmake -DBUILD_DEMOS=0 -DBUILD_EXTRAS=0 -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=0 .. make -j$threads cd $currentDir @@ -25,5 +32,5 @@ cd $currentDir mkdir -p build cd build -cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=0 .. +$cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=0 .. make -j$threads