Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make inference_lib_dist for fluid inference shared library #7977

Merged
merged 7 commits into from
Feb 7, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions cmake/external/eigen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ add_dependencies(eigen3 extern_eigen3)

LIST(APPEND external_project_dependencies eigen3)

IF(NOT WITH_C_API AND WITH_FLUID)
INSTALL(FILES ${EIGEN_INCLUDE_DIR}/Eigen/Core DESTINATION third_party/eigen3/Eigen)
INSTALL(DIRECTORY ${EIGEN_INCLUDE_DIR}/Eigen/src DESTINATION third_party/eigen3/Eigen)
INSTALL(DIRECTORY ${EIGEN_INCLUDE_DIR}/unsupported/Eigen DESTINATION third_party/eigen3/unsupported)
ENDIF()
set(lib_dir "${CMAKE_INSTALL_PREFIX}/third_party/eigen3")
add_custom_target(eigen3_lib
COMMAND mkdir -p "${lib_dir}/Eigen" "${lib_dir}/unsupported"
COMMAND cp "${EIGEN_INCLUDE_DIR}/Eigen/Core" "${lib_dir}/Eigen"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use ${CMAKE_COMMAND} -E copy_directory, like here

COMMAND cp -r "${EIGEN_INCLUDE_DIR}/Eigen/src" "${lib_dir}/Eigen"
COMMAND cp -r "${EIGEN_INCLUDE_DIR}/unsupported/Eigen" "${lib_dir}/unsupported"
)
9 changes: 8 additions & 1 deletion cmake/external/gflags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,18 @@ ADD_DEPENDENCIES(gflags extern_gflags)

LIST(APPEND external_project_dependencies gflags)

IF(WITH_C_API OR WITH_FLUID)
IF(WITH_C_API)
INSTALL(DIRECTORY ${GFLAGS_INCLUDE_DIR} DESTINATION third_party/gflags)
IF(ANDROID)
INSTALL(FILES ${GFLAGS_LIBRARIES} DESTINATION third_party/gflags/lib/${ANDROID_ABI})
ELSE()
INSTALL(FILES ${GFLAGS_LIBRARIES} DESTINATION third_party/gflags/lib)
ENDIF()
ENDIF()

set(lib_dir "${CMAKE_INSTALL_PREFIX}/third_party/install/gflags")
add_custom_target(gflags_lib
COMMAND mkdir -p "${lib_dir}/lib"
COMMAND cp -r "${GFLAGS_INCLUDE_DIR}" "${lib_dir}"
COMMAND cp "${GFLAGS_LIBRARIES}" "${lib_dir}/lib"
)
9 changes: 8 additions & 1 deletion cmake/external/glog.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,18 @@ LINK_LIBRARIES(glog gflags)

LIST(APPEND external_project_dependencies glog)

IF(WITH_C_API OR WITH_FLUID)
IF(WITH_C_API)
INSTALL(DIRECTORY ${GLOG_INCLUDE_DIR} DESTINATION third_party/glog)
IF(ANDROID)
INSTALL(FILES ${GLOG_LIBRARIES} DESTINATION third_party/glog/lib/${ANDROID_ABI})
ELSE()
INSTALL(FILES ${GLOG_LIBRARIES} DESTINATION third_party/glog/lib)
ENDIF()
ENDIF()

set(lib_dir "${CMAKE_INSTALL_PREFIX}/third_party/install/glog")
add_custom_target(glog_lib
COMMAND mkdir -p "${lib_dir}/lib"
COMMAND cp -r "${GLOG_INCLUDE_DIR}" "${lib_dir}"
COMMAND cp "${GLOG_LIBRARIES}" "${lib_dir}/lib"
)
9 changes: 8 additions & 1 deletion cmake/external/protobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ IF(NOT PROTOBUF_FOUND)
SET(PROTOBUF_PROTOC_LIBRARY ${extern_protobuf_PROTOC_LIBRARY}
CACHE FILEPATH "protoc library." FORCE)

IF(WITH_C_API OR WITH_FLUID)
IF(WITH_C_API)
INSTALL(DIRECTORY ${PROTOBUF_INCLUDE_DIR} DESTINATION third_party/protobuf)
IF(ANDROID)
INSTALL(FILES ${PROTOBUF_LITE_LIBRARY} DESTINATION third_party/protobuf/lib/${ANDROID_ABI})
Expand All @@ -259,6 +259,13 @@ IF(NOT PROTOBUF_FOUND)
ENDIF()
ENDIF()

set(lib_dir "${CMAKE_INSTALL_PREFIX}/third_party/install/protobuf")
add_custom_target(protobuf_lib
COMMAND mkdir -p "${lib_dir}/lib"
COMMAND cp -r "${PROTOBUF_INCLUDE_DIR}" "${lib_dir}"
COMMAND cp "${PROTOBUF_LITE_LIBRARY}" "${lib_dir}/lib"
)

IF(CMAKE_CROSSCOMPILING)
PROMPT_PROTOBUF_LIB(protobuf_host extern_protobuf)
ELSE()
Expand Down
13 changes: 7 additions & 6 deletions paddle/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ cc_test(init_test SRCS init_test.cc DEPS init)
cc_test(op_kernel_type_test SRCS op_kernel_type_test.cc DEPS place device_context framework_proto)
cc_test(cow_ptr_tests SRCS details/cow_ptr_test.cc)

