CMakeLists.txt 4.8 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 53

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 已提交
54
endif()
G
guru4elephant 已提交
55

D
dongdaxiang 已提交
56 57 58 59 60 61 62 63
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()

64
if (SERVER)
G
guru4elephant 已提交
65 66 67
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)
M
MRXLT 已提交
68
if (NOT WITH_GPU)
G
guru4elephant 已提交
69
add_custom_command(TARGET server_config_py_proto POST_BUILD
G
guru4elephant 已提交
70 71 72
		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 已提交
73
		WORKING_DIRECTORY ${CMAKE_CURRENT_BINRARY_DIR})
74 75 76 77 78 79

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})
M
MRXLT 已提交
80 81 82 83 84 85 86 87 88
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})
89

M
MRXLT 已提交
90 91 92 93 94 95 96 97 98
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})
endif()
G
guru4elephant 已提交
99
endif()