2
2
# The script to detect Intel(R) Integrated Performance Primitives (IPP)
3
3
# installation/package
4
4
#
5
- # Windows host:
6
- # Run script like this before cmake:
7
- # call "<IPP_INSTALL_DIR>\bin\ippvars.bat" intel64
8
- # for example:
9
- # call "C:\Program Files (x86)\Intel\Composer XE\ipp\bin\ippvars.bat" intel64
5
+ # By default, ICV version will be used.
6
+ # To use standalone IPP update cmake command line :
7
+ # cmake ... -DIPPROOT=<path> ...
8
+ #
9
+ # Note: Backward compatibility is broken, IPPROOT environment path is ignored
10
10
#
11
- # Linux host:
12
- # Run script like this before cmake:
13
- # source /opt/intel/ipp/bin/ippvars.sh [ia32|intel64]
14
11
#
15
12
# On return this will define:
16
13
#
@@ -39,14 +36,6 @@ unset(IPP_VERSION_BUILD)
39
36
40
37
set (IPP_LIB_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX} )
41
38
set (IPP_LIB_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX} )
42
- set (IPP_PREFIX "ipp" )
43
- set (IPP_SUFFIX "_l" )
44
- set (IPPCORE "core" ) # core functionality
45
- set (IPPS "s" ) # signal processing
46
- set (IPPI "i" ) # image processing
47
- set (IPPCC "cc" ) # color conversion
48
- set (IPPCV "cv" ) # computer vision
49
- set (IPPVM "vm" ) # vector math
50
39
51
40
set (IPP_X64 0)
52
41
if (CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8)
@@ -56,21 +45,21 @@ if(CMAKE_CL_64)
56
45
set (IPP_X64 1)
57
46
endif ()
58
47
59
- # This function detects IPP version by analyzing ippversion .h file
60
- macro (ipp_get_version _ROOT_DIR )
48
+ # This function detects IPP version by analyzing .h file
49
+ macro (ipp_get_version VERSION_FILE )
61
50
unset (_VERSION_STR)
62
51
unset (_MAJOR)
63
52
unset (_MINOR)
64
53
unset (_BUILD)
65
54
66
55
# read IPP version info from file
67
- file (STRINGS ${_ROOT_DIR} / include /ippversion.h STR1 REGEX "IPP_VERSION_MAJOR" )
68
- file (STRINGS ${_ROOT_DIR} / include /ippversion.h STR2 REGEX "IPP_VERSION_MINOR" )
69
- file (STRINGS ${_ROOT_DIR} / include /ippversion.h STR3 REGEX "IPP_VERSION_BUILD" )
56
+ file (STRINGS ${VERSION_FILE} STR1 REGEX "IPP_VERSION_MAJOR" )
57
+ file (STRINGS ${VERSION_FILE} STR2 REGEX "IPP_VERSION_MINOR" )
58
+ file (STRINGS ${VERSION_FILE} STR3 REGEX "IPP_VERSION_BUILD" )
70
59
if ("${STR3} " STREQUAL "" )
71
- file (STRINGS ${_ROOT_DIR} / include /ippversion.h STR3 REGEX "IPP_VERSION_UPDATE" )
60
+ file (STRINGS ${VERSION_FILE} STR3 REGEX "IPP_VERSION_UPDATE" )
72
61
endif ()
73
- file (STRINGS ${_ROOT_DIR} / include /ippversion.h STR4 REGEX "IPP_VERSION_STR" )
62
+ file (STRINGS ${VERSION_FILE} STR4 REGEX "IPP_VERSION_STR" )
74
63
75
64
# extract info and assign to variables
76
65
string (REGEX MATCHALL "[0-9]+" _MAJOR ${STR1} )
@@ -83,153 +72,185 @@ macro(ipp_get_version _ROOT_DIR)
83
72
set (IPP_VERSION_MAJOR ${_MAJOR} )
84
73
set (IPP_VERSION_MINOR ${_MINOR} )
85
74
set (IPP_VERSION_BUILD ${_BUILD} )
75
+ endmacro ()
76
+
77
+ macro (_ipp_not_supported)
78
+ message (STATUS ${ARGN} )
79
+ unset (HAVE_IPP)
80
+ unset (HAVE_IPP_ICV_ONLY)
81
+ unset (IPP_VERSION_STR)
82
+ return ()
83
+ endmacro ()
84
+
85
+ # This macro uses IPP_ROOT_DIR variable
86
+ # TODO Cleanup code after ICV package stabilization
87
+ macro (ipp_detect_version)
88
+ set (IPP_INCLUDE_DIRS ${IPP_ROOT_DIR} /include )
86
89
87
90
set (__msg)
88
- if (EXISTS ${_ROOT_DIR} /include /ippicv.h)
89
- ocv_assert(WITH_ICV AND NOT WITH_IPP)
90
- set (__msg " ICV version" )
91
+ if (EXISTS ${IPP_ROOT_DIR} /ippicv.h)
92
+ set (__msg " (ICV version)" )
91
93
set (HAVE_IPP_ICV_ONLY 1)
94
+ if (EXISTS ${IPP_ROOT_DIR} /ippversion.h)
95
+ _ipp_not_supported("Can't resolve IPP directory: ${IPP_ROOT_DIR} " )
96
+ else ()
97
+ ipp_get_version(${IPP_ROOT_DIR} /ippicv.h)
98
+ endif ()
99
+ ocv_assert(IPP_VERSION_STR VERSION_GREATER "8.0" )
100
+ set (IPP_INCLUDE_DIRS ${IPP_ROOT_DIR} /)
101
+ elseif (EXISTS ${IPP_ROOT_DIR} /include /ipp.h)
102
+ ipp_get_version(${IPP_ROOT_DIR} /include /ippversion.h)
103
+ ocv_assert(IPP_VERSION_STR VERSION_GREATER "1.0" )
104
+ else ()
105
+ _ipp_not_supported("Can't resolve IPP directory: ${IPP_ROOT_DIR} " )
92
106
endif ()
93
107
94
- message (STATUS "found IPP: ${_MAJOR} .${_MINOR} .${_BUILD} [${_VERSION_STR} ]${__msg} " )
95
- message (STATUS "at: ${_ROOT_DIR} " )
96
- endmacro ()
108
+ message (STATUS "found IPP${__msg} : ${_MAJOR} .${_MINOR} .${_BUILD} [${IPP_VERSION_STR} ]" )
109
+ message (STATUS "at: ${IPP_ROOT_DIR} " )
97
110
111
+ if (${IPP_VERSION_STR} VERSION_LESS "7.0" )
112
+ _ipp_not_supported("IPP ${IPP_VERSION_STR} is not supported" )
113
+ endif ()
98
114
99
- # This function sets IPP_INCLUDE_DIRS and IPP_LIBRARIES variables
100
- macro (ipp_set_variables _LATEST_VERSION)
101
- if (${_LATEST_VERSION} VERSION_LESS "7.0" )
102
- message (SEND_ERROR "IPP ${_LATEST_VERSION} is not supported" )
103
- unset (HAVE_IPP)
104
- return ()
115
+ set (HAVE_IPP 1)
116
+ if (EXISTS ${IPP_INCLUDE_DIRS} /ipp_redefine.h)
117
+ set (HAVE_IPP_REDEFINE 1)
118
+ else ()
119
+ unset (HAVE_IPP_REDEFINE)
105
120
endif ()
106
121
107
- # set INCLUDE and LIB folders
108
- set (IPP_INCLUDE_DIRS ${IPP_ROOT_DIR} /include )
122
+ macro (_ipp_set_library_dir DIR)
123
+ if (NOT EXISTS ${DIR} )
124
+ _ipp_not_supported("IPP library directory not found" )
125
+ endif ()
126
+ set (IPP_LIBRARY_DIR ${DIR} )
127
+ endmacro ()
109
128
110
129
if (NOT HAVE_IPP_ICV_ONLY)
111
130
if (APPLE )
112
- set (IPP_LIBRARY_DIR ${IPP_ROOT_DIR} /lib)
131
+ _ipp_set_library_dir( ${IPP_ROOT_DIR} /lib)
113
132
elseif (IPP_X64)
114
- if (NOT EXISTS ${IPP_ROOT_DIR} /lib/intel64)
115
- message (SEND_ERROR "IPP EM64T libraries not found" )
116
- endif ()
117
- set (IPP_LIBRARY_DIR ${IPP_ROOT_DIR} /lib/intel64)
133
+ _ipp_set_library_dir(${IPP_ROOT_DIR} /lib/intel64)
118
134
else ()
119
- if (NOT EXISTS ${IPP_ROOT_DIR} /lib/ia32)
120
- message (SEND_ERROR "IPP IA32 libraries not found" )
121
- endif ()
122
- set (IPP_LIBRARY_DIR ${IPP_ROOT_DIR} /lib/ia32)
135
+ _ipp_set_library_dir(${IPP_ROOT_DIR} /lib/ia32)
123
136
endif ()
124
137
else ()
125
- if (APPLE )
126
- set (IPP_LIBRARY_DIR ${IPP_ROOT_DIR} /libs/macosx)
127
- elseif (WIN32 AND NOT ARM)
128
- set (IPP_LIBRARY_DIR ${IPP_ROOT_DIR} /libs/windows)
129
- elseif (UNIX )
130
- set (IPP_LIBRARY_DIR ${IPP_ROOT_DIR} /libs/linux)
138
+ if (EXISTS ${IPP_ROOT_DIR} /lib)
139
+ set (IPP_LIBRARY_DIR ${IPP_ROOT_DIR} /lib)
131
140
else ()
132
- message (MESSAGE "IPP ${_LATEST_VERSION} at ${IPP_ROOT_DIR} is not supported" )
133
- unset (HAVE_IPP)
134
- return ()
141
+ _ipp_not_supported("IPP ${IPP_VERSION_STR} at ${IPP_ROOT_DIR} is not supported" )
135
142
endif ()
136
143
if (X86_64)
137
- set (IPP_LIBRARY_DIR ${IPP_LIBRARY_DIR} /intel64)
144
+ _ipp_set_library_dir( ${IPP_LIBRARY_DIR} /intel64)
138
145
else ()
139
- set (IPP_LIBRARY_DIR ${IPP_LIBRARY_DIR} /ia32)
146
+ _ipp_set_library_dir( ${IPP_LIBRARY_DIR} /ia32)
140
147
endif ()
141
148
endif ()
142
149
150
+ macro (_ipp_add_library name )
151
+ if (EXISTS ${IPP_LIBRARY_DIR} /${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX} )
152
+ list (APPEND IPP_LIBRARIES ${IPP_LIBRARY_DIR} /${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX} )
153
+ else ()
154
+ message (STATUS "Can't find IPP library: ${name} " )
155
+ endif ()
156
+ endmacro ()
157
+
143
158
set (IPP_PREFIX "ipp" )
144
- if (${_LATEST_VERSION } VERSION_LESS "8.0" )
145
- set (IPP_SUFFIX "_l" ) # static not threaded libs suffix IPP 7.x
159
+ if (${IPP_VERSION_STR } VERSION_LESS "8.0" )
160
+ set (IPP_SUFFIX "_l" ) # static not threaded libs suffix IPP 7.x
146
161
else ()
147
162
if (WIN32 )
148
163
set (IPP_SUFFIX "mt" ) # static not threaded libs suffix IPP 8.x for Windows
149
164
else ()
150
165
set (IPP_SUFFIX "" ) # static not threaded libs suffix IPP 8.x for Linux/OS X
151
166
endif ()
152
167
endif ()
153
- set (IPPCORE "core" ) # core functionality
154
- set (IPPSP "s" ) # signal processing
155
- set (IPPIP "i" ) # image processing
156
- set (IPPCC "cc" ) # color conversion
157
- set (IPPCV "cv" ) # computer vision
158
- set (IPPVM "vm" ) # vector math
159
- set (IPPM "m" ) # matrix math
160
-
161
- list (APPEND IPP_LIBRARIES ${IPP_LIBRARY_DIR} /${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPVM}${IPP_SUFFIX}${IPP_LIB_SUFFIX} )
162
- list (APPEND IPP_LIBRARIES ${IPP_LIBRARY_DIR} /${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCC}${IPP_SUFFIX}${IPP_LIB_SUFFIX} )
163
- list (APPEND IPP_LIBRARIES ${IPP_LIBRARY_DIR} /${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCV}${IPP_SUFFIX}${IPP_LIB_SUFFIX} )
164
- list (APPEND IPP_LIBRARIES ${IPP_LIBRARY_DIR} /${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPI}${IPP_SUFFIX}${IPP_LIB_SUFFIX} )
165
- list (APPEND IPP_LIBRARIES ${IPP_LIBRARY_DIR} /${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPS}${IPP_SUFFIX}${IPP_LIB_SUFFIX} )
166
- list (APPEND IPP_LIBRARIES ${IPP_LIBRARY_DIR} /${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCORE}${IPP_SUFFIX}${IPP_LIB_SUFFIX} )
167
- if (NOT HAVE_IPP_ICV_ONLY)
168
- list (APPEND IPP_LIBRARIES ${IPP_LIBRARY_DIR} /${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPM}${IPP_SUFFIX}${IPP_LIB_SUFFIX} )
169
- endif ()
170
168
171
- # FIXIT
172
- # if(UNIX AND NOT HAVE_IPP_ICV_ONLY)
173
- # get_filename_component(INTEL_COMPILER_LIBRARY_DIR ${IPP_ROOT_DIR}/../lib REALPATH)
174
- if (UNIX )
175
- if (NOT HAVE_IPP_ICV_ONLY)
169
+ if (HAVE_IPP_ICV_ONLY)
170
+ _ipp_add_library(icv)
171
+ else ()
172
+ _ipp_add_library(core)
173
+ _ipp_add_library(s)
174
+ _ipp_add_library(i)
175
+ _ipp_add_library(cc)
176
+ _ipp_add_library(cv)
177
+ _ipp_add_library(vm)
178
+ _ipp_add_library(m)
179
+
180
+ if (UNIX )
176
181
get_filename_component (INTEL_COMPILER_LIBRARY_DIR ${IPP_ROOT_DIR} /../lib REALPATH)
177
- else ()
178
- set (INTEL_COMPILER_LIBRARY_DIR "/opt/intel/lib" )
179
- endif ()
180
- if (IPP_X64)
181
- if (NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR} /intel64)
182
- message (SEND_ERROR "Intel compiler EM64T libraries not found" )
182
+ if (NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR} )
183
+ get_filename_component (INTEL_COMPILER_LIBRARY_DIR ${IPP_ROOT_DIR} /../compiler/lib REALPATH)
183
184
endif ()
184
- if (NOT APPLE )
185
- set (INTEL_COMPILER_LIBRARY_DIR ${INTEL_COMPILER_LIBRARY_DIR} /intel64)
186
- endif ()
187
- else ()
188
- if (NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR} /ia32)
189
- message (SEND_ERROR "Intel compiler IA32 libraries not found" )
185
+ if (NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR} )
186
+ _ipp_not_supported("IPP configuration error: can't find Intel compiler library dir ${INTEL_COMPILER_LIBRARY_DIR} " )
190
187
endif ()
191
- if (NOT APPLE )
192
- set (INTEL_COMPILER_LIBRARY_DIR ${INTEL_COMPILER_LIBRARY_DIR} /ia32)
188
+ if (NOT APPLE )
189
+ if (IPP_X64)
190
+ if (NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR} /intel64)
191
+ message (SEND_ERROR "Intel compiler EM64T libraries not found" )
192
+ endif ()
193
+ set (INTEL_COMPILER_LIBRARY_DIR ${INTEL_COMPILER_LIBRARY_DIR} /intel64)
194
+ else ()
195
+ if (NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR} /ia32)
196
+ message (SEND_ERROR "Intel compiler IA32 libraries not found" )
197
+ endif ()
198
+ set (INTEL_COMPILER_LIBRARY_DIR ${INTEL_COMPILER_LIBRARY_DIR} /ia32)
199
+ endif ()
193
200
endif ()
194
- endif ()
195
- list (APPEND IPP_LIBRARIES ${INTEL_COMPILER_LIBRARY_DIR} /${IPP_LIB_PREFIX} irc${CMAKE_SHARED_LIBRARY_SUFFIX} )
196
- list (APPEND IPP_LIBRARIES ${INTEL_COMPILER_LIBRARY_DIR} /${IPP_LIB_PREFIX} imf${CMAKE_SHARED_LIBRARY_SUFFIX} )
197
- list (APPEND IPP_LIBRARIES ${INTEL_COMPILER_LIBRARY_DIR} /${IPP_LIB_PREFIX} svml${CMAKE_SHARED_LIBRARY_SUFFIX} )
201
+
202
+ macro (_ipp_add_compiler_library name )
203
+ if (EXISTS ${INTEL_COMPILER_LIBRARY_DIR} /${IPP_LIB_PREFIX}${name}${CMAKE_SHARED_LIBRARY_SUFFIX} )
204
+ list (APPEND IPP_LIBRARIES ${INTEL_COMPILER_LIBRARY_DIR} /${IPP_LIB_PREFIX}${name}${CMAKE_SHARED_LIBRARY_SUFFIX} )
205
+ else ()
206
+ message (STATUS "Can't find compiler library: ${name} " )
207
+ endif ()
208
+ endmacro ()
209
+
210
+ _ipp_add_compiler_library(irc)
211
+ _ipp_add_compiler_library(imf)
212
+ _ipp_add_compiler_library(svml)
213
+ endif (UNIX )
198
214
endif ()
199
215
200
216
#message(STATUS "IPP libs: ${IPP_LIBRARIES}")
201
217
endmacro ()
202
218
203
- if (WITH_IPP)
204
- set (IPPPATH $ENV{IPPROOT} )
205
- if (UNIX )
206
- list (APPEND IPPPATH /opt/intel/ipp)
207
- endif ()
208
- elseif (WITH_ICV)
209
- if (DEFINED ENV{IPPICVROOT})
210
- set (IPPPATH $ENV{IPPICVROOT} )
211
- else ()
212
- set (IPPPATH ${OpenCV_SOURCE_DIR} /3rdparty/ippicv)
213
- endif ()
219
+ # OPENCV_IPP_PATH is an environment variable for internal usage only, do not use it
220
+ if (DEFINED ENV{OPENCV_IPP_PATH} AND NOT DEFINED IPPROOT)
221
+ set (IPPROOT "$ENV{OPENCV_IPP_PATH} " )
222
+ endif ()
223
+ if (NOT DEFINED IPPROOT)
224
+ set (IPPROOT "${OpenCV_SOURCE_DIR} /3rdparty/ippicv" )
214
225
endif ()
215
226
216
-
227
+ # Try ICV
217
228
find_path (
218
- IPP_H_PATH
219
- NAMES ippversion.h
220
- PATHS ${IPPPATH}
221
- PATH_SUFFIXES include
222
- DOC "The path to Intel(R) IPP header files"
229
+ IPP_ICV_H_PATH
230
+ NAMES ippicv.h
231
+ PATHS ${IPPROOT}
232
+ DOC "The path to Intel(R) IPP ICV header files"
223
233
NO_DEFAULT_PATH
224
234
NO_CMAKE_PATH)
235
+ set (IPP_ROOT_DIR ${IPP_ICV_H_PATH} )
225
236
226
- if (IPP_H_PATH)
227
- set (HAVE_IPP 1)
228
-
237
+ if (NOT IPP_ICV_H_PATH)
238
+ # Try standalone IPP
239
+ find_path (
240
+ IPP_H_PATH
241
+ NAMES ippversion.h
242
+ PATHS ${IPPROOT}
243
+ PATH_SUFFIXES include
244
+ DOC "The path to Intel(R) IPP header files"
245
+ NO_DEFAULT_PATH
246
+ NO_CMAKE_PATH)
247
+ if (IPP_H_PATH)
229
248
get_filename_component (IPP_ROOT_DIR ${IPP_H_PATH} PATH )
249
+ endif ()
250
+ endif ()
230
251
231
- ipp_get_version( ${ IPP_ROOT_DIR} )
232
- ipp_set_variables( ${IPP_VERSION_STR} )
252
+ if ( IPP_ROOT_DIR)
253
+ ipp_detect_version( )
233
254
endif ()
234
255
235
256
0 commit comments