Build Extension Library Using CMake*

Inference Engine build infrastructure provides the Inference Engine Package for application development.

To build an extension library, use the following CMake script:

set(CMAKE_CXX_STANDARD 11)
set(TARGET_NAME "template_extension")
find_package(ngraph REQUIRED OPTIONAL_COMPONENTS onnx_importer)
find_package(InferenceEngine REQUIRED)
file(GLOB_RECURSE SRC *.cpp)
add_library(${TARGET_NAME} SHARED ${SRC})
target_compile_definitions(${TARGET_NAME} PRIVATE IMPLEMENT_INFERENCE_EXTENSION_API)
target_link_libraries(${TARGET_NAME} PRIVATE IE::inference_engine ${NGRAPH_LIBRARIES})
if (ngraph_onnx_importer_FOUND)
target_link_libraries(${TARGET_NAME} PRIVATE ${ONNX_IMPORTER_LIBRARIES})
target_compile_definitions(${TARGET_NAME} PRIVATE NGRAPH_ONNX_IMPORT_ENABLED)
endif()

This CMake script finds the Inference Engine and nGraph using the find_package CMake command.

To build an extension library, run the commands below:

$ cd template_extension
$ mkdir build
$ cd build
$ cmake -DInferenceEngine_DIR=[IE_DIR] -Dngraph_DIR=[NGRAPH_DIR] ../
$ cmake --build .