Add 'CaffeProto' as an external module (#193)
author박종현/동작제어Lab(SR)/Senior Engineer/삼성전자 <jh1302.park@samsung.com>
Fri, 4 May 2018 01:14:35 +0000 (10:14 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Fri, 4 May 2018 01:14:35 +0000 (10:14 +0900)
This commit adds 'CaffeProto' external module which provides
'libcaffeproto' library. This library allows us to parse .prototxt
and .caffemodel files.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
cmake/packages/CaffeProtoConfig.cmake [new file with mode: 0644]

diff --git a/cmake/packages/CaffeProtoConfig.cmake b/cmake/packages/CaffeProtoConfig.cmake
new file mode 100644 (file)
index 0000000..7863a24
--- /dev/null
@@ -0,0 +1,27 @@
+function(_CaffeProto_import)
+  nncc_find_package(CaffeSource)
+
+  if(NOT CaffeSource_FOUND)
+    set(CaffeProto_FOUND FALSE PARENT_SCOPE)
+    return()
+  endif(NOT CaffeSource_FOUND)
+
+  nncc_find_package(Protobuf)
+
+  if(NOT Protobuf_FOUND)
+    set(CaffeProto_FOUND FALSE PARENT_SCOPE)
+    return()
+  endif(NOT Protobuf_FOUND)
+
+  Protobuf_Generate(CAFFE_PROTO "${CMAKE_BINARY_DIR}/generated/caffe" "${CaffeSource_DIR}/src" "caffe/proto/caffe.proto")
+
+  if(NOT TARGET caffeproto)
+    add_library(caffeproto SHARED ${CAFFE_PROTO_SOURCES})
+    target_include_directories(caffeproto PUBLIC ${CAFFE_PROTO_INCLUDE_DIRS})
+    target_link_libraries(caffeproto libprotobuf)
+  endif(NOT TARGET caffeproto)
+
+  set(CaffeProto_FOUND TRUE PARENT_SCOPE)
+endfunction(_CaffeProto_import)
+
+_CaffeProto_import()