Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / cmake / dependencies.cmake
1 # Copyright (C) 2018-2019 Intel Corporation
2 #
3 # SPDX-License-Identifier: Apache-2.0
4 #
5
6 cmake_policy(SET CMP0054 NEW)
7
8 #features trigger supported by build system
9 include(check_features)
10 include(debug)
11
12 #we have number of dependencies stored on ftp
13 include(dependency_solver)
14
15 #prepare temporary folder
16 if (DEFINED ENV{${DL_SDK_TEMP}} AND NOT $ENV{${DL_SDK_TEMP}} STREQUAL "")
17     if (WIN32)
18         string(REPLACE "\\" "\\\\" TEMP $ENV{${DL_SDK_TEMP}})
19     else(WIN32)
20         set(TEMP $ENV{${DL_SDK_TEMP}})
21     endif(WIN32)
22
23     if (ENABLE_ALTERNATIVE_TEMP)
24         set(ALTERNATIVE_PATH ${IE_MAIN_SOURCE_DIR}/temp)
25     endif()
26 else ()
27     message(STATUS "DL_SDK_TEMP envionment not set")
28     set(TEMP ${IE_MAIN_SOURCE_DIR}/temp)
29 endif ()
30
31
32 include(ExternalProject)
33
34 if (ENABLE_SAME_BRANCH_FOR_MODELS)
35     branchName(MODELS_BRANCH)
36 else()
37     set(MODELS_BRANCH "master")
38 endif()
39
40 ## enable cblas_gemm from OpenBLAS package
41 if (GEMM STREQUAL "OPENBLAS")
42 if(NOT BLAS_LIBRARIES OR NOT BLAS_INCLUDE_DIRS)
43     find_package(BLAS REQUIRED)
44     if(BLAS_FOUND)
45         find_path(BLAS_INCLUDE_DIRS cblas.h)
46     else()
47         message(ERROR "OpenBLAS not found: install OpenBLAS or set -DBLAS_INCLUDE_DIRS=<path to dir with cblas.h> and -DBLAS_LIBRARIES=<path to libopenblas.so or openblas.lib>")
48     endif()
49 endif()
50 debug_message(STATUS "openblas=" ${BLAS_LIBRARIES})
51 endif ()
52
53 #MKL-ml package
54 if (GEMM STREQUAL "MKL")
55 if(NOT MKLROOT)
56     message(FATAL_ERROR "MKLROOT not found: install MKL and set -DMKLROOT=<path_to_MKL>")
57 endif()
58 set(MKL ${MKLROOT})
59 debug_message(STATUS "mkl_ml=" ${MKLROOT})
60 endif ()
61
62 ## Intel OMP package
63 if (THREADING STREQUAL "OMP")
64 if (WIN32)
65     RESOLVE_DEPENDENCY(OMP
66             ARCHIVE_WIN "iomp.zip"
67             TARGET_PATH "${TEMP}/omp"
68             ENVIRONMENT "OMP"
69             VERSION_REGEX ".*_([a-z]*_([a-z0-9]+\\.)*[0-9]+).*")
70 elseif(LINUX)
71     RESOLVE_DEPENDENCY(OMP
72             ARCHIVE_LIN "iomp.tgz"
73             TARGET_PATH "${TEMP}/omp"
74             ENVIRONMENT "OMP"
75             VERSION_REGEX ".*_([a-z]*_([a-z0-9]+\\.)*[0-9]+).*")
76 else(APPLE)
77     RESOLVE_DEPENDENCY(OMP
78             ARCHIVE_MAC "iomp_20190130_mac.tgz"
79             TARGET_PATH "${TEMP}/omp"
80             ENVIRONMENT "OMP"
81             VERSION_REGEX ".*_([a-z]*_([a-z0-9]+\\.)*[0-9]+).*")
82 endif()
83 log_rpath_from_dir(OMP "${OMP}/lib")
84 debug_message(STATUS "intel_omp=" ${OMP})
85 endif ()
86
87 ## TBB package
88 if (THREADING STREQUAL "TBB")
89 if (WIN32)
90     #TODO: add target_path to be platform specific as well, to avoid following if
91     RESOLVE_DEPENDENCY(TBB
92             ARCHIVE_WIN "tbb2019_20181010_win.zip" #TODO: windows zip archive created incorrectly using old name for folder
93             TARGET_PATH "${TEMP}/tbb"
94             ENVIRONMENT "TBBROOT"
95             VERSION_REGEX ".*_([a-z]*_([a-z0-9]+\\.)*[0-9]+).*")
96 elseif(LINUX)
97     RESOLVE_DEPENDENCY(TBB
98             ARCHIVE_LIN "tbb2019_20181010_lin.tgz"
99             TARGET_PATH "${TEMP}/tbb"
100             ENVIRONMENT "TBBROOT")
101 else(APPLE)
102     RESOLVE_DEPENDENCY(TBB
103             ARCHIVE_MAC "tbb2019_20190130_mac.tgz"
104             TARGET_PATH "${TEMP}/tbb"
105             ENVIRONMENT "TBBROOT"
106             VERSION_REGEX ".*_([a-z]*_([a-z0-9]+\\.)*[0-9]+).*")
107 endif()
108 log_rpath_from_dir(TBB "${TBB}/lib")
109 debug_message(STATUS "tbb=" ${TBB})
110 endif ()
111
112 if (ENABLE_OPENCV)
113 if (WIN32)
114     RESOLVE_DEPENDENCY(OPENCV
115             ARCHIVE_WIN "opencv_4.1.0-0437.zip"
116             TARGET_PATH "${TEMP}/opencv_4.1.0"
117             ENVIRONMENT "OpenCV_DIR"
118             VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+).*")
119     log_rpath_from_dir(OPENCV "\\opencv_4.1.0\\bin")
120     set( ENV{OpenCV_DIR} ${OPENCV}/cmake )
121 elseif(APPLE)
122     RESOLVE_DEPENDENCY(OPENCV
123             ARCHIVE_MAC "opencv_4.1.0-0437_osx.tar.xz"
124             TARGET_PATH "${TEMP}/opencv_4.1.0_osx"
125             ENVIRONMENT "OpenCV_DIR"
126             VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+).*")
127     log_rpath_from_dir(OPENCV "opencv_4.1.0_osx/lib")
128     set( ENV{OpenCV_DIR} ${OPENCV}/cmake )
129 elseif(LINUX)
130 if (${LINUX_OS_NAME} STREQUAL "Ubuntu 16.04")
131     RESOLVE_DEPENDENCY(OPENCV
132             ARCHIVE_LIN "opencv_4.1.0-0437_ubuntu16.tar.xz"
133             TARGET_PATH "${TEMP}/opencv_4.1.0_ubuntu16"
134             ENVIRONMENT "OpenCV_DIR"
135             VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+).*")
136     log_rpath_from_dir(OPENCV "opencv_4.1.0_ubuntu16/lib")
137 elseif (${LINUX_OS_NAME} STREQUAL "Ubuntu 18.04")
138     RESOLVE_DEPENDENCY(OPENCV
139             ARCHIVE_LIN "opencv_4.1.0-0437_ubuntu18.tar.xz"
140             TARGET_PATH "${TEMP}/opencv_4.1.0_ubuntu18"
141             ENVIRONMENT "OpenCV_DIR"
142             VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+).*")
143     log_rpath_from_dir(OPENCV "opencv_4.1.0_ubuntu18/lib")
144 elseif (${LINUX_OS_NAME} STREQUAL "CentOS 7")
145     RESOLVE_DEPENDENCY(OPENCV
146             ARCHIVE_LIN "opencv_4.1.0-0437_centos7.tar.xz"
147             TARGET_PATH "${TEMP}/opencv_4.1.0_centos"
148             ENVIRONMENT "OpenCV_DIR"
149             VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+).*")
150     log_rpath_from_dir(OPENCV "opencv_4.1.0_centos/lib")
151 elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l" AND
152         (${LINUX_OS_NAME} STREQUAL "Debian 9" OR
153          ${LINUX_OS_NAME} STREQUAL "Raspbian 9"))
154     RESOLVE_DEPENDENCY(OPENCV
155             ARCHIVE_LIN "opencv_4.1.0-0437_debian9arm.tar.xz"
156             TARGET_PATH "${TEMP}/opencv_4.1.0_debian9arm"
157             ENVIRONMENT "OpenCV_DIR"
158             VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+).*")
159     log_rpath_from_dir(OPENCV "opencv_4.1.0_debian9arm/lib")
160 endif()
161     set( ENV{OpenCV_DIR} ${OPENCV}/cmake )
162 endif()
163 debug_message(STATUS "opencv=" ${OPENCV})
164 endif()
165
166
167 include(ie_parallel)
168
169 if (ENABLE_GNA)
170     RESOLVE_DEPENDENCY(GNA
171             ARCHIVE_UNIFIED "gna_20181120.zip"
172             TARGET_PATH "${TEMP}/gna")
173 endif()
174
175 configure_file(
176         "${CMAKE_SOURCE_DIR}/cmake/share/InferenceEngineConfig.cmake.in"
177         "${CMAKE_BINARY_DIR}/share/InferenceEngineConfig.cmake"
178         @ONLY)
179
180 configure_file(
181         "${CMAKE_SOURCE_DIR}/cmake/share/InferenceEngineConfig-version.cmake.in"
182         "${CMAKE_BINARY_DIR}/share/InferenceEngineConfig-version.cmake"
183         COPYONLY)
184
185 configure_file(
186         "${CMAKE_SOURCE_DIR}/cmake/ie_parallel.cmake"
187         "${CMAKE_BINARY_DIR}/share/ie_parallel.cmake"
188         COPYONLY)