CMakeLists.txt 782 字节
Newer Older
Y
Yu Yang 已提交
1
file(GLOB proto_filenames . *.proto)
Y
Yu Yang 已提交
2
proto_library(paddle_proto SRCS ${proto_filenames})
Y
Yu Yang 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

set(PROTO_GEN)
set(PROTO_GEN_PY)

foreach(filename ${proto_filenames})
    get_filename_component(base_filename ${filename} NAME_WE)
    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}
            COMMAND env ${py_env} ${PROTOBUF_PROTOC_EXECUTABLE} --python_out ${PROJ_ROOT}/python/paddle/proto
            --proto_path ${PROJ_ROOT}/proto ${PROJ_ROOT}/proto/${filename}
            DEPENDS ${filename} ${external_project_dependencies})
endforeach()

add_custom_target(gen_proto_py ALL DEPENDS ${PROTO_GEN_PY})