From bf45fadda95a1ba9f62887906c2060da8ce424ff Mon Sep 17 00:00:00 2001 From: zhaojiaying01 Date: Thu, 12 Jul 2018 15:28:10 +0800 Subject: [PATCH] fix ios compilation problems --- CMakeLists.txt | 11 ++++++++--- tools/build.sh | 6 ------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5b9ec25aa..2532ecf243 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,11 +14,16 @@ file(GLOB_RECURSE PADDLE_MOBILE_CC src/*.cc src/*.cpp src/*.c src/*.mm) file(GLOB_RECURSE PADDLE_MOBILE_H src/*.h) include_directories(src/) -set(CMAKE_CXX_FLAGS "-std=c++14 -O3 -s ${CMAKE_CXX_FLAGS}") +if(IS_IOS) + set(CMAKE_CXX_FLAGS "-fobjc-abi-version=2 -fobjc-arc -std=gnu++11 -stdlib=libc++ -O3 -s -isysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS}") +else() + set(CMAKE_CXX_FLAGS "-std=c++14 -O3 -s ${CMAKE_CXX_FLAGS}") +endif() + if (DEBUGING) message(STATUS "debug") - set(CMAKE_BUILD_TYPE Debug) - set(CMAKE_CXX_FLAGS_DEBUG "-g -DNDEBUG") + set(CMAKE_BUILD_TYPE Release) + set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG") add_definitions(-DPADDLE_MOBILE_DEBUG) else () set(CMAKE_BUILD_TYPE Release) diff --git a/tools/build.sh b/tools/build.sh index e1a47e64e6..ce330e6d63 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -94,8 +94,6 @@ build_for_ios() { MODE="Release" BUILD_DIR=../build/release/"${PLATFORM}" TOOLCHAIN_FILE="./tools/ios-cmake/ios.toolchain.cmake" - C_FLAGS="-fobjc-abi-version=2 -fobjc-arc -isysroot ${CMAKE_OSX_SYSROOT}" - CXX_FLAGS="-fobjc-abi-version=2 -fobjc-arc -std=gnu++14 -stdlib=libc++ -isysroot ${CMAKE_OSX_SYSROOT}" mkdir -p "${BUILD_DIR}" if [ $# -eq 1 ]; then cmake .. \ @@ -103,8 +101,6 @@ build_for_ios() { -DCMAKE_BUILD_TYPE="${MODE}" \ -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \ -DIOS_PLATFORM=OS \ - -DCMAKE_C_FLAGS="${C_FLAGS}" \ - -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \ -DNET=$1 \ -DIS_IOS="true" else @@ -113,8 +109,6 @@ build_for_ios() { -DCMAKE_BUILD_TYPE="${MODE}" \ -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \ -DIOS_PLATFORM=OS \ - -DCMAKE_C_FLAGS="${C_FLAGS}" \ - -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \ -DIS_IOS="true" fi cd "${BUILD_DIR}" -- GitLab