2018-02-06 16:57:35 +08:00
# The script detects Intel(R) Inference Engine installation
#
2018-07-30 23:21:17 +08:00
# Cache variables:
# INF_ENGINE_RELEASE - a number reflecting IE source interface (linked with OpenVINO release)
2018-02-06 16:57:35 +08:00
#
2018-07-30 23:21:17 +08:00
# Detect parameters:
# 1. Native cmake IE package:
2019-08-15 01:33:49 +08:00
# - environment variable InferenceEngine_DIR is set to location of cmake module
2018-07-30 23:21:17 +08:00
# 2. Custom location:
# - INF_ENGINE_INCLUDE_DIRS - headers search location
# - INF_ENGINE_LIB_DIRS - library search location
# 3. OpenVINO location:
2019-03-21 23:58:22 +08:00
# - environment variable INTEL_OPENVINO_DIR is set to location of OpenVINO installation dir
# - INF_ENGINE_PLATFORM - part of name of library directory representing its platform
2018-02-06 16:57:35 +08:00
#
2018-07-30 23:21:17 +08:00
# Result:
# INF_ENGINE_TARGET - set to name of imported library target representing InferenceEngine
2018-02-06 16:57:35 +08:00
#
2018-07-30 23:21:17 +08:00
function ( add_custom_ie_build _inc _lib _lib_rel _lib_dbg _msg )
if ( NOT _inc OR NOT ( _lib OR _lib_rel OR _lib_dbg ) )
return ( )
endif ( )
add_library ( inference_engine UNKNOWN IMPORTED )
set_target_properties ( inference_engine PROPERTIES
I M P O R T E D _ L O C A T I O N " $ { _ l i b } "
I M P O R T E D _ I M P L I B _ R E L E A S E " $ { _ l i b _ r e l } "
I M P O R T E D _ I M P L I B _ D E B U G " $ { _ l i b _ d b g } "
I N T E R F A C E _ I N C L U D E _ D I R E C T O R I E S " $ { _ i n c } "
)
2019-12-02 21:16:06 +08:00
find_library ( ie_builder_custom_lib "inference_engine_nn_builder" PATHS "${INF_ENGINE_LIB_DIRS}" NO_DEFAULT_PATH )
if ( EXISTS "${ie_builder_custom_lib}" )
add_library ( inference_engine_nn_builder UNKNOWN IMPORTED )
set_target_properties ( inference_engine_nn_builder PROPERTIES
I M P O R T E D _ L O C A T I O N " $ { i e _ b u i l d e r _ c u s t o m _ l i b } "
)
endif ( )
2019-03-21 23:58:22 +08:00
if ( NOT INF_ENGINE_RELEASE VERSION_GREATER "2018050000" )
find_library ( INF_ENGINE_OMP_LIBRARY iomp5 PATHS "${INF_ENGINE_OMP_DIR}" NO_DEFAULT_PATH )
if ( NOT INF_ENGINE_OMP_LIBRARY )
message ( WARNING "OpenMP for IE have not been found. Set INF_ENGINE_OMP_DIR variable if you experience build errors." )
else ( )
set_target_properties ( inference_engine PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "${INF_ENGINE_OMP_LIBRARY}" )
endif ( )
2018-07-30 23:21:17 +08:00
endif ( )
set ( INF_ENGINE_VERSION "Unknown" CACHE STRING "" )
2019-12-02 21:16:06 +08:00
set ( INF_ENGINE_TARGET inference_engine )
if ( TARGET inference_engine_nn_builder )
list ( APPEND INF_ENGINE_TARGET inference_engine_nn_builder )
set ( _msg "${_msg}, with IE NN Builder API" )
endif ( )
set ( INF_ENGINE_TARGET "${INF_ENGINE_TARGET}" PARENT_SCOPE )
2018-07-30 23:21:17 +08:00
message ( STATUS "Detected InferenceEngine: ${_msg}" )
endfunction ( )
2018-02-06 16:57:35 +08:00
2018-07-30 23:21:17 +08:00
# ======================
2018-02-06 16:57:35 +08:00
2018-07-30 23:21:17 +08:00
find_package ( InferenceEngine QUIET )
if ( InferenceEngine_FOUND )
2019-08-23 17:54:07 +08:00
set ( INF_ENGINE_TARGET ${ InferenceEngine_LIBRARIES } )
2018-07-30 23:21:17 +08:00
set ( INF_ENGINE_VERSION "${InferenceEngine_VERSION}" CACHE STRING "" )
2019-12-02 21:16:06 +08:00
message ( STATUS "Detected InferenceEngine: cmake package (${InferenceEngine_VERSION})" )
2018-02-06 16:57:35 +08:00
endif ( )
2018-07-30 23:21:17 +08:00
if ( NOT INF_ENGINE_TARGET AND INF_ENGINE_LIB_DIRS AND INF_ENGINE_INCLUDE_DIRS )
find_path ( ie_custom_inc "inference_engine.hpp" PATHS "${INF_ENGINE_INCLUDE_DIRS}" NO_DEFAULT_PATH )
find_library ( ie_custom_lib "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}" NO_DEFAULT_PATH )
find_library ( ie_custom_lib_rel "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}/Release" NO_DEFAULT_PATH )
find_library ( ie_custom_lib_dbg "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}/Debug" NO_DEFAULT_PATH )
add_custom_ie_build ( "${ie_custom_inc}" "${ie_custom_lib}" "${ie_custom_lib_rel}" "${ie_custom_lib_dbg}" "INF_ENGINE_{INCLUDE,LIB}_DIRS" )
2018-02-06 16:57:35 +08:00
endif ( )
2019-03-21 23:58:22 +08:00
set ( _loc "$ENV{INTEL_OPENVINO_DIR}" )
if ( NOT _loc AND DEFINED ENV{INTEL_CVSDK_DIR} )
set ( _loc "$ENV{INTEL_CVSDK_DIR}" ) # OpenVINO 2018.x
endif ( )
2018-07-30 23:21:17 +08:00
if ( NOT INF_ENGINE_TARGET AND _loc )
2019-03-21 23:58:22 +08:00
if ( NOT INF_ENGINE_RELEASE VERSION_GREATER "2018050000" )
set ( INF_ENGINE_PLATFORM_DEFAULT "ubuntu_16.04" )
else ( )
set ( INF_ENGINE_PLATFORM_DEFAULT "" )
endif ( )
set ( INF_ENGINE_PLATFORM "${INF_ENGINE_PLATFORM_DEFAULT}" CACHE STRING "InferenceEngine platform (library dir)" )
2018-07-30 23:21:17 +08:00
find_path ( ie_custom_env_inc "inference_engine.hpp" PATHS "${_loc}/deployment_tools/inference_engine/include" NO_DEFAULT_PATH )
find_library ( ie_custom_env_lib "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/${INF_ENGINE_PLATFORM}/intel64" NO_DEFAULT_PATH )
find_library ( ie_custom_env_lib_rel "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/intel64/Release" NO_DEFAULT_PATH )
find_library ( ie_custom_env_lib_dbg "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/intel64/Debug" NO_DEFAULT_PATH )
add_custom_ie_build ( "${ie_custom_env_inc}" "${ie_custom_env_lib}" "${ie_custom_env_lib_rel}" "${ie_custom_env_lib_dbg}" "OpenVINO (${_loc})" )
2018-07-16 18:58:59 +08:00
endif ( )
2018-07-30 23:21:17 +08:00
# Add more features to the target
2018-02-06 16:57:35 +08:00
2018-07-30 23:21:17 +08:00
if ( INF_ENGINE_TARGET )
if ( NOT INF_ENGINE_RELEASE )
2019-09-02 20:35:35 +08:00
message ( WARNING "InferenceEngine version have not been set, 2019R3 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors." )
2018-07-30 23:21:17 +08:00
endif ( )
2019-09-02 20:35:35 +08:00
set ( INF_ENGINE_RELEASE "2019030000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2018R2.0.2 -> 2018020002)" )
2018-07-30 23:21:17 +08:00
set_target_properties ( ${ INF_ENGINE_TARGET } PROPERTIES
I N T E R F A C E _ C O M P I L E _ D E F I N I T I O N S " H A V E _ I N F _ E N G I N E = 1 ; I N F _ E N G I N E _ R E L E A S E = $ { I N F _ E N G I N E _ R E L E A S E } "
)
endif ( )
2019-12-02 21:16:06 +08:00
if ( WITH_NGRAPH )
find_package ( ngraph QUIET )
if ( ngraph_FOUND )
ocv_assert ( TARGET ngraph::ngraph )
if ( INF_ENGINE_RELEASE VERSION_LESS "2019039999" )
message ( WARNING "nGraph is not tested with current InferenceEngine version: INF_ENGINE_RELEASE=${INF_ENGINE_RELEASE}" )
endif ( )
message ( STATUS "Detected ngraph: cmake package (${ngraph_VERSION})" )
set ( HAVE_NGRAPH ON )
endif ( )
endif ( )