Browse Source

Use bundled generate_protobuf() function

pull/3213/head
Dark Dragon 2 years ago
parent
commit
253baa98a4
1 changed files with 13 additions and 21 deletions
  1. +13
    -21
      cpp/CMakeLists.txt

+ 13
- 21
cpp/CMakeLists.txt View File

@ -221,25 +221,18 @@ endif ()
set (RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../resources")
set (
PROTOBUF_SOURCES "${RESOURCES_DIR}/phonemetadata.proto"
"${RESOURCES_DIR}/phonenumber.proto"
PROTO_FILES "${RESOURCES_DIR}/phonemetadata.proto"
"${RESOURCES_DIR}/phonenumber.proto"
)
set (
PROTOBUF_OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/src/phonenumbers/phonemetadata.pb.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/src/phonenumbers/phonemetadata.pb.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/phonenumbers/phonenumber.pb.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/src/phonenumbers/phonenumber.pb.h"
)
add_custom_command (
COMMAND protobuf::protoc
ARGS --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/src/phonenumbers/ --proto_path=${RESOURCES_DIR} ${PROTOBUF_SOURCES}
VERBATIM
OUTPUT ${PROTOBUF_OUTPUT}
DEPENDS ${PROTOBUF_SOURCES}
)
add_library(proto-objects OBJECT ${PROTO_FILES})
target_link_libraries(proto-objects PUBLIC protobuf::libprotobuf)
set(PROTO_BINARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_include_directories(proto-objects PUBLIC "$<BUILD_INTERFACE:${PROTO_BINARY_DIR}>")
protobuf_generate(
TARGET proto-objects
IMPORT_DIRS "${RESOURCES_DIR}"
PROTOC_OUT_DIR "${PROTO_BINARY_DIR}/phonenumbers")
if (BUILD_GEOCODER)
# Geocoding data cpp file generation
@ -269,9 +262,7 @@ set (
"src/phonenumbers/base/strings/string_piece.cc"
"src/phonenumbers/default_logger.cc"
"src/phonenumbers/logger.cc"
"src/phonenumbers/phonemetadata.pb.cc" # Generated by Protocol Buffers.
"src/phonenumbers/phonenumber.cc"
"src/phonenumbers/phonenumber.pb.cc" # Generated by Protocol Buffers.
"src/phonenumbers/phonenumberutil.cc"
"src/phonenumbers/regex_based_matcher.cc"
"src/phonenumbers/regexp_cache.cc"
@ -292,7 +283,6 @@ if (BUILD_GEOCODER)
"src/phonenumbers/geocoding/geocoding_data.cc"
"src/phonenumbers/geocoding/mapping_file_provider.cc"
"src/phonenumbers/geocoding/phonenumber_offline_geocoder.cc"
"src/phonenumbers/phonenumber.pb.h" # Forces proto buffer generation.
)
endif ()
@ -452,6 +442,8 @@ if (APPLE)
list (APPEND LIBRARY_DEPS ${COREFOUNDATION_LIB} ${FOUNDATION_LIB})
endif ()
list (APPEND LIBRARY_DEPS proto-objects)
#----------------------------------------------------------------
# Build libraries
#----------------------------------------------------------------
@ -603,7 +595,7 @@ endif()
# Install built libraries
#----------------------------------------------------------------
set (BUILT_LIBS)
set (BUILT_LIBS proto-objects)
set(targets_export_name "${PROJECT_NAME}-targets")
if (BUILD_STATIC_LIB)


Loading…
Cancel
Save