CMakeLists.txt 7.1 KB
Newer Older
D
dongdaxiang 已提交
1
if (SERVER OR CLIENT)
W
wangguibao 已提交
2
LIST(APPEND protofiles
W
wangguibao 已提交
3 4
        ${CMAKE_CURRENT_LIST_DIR}/proto/server_configure.proto
        ${CMAKE_CURRENT_LIST_DIR}/proto/sdk_configure.proto
5
        ${CMAKE_CURRENT_LIST_DIR}/proto/inferencer_configure.proto
G
guru4elephant 已提交
6
	${CMAKE_CURRENT_LIST_DIR}/proto/general_model_config.proto
W
wangguibao 已提交
7 8 9
)

PROTOBUF_GENERATE_CPP(configure_proto_srcs configure_proto_hdrs ${protofiles})
10
list(APPEND configure_srcs ${configure_proto_srcs})
W
wangguibao 已提交
11

12
list(APPEND configure_srcs ${CMAKE_CURRENT_LIST_DIR}/src/configure_parser.cpp)
W
wangguibao 已提交
13

14
add_library(configure ${configure_srcs})
W
wangguibao 已提交
15
add_dependencies(configure brpc)
W
wangguibao 已提交
16 17 18

add_executable(test_configure
        ${CMAKE_CURRENT_LIST_DIR}/tests/test_configure.cpp)
19
target_link_libraries(test_configure configure protobuf)
20 21 22 23

install(TARGETS configure 
        ARCHIVE DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/lib
        )
G
guru4elephant 已提交
24

W
wangguibao 已提交
25 26 27 28
install(FILES ${CMAKE_CURRENT_LIST_DIR}/include/configure_parser.h
        DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/include/configure/include)

