-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add pb_cc_library in generic.cmake #2653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
b1a311c
30b75a5
64b78b1
456f9cc
32d6587
b88ca54
4a4ec31
2d3c186
3d44fd5
52efb24
a1e7284
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -331,3 +331,14 @@ function(go_test TARGET_NAME) | |
| add_custom_target(${TARGET_NAME} ALL DEPENDS ${TARGET_NAME}_timestamp ${go_test_DEPS}) | ||
| add_test(${TARGET_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}) | ||
| endfunction(go_test) | ||
|
|
||
| function(proto_library TARGET_NAME) | ||
| set(oneValueArgs "") | ||
| set(multiValueArgs SRCS) | ||
| cmake_parse_arguments(proto_library "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||
| set(proto_srcs) | ||
| set(proto_hdrs) | ||
| protobuf_generate_cpp(proto_srcs proto_hdrs ${proto_library_SRCS}) | ||
| include_directories(${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
| cc_library(${TARGET_NAME} SRCS ${proto_srcs}) | ||
|
||
| endfunction() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,43 +1,22 @@ | ||
| set(proto_filenames | ||
| DataConfig.proto | ||
| DataFormat.proto | ||
| ModelConfig.proto | ||
| ParameterConfig.proto | ||
| ParameterService.proto | ||
| TrainerConfig.proto | ||
| OptimizerConfig.proto | ||
| ParameterServerConfig.proto) | ||
| file(GLOB proto_filenames . *.proto) | ||
| proto_library(paddle_proto SRCS ${proto_filenames}) | ||
|
|
||
| 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} | ||
| COMMAND env ${py_env} ${PROTOBUF_PROTOC_EXECUTABLE} | ||
| --cpp_out ${CMAKE_CURRENT_BINARY_DIR} | ||
| --proto_path ${PROJ_ROOT}/proto ${PROJ_ROOT}/proto/${filename} | ||
| DEPENDS ${filename} ${external_project_dependencies}) | ||
|
|
||
| get_filename_component(ABS_FIL ${filename} ABSOLUTE) | ||
| get_filename_component(FIL_WE ${filename} NAME_WE) | ||
| set(CUR_PROTO_GEN_PY | ||
| ${PROJ_ROOT}/paddle/python/paddle/proto/${base_filename}_pb2.py) | ||
| ${PROJ_ROOT}/paddle/python/paddle/proto/${FIL_WE}_pb2.py) | ||
| set(PROTO_GEN_PY | ||
| ${CUR_PROTO_GEN_PY} | ||
| ${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}) | ||
| COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} | ||
| ARGS "--python_out=${PROJ_ROOT}/python/paddle/proto" | ||
| "-I" ${CMAKE_CURRENT_SOURCE_DIR} ${ABS_FIL} | ||
| DEPENDS ${ABS_FIL} ${external_project_dependencies}) | ||
| endforeach() | ||
|
|
||
| add_custom_target(gen_proto_cpp ALL DEPENDS ${PROTO_GEN}) | ||
| add_custom_target(gen_proto_py ALL DEPENDS ${PROTO_GEN_PY}) | ||
|
|
||
| add_library(paddle_proto STATIC ${PROTO_GEN}) | ||
| target_include_directories(paddle_proto PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd thought that we should moved
include_directories(${CMAKE_CURRENT_BINARY_DIR})out from this function to the top of generic.cmake?