2 # The script to detect Intel(R) Integrated Performance Primitives Integration Wrappers (IPP IW)
6 # On return this will define:
8 # HAVE_IPP_IW - True if Intel IPP found
9 # IPP_IW_PATH - Root of Intel IPP IW directory
10 # IPP_IW_LIBRARIES - Intel IPP IW libraries
11 # IPP_IW_INCLUDES - Intel IPP IW include folder
14 unset(HAVE_IPP_IW CACHE)
16 unset(IPP_IW_LIBRARIES)
17 unset(IPP_IW_INCLUDES)
18 unset(IW_CONFIG_DEBUG)
19 #set(IW_CONFIG_DEBUG 1)
25 macro(ippiw_debugmsg MESSAGE)
26 if(DEFINED IW_CONFIG_DEBUG)
27 message(STATUS "${MESSAGE}")
30 file(TO_CMAKE_PATH "${IPPROOT}" IPPROOT)
32 # This function detects Intel IPP IW version by analyzing .h file
33 macro(ippiw_setup PATH BUILD)
34 set(FILE "${PATH}/include/iw/iw_ll.h") # check if Intel IPP IW is OpenCV specific
35 ippiw_debugmsg("Checking path: ${PATH}")
37 set(FILE "${PATH}/include/iw/iw_version.h")
38 ippiw_debugmsg("vfile\tok")
39 file(STRINGS "${FILE}" IW_VERSION_MAJOR REGEX "IW_VERSION_MAJOR")
40 file(STRINGS "${FILE}" IW_VERSION_MINOR REGEX "IW_VERSION_MINOR")
41 file(STRINGS "${FILE}" IW_VERSION_UPDATE REGEX "IW_VERSION_UPDATE")
43 file(STRINGS "${FILE}" IW_MIN_COMPATIBLE_IPP_MAJOR REGEX "IW_MIN_COMPATIBLE_IPP_MAJOR")
44 file(STRINGS "${FILE}" IW_MIN_COMPATIBLE_IPP_MINOR REGEX "IW_MIN_COMPATIBLE_IPP_MINOR")
45 file(STRINGS "${FILE}" IW_MIN_COMPATIBLE_IPP_UPDATE REGEX "IW_MIN_COMPATIBLE_IPP_UPDATE")
47 string(REGEX MATCH "[0-9]+" IW_MIN_COMPATIBLE_IPP_MAJOR ${IW_MIN_COMPATIBLE_IPP_MAJOR})
48 string(REGEX MATCH "[0-9]+" IW_MIN_COMPATIBLE_IPP_MINOR ${IW_MIN_COMPATIBLE_IPP_MINOR})
49 string(REGEX MATCH "[0-9]+" IW_MIN_COMPATIBLE_IPP_UPDATE ${IW_MIN_COMPATIBLE_IPP_UPDATE})
51 string(REGEX MATCH "[0-9]+" IW_VERSION_MAJOR ${IW_VERSION_MAJOR})
52 string(REGEX MATCH "[0-9]+" IW_VERSION_MINOR ${IW_VERSION_MINOR})
53 string(REGEX MATCH "[0-9]+" IW_VERSION_UPDATE ${IW_VERSION_UPDATE})
55 math(EXPR IPP_VERSION_EXP "${IPP_VERSION_MAJOR}*10000 + ${IPP_VERSION_MINOR}*100 + ${IPP_VERSION_BUILD}")
56 math(EXPR IW_MIN_COMPATIBLE_IPP_EXP "${IW_MIN_COMPATIBLE_IPP_MAJOR}*10000 + ${IW_MIN_COMPATIBLE_IPP_MINOR}*100 + ${IW_MIN_COMPATIBLE_IPP_UPDATE}")
58 if((IPP_VERSION_EXP GREATER IW_MIN_COMPATIBLE_IPP_EXP) OR (IPP_VERSION_EXP EQUAL IW_MIN_COMPATIBLE_IPP_EXP))
59 ippiw_debugmsg("version\tok")
62 if(EXISTS "${PATH}/src/iw_core.c")
63 ippiw_debugmsg("sources\tok")
64 set(IPP_IW_PATH "${PATH}")
65 message(STATUS "found Intel IPP IW sources: ${IW_VERSION_MAJOR}.${IW_VERSION_MINOR}.${IW_VERSION_UPDATE}")
66 message(STATUS "at: ${IPP_IW_PATH}")
68 set(IPP_IW_LIBRARY ippiw)
69 set(IPP_IW_INCLUDES "${IPP_IW_PATH}/include")
70 set(IPP_IW_LIBRARIES ${IPP_IW_LIBRARY})
71 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OpenCV_SOURCE_DIR}/3rdparty/ippicv/CMakeLists.txt" "${IPP_IW_PATH}/")
72 add_subdirectory("${IPP_IW_PATH}/" ${OpenCV_BINARY_DIR}/3rdparty/ippiw)
80 set(FILE "${PATH}/lib/intel64/${CMAKE_STATIC_LIBRARY_PREFIX}ipp_iw${CMAKE_STATIC_LIBRARY_SUFFIX}")
82 set(FILE "${PATH}/lib/ia32/${CMAKE_STATIC_LIBRARY_PREFIX}ipp_iw${CMAKE_STATIC_LIBRARY_SUFFIX}")
85 ippiw_debugmsg("binaries\tok (64=${IPP_X64})")
86 set(IPP_IW_PATH "${PATH}")
87 message(STATUS "found Intel IPP IW binaries: ${IW_VERSION_MAJOR}.${IW_VERSION_MINOR}.${IW_VERSION_UPDATE}")
88 message(STATUS "at: ${IPP_IW_PATH}")
90 add_library(ippiw STATIC IMPORTED)
91 set_target_properties(ippiw PROPERTIES
92 IMPORTED_LINK_INTERFACE_LIBRARIES ""
93 IMPORTED_LOCATION "${FILE}"
95 if (NOT BUILD_SHARED_LIBS)
96 # CMake doesn't support "install(TARGETS ${name} ...)" command with imported targets
97 install(FILES "${FILE}"
98 DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
99 set(IPPIW_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_3P_LIB_INSTALL_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}ipp_iw${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE INTERNAL "" FORCE)
100 set(IPPIW_LOCATION_PATH "${FILE}" CACHE INTERNAL "" FORCE)
103 set(IPP_IW_INCLUDES "${IPP_IW_PATH}/include")
104 set(IPP_IW_LIBRARIES ippiw)
116 # check os and architecture
118 set(IW_PACKAGE_SUBDIR "ippiw_mac")
119 elseif((UNIX AND NOT ANDROID) OR (UNIX AND ANDROID_ABI MATCHES "x86"))
120 set(IW_PACKAGE_SUBDIR "ippiw_lnx")
121 elseif(WIN32 AND NOT ARM)
122 set(IW_PACKAGE_SUBDIR "ippiw_win")
124 message(SEND_ERROR "Improper system for Intel IPP Integrations Wrappers. This message shouldn't appear. Check Intel IPP configurations steps")
128 # check build options first
131 if(DEFINED IPPIWROOT)
132 ippiw_setup("${IPPIWROOT}/" 1)
133 message(STATUS "Can't find Intel IPP IW sources at: ${IPPIWROOT}")
137 ippiw_setup("${OpenCV_SOURCE_DIR}/3rdparty/ippiw" 1)
139 set(IPPIW_ROOT "${IPPROOT}/../${IW_PACKAGE_SUBDIR}")
140 ocv_install_3rdparty_licenses(ippiw
141 "${IPPIW_ROOT}/EULA.txt"
142 "${IPPIW_ROOT}/redist.txt"
143 "${IPPIW_ROOT}/support.txt"
144 "${IPPIW_ROOT}/third-party-programs.txt")
147 get_filename_component(__PATH "${IPPROOT}/../${IW_PACKAGE_SUBDIR}/" ABSOLUTE)
148 ippiw_setup("${__PATH}" 1)
153 if(DEFINED IPPIWROOT)
154 ippiw_setup("${IPPIWROOT}/" 0)
155 message(STATUS "Can't find Intel IPP IW sources at: ${IPPIWROOT}")
158 # check binaries in IPP folder
159 ippiw_setup("${IPPROOT}/" 0)
161 # check binaries near IPP folder
162 ippiw_setup("${IPPROOT}/../${IW_PACKAGE_SUBDIR}/" 0)
165 # take Intel IPP IW from ICV package
166 if(NOT HAVE_IPP_ICV AND BUILD_IPP_IW)
167 message(STATUS "Cannot find Intel IPP IW. Checking \"Intel IPP for OpenCV\" package")
169 include("${OpenCV_SOURCE_DIR}/3rdparty/ippicv/ippicv.cmake")
170 download_ippicv(TEMP_ROOT)
171 set(IPPIW_ROOT "${TEMP_ROOT}/../${IW_PACKAGE_SUBDIR}")
172 ocv_install_3rdparty_licenses(ippiw
173 "${IPPIW_ROOT}/EULA.txt"
174 "${IPPIW_ROOT}/redist.txt"
175 "${IPPIW_ROOT}/support.txt"
176 "${IPPIW_ROOT}/third-party-programs.txt")
178 # Package sources. Only sources are compatible with regular Intel IPP
179 ippiw_setup("${IPPIW_ROOT}" 1)
184 message(STATUS "Cannot find Intel IPP Integration Wrappers, optimizations will be limited. Use IPPIWROOT to set custom location")