diff --git a/cmake/external_protobuf.cmake b/cmake/external_protobuf.cmake index 9d5111b78..215af9914 100644 --- a/cmake/external_protobuf.cmake +++ b/cmake/external_protobuf.cmake @@ -44,7 +44,8 @@ if(CMAKE_CROSSCOMPILING) message(FATAL_ERROR "System Protobuf is needed while cross-compiling") endif() else() - set(PROTOC_VERSION "3.7.1") + # This version of Protobuf needs to match the version used by ONNX Runtime + set(PROTOC_VERSION "3.11.3") endif() set(NGRAPH_PROTOBUF_GIT_TAG "v${PROTOC_VERSION}") @@ -178,14 +179,21 @@ endif() # Use the interface of FindProtobuf.cmake # ----------------------------------------------------------------------------- -if (NOT TARGET protobuf::libprotobuf) - add_library(protobuf::libprotobuf UNKNOWN IMPORTED) - set_target_properties(protobuf::libprotobuf PROPERTIES - INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}" - IMPORTED_LOCATION "${Protobuf_LIBRARY}") - add_dependencies(protobuf::libprotobuf ext_protobuf) +if (NOT TARGET libprotobuf) + add_library(libprotobuf INTERFACE) + if (WIN32) + target_link_libraries(libprotobuf INTERFACE + debug ${Protobuf_INSTALL_PREFIX}/lib/libprotobufd.lib + optimized ${Protobuf_INSTALL_PREFIX}/lib/libprotobuf.lib) + else() + target_link_libraries(libprotobuf INTERFACE + ${Protobuf_INSTALL_PREFIX}/lib/libprotobuf.a) + endif() + set_target_properties(libprotobuf PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}") + add_dependencies(libprotobuf ext_protobuf) endif() -set(Protobuf_LIBRARIES protobuf::libprotobuf) +set(Protobuf_LIBRARIES libprotobuf) if (NOT TARGET protobuf::protoc) add_executable(protobuf::protoc IMPORTED)