Rollback Protocol Buffer 3.6.1 integration (#2949)
author박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 29 Jan 2019 09:56:11 +0000 (18:56 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 29 Jan 2019 09:56:11 +0000 (18:56 +0900)
Let's rollback to previous Protocol Buffer import routine.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
CMakeLists.txt
cmake/packages/ProtobufConfig.cmake

index 859c017..abd31fe 100644 (file)
@@ -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)
index 5679614..2bacde6 100644 (file)
@@ -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)