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)
find_package(OpenCV QUIET COMPONENTS core)
set(SRC cpu_kernel.cpp extension.cpp op.cpp)
if (OpenCV_FOUND)
set(SRC ${SRC} fft_kernel.cpp fft_op.cpp)
endif()
add_library(${TARGET_NAME} MODULE ${SRC})
if (OpenCV_FOUND)
target_compile_definitions(${TARGET_NAME} PRIVATE OPENCV_IMPORT_ENABLED)
target_link_libraries(${TARGET_NAME} PRIVATE opencv_core)
endif()
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()
Inference Engine C++ API.
Definition: cldnn_config.hpp:15

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 .