3.8 KiB
Build Plugin Using CMake
OpenVINO build infrastructure provides the OpenVINO Developer Package for plugin development.
OpenVINO Developer Package
To automatically generate the OpenVINO Developer Package, run the cmake tool during a OpenVINO build:
$ mkdir openvino-release-build
$ cd openvino-release-build
$ cmake -DCMAKE_BUILD_TYPE=Release ../openvino
Once the commands above are executed, the OpenVINO Developer Package is generated in the openvino-release-build folder. It consists of several files:
OpenVINODeveloperPackageConfig.cmake- the main CMake script which imports targets and provides compilation flags and CMake options.OpenVINODeveloperPackageConfig-version.cmake- a file with a package version.targets_developer.cmake- an automatically generated file which contains all targets exported from the OpenVINO build tree. This file is included byOpenVINODeveloperPackageConfig.cmaketo import the following targets:- Libraries for plugin development:
openvino::runtime- shared OpenVINO libraryopenvino::runtime::dev- interface library with OpenVINO Developer APIopenvino::pugixml- static Pugixml libraryopenvino::xbyak- interface library with Xbyak headersopenvino::itt- static library with tools for performance measurement using Intel ITT
- Libraries for tests development:
openvino::gtest,openvino::gtest_main,openvino::gmock- Google Tests framework librariesopenvino::commonTestUtils- static library with common tests utilitiesopenvino::funcTestUtils- static library with functional tests utilitiesopenvino::unitTestUtils- static library with unit tests utilitiesopenvino::ngraphFunctions- static library with the set ofov::Modelbuildersopenvino::funcSharedTests- static library with common functional testsopenvino::ngraph_reference- static library with operation reference implementations.
- Libraries for plugin development:
Note
: it's enough just to run
cmake --build . --target ov_dev_targetscommand to build only targets from the OpenVINO Developer package.
Build Plugin using OpenVINO Developer Package
To build a plugin source tree using the OpenVINO Developer Package, run the commands below:
$ mkdir template-plugin-release-build
$ cd template-plugin-release-build
$ cmake -DOpenVINODeveloperPackage_DIR=../openvino-release-build ../template-plugin
A common plugin consists of the following components:
- Plugin code in the
srcfolder - Code of tests in the
testsfolder
To build a plugin and its tests, run the following CMake scripts:
- Root
CMakeLists.txt, which finds the OpenVINO Developer Package using thefind_packageCMake command and adds thesrcandtestssubdirectories with plugin sources and their tests respectively: @snippet template/CMakeLists.txt cmake:mainNote
: The default values of the
ENABLE_TESTS,ENABLE_FUNCTIONAL_TESTSoptions are shared via the OpenVINO Developer Package and they are the same as for the main OpenVINO build tree. You can override them during plugin build using the command below:
$ cmake -DENABLE_FUNCTIONAL_TESTS=OFF -DOpenVINODeveloperPackage_DIR=../openvino-release-build ../template-plugin
-
src/CMakeLists.txtto build a plugin shared library from sources: @snippet template/src/CMakeLists.txt cmake:pluginNote
:
openvino::...targets are imported from the OpenVINO Developer Package. -
tests/functional/CMakeLists.txtto build a set of functional plugin tests: @snippet template/tests/functional/CMakeLists.txt cmake:functional_testsNote
: The
openvino::funcSharedTestsstatic library with common functional OpenVINO Plugin tests is imported via the OpenVINO Developer Package.