CMake changes were done to allow ONNX downloading and onnx.proto compiling.
Signed-off-by: Andrew V. Tischenko a.tischenko@partner.samsung.com
option(DOWNLOAD_FLATBUFFERS "Download FlatBuffers source" ON)
option(DOWNLOAD_TENSORFLOW "Download TensorFlow source" ON)
option(DOWNLOAD_CAFFE "Download Caffe source" ON)
+# TODO: we need protoc version 2.6 and higher but server has 2.5 only
+# that's why we can't compile onnx.proto
+option(DOWNLOAD_ONNX "Download ONNX source" OFF)
option(BUILD_GTEST "Download and build Google Test" ON)
--- /dev/null
+Protobuf_Generate(ONNX_PROTO "${CMAKE_CURRENT_BINARY_DIR}/generated"
+ "${ONNXSource_DIR}" "onnx/onnx.proto")
+
+add_library(onnxproto SHARED ${ONNX_PROTO_SOURCES})
+target_include_directories(onnxproto PUBLIC ${ONNX_PROTO_INCLUDE_DIRS})
+target_link_libraries(onnxproto libprotobuf)
--- /dev/null
+function(_ONNXProto_import)
+ nncc_find_package(ONNXSource QUIET)
+
+ if(NOT ONNXSource_FOUND)
+ set(ONNXProto_FOUND FALSE PARENT_SCOPE)
+ return()
+ endif(NOT ONNXSource_FOUND)
+
+ nncc_find_package(Protobuf QUIET)
+
+ if(NOT Protobuf_FOUND)
+ set(ONNXProto_FOUND FALSE PARENT_SCOPE)
+ return()
+ endif(NOT Protobuf_FOUND)
+
+ if(NOT TARGET onnxproto)
+ nncc_include(ExternalProjectTools)
+ add_extdirectory("${CMAKE_CURRENT_LIST_DIR}/ONNXProto" onnxproto)
+ endif(NOT TARGET onnxproto)
+
+ message(STATUS "Found ONNX: TRUE")
+ set(ONNXProto_FOUND TRUE PARENT_SCOPE)
+endfunction(_ONNXProto_import)
+
+_ONNXProto_import()
--- /dev/null
+function(_ONNXSource_import)
+ if(NOT DOWNLOAD_ONNX)
+ set(ONNXSource_FOUND FALSE PARENT_SCOPE)
+ return()
+ endif(NOT DOWNLOAD_ONNX)
+
+ nncc_include(ExternalSourceTools)
+ nncc_include(OptionTools)
+
+ envoption(ONNX_URL https://github.com/onnx/onnx/archive/v1.3.0.zip)
+ ExternalSource_Download(ONNX ${ONNX_URL})
+
+ set(ONNXSource_DIR ${ONNX_SOURCE_DIR} PARENT_SCOPE)
+ set(ONNXSource_FOUND TRUE PARENT_SCOPE)
+endfunction(_ONNXSource_import)
+
+_ONNXSource_import()