FILE(GLOB inc ${CMAKE_CURRENT_BINARY_DIR}/*.pb.h)
G
guru4elephant 已提交
29

W
wangguibao 已提交
30 31
install(FILES ${inc}
        DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/include/configure)
D
dongdaxiang 已提交
32
endif()
G
guru4elephant 已提交
33

34 35 36 37
py_proto_compile(general_model_config_py_proto SRCS proto/general_model_config.proto)
add_custom_target(general_model_config_py_proto_init ALL COMMAND ${CMAKE_COMMAND} -E touch __init__.py)
add_dependencies(general_model_config_py_proto general_model_config_py_proto_init)

38
if (CLIENT)
G
guru4elephant 已提交
39 40 41 42
py_proto_compile(sdk_configure_py_proto SRCS proto/sdk_configure.proto)
add_custom_target(sdk_configure_py_proto_init ALL COMMAND ${CMAKE_COMMAND} -E touch __init__.py)
add_dependencies(sdk_configure_py_proto sdk_configure_py_proto_init)
add_custom_command(TARGET sdk_configure_py_proto POST_BUILD
G
guru4elephant 已提交
43 44 45
		COMMAND ${CMAKE_COMMAND} -E make_directory ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_client/proto
		COMMAND cp *.py ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_client/proto
		COMMENT "Copy generated python proto into directory paddle_serving_client/proto."
G
guru4elephant 已提交
46
		WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
47 48 49 50 51 52

add_custom_command(TARGET general_model_config_py_proto POST_BUILD
                COMMAND ${CMAKE_COMMAND} -E make_directory ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_client/proto
                COMMAND cp *.py ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_client/proto
                COMMENT "Copy generated general_model_config proto file into directory paddle_serving_client/proto."
                WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
G
guru4elephant 已提交
53
endif()
G
guru4elephant 已提交
54

D
dongdaxiang 已提交
55 56 57 58 59 60 61 62
if (APP)
add_custom_command(TARGET general_model_config_py_proto POST_BUILD
                COMMAND ${CMAKE_COMMAND} -E make_directory ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_app/proto
                COMMAND cp *.py ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_app/proto
                COMMENT "Copy generated general_model_config proto file into directory paddle_serving_app/proto."
                WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()

63
if (SERVER)
G
guru4elephant 已提交
64 65 66
py_proto_compile(server_config_py_proto SRCS proto/server_configure.proto)
add_custom_target(server_config_py_proto_init ALL COMMAND ${CMAKE_COMMAND} -E touch __init__.py)
add_dependencies(server_config_py_proto server_config_py_proto_init)
B
barrierye 已提交
67 68 69 70 71 72 73 74

py_proto_compile(pyserving_channel_py_proto SRCS proto/pyserving_channel.proto)
add_custom_target(pyserving_channel_py_proto_init ALL COMMAND ${CMAKE_COMMAND} -E touch __init__.py)
add_dependencies(pyserving_channel_py_proto pyserving_channel_py_proto_init)

py_grpc_proto_compile(general_python_service_py_proto SRCS proto/general_python_service.proto)
add_custom_target(general_python_service_py_proto_init ALL COMMAND ${CMAKE_COMMAND} -E touch __init__.py)
add_dependencies(general_python_service_py_proto general_python_service_py_proto_init)
M
MRXLT 已提交
75
if (NOT WITH_GPU)
G
guru4elephant 已提交
76
add_custom_command(TARGET server_config_py_proto POST_BUILD
G
guru4elephant 已提交
77 78 79
		COMMAND ${CMAKE_COMMAND} -E make_directory ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_server/proto
		COMMAND cp *.py ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_server/proto
		COMMENT "Copy generated python proto into directory paddle_serving_server/proto."
G
guru4elephant 已提交
80
		WORKING_DIRECTORY ${CMAKE_CURRENT_BINRARY_DIR})
81 82 83 84 85 86

add_custom_command(TARGET general_model_config_py_proto POST_BUILD
		COMMAND ${CMAKE_COMMAND} -E make_directory ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_server/proto
		COMMAND cp *.py ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_server/proto
		COMMENT "Copy generated general_model_config proto file into directory paddle_serving_server/proto."
		WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
B
barrierye 已提交
87 88 89 90 91 92 93 94 95 96 97 98

add_custom_command(TARGET general_python_service_py_proto POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E make_directory ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_server/proto
        COMMAND cp *.py ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_server/proto
        COMMENT "Copy generated general_python_service proto file into directory paddle_serving_server/proto."
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
            
add_custom_command(TARGET pyserving_channel_py_proto POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E make_directory ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_server/proto
        COMMAND cp *.py ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_server/proto
        COMMENT "Copy generated pyserving_channel proto file into directory paddle_serving_server/proto."
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
M
MRXLT 已提交
99 100 101 102 103 104 105 106 107
else()
add_custom_command(TARGET server_config_py_proto POST_BUILD
		COMMAND ${CMAKE_COMMAND} -E make_directory
        ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_server_gpu/proto
		COMMAND cp *.py
        ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_server_gpu/proto
		COMMENT "Copy generated python proto into directory
        paddle_serving_server_gpu/proto."
		WORKING_DIRECTORY ${CMAKE_CURRENT_BINRARY_DIR})
108

M
MRXLT 已提交
109 110 111 112 113 114 115 116
add_custom_command(TARGET general_model_config_py_proto POST_BUILD
		COMMAND ${CMAKE_COMMAND} -E make_directory
        ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_server_gpu/proto
		COMMAND cp *.py
        ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_server_gpu/proto
		COMMENT "Copy generated general_model_config proto file into directory
        paddle_serving_server_gpu/proto."
		WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
B
barrierye 已提交
117 118 119 120 121 122 123 124 125 126 127 128

add_custom_command(TARGET general_python_service_py_proto POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E make_directory ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_server_gpu/proto
        COMMAND cp *.py ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_server_gpu/proto
        COMMENT "Copy generated general_python_service proto file into directory paddle_serving_server_gpu/proto."
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

add_custom_command(TARGET pyserving_channel_py_proto POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E make_directory ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_server_gpu/proto
        COMMAND cp *.py ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_server_gpu/proto
        COMMENT "Copy generated pyserving_channel proto file into directory paddle_serving_server_gpu/proto."
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
M
MRXLT 已提交
129
endif()
G
guru4elephant 已提交
130
endif()