Merge pull request #11882 from alalek:videoio_vfw_lower_priority
[platform/upstream/opencv.git] / cmake / OpenCVDetectInferenceEngine.cmake
1 # The script detects Intel(R) Inference Engine installation
2 #
3 # Parameters:
4 # INTEL_CVSDK_DIR - Path to Inference Engine root folder
5 # IE_PLUGINS_PATH - Path to folder with Inference Engine plugins
6 #
7 # On return this will define:
8 #
9 # HAVE_INF_ENGINE          - True if Intel Inference Engine was found
10 # INF_ENGINE_INCLUDE_DIRS  - Inference Engine include folder
11 # INF_ENGINE_LIBRARIES     - Inference Engine libraries and it's dependencies
12 #
13 macro(ie_fail)
14     set(HAVE_INF_ENGINE FALSE)
15     return()
16 endmacro()
17
18 if(NOT HAVE_CXX11)
19     ie_fail()
20 endif()
21
22 if(NOT INF_ENGINE_ROOT_DIR OR NOT EXISTS "${INF_ENGINE_ROOT_DIR}/include/inference_engine.hpp")
23     set(ie_root_paths "${INF_ENGINE_ROOT_DIR}")
24     if(DEFINED ENV{INTEL_CVSDK_DIR})
25         list(APPEND ie_root_paths "$ENV{INTEL_CVSDK_DIR}")
26         list(APPEND ie_root_paths "$ENV{INTEL_CVSDK_DIR}/inference_engine")
27     endif()
28     if(DEFINED INTEL_CVSDK_DIR)
29         list(APPEND ie_root_paths "${INTEL_CVSDK_DIR}")
30         list(APPEND ie_root_paths "${INTEL_CVSDK_DIR}/inference_engine")
31     endif()
32
33     if(NOT ie_root_paths)
34         list(APPEND ie_root_paths "/opt/intel/deeplearning_deploymenttoolkit/deployment_tools/inference_engine")
35     endif()
36
37     find_path(INF_ENGINE_ROOT_DIR include/inference_engine.hpp PATHS ${ie_root_paths})
38 endif()
39
40 set(INF_ENGINE_INCLUDE_DIRS "${INF_ENGINE_ROOT_DIR}/include" CACHE PATH "Path to Inference Engine include directory")
41
42 if(NOT INF_ENGINE_ROOT_DIR
43     OR NOT EXISTS "${INF_ENGINE_ROOT_DIR}"
44     OR NOT EXISTS "${INF_ENGINE_ROOT_DIR}/include/inference_engine.hpp"
45 )
46     ie_fail()
47 endif()
48
49 set(INF_ENGINE_LIBRARIES "")
50
51 set(ie_lib_list inference_engine)
52
53 link_directories(
54   ${INTEL_CVSDK_DIR}/inference_engine/external/mkltiny_lnx/lib
55   ${INTEL_CVSDK_DIR}/inference_engine/external/cldnn/lib
56 )
57
58 foreach(lib ${ie_lib_list})
59     find_library(${lib}
60         NAMES ${lib}
61         # For inference_engine
62         HINTS ${IE_PLUGINS_PATH}
63         HINTS "$ENV{IE_PLUGINS_PATH}"
64     )
65     if(NOT ${lib})
66         ie_fail()
67     endif()
68     list(APPEND INF_ENGINE_LIBRARIES ${${lib}})
69 endforeach()
70
71 set(HAVE_INF_ENGINE TRUE)