From c7f7bccba0c70e34fb6133edac3504a55308969e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Tue, 29 Jan 2019 18:56:11 +0900 Subject: [PATCH] Rollback Protocol Buffer 3.6.1 integration (#2949) Let's rollback to previous Protocol Buffer import routine. Signed-off-by: Jonghyun Park --- CMakeLists.txt | 2 +- cmake/packages/ProtobufConfig.cmake | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 859c017..abd31fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ message(STATUS "Use '${CMAKE_BUILD_TYPE}' configuration") ### Configuration ### option(DOWNLOAD_PROTOBUF "Download Protocol Buffer source" ON) -option(BUILD_PROTOBUF "Locally build Protocol Buffer from the downloaded source" ON) +option(BUILD_PROTOBUF "Locally build Protocol Buffer from the downloaded source" OFF) option(DOWNLOAD_EIGEN "Download Eigen source" ON) option(DOWNLOAD_FARMHASH "Download farmhash source" ON) option(DOWNLOAD_GEMMLOWP "Download GEMM low precesion library source" ON) diff --git a/cmake/packages/ProtobufConfig.cmake b/cmake/packages/ProtobufConfig.cmake index 5679614..2bacde6 100644 --- a/cmake/packages/ProtobufConfig.cmake +++ b/cmake/packages/ProtobufConfig.cmake @@ -1,3 +1,27 @@ +# TODO Use CONFIG version after bug fix +function(_Protobuf_module_import) + # Let's use find_package here not to export unnecessary definitions + find_package(Protobuf MODULE QUIET) + + if(NOT PROTOBUF_FOUND) + set(Protobuf_FOUND FALSE PARENT_SCOPE) + return() + endif(NOT PROTOBUF_FOUND) + + if(NOT TARGET protoc) + add_executable(protoc IMPORTED) + set_target_properties(protoc PROPERTIES IMPORTED_LOCATION ${PROTOBUF_PROTOC_EXECUTABLE}) + endif(NOT TARGET protoc) + + if(NOT TARGET libprotobuf) + add_library(libprotobuf INTERFACE) + target_include_directories(libprotobuf INTERFACE ${PROTOBUF_INCLUDE_DIRS}) + target_link_libraries(libprotobuf INTERFACE ${PROTOBUF_LIBRARIES}) + endif(NOT TARGET libprotobuf) + + set(Protobuf_FOUND TRUE PARENT_SCOPE) +endfunction(_Protobuf_module_import) + function(_Protobuf_import) # Let's use find_package here not to export unnecessary definitions # NOTE Here we use "exact" match to avoid possible infinite loop @@ -78,8 +102,10 @@ function(_Protobuf_build) message(STATUS "Succeeded in building Protocol Buffer") endfunction(_Protobuf_build) +# TODO Use Protocol Buffer 3.6.1 _Protobuf_build() -_Protobuf_import() +#_Protobuf_import() +_Protobuf_module_import() if(Protobuf_FOUND) function(Protobuf_Generate PREFIX OUTPUT_DIR PROTO_DIR) -- 2.7.4