CMakeLists.txt 2.1 KB
Newer Older
Z
zhangjinchao01 已提交
1 2 3
set(API_SOURCES
    Arguments.cpp
    ConfigParser.cpp
Y
Yu Yang 已提交
4
    Evaluator.cpp
Z
zhangjinchao01 已提交
5 6 7 8
    GradientMachine.cpp
    Matrix.cpp
    Parameter.cpp
    ParameterOptimizer.cpp
Y
Yu Yang 已提交
9
    ParameterUpdater.cpp
Z
zhangjinchao01 已提交
10 11 12 13 14 15 16 17 18 19 20 21
    SequenceGenerator.cpp
    Trainer.cpp
    Util.cpp
    Vector.cpp)
set(API_HEADER
    PaddleAPI.h
    Internal.h)

add_library(paddle_api STATIC
        ${API_SOURCES})
add_dependencies(paddle_api gen_proto_cpp)

22
list(LENGTH "${GFLAGS_LIBRARIES}" GFLAGS_LIBRARIES_LENGTH)
Z
zhangjinchao01 已提交
23

24 25 26 27 28 29 30 31
if(${GFLAGS_LIBRARIES_LENGTH} EQUAL 0 AND TARGET "${GFLAGS_LIBRARIES}")
# Because gflags compiled by cmake, so it is imported by cmake target,
# not a real library path. Get the real library path here.
message(STATUS "GFLAGS Libraries is ${GFLAGS_LIBRARIES}")
get_target_property(GFLAGS_LOCATION ${GFLAGS_LIBRARIES} LOCATION)
message(STATUS "GFLAGS Target location is ${GFLAGS_LOCATION}")
else()
set(GFLAGS_LOCATION ${GFLAGS_LIBRARIES})
Z
zhangjinchao01 已提交
32 33 34 35 36 37 38 39 40
endif()

configure_file(
    paddle_api_config.py.in
    ${PROJ_ROOT}/paddle/api/paddle_api_config.py
)

generate_python_api(python_swig_sources)

E
emailweixu 已提交
41 42
file(GLOB PY_PADDLE_PYTHON_FILES ${PROJ_ROOT}/paddle/py_paddle/*.py)

Z
zhangjinchao01 已提交
43
# TODO(yuyang18) : make wheel name calculated by cmake
44 45 46 47
add_custom_command(OUTPUT ${PROJ_ROOT}/paddle/dist/.timestamp
    COMMAND ${PYTHON_EXECUTABLE} setup.py  bdist_wheel
    COMMAND ${CMAKE_COMMAND} -E touch dist/.timestamp
    COMMAND rm -rf py_paddle.egg-info build
Z
zhangjinchao01 已提交
48 49 50
    WORKING_DIRECTORY ${PROJ_ROOT}/paddle
    DEPENDS python_swig_sources
            paddle_parameter
H
hedaoyuan 已提交
51
            paddle_function
Z
zhangjinchao01 已提交
52 53 54 55 56 57 58
            paddle_math
            paddle_utils
            paddle_gserver
            paddle_pserver
            paddle_trainer
            paddle_api
            paddle_cuda
59
        ${PY_PADDLE_PYTHON_FILES}
Z
zhangjinchao01 已提交
60 61
)

62 63 64
install(DIRECTORY ${PROJ_ROOT}/paddle/dist/
    DESTINATION opt/paddle/share/wheels
)
Z
zhangjinchao01 已提交
65 66

add_custom_target(python_api_wheel ALL DEPENDS
67
  ${PROJ_ROOT}/paddle/dist/.timestamp)
Y
Yu Yang 已提交
68 69 70 71 72 73 74 75 76
add_dependencies(python_api_wheel python_swig_sources
  paddle_parameter
  paddle_math
  paddle_utils
  paddle_gserver
  paddle_pserver
  paddle_trainer
  paddle_api
  paddle_cuda)
Z
zhangjinchao01 已提交
77 78 79 80

if(WITH_TESTING)
    add_subdirectory(test)
endif()