CMakeLists.txt 1.5 KB
Newer Older
Z
zhangjinchao01 已提交
1 2 3 4 5 6
set(proto_filenames
    DataConfig.proto
    DataFormat.proto
    ModelConfig.proto
    ParameterConfig.proto
    ParameterService.proto
7
    TrainerConfig.proto
D
dzhwinter 已提交
8
    OptimizerConfig.proto
9
    ParameterServerConfig.proto)
Z
zhangjinchao01 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22

set(PROTO_GEN)
set(PROTO_GEN_PY)

foreach(filename ${proto_filenames})
    get_filename_component(base_filename ${filename} NAME_WE)
    set(CUR_PROTO_GEN
        ${CMAKE_CURRENT_BINARY_DIR}/${base_filename}.pb.h
        ${CMAKE_CURRENT_BINARY_DIR}/${base_filename}.pb.cc)
    set(PROTO_GEN
        ${PROTO_GEN}
        ${CUR_PROTO_GEN})
    add_custom_command(OUTPUT ${CUR_PROTO_GEN}
L
liaogang 已提交
23
        COMMAND env ${py_env} ${PROTOBUF_PROTOC_EXECUTABLE} 
Z
zhangjinchao01 已提交
24
                  --cpp_out ${CMAKE_CURRENT_BINARY_DIR}
25 26
          --proto_path ${PROJ_ROOT}/proto ${PROJ_ROOT}/proto/${filename}
        DEPENDS ${filename} ${external_project_dependencies})
Z
zhangjinchao01 已提交
27 28 29 30 31 32 33

    set(CUR_PROTO_GEN_PY
        ${PROJ_ROOT}/paddle/python/paddle/proto/${base_filename}_pb2.py)
    set(PROTO_GEN_PY
        ${CUR_PROTO_GEN_PY}
        ${PROTO_GEN_PY})
    add_custom_command(OUTPUT ${CUR_PROTO_GEN_PY}
L
liaogang 已提交
34
        COMMAND env ${py_env} ${PROTOBUF_PROTOC_EXECUTABLE} --python_out ${PROJ_ROOT}/python/paddle/proto
35 36
    --proto_path ${PROJ_ROOT}/proto ${PROJ_ROOT}/proto/${filename}
        DEPENDS ${filename} ${external_project_dependencies})
Z
zhangjinchao01 已提交
37 38 39 40
endforeach()

add_custom_target(gen_proto_cpp ALL DEPENDS ${PROTO_GEN})
add_custom_target(gen_proto_py ALL DEPENDS ${PROTO_GEN_PY})
41 42

add_library(paddle_proto STATIC ${PROTO_GEN})
Z
zhangjinchao01 已提交
43
target_include_directories(paddle_proto PUBLIC ${CMAKE_CURRENT_BINARY_DIR})