From aeea8ab1c4e102ac687da3598011767d7b7a7321 Mon Sep 17 00:00:00 2001 From: Liu Yiqun Date: Wed, 30 Aug 2017 19:59:01 +0800 Subject: [PATCH] Remove the linking of train-related libraries when cross-compiling for Android and iOS. Recover the mistakenly deleted WARPCTC variable in cmake. --- cmake/cross_compiling/ios.cmake | 2 +- cmake/external/gtest.cmake | 19 ++++++++++--------- cmake/external/openblas.cmake | 2 +- cmake/external/warpctc.cmake | 8 ++++++-- cmake/util.cmake | 13 +++++++++---- paddle/capi/CMakeLists.txt | 6 +++--- 6 files changed, 30 insertions(+), 20 deletions(-) diff --git a/cmake/cross_compiling/ios.cmake b/cmake/cross_compiling/ios.cmake index d805423cb1..eea17436bd 100644 --- a/cmake/cross_compiling/ios.cmake +++ b/cmake/cross_compiling/ios.cmake @@ -77,7 +77,7 @@ set(IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform") # Set the architecture for iOS if(NOT DEFINED IOS_ARCH) if(IOS_PLATFORM STREQUAL "OS") - # FIXME: support "armv7;armv7s;arm64" future + # FIXME(liuyiqun): support "armv7;armv7s;arm64" future set(IOS_ARCH "arm64") elseif(IOS_PLATFORM STREQUAL "SIMULATOR") set(IOS_ARCH "i386;x86_64") diff --git a/cmake/external/gtest.cmake b/cmake/external/gtest.cmake index e3970073a1..6a2a79b763 100644 --- a/cmake/external/gtest.cmake +++ b/cmake/external/gtest.cmake @@ -48,15 +48,16 @@ IF(WITH_TESTING) PREFIX ${GTEST_SOURCES_DIR} UPDATE_COMMAND "" CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - CMAKE_ARGS -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} - CMAKE_ARGS -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${GTEST_INSTALL_DIR} - CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON - CMAKE_ARGS -DBUILD_GMOCK=ON - CMAKE_ARGS -Dgtest_disable_pthreads=ON - CMAKE_ARGS -Dgtest_force_shared_crt=ON - CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} + -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} + -DCMAKE_INSTALL_PREFIX=${GTEST_INSTALL_DIR} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DBUILD_GMOCK=ON + -Dgtest_disable_pthreads=ON + -Dgtest_force_shared_crt=ON + -DCMAKE_BUILD_TYPE=Release + ${EXTERNAL_OPTIONAL_ARGS} CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${GTEST_INSTALL_DIR} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=Release diff --git a/cmake/external/openblas.cmake b/cmake/external/openblas.cmake index 849956f490..66c2a8bd80 100644 --- a/cmake/external/openblas.cmake +++ b/cmake/external/openblas.cmake @@ -40,7 +40,7 @@ IF(NOT ${CBLAS_FOUND}) SET(OPTIONAL_ARGS ${OPTIONAL_ARGS} TARGET=ARMV8 BINARY=64 USE_THREAD=0) ENDIF() ELSEIF(IOS) - # FIXME: support multiple architectures + # FIXME(liuyiqun): support multiple architectures SET(OPENBLAS_COMMIT "b5c96fcfcdc82945502a2303116a64d89985daf5") SET(OPENBLAS_CC "${OPENBLAS_CC} ${CMAKE_C_FLAGS} -isysroot ${CMAKE_OSX_SYSROOT}") IF(CMAKE_OSX_ARCHITECTURES MATCHES "armv7") diff --git a/cmake/external/warpctc.cmake b/cmake/external/warpctc.cmake index 1327c6b95d..bb258c7b55 100644 --- a/cmake/external/warpctc.cmake +++ b/cmake/external/warpctc.cmake @@ -19,11 +19,12 @@ SET(WARPCTC_INSTALL_DIR ${THIRD_PARTY_PATH}/install/warpctc) SET(WARPCTC_INCLUDE_DIR "${WARPCTC_INSTALL_DIR}/include" CACHE PATH "Warp-ctc Directory" FORCE) +# Used in unit test test_WarpCTCLayer +SET(WARPCTC_LIB_DIR "${WARPCTC_INSTALL_DIR}/lib" + CACHE PATH "Warp-ctc Library Directory" FORCE) SET(WARPCTC_LIBRARIES "${WARPCTC_INSTALL_DIR}/lib/libwarpctc${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE FILEPATH "Warp-ctc Library" FORCE) -INCLUDE_DIRECTORIES(${WARPCTC_INCLUDE_DIR}) - IF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" ) SET(USE_OMP OFF) ELSE() @@ -54,6 +55,9 @@ ExternalProject_Add( -DCMAKE_INSTALL_PREFIX:PATH=${WARPCTC_INSTALL_DIR} ) +MESSAGE(STATUS "warp-ctc library: ${WARPCTC_LIBRARIES}") +INCLUDE_DIRECTORIES(${WARPCTC_INCLUDE_DIR}) + ADD_LIBRARY(warpctc STATIC IMPORTED GLOBAL) SET_PROPERTY(TARGET warpctc PROPERTY IMPORTED_LOCATION ${WARPCTC_LIBRARIES}) ADD_DEPENDENCIES(warpctc extern_warpctc) diff --git a/cmake/util.cmake b/cmake/util.cmake index 0da4969d31..bfe269ea25 100644 --- a/cmake/util.cmake +++ b/cmake/util.cmake @@ -71,20 +71,25 @@ function(link_paddle_exe TARGET_NAME) generate_rdma_links() endif() + if(NOT ANDROID AND NOT IOS) + set(PADDLE_TRAIN_LIBS + paddle_pserver + paddle_network + paddle_trainer_lib + paddle_optimizer) + endif() + target_circle_link_libraries(${TARGET_NAME} ARCHIVE_START paddle_gserver paddle_function ARCHIVE_END - paddle_pserver - paddle_trainer_lib - paddle_network paddle_math paddle_utils paddle_parameter paddle_proto paddle_cuda - paddle_optimizer + ${PADDLE_TRAIN_LIBS} ${EXTERNAL_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} diff --git a/paddle/capi/CMakeLists.txt b/paddle/capi/CMakeLists.txt index 7a83508f31..071f5a0b0d 100644 --- a/paddle/capi/CMakeLists.txt +++ b/paddle/capi/CMakeLists.txt @@ -30,7 +30,7 @@ add_dependencies(paddle_capi paddle_proto) # combine all paddle static libraries together, into libpaddle_capi_whole.a # user should use PaddleCAPI as -lpaddle_capi_whole -set(PADDLE_INFER_LIBS +set(PADDLE_CAPI_INFER_LIBS paddle_utils paddle_parameter paddle_math @@ -40,9 +40,9 @@ set(PADDLE_INFER_LIBS paddle_proto ) -set(PADDLE_TRAIN_LIBS paddle_pserver paddle_network) +set(PADDLE_CAPI_TRAIN_LIBS paddle_pserver paddle_network) -cc_library(paddle_capi_whole DEPS paddle_capi ${PADDLE_INFER_LIBS}) +cc_library(paddle_capi_whole DEPS paddle_capi ${PADDLE_CAPI_INFER_LIBS}) # No shared library for iOS if(NOT IOS) -- GitLab