CMakeLists.txt 2.7 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
    SequenceGenerator.cpp
    Trainer.cpp
    Util.cpp
    Vector.cpp)
set(API_HEADER
    PaddleAPI.h
    Internal.h)

L
liaogang 已提交
18
add_library(paddle_api STATIC ${API_SOURCES})
Z
zhangjinchao01 已提交
19 20
add_dependencies(paddle_api gen_proto_cpp)

L
liaogang 已提交
21 22
INCLUDE(${SWIG_USE_FILE})
INCLUDE_DIRECTORIES(${PROJ_ROOT}/paddle)
Z
zhangjinchao01 已提交
23

L
liaogang 已提交
24 25 26
FILE(GLOB PY_PADDLE_PYTHON_FILES ${PROJ_ROOT}/paddle/py_paddle/*.py)

SET_SOURCE_FILES_PROPERTIES(Paddle.i PROPERTIES CPLUSPLUS ON)
Z
zhangjinchao01 已提交
27

L
liaogang 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
SET(CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_BINARY_DIR})
SET(CMAKE_CXX_FLAGS "-std=c++11 -fPIC")
SET(SWIG_MODULE_swig_paddle_EXTRA_DEPS
    paddle_parameter
    paddle_function
    paddle_math
    paddle_utils
    paddle_gserver
    paddle_pserver
    paddle_api
    paddle_cuda
    paddle_trainer_lib
    paddle_network
    paddle_proto
    ${PY_PADDLE_PYTHON_FILES}
    ${external_project_dependencies}
Z
zhangjinchao01 已提交
44 45
)

L
liaogang 已提交
46 47 48
IF(APPLE)
    SET(CMAKE_LINK_FLAGS "-undefined dynamic_lookup -Wl,-all_load")
ENDIF(APPLE)
Z
zhangjinchao01 已提交
49

L
liaogang 已提交
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
SWIG_ADD_MODULE(swig_paddle python Paddle.i)
SWIG_LINK_LIBRARIES(swig_paddle
    ${CMAKE_LINK_FLAGS}
    ${CMAKE_DL_LIBS}
    ${EXTERNAL_LIBS}
    ${PYTHON_LIBRARIES}
    ${CMAKE_THREAD_LIBS_INIT}
    ${RDMA_LD_FLAGS}
    ${RDMA_LIBS}
    paddle_parameter
    paddle_function
    paddle_math
    paddle_utils
    paddle_gserver
    paddle_pserver
    paddle_api
    paddle_cuda
    paddle_trainer_lib
    paddle_network
    paddle_proto
)
E
emailweixu 已提交
71

72
add_custom_command(OUTPUT ${PROJ_ROOT}/paddle/dist/.timestamp
L
liaogang 已提交
73 74
    COMMAND mv ${CMAKE_CURRENT_BINARY_DIR}/swig_paddle.py ${PROJ_ROOT}/paddle/py_paddle
         && mv ${CMAKE_CURRENT_BINARY_DIR}/_swig_paddle.so ${PROJ_ROOT}/paddle/py_paddle
L
liaogang 已提交
75
    COMMAND env ${py_env} ${PYTHON_EXECUTABLE} setup.py bdist_wheel
76 77
    COMMAND ${CMAKE_COMMAND} -E touch dist/.timestamp
    COMMAND rm -rf py_paddle.egg-info build
Z
zhangjinchao01 已提交
78
    WORKING_DIRECTORY ${PROJ_ROOT}/paddle
L
liaogang 已提交
79
    DEPENDS _swig_paddle
Z
zhangjinchao01 已提交
80 81
)

L
liaogang 已提交
82
add_custom_target(python_api_wheel ALL DEPENDS ${PROJ_ROOT}/paddle/dist/.timestamp)
Z
zhangjinchao01 已提交
83

L
liaogang 已提交
84
install(DIRECTORY ${PROJ_ROOT}/paddle/dist/ DESTINATION opt/paddle/share/wheels)
Z
zhangjinchao01 已提交
85 86

if(WITH_TESTING)
87 88 89 90 91 92 93 94 95 96 97 98 99 100
    IF(NOT PY_PIP_FOUND)
        SET(PIP_SOURCES_DIR ${PYTHON_SOURCES_DIR}/pip)
        ExternalProject_Add(pip
            ${EXTERNAL_PROJECT_LOG_ARGS}
            GIT_REPOSITORY      https://github.com/pypa/pip.git
            GIT_TAG             9.0.1
            PREFIX              ${PIP_SOURCES_DIR}
            CONFIGURE_COMMAND   ""
            BUILD_COMMAND       ""
            INSTALL_COMMAND     env ${py_env} ${PYTHON_EXECUTABLE} setup.py install
            BUILD_IN_SOURCE     1
            DEPENDS python setuptools python_api_wheel
        )
    ENDIF()
Z
zhangjinchao01 已提交
101 102
    add_subdirectory(test)
endif()