if(NOT WITH_C_API AND WITH_FLUID)
file(GLOB FRAMEWORK_HEADERS *.h)
install(FILES ${FRAMEWORK_HEADERS} DESTINATION include/paddle/framework)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/framework.pb.h DESTINATION include/paddle/framework)
install(FILES details/cow_ptr.h details/op_registry.h DESTINATION include/paddle/framework/details)
endif()
set(lib_dir "${CMAKE_INSTALL_PREFIX}/paddle/framework")
add_custom_target(framework_lib DEPENDS framework_py_proto
COMMAND mkdir -p "${lib_dir}/details"
COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${lib_dir}"
COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/details/*.h" "${lib_dir}/details"
COMMAND cp "${CMAKE_CURRENT_BINARY_DIR}/framework.pb.h" "${lib_dir}"
)

cc_test(channel_test SRCS channel_test.cc)
17 changes: 11 additions & 6 deletions paddle/inference/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,21 @@ add_library(paddle_fluid_shared SHARED io.cc)
target_circle_link_libraries(paddle_fluid_shared
ARCHIVE_START
${GLOB_OP_LIB}
ARCHIVE_END
${FLUID_CORE_MODULES})
${FLUID_CORE_MODULES}
ARCHIVE_END)

SET_TARGET_PROPERTIES(paddle_fluid_shared PROPERTIES OUTPUT_NAME paddle_fluid)

# install library & headers
if(NOT WITH_C_API AND WITH_FLUID)
install(FILES io.h DESTINATION include/paddle/inference)
install(TARGETS paddle_fluid_shared DESTINATION lib)
endif()
set(lib_dir "${CMAKE_INSTALL_PREFIX}/paddle/inference")
add_custom_target(inference_lib DEPENDS paddle_fluid_shared
COMMAND mkdir -p "${lib_dir}"
COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${lib_dir}"
COMMAND cp "${CMAKE_CURRENT_BINARY_DIR}/libpaddle_fluid.so" "${lib_dir}"
)
add_custom_target(inference_lib_dist DEPENDS
inference_lib framework_lib memory_lib platform_lib string_lib
gflags_lib glog_lib protobuf_lib eigen3_lib)

add_executable(example example.cc)
if(APPLE)
Expand Down
12 changes: 6 additions & 6 deletions paddle/memory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ cc_library(paddle_memory

cc_test(memory_test SRCS memory_test.cc DEPS place paddle_memory)

if(NOT WITH_C_API AND WITH_FLUID)
file(GLOB MEMORY_HEADERS *.h)
file(GLOB MEMORY_DETAIL_HEADERS detail/*.h)
install(FILES ${MEMORY_HEADERS} DESTINATION include/paddle/memory)
install(FILES ${MEMORY_DETAIL_HEADERS} DESTINATION include/paddle/memory/detail)
endif()
set(lib_dir "${CMAKE_INSTALL_PREFIX}/paddle/memory")
add_custom_target(memory_lib
COMMAND mkdir -p "${lib_dir}/detail"
COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${lib_dir}"
COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/detail/*.h" "${lib_dir}/detail"
)
14 changes: 7 additions & 7 deletions paddle/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ nv_test(nccl_test SRCS nccl_test.cu DEPS dynload_cuda gpu_info device_context)
cc_library(profiler SRCS profiler.cc DEPS device_context)
cc_test(profiler_test SRCS profiler_test.cc DEPS profiler)

if(NOT WITH_C_API AND WITH_FLUID)
file(GLOB PLATFORM_HEADERS *.h)
file(GLOB PLATFORM_dynload_HEADERS dynload/*.h)
install(FILES ${PLATFORM_HEADERS} DESTINATION include/paddle/platform)
install(FILES ${PLATFORM_HEADERS} DESTINATION include/paddle/platform/dynload)
install(FILES details/device_ptr_cast.h DESTINATION include/paddle/platform/details)
endif()
set(lib_dir "${CMAKE_INSTALL_PREFIX}/paddle/platform")
add_custom_target(platform_lib
COMMAND mkdir -p "${lib_dir}/dynload" "${lib_dir}/details"
COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${lib_dir}"
COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/dynload/*.h" "${lib_dir}/dynload"
COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/details/*.h" "${lib_dir}/details"
)
11 changes: 6 additions & 5 deletions paddle/string/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ cc_test(stringpiece_test SRCS piece_test.cc DEPS stringpiece glog gflags)
cc_test(stringprintf_test SRCS printf_test.cc DEPS glog gflags)
cc_test(to_string_test SRCS to_string_test.cc)

if(NOT WITH_C_API AND WITH_FLUID)
file(GLOB STRING_HEADERS *.h)
install(FILES ${STRING_HEADERS} DESTINATION include/paddle/string)
install(FILES tinyformat/tinyformat.h DESTINATION include/paddle/string/tinyformat)
endif()
set(lib_dir "${CMAKE_INSTALL_PREFIX}/paddle/string")
add_custom_target(string_lib
COMMAND mkdir -p "${lib_dir}/tinyformat"
COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${lib_dir}"
COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/tinyformat/*.h" "${lib_dir}/tinyformat"
)