CMakeLists.txt 2.2 KB
Newer Older
Y
Yu Yang 已提交
1 2 3 4 5 6
if (WITH_DOUBLE)
  set(PADDLE_FLOAT_TYPE double)
else ()
  set(PADDLE_FLOAT_TYPE float)
endif()

Y
Yu Yang 已提交
7 8 9 10
# config.h used for C-API. It will store Paddle building configuration as a
# header. Make user just include PaddleCAPI.h then can get building
# configuration without explicitly set -DPADDLE_WITH_DOUBLE when building their
# libraries.
Y
Yu Yang 已提交
11 12
configure_file(config.h.in config.h @ONLY)

Y
Yu Yang 已提交
13 14
# PaddleCAPI.h is the only header we exposed. It currently only used for model
# inference.
Y
Yu Yang 已提交
15
file(GLOB CAPI_HEADERS *.h)
Y
Yu Yang 已提交
16
set(CAPI_PRIVATE_HEADER capi_private.h)
Y
Yu Yang 已提交
17
list(REMOVE_ITEM CAPI_HEADERS ${CAPI_PRIVATE_HEADER})
Y
Yu Yang 已提交
18 19
file(GLOB CAPI_SOURCES *.cpp)

Y
Yu Yang 已提交
20
# building paddle_capi
Y
Yu Yang 已提交
21 22
add_library(paddle_capi STATIC ${CAPI_HEADERS} ${CAPI_PRIVATE_HEADER}
  ${CAPI_SOURCES})
Y
Yu Yang 已提交
23 24

target_include_directories(paddle_capi PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
Y
Yu Yang 已提交
25

Y
Yu Yang 已提交
26 27
add_style_check_target(paddle_capi ${CAPI_SOURCES} ${CAPI_HEADER}
  ${CAPI_PRIVATE_HEADER})
Y
Yu Yang 已提交
28

Y
Yu Yang 已提交
29
add_dependencies(paddle_capi paddle_proto)
Y
Yu Yang 已提交
30

Y
Yu Yang 已提交
31 32 33

# combine all paddle static libraries together, into libpaddle_capi_whole.a
# user should use PaddleCAPI as -lpaddle_capi_whole
34 35 36 37 38 39 40 41 42
set(PADDLE_INFER_LIBS
    paddle_utils
    paddle_parameter
    paddle_math
    paddle_cuda
    paddle_function
    paddle_gserver
    paddle_proto
    )
Y
Yu Yang 已提交
43

44 45 46 47 48 49 50 51 52 53
set(PADDLE_TRAIN_LIBS paddle_pserver paddle_network)

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()
Y
Yu Yang 已提交
54

Y
Yu Yang 已提交
55
# install library & headers.
Y
Yu Yang 已提交
56
install(FILES ${CAPI_HEADERS} DESTINATION include/paddle)
Y
Yu Yang 已提交
57
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h DESTINATION include/paddle)
58
if(ANDROID)
59 60 61
  install(TARGETS paddle_capi_whole paddle_capi_shared
          ARCHIVE DESTINATION lib/${ANDROID_ABI}
          LIBRARY DESTINATION lib/${ANDROID_ABI})
62
else(ANDROID)
63 64 65 66 67
  install(TARGETS paddle_capi_whole
          ARCHIVE DESTINATION lib)
  if(NOT IOS)
    install(TARGETS paddle_capi_shared DESTINATION lib)
  endif()
68
endif(ANDROID)
Y
Yu Yang 已提交
69 70

# this variable used for unittest
Y
Yu Yang 已提交
71 72 73 74 75 76 77
set(PADDLE_CAPI_INC_PATH
  ${CMAKE_CURRENT_BINARY_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR})

if (WITH_TESTING)
  add_subdirectory(tests)
endif()