From 5b20ad3791413d3351c26b71103b20ba8cc2aa4e Mon Sep 17 00:00:00 2001 From: Doron Adler Date: Sun, 1 Jul 2018 14:48:20 +0300 Subject: [PATCH] Fixed a mistake I Introduced in the build script where debug and shared-lib parameters were expecting a "=" Revert to default Release build type, but this time only for iOS Do not attempt to use minizip if you are building for iOS shared dylib Keep in mind that the "Shared" option only apply to the assimp library and not the other two built libraries --- CMakeLists.txt | 14 +++++++++++++- port/iOS/build.sh | 37 ++++++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d799c71f1..66d9ced4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,6 +106,12 @@ OPTION ( BUILD_DOCS OFF ) +IF (IOS) + IF (NOT CMAKE_BUILD_TYPE) + SET(CMAKE_BUILD_TYPE "Release") + ENDIF (NOT CMAKE_BUILD_TYPE) +ENDIF (IOS) + # Use subset of Windows.h if (WIN32) ADD_DEFINITIONS( -DWIN32_LEAN_AND_MEAN ) @@ -336,7 +342,13 @@ ENDIF(NOT ZLIB_FOUND) INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) # Search for unzip -use_pkgconfig(UNZIP minizip) +IF ( NOT IOS ) + use_pkgconfig(UNZIP minizip) +ELSE ( NOT IOS ) + IF(NOT BUILD_SHARED_LIBS) + use_pkgconfig(UNZIP minizip) + ENDIF (NOT BUILD_SHARED_LIBS) +ENDIF ( NOT IOS ) IF ( ASSIMP_NO_EXPORT ) ADD_DEFINITIONS( -DASSIMP_BUILD_NO_EXPORT) diff --git a/port/iOS/build.sh b/port/iOS/build.sh index 8167c1e0c..5f0abfdb9 100755 --- a/port/iOS/build.sh +++ b/port/iOS/build.sh @@ -90,10 +90,10 @@ build_arch() if [[ "$BUILD_SHARED_LIBS" =~ "ON" ]]; then echo "[!] Moving built dynamic libraries into: $BUILD_DIR/$1/" mv ./lib/*.dylib $BUILD_DIR/$1/ - else - echo "[!] Moving built static libraries into: $BUILD_DIR/$1/" - mv ./lib/*.a $BUILD_DIR/$1/ - fi + fi + + echo "[!] Moving built static libraries into: $BUILD_DIR/$1/" + mv ./lib/*.a $BUILD_DIR/$1/ } echo "[!] $0 - assimp iOS build script" @@ -117,11 +117,11 @@ for i in "$@"; do DEPLOY_ARCHS=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` echo "[!] Selecting architectures: $DEPLOY_ARCHS" ;; - -d=*|--debug=*) + --debug) BUILD_TYPE=Debug echo "[!] Selecting build type: Debug" ;; - -s=*|--shared-lib=*) + --shared-lib) BUILD_SHARED_LIBS=ON echo "[!] Will generate dynamic libraries" ;; @@ -155,7 +155,7 @@ for ARCH_TARGET in $DEPLOY_ARCHS; do done -make_fat_binary() +make_fat_static_or_shared_binary() { LIB_NAME=$1 LIPO_ARGS='' @@ -166,16 +166,31 @@ make_fat_binary() LIPO_ARGS="$LIPO_ARGS-arch $ARCH_TARGET $BUILD_DIR/$ARCH_TARGET/$LIB_NAME.a " fi done - LIPO_ARGS="$LIPO_ARGS-create -output $BUILD_DIR/$LIB_NAME-fat.a" + if [[ "$BUILD_SHARED_LIBS" =~ "ON" ]]; then + LIPO_ARGS="$LIPO_ARGS -create -output $BUILD_DIR/$LIB_NAME-fat.dylib" + else + LIPO_ARGS="$LIPO_ARGS -create -output $BUILD_DIR/$LIB_NAME-fat.a" + fi + lipo $LIPO_ARGS +} + +make_fat_static_binary() +{ + LIB_NAME=$1 + LIPO_ARGS='' + for ARCH_TARGET in $DEPLOY_ARCHS; do + LIPO_ARGS="$LIPO_ARGS-arch $ARCH_TARGET $BUILD_DIR/$ARCH_TARGET/$LIB_NAME.a " + done + LIPO_ARGS="$LIPO_ARGS -create -output $BUILD_DIR/$LIB_NAME-fat.a" lipo $LIPO_ARGS } if [[ "$DEPLOY_FAT" -eq 1 ]]; then echo '[+] Creating fat binaries ...' - make_fat_binary 'libassimp' - make_fat_binary 'libIrrXML' - make_fat_binary 'libzlibstatic' + make_fat_static_or_shared_binary 'libassimp' + make_fat_static_binary 'libIrrXML' + make_fat_static_binary 'libzlibstatic' echo "[!] Done! The fat binaries can be found at $BUILD_DIR" fi