Skip to content

Commit a952540

Browse files
Openvino cmake config (openvinotoolkit#7419)
* Added OpenVINOConfig.cmake * OpenVINOConfig.cmake part 2 * Trying to fix cmake generation * Fixes * Export frontends as well * Fixed condition * Added OpenVINO cmake package usage: docs, C samples * Use more OpenVINO config * Install OpenVINOConfig.cmake * Trying to fix private plugins * Trying to fix .tox * Trying to fix ARM * Fixed samples build * Explicit ngraph duplicated targets * Fixed fuzzing tests build * Added IR frontend installation * Removed install directory for IE reader * Removed IR frontend from export list * Reverted ngraph_DIR * Try to fix .tox * Fixed ieFuncTests with ONNX extensions * Attempt #2 * Trying to fix ngraph setup.py * Fix * Trying to fix ONNX ngraph .tox CI * Trying to remove spaces * Fixed ngraph_DIR -> OpenVINO_DIR * Removed junk files * Try to fix ngraph wheel * Try to fix ie_wheel * Try to fix ngraph wheel
1 parent deeb964 commit a952540

File tree

51 files changed

+523
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+523
-174
lines changed

.ci/openvino-onnx/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ RUN make -j $(nproc) install
7575

7676
# Run tests via tox
7777
WORKDIR /openvino/runtime/bindings/python
78-
ENV ngraph_DIR=/openvino/dist/deployment_tools/ngraph
78+
ENV OpenVINO_DIR=/openvino/dist/deployment_tools/inference_engine/share
7979
ENV LD_LIBRARY_PATH=/openvino/dist/deployment_tools/ngraph/lib
8080
ENV PYTHONPATH=/openvino/bin/intel64/${BUILD_TYPE}/lib/python_api/python3.8:${PYTHONPATH}
8181
CMD tox

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ message (STATUS "CMAKE_BUILD_TYPE ...................... " ${CMAKE_BUILD_TYPE})
3333

3434
# remove file with exported developer targets to force its regeneration
3535
file(REMOVE "${CMAKE_BINARY_DIR}/InferenceEngineTargets.cmake")
36+
file(REMOVE "${CMAKE_BINARY_DIR}/OpenVINOTargets.cmake")
3637
foreach(component IN LISTS openvino_export_components)
3738
file(REMOVE "${CMAKE_BINARY_DIR}/${component}_dev_targets.cmake")
3839
unset(${component} CACHE)
@@ -83,13 +84,14 @@ include(cmake/test_model_zoo.cmake)
8384
add_subdirectory(thirdparty)
8485
add_subdirectory(openvino)
8586
add_subdirectory(ngraph)
87+
88+
add_subdirectory(runtime)
8689
add_subdirectory(inference-engine)
8790

8891
# for Template plugin
8992
openvino_developer_export_targets(COMPONENT ngraph TARGETS ngraph_backend interpreter_backend)
9093
include(cmake/extra_modules.cmake)
9194

92-
add_subdirectory(runtime)
9395
add_subdirectory(model-optimizer)
9496
add_subdirectory(docs)
9597
add_subdirectory(tools)

cmake/templates/InferenceEngineConfig.cmake.in

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,25 @@ _ie_find_dependency(ngraph
111111
if(NOT TARGET inference_engine)
112112
set(_ie_as_external_package ON)
113113
include("${CMAKE_CURRENT_LIST_DIR}/InferenceEngineTargets.cmake")
114+
115+
# create targets with old names for compatibility
116+
if(TARGET IE::runtime AND NOT TARGET IE::inference_engine)
117+
add_library(IE::inference_engine INTERFACE IMPORTED)
118+
set_target_properties(IE::inference_engine PROPERTIES
119+
INTERFACE_LINK_LIBRARIES IE::runtime)
120+
endif()
121+
122+
if(TARGET IE::core AND NOT TARGET ngraph::ngraph)
123+
add_library(IE::ngraph INTERFACE IMPORTED)
124+
set_target_properties(IE::ngraph PROPERTIES
125+
INTERFACE_LINK_LIBRARIES IE::core)
126+
endif()
127+
128+
if(TARGET IE::runtime::c AND NOT TARGET IE::inference_engine_c_api)
129+
add_library(IE::inference_engine_c_api INTERFACE IMPORTED)
130+
set_target_properties(IE::inference_engine_c_api PROPERTIES
131+
INTERFACE_LINK_LIBRARIES IE::runtime::c)
132+
endif()
114133
endif()
115134

116135
# mark components as available

cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,17 @@ find_dependency(InferenceEngine
4444
NO_CMAKE_FIND_ROOT_PATH
4545
NO_DEFAULT_PATH)
4646

47+
find_dependency(OpenVINO
48+
PATHS "${CMAKE_CURRENT_LIST_DIR}"
49+
NO_CMAKE_FIND_ROOT_PATH
50+
NO_DEFAULT_PATH)
51+
4752
# WA for cmake: it exports ngraph as IE::ngraph in the IE export list
4853
# while we already have ngraph export in its own export list as ngraph::ngraph
49-
set_property(TARGET ngraph::ngraph PROPERTY IMPORTED_GLOBAL TRUE)
50-
add_library(IE::ngraph ALIAS ngraph::ngraph)
54+
if(TARGET ngraph::ngraph AND NOT TARGET IE::ngraph)
55+
add_library(IE::ngraph INTERFACE IMPORTED)
56+
set_target_properties(IE::ngraph PROPERTIES INTERFACE_LINK_LIBRARIES ngraph::ngraph)
57+
endif()
5158

5259
foreach(component @openvino_export_components@)
5360
include("${CMAKE_CURRENT_LIST_DIR}/${component}_dev_targets.cmake")
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (C) 2018-2021 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
5+
set(PACKAGE_VERSION_MAJOR @IE_VERSION_MAJOR@)
6+
set(PACKAGE_VERSION_MINOR @IE_VERSION_MINOR@)
7+
set(PACKAGE_VERSION_PATCH @IE_VERSION_PATCH@)
8+
set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")
9+
10+
set(PACKAGE_VERSION_EXACT False)
11+
set(PACKAGE_VERSION_COMPATIBLE False)
12+
13+
if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
14+
set(PACKAGE_VERSION_EXACT True)
15+
set(PACKAGE_VERSION_COMPATIBLE True)
16+
endif()
17+
18+
if(PACKAGE_FIND_VERSION_MAJOR EQUAL PACKAGE_VERSION_MAJOR AND
19+
PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION)
20+
set(PACKAGE_VERSION_COMPATIBLE True)
21+
endif()
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
# Copyright (C) 2018-2021 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# FindOpenVINO
5+
# ------
6+
#
7+
# Provides OpenVINO runtime for model creation and inference, frontend libraries
8+
# to convert models from framework specific formats.
9+
#
10+
# The following components are supported:
11+
#
12+
# * `Runtime`: OpenVINO C++ and C Core & Inference Runtime, frontend manager
13+
# * `ONNX`: OpenVINO ONNX frontend
14+
# * `PaddlePaddle`: OpenVINO PaddlePaddle frontend
15+
#
16+
# If no components are specified, `Runtime` component is provided:
17+
#
18+
# find_package(OpenVINO REQUIRED) # only Runtime component
19+
#
20+
# If specific components are required:
21+
#
22+
# find_package(OpenVINO REQUIRED COMPONENTS Runtime ONNX)
23+
#
24+
# Imported Targets:
25+
# ------
26+
#
27+
# Runtime targets:
28+
#
29+
# `openvino::runtime`
30+
# The OpenVINO C++ Core & Inference Runtime
31+
#
32+
# `openvino::runtime::c`
33+
# The OpenVINO C Inference Runtime
34+
#
35+
# `openvino::core`
36+
# The OpenVINO C++ Core Runtime
37+
#
38+
# Frontend specific targets:
39+
#
40+
# `openvino::frontend::manager`
41+
# OpenVINO frontend manager
42+
#
43+
# `openvino::frontend::onnx`
44+
# ONNX FrontEnd target (optional)
45+
#
46+
# `openvino::frontend::paddlepaddle`
47+
# PaddlePaddle FrontEnd target (optional)
48+
#
49+
# Result variables:
50+
# ------
51+
#
52+
# The module sets the following variables in your project:
53+
#
54+
# `OpenVINO_FOUND`
55+
# System has OpenVINO Runtime installed
56+
#
57+
# `OpenVINO_Runtime_FOUND`
58+
# OpenVINO C++ Core & Inference Runtime is available
59+
#
60+
# `OpenVINO_Frontend_ONNX_FOUND`
61+
# OpenVINO ONNX frontend is available
62+
#
63+
# `OpenVINO_Frontend_PaddlePaddle_FOUND`
64+
# OpenVINO PaddlePaddle frontend is available
65+
#
66+
# OpenVINO version variables:
67+
#
68+
# `OpenVINO_VERSION_MAJOR`
69+
# Major version component
70+
#
71+
# `OpenVINO_VERSION_MINOR`
72+
# minor version component
73+
#
74+
# `OpenVINO_VERSION_PATCH`
75+
# Patch version component
76+
#
77+
78+
@PACKAGE_INIT@
79+
80+
#
81+
# Common functions
82+
#
83+
84+
if(NOT DEFINED CMAKE_FIND_PACKAGE_NAME)
85+
set(CMAKE_FIND_PACKAGE_NAME OpenVINO)
86+
set(_need_package_name_reset ON)
87+
endif()
88+
89+
# we have to use our own version of find_dependency because of support cmake 3.7
90+
macro(_ov_find_dependency dep)
91+
set(cmake_fd_quiet_arg)
92+
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
93+
set(cmake_fd_quiet_arg QUIET)
94+
endif()
95+
set(cmake_fd_required_arg)
96+
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
97+
set(cmake_fd_required_arg REQUIRED)
98+
endif()
99+
100+
get_property(cmake_fd_alreadyTransitive GLOBAL PROPERTY
101+
_CMAKE_${dep}_TRANSITIVE_DEPENDENCY)
102+
103+
find_package(${dep} ${ARGN}
104+
${cmake_fd_quiet_arg}
105+
${cmake_fd_required_arg})
106+
107+
if(NOT DEFINED cmake_fd_alreadyTransitive OR cmake_fd_alreadyTransitive)
108+
set_property(GLOBAL PROPERTY _CMAKE_${dep}_TRANSITIVE_DEPENDENCY TRUE)
109+
endif()
110+
111+
if(NOT ${dep}_FOUND)
112+
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency ${dep} could not be found.")
113+
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
114+
return()
115+
endif()
116+
117+
set(cmake_fd_required_arg)
118+
set(cmake_fd_quiet_arg)
119+
endmacro()
120+
121+
function(_ov_target_no_deprecation_error)
122+
if(NOT MSVC)
123+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
124+
set(flags "-diag-warning=1786")
125+
else()
126+
set(flags "-Wno-error=deprecated-declarations")
127+
endif()
128+
if(CMAKE_CROSSCOMPILING)
129+
set_target_properties(${ARGV} PROPERTIES
130+
INTERFACE_LINK_OPTIONS "-Wl,--allow-shlib-undefined")
131+
endif()
132+
133+
set_target_properties(${ARGV} PROPERTIES INTERFACE_COMPILE_OPTIONS ${flags})
134+
endif()
135+
endfunction()
136+
137+
#
138+
# OpenVINO config
139+
#
140+
141+
# need to store current PACKAGE_PREFIX_DIR, because it's overwritten by sub-package one
142+
set(_ov_package_prefix_dir "${PACKAGE_PREFIX_DIR}")
143+
144+
set(THREADING "@THREADING@")
145+
if(THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO" AND NOT TBB_FOUND)
146+
set_and_check(_tbb_dir "@PACKAGE_IE_TBB_DIR@")
147+
_ov_find_dependency(TBB
148+
COMPONENTS tbb tbbmalloc
149+
CONFIG
150+
PATHS ${TBBROOT}/cmake
151+
${_tbb_dir}
152+
NO_CMAKE_FIND_ROOT_PATH
153+
NO_DEFAULT_PATH)
154+
endif()
155+
156+
if(NOT TARGET inference_engine)
157+
set(_ov_as_external_package ON)
158+
include("${CMAKE_CURRENT_LIST_DIR}/OpenVINOTargets.cmake")
159+
endif()
160+
161+
#
162+
# Components
163+
#
164+
165+
set(${CMAKE_FIND_PACKAGE_NAME}_Runtime_FOUND ON)
166+
167+
set(${CMAKE_FIND_PACKAGE_NAME}_ONNX_FOUND @NGRAPH_ONNX_FRONTEND_ENABLE@)
168+
set(${CMAKE_FIND_PACKAGE_NAME}_PaddlePaddle_FOUND @NGRAPH_PDPD_FRONTEND_ENABLE@)
169+
170+
set(${CMAKE_FIND_PACKAGE_NAME}_Frontend_ONNX_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_ONNX_FOUND})
171+
set(${CMAKE_FIND_PACKAGE_NAME}_Frontend_PaddlePaddle_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_PaddlePaddle_FOUND})
172+
173+
# if no components specified, only Runtime is provided
174+
if(NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
175+
set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS Runtime)
176+
endif()
177+
178+
#
179+
# Apply common functions
180+
#
181+
182+
foreach(target openvino::runtime openvino::runtime::c openvino::core
183+
openvino::frontend::manager openvino::frontend::onnx
184+
openvino::frontend::paddlepaddle)
185+
if(TARGET ${target} AND _ov_as_external_package)
186+
_ov_target_no_deprecation_error(${target})
187+
endif()
188+
endforeach()
189+
unset(_ov_as_external_package)
190+
191+
# restore PACKAGE_PREFIX_DIR
192+
set(PACKAGE_PREFIX_DIR ${_ov_package_prefix_dir})
193+
unset(_ov_package_prefix_dir)
194+
195+
check_required_components(${CMAKE_FIND_PACKAGE_NAME})
196+
197+
if(_need_package_name_reset)
198+
unset(CMAKE_FIND_PACKAGE_NAME)
199+
unset(_need_package_name_reset)
200+
endif()
201+
202+
unset(${CMAKE_FIND_PACKAGE_NAME}_PaddlePaddle_FOUND)
203+
unset(${CMAKE_FIND_PACKAGE_NAME}_ONNX_FOUND)

cmake/templates/ngraphConfig.cmake.in

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,50 @@
3939

4040
if(NOT TARGET ngraph)
4141
include("${CMAKE_CURRENT_LIST_DIR}/ngraphTargets.cmake")
42+
43+
# create targets with old names for compatibility
44+
if(TARGET ngraph::core AND NOT TARGET ngraph::ngraph)
45+
add_library(ngraph::ngraph INTERFACE IMPORTED)
46+
set_target_properties(ngraph::ngraph PROPERTIES
47+
INTERFACE_LINK_LIBRARIES ngraph::core)
48+
endif()
49+
50+
if(TARGET ngraph::frontend::manager AND NOT TARGET ngraph::frontend_manager)
51+
add_library(ngraph::frontend_manager INTERFACE IMPORTED)
52+
set_target_properties(ngraph::frontend_manager PROPERTIES
53+
INTERFACE_LINK_LIBRARIES ngraph::frontend::manager)
54+
endif()
55+
56+
if(TARGET ngraph::frontend::onnx AND NOT TARGET ngraph::onnx_ngraph_frontend)
57+
add_library(ngraph::onnx_ngraph_frontend INTERFACE IMPORTED)
58+
set_target_properties(ngraph::onnx_ngraph_frontend PROPERTIES
59+
INTERFACE_LINK_LIBRARIES ngraph::frontend::onnx)
60+
endif()
61+
62+
if(TARGET ngraph::frontend::paddlepaddle AND NOT TARGET ngraph::paddlepaddle_ngraph_frontend)
63+
add_library(ngraph::paddlepaddle_ngraph_frontend INTERFACE IMPORTED)
64+
set_target_properties(ngraph::paddlepaddle_ngraph_frontend PROPERTIES
65+
INTERFACE_LINK_LIBRARIES ngraph::frontend::paddlepaddle)
66+
endif()
4267
endif()
4368

4469
set(ngraph_ngraph_FOUND ON)
4570
set(NGRAPH_LIBRARIES ngraph::ngraph)
4671

4772
set(ngraph_onnx_ngraph_frontend_FOUND @NGRAPH_ONNX_FRONTEND_ENABLE@)
4873

49-
# ngraph::onnx_importer target and variables are deprecated
5074
set(ngraph_onnx_importer_FOUND @NGRAPH_ONNX_FRONTEND_ENABLE@)
5175
if(ngraph_onnx_importer_FOUND)
5276
set(ONNX_IMPORTER_LIBRARIES ngraph::onnx_ngraph_frontend)
77+
# ngraph::onnx_importer target and variables are deprecated
78+
# but need to create a dummy target for BW compatibility
5379
if(NOT TARGET ngraph::onnx_importer)
5480
add_library(ngraph::onnx_importer INTERFACE IMPORTED)
5581
set_target_properties(ngraph::onnx_importer PROPERTIES
56-
INTERFACE_LINK_LIBRARIES ngraph::onnx_ngraph_frontend
57-
)
82+
INTERFACE_LINK_LIBRARIES ngraph::onnx_ngraph_frontend)
5883
endif()
5984
endif()
6085

