-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Openvino cmake config #7419
Openvino cmake config #7419
Changes from 34 commits
6ae131c
00e269e
b84a30e
68fab86
ef84fde
1f2bb08
005658e
5126bed
8974fc3
4361b48
8666873
60d5fef
28cd2e3
65103fb
5e3019b
356540f
42e746d
330f2e4
691fc64
22e3757
5a6c926
f75286e
06a0dae
475d08c
61efd81
3e011a4
4a1d60b
587a312
4e9e02c
b7ee2f8
2e9eb18
44f523c
97be889
d0e7573
30e4105
e1940a7
c7f8f03
1d61994
4b24008
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,25 @@ _ie_find_dependency(ngraph | |
if(NOT TARGET inference_engine) | ||
set(_ie_as_external_package ON) | ||
include("${CMAKE_CURRENT_LIST_DIR}/InferenceEngineTargets.cmake") | ||
|
||
# create targets with old names for compatibility | ||
if(TARGET IE::runtime AND NOT TARGET IE::inference_engine) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we change prefix to OV? OV::runtime |
||
add_library(IE::inference_engine INTERFACE IMPORTED) | ||
set_target_properties(IE::inference_engine PROPERTIES | ||
INTERFACE_LINK_LIBRARIES IE::runtime) | ||
endif() | ||
|
||
if(TARGET IE::core AND NOT TARGET ngraph::ngraph) | ||
add_library(IE::ngraph INTERFACE IMPORTED) | ||
set_target_properties(IE::ngraph PROPERTIES | ||
INTERFACE_LINK_LIBRARIES IE::core) | ||
endif() | ||
|
||
if(TARGET IE::runtime::c AND NOT TARGET IE::inference_engine_c_api) | ||
add_library(IE::inference_engine_c_api INTERFACE IMPORTED) | ||
set_target_properties(IE::inference_engine_c_api PROPERTIES | ||
INTERFACE_LINK_LIBRARIES IE::runtime::c) | ||
endif() | ||
endif() | ||
|
||
# mark components as available | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright (C) 2018-2021 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
set(PACKAGE_VERSION_MAJOR @IE_VERSION_MAJOR@) | ||
set(PACKAGE_VERSION_MINOR @IE_VERSION_MINOR@) | ||
set(PACKAGE_VERSION_PATCH @IE_VERSION_PATCH@) | ||
set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}") | ||
|
||
set(PACKAGE_VERSION_EXACT False) | ||
set(PACKAGE_VERSION_COMPATIBLE False) | ||
|
||
if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) | ||
set(PACKAGE_VERSION_EXACT True) | ||
set(PACKAGE_VERSION_COMPATIBLE True) | ||
endif() | ||
|
||
if(PACKAGE_FIND_VERSION_MAJOR EQUAL PACKAGE_VERSION_MAJOR AND | ||
PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION) | ||
set(PACKAGE_VERSION_COMPATIBLE True) | ||
endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
# Copyright (C) 2018-2021 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# FindOpenVINO | ||
# ------ | ||
# | ||
# Provides OpenVINO runtime for model creation and inference, frontend libraries | ||
# to convert models from framework specific formats. | ||
# | ||
# The following components are supported: | ||
# | ||
# * `Runtime`: OpenVINO C++ and C Core & Inference Runtime, frontend manager | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a |
||
# * `ONNX`: OpenVINO ONNX frontend | ||
# * `PaddlePaddle`: OpenVINO PaddlePaddle frontend | ||
# | ||
# If no components are specified, `Runtime` component is provided: | ||
# | ||
# find_package(OpenVINO REQUIRED) # only Runtime component | ||
# | ||
# If specific components are required: | ||
# | ||
# find_package(OpenVINO REQUIRED COMPONENTS Runtime ONNX) | ||
# | ||
# Imported Targets: | ||
# ------ | ||
# | ||
# Runtime targets: | ||
# | ||
# `openvino::runtime` | ||
# The OpenVINO C++ Core & Inference Runtime | ||
# | ||
# `openvino::runtime::c` | ||
# The OpenVINO C Inference Runtime | ||
# | ||
# `openvino::core` | ||
# The OpenVINO C++ Core Runtime | ||
# | ||
# Frontend specific targets: | ||
# | ||
# `openvino::frontend::manager` | ||
# OpenVINO frontend manager | ||
# | ||
# `openvino::frontend::onnx` | ||
# ONNX FrontEnd target (optional) | ||
# | ||
# `openvino::frontend::paddlepaddle` | ||
# PaddlePaddle FrontEnd target (optional) | ||
# | ||
# Result variables: | ||
# ------ | ||
# | ||
# The module sets the following variables in your project: | ||
# | ||
# `OpenVINO_FOUND` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if user wants to use nGraph without the runtime? |
||
# System has OpenVINO Runtime installed | ||
# | ||
# `OpenVINO_Runtime_FOUND` | ||
# OpenVINO C++ Core & Inference Runtime is available | ||
# | ||
# `OpenVINO_Frontend_ONNX_FOUND` | ||
# OpenVINO ONNX frontend is available | ||
# | ||
# `OpenVINO_Frontend_PaddlePaddle_FOUND` | ||
# OpenVINO PaddlePaddle frontend is available | ||
# | ||
# OpenVINO version variables: | ||
# | ||
# `OpenVINO_VERSION_MAJOR` | ||
# Major version component | ||
# | ||
# `OpenVINO_VERSION_MINOR` | ||
# minor version component | ||
# | ||
# `OpenVINO_VERSION_PATCH` | ||
# Patch version component | ||
# | ||
|
||
@PACKAGE_INIT@ | ||
|
||
# | ||
# Common functions | ||
# | ||
|
||
if(NOT DEFINED CMAKE_FIND_PACKAGE_NAME) | ||
set(CMAKE_FIND_PACKAGE_NAME OpenVINO) | ||
set(_need_package_name_reset ON) | ||
endif() | ||
|
||
# we have to use our own version of find_dependency because of support cmake 3.7 | ||
macro(_ov_find_dependency dep) | ||
set(cmake_fd_quiet_arg) | ||
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) | ||
set(cmake_fd_quiet_arg QUIET) | ||
endif() | ||
set(cmake_fd_required_arg) | ||
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) | ||
set(cmake_fd_required_arg REQUIRED) | ||
endif() | ||
|
||
get_property(cmake_fd_alreadyTransitive GLOBAL PROPERTY | ||
_CMAKE_${dep}_TRANSITIVE_DEPENDENCY) | ||
|
||
find_package(${dep} ${ARGN} | ||
${cmake_fd_quiet_arg} | ||
${cmake_fd_required_arg}) | ||
|
||
if(NOT DEFINED cmake_fd_alreadyTransitive OR cmake_fd_alreadyTransitive) | ||
set_property(GLOBAL PROPERTY _CMAKE_${dep}_TRANSITIVE_DEPENDENCY TRUE) | ||
endif() | ||
|
||
if(NOT ${dep}_FOUND) | ||
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency ${dep} could not be found.") | ||
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False) | ||
return() | ||
endif() | ||
|
||
set(cmake_fd_required_arg) | ||
set(cmake_fd_quiet_arg) | ||
endmacro() | ||
|
||
function(_ov_target_no_deprecation_error) | ||
if(NOT MSVC) | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") | ||
set(flags "-diag-warning=1786") | ||
else() | ||
set(flags "-Wno-error=deprecated-declarations") | ||
endif() | ||
if(CMAKE_CROSSCOMPILING) | ||
set_target_properties(${ARGV} PROPERTIES | ||
INTERFACE_LINK_OPTIONS "-Wl,--allow-shlib-undefined") | ||
endif() | ||
|
||
set_target_properties(${ARGV} PROPERTIES INTERFACE_COMPILE_OPTIONS ${flags}) | ||
endif() | ||
endfunction() | ||
|
||
# | ||
# OpenVINO config | ||
# | ||
|
||
# need to store current PACKAGE_PREFIX_DIR, because it's overwritten by sub-package one | ||
set(_ov_package_prefix_dir "${PACKAGE_PREFIX_DIR}") | ||
|
||
set(THREADING "@THREADING@") | ||
if(THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO" AND NOT TBB_FOUND) | ||
set_and_check(_tbb_dir "@PACKAGE_IE_TBB_DIR@") | ||
_ov_find_dependency(TBB | ||
COMPONENTS tbb tbbmalloc | ||
CONFIG | ||
PATHS ${TBBROOT}/cmake | ||
${_tbb_dir} | ||
NO_CMAKE_FIND_ROOT_PATH | ||
NO_DEFAULT_PATH) | ||
endif() | ||
|
||
if(NOT TARGET inference_engine) | ||
set(_ov_as_external_package ON) | ||
include("${CMAKE_CURRENT_LIST_DIR}/OpenVINOTargets.cmake") | ||
endif() | ||
|
||
# | ||
# Components | ||
# | ||
|
||
set(${CMAKE_FIND_PACKAGE_NAME}_Runtime_FOUND ON) | ||
|
||
set(${CMAKE_FIND_PACKAGE_NAME}_ONNX_FOUND @NGRAPH_ONNX_FRONTEND_ENABLE@) | ||
set(${CMAKE_FIND_PACKAGE_NAME}_PaddlePaddle_FOUND @NGRAPH_PDPD_FRONTEND_ENABLE@) | ||
|
||
set(${CMAKE_FIND_PACKAGE_NAME}_Frontend_ONNX_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_ONNX_FOUND}) | ||
set(${CMAKE_FIND_PACKAGE_NAME}_Frontend_PaddlePaddle_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_PaddlePaddle_FOUND}) | ||
|
||
# if no components specified, only Runtime is provided | ||
if(NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS) | ||
set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS Runtime) | ||
endif() | ||
|
||
# | ||
# Apply common functions | ||
# | ||
|
||
foreach(target openvino::runtime openvino::runtime::c openvino::core | ||
openvino::frontend::manager openvino::frontend::onnx | ||
openvino::frontend::paddlepaddle) | ||
if(TARGET ${target} AND _ov_as_external_package) | ||
_ov_target_no_deprecation_error(${target}) | ||
endif() | ||
endforeach() | ||
unset(_ov_as_external_package) | ||
|
||
# restore PACKAGE_PREFIX_DIR | ||
set(PACKAGE_PREFIX_DIR ${_ov_package_prefix_dir}) | ||
unset(_ov_package_prefix_dir) | ||
|
||
check_required_components(${CMAKE_FIND_PACKAGE_NAME}) | ||
|
||
if(_need_package_name_reset) | ||
unset(CMAKE_FIND_PACKAGE_NAME) | ||
unset(_need_package_name_reset) | ||
endif() | ||
|
||
unset(${CMAKE_FIND_PACKAGE_NAME}_PaddlePaddle_FOUND) | ||
unset(${CMAKE_FIND_PACKAGE_NAME}_ONNX_FOUND) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,26 +39,50 @@ | |
|
||
if(NOT TARGET ngraph) | ||
include("${CMAKE_CURRENT_LIST_DIR}/ngraphTargets.cmake") | ||
|
||
# create targets with old names for compatibility | ||
if(TARGET ngraph::core AND NOT TARGET ngraph::ngraph) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not openvino::core? |
||
add_library(ngraph::ngraph INTERFACE IMPORTED) | ||
set_target_properties(ngraph::ngraph PROPERTIES | ||
INTERFACE_LINK_LIBRARIES ngraph::core) | ||
endif() | ||
|
||
if(TARGET ngraph::frontend::manager AND NOT TARGET ngraph::frontend_manager) | ||
add_library(ngraph::frontend_manager INTERFACE IMPORTED) | ||
set_target_properties(ngraph::frontend_manager PROPERTIES | ||
INTERFACE_LINK_LIBRARIES ngraph::frontend::manager) | ||
endif() | ||
|
||
if(TARGET ngraph::frontend::onnx AND NOT TARGET ngraph::onnx_ngraph_frontend) | ||
add_library(ngraph::onnx_ngraph_frontend INTERFACE IMPORTED) | ||
set_target_properties(ngraph::onnx_ngraph_frontend PROPERTIES | ||
INTERFACE_LINK_LIBRARIES ngraph::frontend::onnx) | ||
endif() | ||
|
||
if(TARGET ngraph::frontend::paddlepaddle AND NOT TARGET ngraph::paddlepaddle_ngraph_frontend) | ||
add_library(ngraph::paddlepaddle_ngraph_frontend INTERFACE IMPORTED) | ||
set_target_properties(ngraph::paddlepaddle_ngraph_frontend PROPERTIES | ||
INTERFACE_LINK_LIBRARIES ngraph::frontend::paddlepaddle) | ||
endif() | ||
endif() | ||
|
||
set(ngraph_ngraph_FOUND ON) | ||
set(NGRAPH_LIBRARIES ngraph::ngraph) | ||
|
||
set(ngraph_onnx_ngraph_frontend_FOUND @NGRAPH_ONNX_FRONTEND_ENABLE@) | ||
|
||
# ngraph::onnx_importer target and variables are deprecated | ||
set(ngraph_onnx_importer_FOUND @NGRAPH_ONNX_FRONTEND_ENABLE@) | ||
if(ngraph_onnx_importer_FOUND) | ||
set(ONNX_IMPORTER_LIBRARIES ngraph::onnx_ngraph_frontend) | ||
# ngraph::onnx_importer target and variables are deprecated | ||
# but need to create a dummy target for BW compatibility | ||
if(NOT TARGET ngraph::onnx_importer) | ||
add_library(ngraph::onnx_importer INTERFACE IMPORTED) | ||
set_target_properties(ngraph::onnx_importer PROPERTIES | ||
INTERFACE_LINK_LIBRARIES ngraph::onnx_ngraph_frontend | ||
) | ||
INTERFACE_LINK_LIBRARIES ngraph::onnx_ngraph_frontend) | ||
endif() | ||
endif() | ||
|
||
set(ngraph_paddlepaddle_frontend_FOUND @NGRAPH_PDPD_FRONTEND_ENABLE@) | ||
set(ir_frontend_FOUND @IR_FRONTEND_ENABLE@) | ||
|
||
check_required_components(ngraph) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a temporary change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OpenVINO_DIR
is permanent, path will be changed in future.