CMakeLists.txt 1.3 KB
Newer Older
L
Luo Tao 已提交
1
set(FLUID_CORE_MODULES proto_desc paddle_memory executor prune init)
2 3

cc_library(paddle_fluid_api
4
    SRCS io.cc
L
Luo Tao 已提交
5
    DEPS ${FLUID_CORE_MODULES} ${GLOB_OP_LIB})
6

L
Luo Tao 已提交
7 8 9 10
# Merge all modules into a single static library
cc_library(paddle_fluid DEPS paddle_fluid_api ${FLUID_CORE_MODULES} ${GLOB_OP_LIB})

# Create shared library
11
add_library(paddle_fluid_shared SHARED io.cc)
L
Luo Tao 已提交
12 13 14 15 16 17

target_circle_link_libraries(paddle_fluid_shared
  ARCHIVE_START
  ${GLOB_OP_LIB}
  ARCHIVE_END
  ${FLUID_CORE_MODULES})
18

19 20
SET_TARGET_PROPERTIES(paddle_fluid_shared PROPERTIES OUTPUT_NAME paddle_fluid)

L
Luo Tao 已提交
21 22
# install library & headers
if(NOT WITH_C_API AND WITH_FLUID)
23
  install(FILES io.h DESTINATION include/paddle/inference)
L
Luo Tao 已提交
24 25 26
  install(TARGETS paddle_fluid_shared DESTINATION lib)
endif()

27
add_executable(example example.cc)
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
if(APPLE)
  set(OPTIONAL_LINK_FLAGS)
  if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
    set(OPTIONAL_LINK_FLAGS "-undefined dynamic_lookup")
  endif()
  target_link_libraries(example
      -Wl,-force_load paddle_fluid
      ${OPTIONAL_LINK_FLAGS}
      ${PTOOLS_LIB})
else()
  target_link_libraries(example
      -Wl,--start-group -Wl,--whole-archive paddle_fluid
      -Wl,--no-whole-archive -Wl,--end-group
      ${PTOOLS_LIB})
endif()