Commit 9ede407b authored by zhujiashun's avatar zhujiashun

add generating proto code to compatible with different version of cmake

parent 452c3c3b
......@@ -124,6 +124,27 @@ foreach(PROTO ${PROTOS})
)
endforeach()
file(GLOB brpc_PROTOS "src/brpc/*.proto")
foreach(PROTO ${brpc_PROTOS})
get_filename_component(PROTO_WE ${PROTO} NAME_WE)
list(APPEND PROTO_SRCS "${CMAKE_CURRENT_BINARY_DIR}/brpc/${PROTO_WE}.pb.cc")
execute_process(
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} --proto_path=${PROTOBUF_INCLUDE_DIR} --proto_path=${CMAKE_SOURCE_DIR}/src --proto_path=${CMAKE_SOURCE_DIR}/src/brpc/ ${PROTO}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endforeach()
file(GLOB brpc_policy_PROTOS "src/brpc/policy/*.proto")
foreach(PROTO ${brpc_policy_PROTOS})
get_filename_component(PROTO_WE ${PROTO} NAME_WE)
list(APPEND PROTO_SRCS "${CMAKE_CURRENT_BINARY_DIR}/brpc/policy/${PROTO_WE}.pb.cc")
execute_process(
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} --proto_path=${PROTOBUF_INCLUDE_DIR} --proto_path=${CMAKE_SOURCE_DIR}/src --proto_path=${CMAKE_SOURCE_DIR}/src/brpc/policy ${PROTO}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endforeach()
# list all source files
set(BUTIL_SOURCES
${CMAKE_SOURCE_DIR}/src/butil/third_party/dmg_fp/g_fmt.cc
${CMAKE_SOURCE_DIR}/src/butil/third_party/dmg_fp/dtoa_wrapper.cc
......@@ -273,12 +294,12 @@ set(SOURCES
${PROTO_SRCS}
)
ADD_SUBDIRECTORY(src)
add_subdirectory(src)
if(BUILD_EXAMPLE)
ADD_SUBDIRECTORY(example)
add_subdirectory(example)
endif()
if(BUILD_UNIT_TESTS)
ADD_SUBDIRECTORY(test)
add_subdirectory(test)
endif()
install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/
......@@ -287,3 +308,10 @@ install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/
PATTERN "*.h"
PATTERN "*.hpp"
)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/
DESTINATION include
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp"
)
......@@ -12,6 +12,7 @@ include_directories(${CMAKE_SOURCE_DIR}/src)
add_library(BUTIL_LIB OBJECT ${BUTIL_SOURCES})
add_library(OBJ_LIB OBJECT ${SOURCES})
# shared library needs POSITION_INDEPENDENT_CODE
set_property(TARGET ${OBJ_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1)
set_property(TARGET ${BUTIL_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1)
......@@ -44,3 +45,9 @@ install(TARGETS brpc
LIBRARY DESTINATION lib${LIBSUFFIX}
ARCHIVE DESTINATION lib${LIBSUFFIX}
)
install(TARGETS brpc_static
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIBSUFFIX}
ARCHIVE DESTINATION lib${LIBSUFFIX}
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment