Skip to content

Commit

Permalink
Fixed ngraph unit-test compilation with protobuf-lite (openvinotoolki…
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov authored and andrei-cv committed Aug 30, 2021
1 parent 389e014 commit 9770ebe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions ngraph/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -613,16 +613,16 @@ if (NGRAPH_ONNX_IMPORT_ENABLE AND NOT NGRAPH_USE_PROTOBUF_LITE)
${Protobuf_INCLUDE_DIRS})
target_compile_definitions(unit-test
PRIVATE $<TARGET_PROPERTY:onnx,INTERFACE_COMPILE_DEFINITIONS>)

get_target_property(ONNX_IMPORTER_SRC_DIR onnx_importer SOURCE_DIR)
target_include_directories(unit-test PRIVATE ${ONNX_IMPORTER_SRC_DIR}/src)
endif()

if (OV_COMPILER_IS_CLANG)
target_compile_options(unit-test PRIVATE -Wno-undef -Wno-reserved-id-macro)
endif()

if (NGRAPH_ONNX_IMPORT_ENABLE)
get_target_property(ONNX_IMPORTER_SRC_DIR onnx_importer SOURCE_DIR)
target_include_directories(unit-test PRIVATE ${ONNX_IMPORTER_SRC_DIR}/src)

target_link_libraries(unit-test PRIVATE onnx_importer)
endif()

Expand Down
7 changes: 1 addition & 6 deletions thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ if(NGRAPH_PDPD_FRONTEND_ENABLE OR NGRAPH_ONNX_IMPORT_ENABLE)
if(VERBOSE_BUILD)
set(Protobuf_DEBUG ON)
endif()
find_package(Protobuf REQUIRED)
find_package(Protobuf 3.9.0 REQUIRED)
if(NGRAPH_USE_PROTOBUF_LITE)
set(Protobuf_LIBRARIES protobuf::libprotobuf-lite)
else()
Expand Down Expand Up @@ -162,11 +162,6 @@ if(NGRAPH_PDPD_FRONTEND_ENABLE OR NGRAPH_ONNX_IMPORT_ENABLE)
target_compile_options(${target} ${link_type} -Wno-undef)
endif()
endforeach()

# version checks
if(protobuf_VERSION VERSION_LESS "3.9" AND NGRAPH_USE_PROTOBUF_LITE)
message(FATAL_ERROR "Minimum supported version of protobuf-lite library is 3.9.0 (provided ${protobuf_VERSION})")
endif()
endif()

#
Expand Down
4 changes: 4 additions & 0 deletions thirdparty/protobuf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ if(NGRAPH_USE_PROTOBUF_LITE)
VISIBILITY_INLINES_HIDDEN OFF)
endif()

if(protobuf_VERSION VERSION_LESS "3.9" AND NGRAPH_USE_PROTOBUF_LITE)
message(FATAL_ERROR "Minimum supported version of protobuf-lite library is 3.9.0 (provided ${protobuf_VERSION})")
endif()

if(ENABLE_LTO AND protobuf_VERSION VERSION_GREATER_EQUAL "3.8")
message(WARNING "Protobuf in version 3.8.0+ can throw runtime exceptions if LTO is enabled.")
endif()
Expand Down

0 comments on commit 9770ebe

Please sign in to comment.