diff --git a/cmake/features.cmake b/cmake/features.cmake index 49e92b94394c8d..ea32a7a42fe822 100644 --- a/cmake/features.cmake +++ b/cmake/features.cmake @@ -121,6 +121,7 @@ else() endif() ie_dependent_option(NGRAPH_ONNX_IMPORT_ENABLE "Enable ONNX importer" ON "protoc_available" OFF) +ie_dependent_option(NGRAPH_ONNX_EDITOR_ENABLE "Enable ONNX Editor" ON "NGRAPH_ONNX_IMPORT_ENABLE" OFF) ie_dependent_option(NGRAPH_PDPD_FRONTEND_ENABLE "Enable PaddlePaddle FrontEnd" ON "protoc_available" OFF) ie_dependent_option(NGRAPH_USE_PROTOBUF_LITE "Compiles and links with protobuf-lite" OFF "NGRAPH_ONNX_IMPORT_ENABLE OR NGRAPH_PDPD_FRONTEND_ENABLE" OFF) diff --git a/ngraph/frontend/paddlepaddle/CMakeLists.txt b/ngraph/frontend/paddlepaddle/CMakeLists.txt index a14011039a26c1..fb7fa5dadbe97a 100644 --- a/ngraph/frontend/paddlepaddle/CMakeLists.txt +++ b/ngraph/frontend/paddlepaddle/CMakeLists.txt @@ -23,6 +23,12 @@ set(PROTO_HDRS) # Generate protobuf file on build time for each '.proto' file in src/proto file(GLOB proto_files ${CMAKE_CURRENT_SOURCE_DIR}/src/proto/*.proto) +if(CMAKE_CROSSCOMPILING) + set(PDPD_PROTOC_EXECUTABLE ${SYSTEM_PROTOC}) +else() + set(PDPD_PROTOC_EXECUTABLE $) +endif() + foreach(INFILE ${proto_files}) get_filename_component(FILE_DIR ${INFILE} DIRECTORY) get_filename_component(FILE_WE ${INFILE} NAME_WE) @@ -31,9 +37,9 @@ foreach(INFILE ${proto_files}) set(GENERATED_PROTO ${INFILE}) add_custom_command( OUTPUT "${OUTPUT_PB_SRC}" "${OUTPUT_PB_HEADER}" - COMMAND ${PROTOC_EXECUTABLE} ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} -I ${FILE_DIR} ${FILE_WE}.proto - DEPENDS ${PROTOC_EXECUTABLE} ${GENERATED_PROTO} - COMMENT "Running C++ protocol buffer compiler (${PROTOC_EXECUTABLE}) on ${GENERATED_PROTO}" + COMMAND ${PDPD_PROTOC_EXECUTABLE} ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} -I ${FILE_DIR} ${FILE_WE}.proto + DEPENDS ${PDPD_PROTOC_EXECUTABLE} ${GENERATED_PROTO} + COMMENT "Running C++ protocol buffer compiler (${PDPD_PROTOC_EXECUTABLE}) on ${GENERATED_PROTO}" VERBATIM COMMAND_EXPAND_LISTS) list(APPEND PROTO_SRCS "${OUTPUT_PB_SRC}") diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index a65fdb2e56680d..0f976b6741895f 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -126,47 +126,15 @@ endif() if(NGRAPH_PDPD_FRONTEND_ENABLE OR NGRAPH_ONNX_IMPORT_ENABLE) if(NGRAPH_USE_SYSTEM_PROTOBUF) - set(Protobuf_USE_STATIC_LIBS ON) - if(VERBOSE_BUILD) - set(Protobuf_DEBUG ON) - endif() find_package(Protobuf REQUIRED) - if(NGRAPH_USE_PROTOBUF_LITE) - set(Protobuf_LIBRARIES protobuf::libprotobuf-lite) - else() - set(Protobuf_LIBRARIES protobuf::libprotobuf) - endif() - set(SYSTEM_PROTOC protobuf::protoc) - set(PROTOC_EXECUTABLE ${SYSTEM_PROTOC}) - - foreach(target ${SYSTEM_PROTOC} ${Protobuf_LIBRARIES}) - set_property(TARGET ${target} PROPERTY IMPORTED_GLOBAL TRUE) - endforeach() else() add_subdirectory(protobuf) endif() # forward variables used in the other places set(SYSTEM_PROTOC ${SYSTEM_PROTOC} PARENT_SCOPE) - set(PROTOC_EXECUTABLE ${PROTOC_EXECUTABLE} PARENT_SCOPE) set(Protobuf_LIBRARIES ${Protobuf_LIBRARIES} PARENT_SCOPE) set(Protobuf_INCLUDE_DIRS ${Protobuf_INCLUDE_DIRS} PARENT_SCOPE) - - # set public / interface compile options - foreach(target IN LISTS Protobuf_LIBRARIES) - set(link_type PUBLIC) - if(NGRAPH_USE_SYSTEM_PROTOBUF) - set(link_type INTERFACE) - endif() - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") - 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() # diff --git a/thirdparty/protobuf/CMakeLists.txt b/thirdparty/protobuf/CMakeLists.txt index c4d6fe26bc2af6..6bc82b140e2f16 100644 --- a/thirdparty/protobuf/CMakeLists.txt +++ b/thirdparty/protobuf/CMakeLists.txt @@ -18,11 +18,11 @@ if(OV_COMPILER_IS_CLANG) endif() set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build tests") -set(protobuf_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE) -set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build with zlib support") # When we build dll libraries. These flags make sure onnx and protobuf build with /MD, not /MT. # These two options can't be mixed, because they requires link two imcompatiable runtime. +set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build with zlib support") + if(NOT DEFINED protobuf_MSVC_STATIC_RUNTIME) set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Link protobuf to static runtime libraries" FORCE) endif() @@ -47,6 +47,10 @@ if(CMAKE_CROSSCOMPILING) set(protobuf_BUILD_PROTOC_BINARIES OFF CACHE BOOL "Build libprotoc and protoc compiler" FORCE) endif() +set(protobuf_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE) +set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build tests") +set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build with zlib support") + add_subdirectory(protobuf/cmake EXCLUDE_FROM_ALL) get_directory_property(protobuf_VERSION DIRECTORY protobuf/cmake DEFINITION protobuf_VERSION) @@ -68,9 +72,10 @@ if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG) CXX_VISIBILITY_PRESET default C_VISIBILITY_PRESET default VISIBILITY_INLINES_HIDDEN OFF) - foreach(target IN LISTS Protobuf_LIBRARIES) + foreach(target libprotobuf libprotobuf-lite) target_compile_options(${target} - PRIVATE -Wno-all -Wno-unused-variable) + PRIVATE -Wno-all -Wno-unused-variable + PUBLIC -Wno-undef) endforeach() endif() @@ -83,6 +88,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") +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() @@ -92,13 +101,6 @@ if(CMAKE_CROSSCOMPILING AND NOT PROTOC_VERSION VERSION_EQUAL protobuf_VERSION) endif() # forward variables used in the other places -if(SYSTEM_PROTOC) - set(SYSTEM_PROTOC ${SYSTEM_PROTOC} PARENT_SCOPE) - set(PROTOC_EXECUTABLE ${SYSTEM_PROTOC} PARENT_SCOPE) -else() - set(PROTOC_EXECUTABLE $ PARENT_SCOPE) -endif() - -set(protobuf_VERSION ${protobuf_VERSION} PARENT_SCOPE) +set(SYSTEM_PROTOC ${SYSTEM_PROTOC} PARENT_SCOPE) set(Protobuf_LIBRARIES ${Protobuf_LIBRARIES} PARENT_SCOPE) set(Protobuf_INCLUDE_DIRS ${Protobuf_INCLUDE_DIRS} PARENT_SCOPE)