Build tensorflow_graphdef by default
authorJonghyun Park <jh1302.park@samsung.com>
Thu, 8 Mar 2018 01:59:55 +0000 (10:59 +0900)
committer박세희/동작제어Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Thu, 8 Mar 2018 22:10:05 +0000 (07:10 +0900)
This commit enables tensorflow_graphdef (and graphdump) build by
default (using protobuf in external).

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
externals/CMakeLists.txt
tools/graphdump/CMakeLists.txt

index 08d366f..63d6bb9 100644 (file)
@@ -16,13 +16,16 @@ set(TENSORFLOW_BASE ${CMAKE_CURRENT_SOURCE_DIR}/tensorflow)
 set(TENSORFLOW_LITE_BASE ${TENSORFLOW_BASE}/tensorflow/contrib/lite)
 
 #
-# TensorFlow Graph Definition Accessor
+# Protocol Buffer (>= 3.5.1)
 #
-if(ENABLE_TENSORFLOW_GRAPHDEF)
-  include(FindProtobuf)
+set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build tests" FORCE)
 
-  find_package(Protobuf REQUIRED)
+add_subdirectory(protobuf/cmake)
 
+#
+# TensorFlow Graph Definition Accessor
+#
+# TODO Reduce indentation level
   list(APPEND TF_GRAPH_PROTO_TAGS tensorflow/core/framework/versions)
   list(APPEND TF_GRAPH_PROTO_TAGS tensorflow/core/framework/function)
   list(APPEND TF_GRAPH_PROTO_TAGS tensorflow/core/framework/types)
@@ -39,15 +42,14 @@ if(ENABLE_TENSORFLOW_GRAPHDEF)
   foreach(TF_GRAPH_PROTO_TAG ${TF_GRAPH_PROTO_TAGS})
     add_custom_command(OUTPUT "${TF_GRAPH_PROTO_GENERATED}/${TF_GRAPH_PROTO_TAG}.pb.cc"
                        COMMAND mkdir -p "${TF_GRAPH_PROTO_GENERATED}"
-                       COMMAND protoc --proto_path=${TENSORFLOW_BASE} --cpp_out=${TF_GRAPH_PROTO_GENERATED} "${TF_GRAPH_PROTO_TAG}.proto")
+                       COMMAND $<TARGET_FILE:protoc> --proto_path=${TENSORFLOW_BASE} --cpp_out=${TF_GRAPH_PROTO_GENERATED} "${TF_GRAPH_PROTO_TAG}.proto")
 
     list(APPEND TF_GRAPH_PROTO_SRCS "${TF_GRAPH_PROTO_GENERATED}/${TF_GRAPH_PROTO_TAG}.pb.cc")
   endforeach()
 
   add_library(tensorflow_graphdef ${TF_GRAPH_PROTO_SRCS})
-  target_include_directories(tensorflow_graphdef PUBLIC ${TF_GRAPH_PROTO_GENERATED} ${PROTOBUF_INCLUDE_DIRS})
-  target_link_libraries(tensorflow_graphdef PUBLIC ${PROTOBUF_LIBRARIES})
-endif(ENABLE_TENSORFLOW_GRAPHDEF)
+  target_include_directories(tensorflow_graphdef PUBLIC ${TF_GRAPH_PROTO_GENERATED})
+  target_link_libraries(tensorflow_graphdef PUBLIC libprotobuf)
 
 #
 # Tensorflow Lite library
index ebb6a4f..7d6a462 100644 (file)
@@ -1,7 +1,6 @@
 # NOTE Graph dump uses libtensorflow_graphdef
-if(ENABLE_TENSORFLOW_GRAPHDEF)
+# TODO Reduce indentation level
   list(APPEND SRCS "src/graphdump.cc")
 
   add_executable(graphdump ${SRCS})
   target_link_libraries(graphdump tensorflow_graphdef)
-endif(ENABLE_TENSORFLOW_GRAPHDEF)