6186
set(ngraph_paddlepaddle_frontend_FOUND @NGRAPH_PDPD_FRONTEND_ENABLE@)
62-
set(ir_frontend_FOUND @IR_FRONTEND_ENABLE@)
6387

6488
check_required_components(ngraph)

docs/CMakeLists.txt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,12 @@ if(NOT ENABLE_DOCKER)
99

1010
add_subdirectory(snippets)
1111

12-
# Detect nGraph
13-
find_package(ngraph QUIET
14-
PATHS "${CMAKE_BINARY_DIR}/ngraph"
15-
NO_DEFAULT_PATH)
16-
if(NOT ngraph_FOUND)
17-
set(ngraph_DIR ${CMAKE_BINARY_DIR}/ngraph)
18-
endif()
19-
20-
# Detect InferenceEngine
21-
find_package(InferenceEngine QUIET
12+
# Detect OpenVINO
13+
find_package(OpenVINO QUIET
2214
PATHS "${CMAKE_BINARY_DIR}"
2315
NO_DEFAULT_PATH)
24-
if(NOT InferenceEngine_FOUND)
25-
set(InferenceEngine_DIR ${CMAKE_BINARY_DIR})
16+
if(NOT OpenVINO_FOUND)
17+
set(OpenVINO_DIR ${CMAKE_BINARY_DIR})
2618
endif()
2719

2820
if(NGRAPH_ONNX_FRONTEND_ENABLE)
@@ -72,7 +64,7 @@ function(build_docs)
7264
set(C_API "${IE_SOURCE_DIR}/ie_bridges/c/include")
7365
set(PLUGIN_API_DIR "${DOCS_BUILD_DIR}/IE_PLUGIN_DG")
7466
set(NGRAPH_DIR "${OpenVINO_SOURCE_DIR}/ngraph")
75-
set(NGRAPH_PY_DIR "${NGRAPH_DIR}/python/src/ngraph/")
67+
set(NGRAPH_PY_DIR "${OpenVINO_SOURCE_DIR}/runtime/bindings/python/src/compatibility/ngraph/")
7668
set(NGRAPH_CPP_DIR "${NGRAPH_DIR}/core/include/" "${NGRAPH_DIR}/frontend/onnx_import/include")
7769

7870
# Preprocessing scripts

0 commit comments

Comments
 (0)