提交 fb38e662 编写于 作者: L Liu Yiqun

Seperate the codes that cannot and don't need to build for iOS devices.

上级 43dde935
...@@ -167,11 +167,16 @@ if(USE_NNPACK) ...@@ -167,11 +167,16 @@ if(USE_NNPACK)
list(APPEND EXTERNAL_LIBS ${NNPACK_LIBS}) list(APPEND EXTERNAL_LIBS ${NNPACK_LIBS})
endif(USE_NNPACK) endif(USE_NNPACK)
message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
add_subdirectory(proto) add_subdirectory(proto)
# "add_subdirectory(go)" should be placed after the following loine, if(NOT ANDROID AND NOT IOS)
# because it depends on paddle/optimizer. # "add_subdirectory(go)" should be placed after the following loine,
add_subdirectory(paddle/optimizer) # because it depends on paddle/optimizer.
add_subdirectory(paddle/optimizer)
endif()
# "add_subdirectory(paddle)" and "add_subdirectory(python)" should be # "add_subdirectory(paddle)" and "add_subdirectory(python)" should be
# placed after this block, because they depends on it. # placed after this block, because they depends on it.
......
...@@ -289,6 +289,8 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) ...@@ -289,6 +289,8 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
message(STATUS "iOS: Targeting iOS '${CMAKE_SYSTEM_VERSION}', " message(STATUS "iOS: Targeting iOS '${CMAKE_SYSTEM_VERSION}', "
"building for '${IOS_PLATFORM}' platform, with architecture '${CMAKE_OSX_ARCHITECTURES}'") "building for '${IOS_PLATFORM}' platform, with architecture '${CMAKE_OSX_ARCHITECTURES}'")
message(STATUS "System CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
message(STATUS "System CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# This little macro lets you set any XCode specific property # This little macro lets you set any XCode specific property
macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE) macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE)
......
...@@ -5,8 +5,12 @@ add_subdirectory(testing) ...@@ -5,8 +5,12 @@ add_subdirectory(testing)
add_subdirectory(math) add_subdirectory(math)
add_subdirectory(parameter) add_subdirectory(parameter)
add_subdirectory(gserver) add_subdirectory(gserver)
add_subdirectory(pserver)
add_subdirectory(trainer) if(NOT ANDROID AND NOT IOS)
add_subdirectory(pserver)
add_subdirectory(trainer)
endif()
add_subdirectory(scripts) add_subdirectory(scripts)
add_subdirectory(string) add_subdirectory(string)
......
...@@ -31,42 +31,40 @@ add_dependencies(paddle_capi paddle_proto) ...@@ -31,42 +31,40 @@ add_dependencies(paddle_capi paddle_proto)
# combine all paddle static libraries together, into libpaddle_capi_whole.a # combine all paddle static libraries together, into libpaddle_capi_whole.a
# user should use PaddleCAPI as -lpaddle_capi_whole # user should use PaddleCAPI as -lpaddle_capi_whole
set(capi_whole_library libpaddle_capi_whole.a) set(PADDLE_INFER_LIBS
add_custom_target(paddle_capi_whole ALL paddle_utils
COMMAND mkdir -p o_files/capi && cd o_files/capi/ && ar -x $<TARGET_FILE:paddle_capi> paddle_parameter
COMMAND mkdir -p o_files/utils && cd o_files/utils/ && ar -x $<TARGET_FILE:paddle_utils> paddle_math
COMMAND mkdir -p o_files/parameter && cd o_files/parameter/ && ar -x $<TARGET_FILE:paddle_parameter> paddle_cuda
COMMAND mkdir -p o_files/math && cd o_files/math/ && ar -x $<TARGET_FILE:paddle_math> paddle_function
COMMAND mkdir -p o_files/cuda && cd o_files/cuda/ && ar -x $<TARGET_FILE:paddle_cuda> paddle_gserver
COMMAND mkdir -p o_files/function && cd o_files/function/ && ar -x $<TARGET_FILE:paddle_function> paddle_proto
COMMAND mkdir -p o_files/gserver && cd o_files/gserver/ && ar -x $<TARGET_FILE:paddle_gserver> )
COMMAND mkdir -p o_files/proto && cd o_files/proto/ && ar -x $<TARGET_FILE:paddle_proto>
COMMAND mkdir -p o_files/network && cd o_files/network/ && ar -x $<TARGET_FILE:paddle_network>
COMMAND mkdir -p o_files/pserver && cd o_files/pserver/ && ar -x $<TARGET_FILE:paddle_pserver>
COMMAND ar crs ${capi_whole_library} `find ./o_files -name '*.o'`
COMMAND rm -rf o_files
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS paddle_capi paddle_utils paddle_parameter paddle_math
paddle_cuda paddle_function paddle_gserver
paddle_proto paddle_pserver paddle_network
)
set_target_properties(paddle_capi_whole
PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${capi_whole_library})
add_library(paddle_capi_shared SHARED ${CAPI_SOURCES}) set(PADDLE_TRAIN_LIBS paddle_pserver paddle_network)
target_include_directories(paddle_capi_shared PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
link_paddle_exe(paddle_capi_shared) cc_library(paddle_capi_whole DEPS paddle_capi ${PADDLE_INFER_LIBS})
# No shared library for iOS
if(NOT IOS)
add_library(paddle_capi_shared SHARED ${CAPI_SOURCES})
target_include_directories(paddle_capi_shared PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
link_paddle_exe(paddle_capi_shared)
endif()
# install library & headers. # install library & headers.
install(FILES ${CAPI_HEADERS} DESTINATION include/paddle) install(FILES ${CAPI_HEADERS} DESTINATION include/paddle)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h DESTINATION include/paddle) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h DESTINATION include/paddle)
if(ANDROID) if(ANDROID)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${capi_whole_library} install(TARGETS paddle_capi_whole paddle_capi_shared
DESTINATION lib/${ANDROID_ABI}) ARCHIVE DESTINATION lib/${ANDROID_ABI}
install(TARGETS paddle_capi_shared DESTINATION lib/${ANDROID_ABI}) LIBRARY DESTINATION lib/${ANDROID_ABI})
else(ANDROID) else(ANDROID)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${capi_whole_library} DESTINATION lib) install(TARGETS paddle_capi_whole
install(TARGETS paddle_capi_shared DESTINATION lib) ARCHIVE DESTINATION lib)
if(NOT IOS)
install(TARGETS paddle_capi_shared DESTINATION lib)
endif()
endif(ANDROID) endif(ANDROID)
# this variable used for unittest # this variable used for unittest
......
...@@ -17,7 +17,8 @@ limitations under the License. */ ...@@ -17,7 +17,8 @@ limitations under the License. */
#include <fenv.h> #include <fenv.h>
#if defined(__APPLE__) || defined(__OSX__) #if (defined(__APPLE__) || defined(__OSX__)) && !defined(__arm__) && \
!defined(__aarch64__)
int fegetexcept(void); int fegetexcept(void);
int feenableexcept(unsigned int excepts); int feenableexcept(unsigned int excepts);
......
...@@ -40,6 +40,8 @@ void Semaphore::wait() { sem_wait(&m->sem); } ...@@ -40,6 +40,8 @@ void Semaphore::wait() { sem_wait(&m->sem); }
void Semaphore::post() { sem_post(&m->sem); } void Semaphore::post() { sem_post(&m->sem); }
/// SpinLockPrivate
#ifdef PADDLE_USE_PTHREAD_SPINLOCK #ifdef PADDLE_USE_PTHREAD_SPINLOCK
class SpinLockPrivate { class SpinLockPrivate {
...@@ -79,6 +81,8 @@ SpinLock::~SpinLock() { delete m; } ...@@ -79,6 +81,8 @@ SpinLock::~SpinLock() { delete m; }
void SpinLock::lock() { m->lock(); } void SpinLock::lock() { m->lock(); }
void SpinLock::unlock() { m->unlock(); } void SpinLock::unlock() { m->unlock(); }
/// ThreadBarrierPrivate
#ifdef PADDLE_USE_PTHREAD_BARRIER #ifdef PADDLE_USE_PTHREAD_BARRIER
class ThreadBarrierPrivate { class ThreadBarrierPrivate {
...@@ -136,6 +140,8 @@ public: ...@@ -136,6 +140,8 @@ public:
#endif #endif
/// ThreadBarrier
ThreadBarrier::ThreadBarrier(int count) : m(new ThreadBarrierPrivate(count)) {} ThreadBarrier::ThreadBarrier(int count) : m(new ThreadBarrierPrivate(count)) {}
ThreadBarrier::~ThreadBarrier() { delete m; } ThreadBarrier::~ThreadBarrier() { delete m; }
void ThreadBarrier::wait() { m->wait(); } void ThreadBarrier::wait() { m->wait(); }
......
...@@ -14,7 +14,8 @@ limitations under the License. */ ...@@ -14,7 +14,8 @@ limitations under the License. */
#include "paddle/utils/Excepts.h" #include "paddle/utils/Excepts.h"
#if defined(__APPLE__) || defined(__OSX__) #if (defined(__APPLE__) || defined(__OSX__)) && !defined(__arm__) && \
!defined(__aarch64__)
int fegetexcept(void) { int fegetexcept(void) {
static fenv_t fenv; static fenv_t fenv;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册