Fixed compilation of ngraph python on some compilers (#4015)

* Fixed compilation of ngraph python on some compilers

* Fixed ONNX importer dependencies compilation for gcc 5.4.0 and 5.5.0
This commit is contained in:
Ilya Lavrenov 2021-01-28 18:58:10 +03:00 committed by GitHub
parent 17eff0cd04
commit 117c04def1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 15 deletions

View File

@ -48,8 +48,9 @@ macro(onnx_set_target_properties)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(onnx PRIVATE /WX-)
else()
target_compile_options(onnx PRIVATE -Wno-unused-parameter)
elseif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
target_compile_options(onnx PRIVATE -Wno-unused-variable -Wno-unused-parameter)
target_compile_options(onnx_proto PRIVATE -Wno-unused-variable)
endif()
set_target_properties(onnx onnx_proto PROPERTIES

View File

@ -66,7 +66,7 @@ endif()
set(NGRAPH_PROTOBUF_GIT_TAG "v${PROTOC_VERSION}")
if ("${CMAKE_GENERATOR}" STREQUAL "Ninja")
if (CMAKE_GENERATOR STREQUAL "Ninja")
set(MAKE_UTIL make)
else()
set(MAKE_UTIL $(MAKE))
@ -75,7 +75,7 @@ endif()
if(PROTOC_VERSION VERSION_LESS "3.9" AND NGRAPH_USE_PROTOBUF_LITE)
message(FATAL_ERROR "Minimum supported version of protobuf-lite library is 3.9.0")
else()
if(CMAKE_CXX_COMPILER_ID MATCHES ".*[Cc]lang")
if(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
include(ExternalProject)
set(Protobuf_INSTALL_PREFIX ${EXTERNAL_PROJECTS_ROOT}/protobuf)
set(Protobuf_PROTOC_EXECUTABLE ${Protobuf_INSTALL_PREFIX}/bin/protoc)
@ -149,6 +149,15 @@ else()
else()
set(Protobuf_LIBRARIES libprotobuf)
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
set(_proto_libs ${Protobuf_LIBRARIES})
if(TARGET libprotoc)
list(APPEND _proto_libs libprotoc)
endif()
set_target_properties(${_proto_libs} PROPERTIES
COMPILE_FLAGS "-Wno-unused-variable")
endif()
endif()
endif()

View File

@ -24,8 +24,6 @@
namespace ngraph
{
static bool s_provenance_enabled = getenv_bool("NGRAPH_PROVENANCE_ENABLE");
NGRAPH_API
void set_provenance_enabled(bool enabled);
NGRAPH_API

View File

@ -20,6 +20,8 @@
namespace ngraph
{
static bool s_provenance_enabled = getenv_bool("NGRAPH_PROVENANCE_ENABLE");
void set_provenance_enabled(bool enabled) { s_provenance_enabled = enabled; }
bool get_provenance_enabled() { return s_provenance_enabled; }
}

View File

@ -50,22 +50,25 @@ else()
message(FATAL_ERROR "Python was not found!")
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
add_compile_options(-fPIC)
endif()
if (APPLE)
add_link_options(-stdlib=libc++)
endif()
# compile options
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# disable warning: This operator was deprecated and will be removed with v0 operation.
add_compile_options(/wd4996)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wno-deprecated-register)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
add_link_options(-stdlib=libc++)
add_compile_options(-Wno-unused-value)
endif()
# create target
file(GLOB_RECURSE SOURCES src/pyngraph/*.cpp)
pybind11_add_module(_${PROJECT_NAME} MODULE ${SOURCES})
target_include_directories(_${PROJECT_NAME} PRIVATE src)
target_include_directories(_${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_link_libraries(_${PROJECT_NAME} PRIVATE ngraph::ngraph ngraph::onnx_importer)
if(OpenVINO_MAIN_SOURCE_DIR OR InferenceEngineDeveloperPackage_FOUND)