--- /dev/null
+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()