From 888546b6f5ba33724d2b6eaa8efae83ef09a65c0 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 11 Feb 2022 15:13:09 +0300 Subject: [PATCH] build(winpack_dldt): force using CMake config for InferenceEngine --- cmake/OpenCVDetectInferenceEngine.cmake | 2 +- .../cmake/InferenceEngineConfig-version.cmake | 29 +++++++++++++++++ .../cmake/InferenceEngineConfig.cmake | 31 +++++++++++++++++++ .../winpack_dldt/2021.4.2/sysroot.config.py | 2 ++ platforms/winpack_dldt/build_package.py | 7 ++--- 5 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 platforms/winpack_dldt/2021.4.2/cmake/InferenceEngineConfig-version.cmake create mode 100644 platforms/winpack_dldt/2021.4.2/cmake/InferenceEngineConfig.cmake diff --git a/cmake/OpenCVDetectInferenceEngine.cmake b/cmake/OpenCVDetectInferenceEngine.cmake index c0279d74d7..f88916d4a7 100644 --- a/cmake/OpenCVDetectInferenceEngine.cmake +++ b/cmake/OpenCVDetectInferenceEngine.cmake @@ -26,7 +26,7 @@ endif() find_package(InferenceEngine QUIET) if(InferenceEngine_FOUND) set(INF_ENGINE_TARGET ${InferenceEngine_LIBRARIES}) - set(INF_ENGINE_VERSION "${InferenceEngine_VERSION}" CACHE STRING "") + set(INF_ENGINE_VERSION "${InferenceEngine_VERSION}") message(STATUS "Detected InferenceEngine: cmake package (${InferenceEngine_VERSION})") endif() diff --git a/platforms/winpack_dldt/2021.4.2/cmake/InferenceEngineConfig-version.cmake b/platforms/winpack_dldt/2021.4.2/cmake/InferenceEngineConfig-version.cmake new file mode 100644 index 0000000000..bc449d05cd --- /dev/null +++ b/platforms/winpack_dldt/2021.4.2/cmake/InferenceEngineConfig-version.cmake @@ -0,0 +1,29 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +set(PACKAGE_VERSION_MAJOR 2021) +set(PACKAGE_VERSION_MINOR 4) +set(PACKAGE_VERSION_PATCH 2) +set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}") + +set(PACKAGE_VERSION_EXACT False) +set(PACKAGE_VERSION_COMPATIBLE False) + +# Compatibility with old versioning for 2.x +if(PACKAGE_FIND_VERSION_MAJOR VERSION_EQUAL 2) + set(PACKAGE_VERSION_COMPATIBLE True) + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) + message(WARNING "Inference Engine versioning has changed. Use ${PACKAGE_VERSION} instead of ${PACKAGE_FIND_VERSION}") + endif() +endif() + +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() diff --git a/platforms/winpack_dldt/2021.4.2/cmake/InferenceEngineConfig.cmake b/platforms/winpack_dldt/2021.4.2/cmake/InferenceEngineConfig.cmake new file mode 100644 index 0000000000..d9c9a12de6 --- /dev/null +++ b/platforms/winpack_dldt/2021.4.2/cmake/InferenceEngineConfig.cmake @@ -0,0 +1,31 @@ +# Inference Engine CMake config for OpenCV windows package + +get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) + +set(InferenceEngine_LIBRARIES IE::inference_engine) +add_library(IE::inference_engine SHARED IMPORTED) + +set_target_properties(IE::inference_engine PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/deployment_tools/inference_engine/include" +) + +# Import target "IE::inference_engine" for configuration "Debug" +set_property(TARGET IE::inference_engine APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) +set_target_properties(IE::inference_engine PROPERTIES + IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/deployment_tools/inference_engine/lib/intel64/inference_engined.lib" + IMPORTED_LINK_DEPENDENT_LIBRARIES_DEBUG "" + IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/bin/inference_engined.dll" + ) + +# Import target "IE::inference_engine" for configuration "Release" +set_property(TARGET IE::inference_engine APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(IE::inference_engine PROPERTIES + IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/deployment_tools/inference_engine/lib/intel64/inference_engine.lib" + IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE "" + IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/inference_engine.dll" + ) + +set(InferenceEngine_FOUND ON) diff --git a/platforms/winpack_dldt/2021.4.2/sysroot.config.py b/platforms/winpack_dldt/2021.4.2/sysroot.config.py index fa4281107d..f11e99f843 100644 --- a/platforms/winpack_dldt/2021.4.2/sysroot.config.py +++ b/platforms/winpack_dldt/2021.4.2/sysroot.config.py @@ -1,3 +1,5 @@ +copytree(self.cpath / 'cmake', self.sysrootdir / 'deployment_tools' / 'inference_engine' / 'cmake') + sysroot_bin_dir = prepare_dir(self.sysrootdir / 'bin') copytree(self.build_dir / 'install', self.sysrootdir / 'ngraph') #rm_one(self.sysrootdir / 'ngraph' / 'lib' / 'ngraph.dll') diff --git a/platforms/winpack_dldt/build_package.py b/platforms/winpack_dldt/build_package.py index 7875f11d31..e799820966 100644 --- a/platforms/winpack_dldt/build_package.py +++ b/platforms/winpack_dldt/build_package.py @@ -386,10 +386,9 @@ class Builder: if self.config.dldt_release: cmake_vars['INF_ENGINE_RELEASE'] = str(self.config.dldt_release) - cmake_vars['INF_ENGINE_LIB_DIRS:PATH'] = str(builderDLDT.sysrootdir / 'deployment_tools/inference_engine/lib/intel64') - assert os.path.exists(cmake_vars['INF_ENGINE_LIB_DIRS:PATH']), cmake_vars['INF_ENGINE_LIB_DIRS:PATH'] - cmake_vars['INF_ENGINE_INCLUDE_DIRS:PATH'] = str(builderDLDT.sysrootdir / 'deployment_tools/inference_engine/include') - assert os.path.exists(cmake_vars['INF_ENGINE_INCLUDE_DIRS:PATH']), cmake_vars['INF_ENGINE_INCLUDE_DIRS:PATH'] + InferenceEngine_DIR = str(builderDLDT.sysrootdir / 'deployment_tools' / 'inference_engine' / 'cmake') + assert os.path.exists(InferenceEngine_DIR), InferenceEngine_DIR + cmake_vars['InferenceEngine_DIR:PATH'] = InferenceEngine_DIR ngraph_DIR = str(builderDLDT.sysrootdir / 'ngraph/cmake') if not os.path.exists(ngraph_DIR):