opencv/3rdparty/ippicv/downloader.cmake

111 lines
4.6 KiB
CMake
Raw Normal View History

2014-04-10 13:42:57 +02:00
#
# The script downloads ICV package
#
# On return this will define:
# OPENCV_ICV_PATH - path to unpacked downloaded package
#
function(_icv_downloader)
# Commit SHA in the opencv_3rdparty repo
2015-12-01 11:12:32 +01:00
set(IPPICV_BINARIES_COMMIT "81a676001ca8075ada498583e4166079e5744668")
2014-04-10 13:42:57 +02:00
# Define actual ICV versions
if(APPLE)
2015-12-01 11:12:32 +01:00
set(OPENCV_ICV_PACKAGE_NAME "ippicv_macosx_20151201.tgz")
set(OPENCV_ICV_PACKAGE_HASH "4ff1fde9a7cfdfe7250bfcd8334e0f2f")
2014-04-10 13:42:57 +02:00
set(OPENCV_ICV_PLATFORM "macosx")
2014-04-28 16:36:58 +02:00
set(OPENCV_ICV_PACKAGE_SUBDIR "/ippicv_osx")
2014-05-13 13:09:10 +02:00
elseif(UNIX)
2015-08-10 17:02:41 +02:00
if(ANDROID AND NOT (ANDROID_ABI STREQUAL x86 OR ANDROID_ABI STREQUAL x86_64))
2014-05-13 13:09:10 +02:00
return()
endif()
2015-12-01 11:12:32 +01:00
set(OPENCV_ICV_PACKAGE_NAME "ippicv_linux_20151201.tgz")
set(OPENCV_ICV_PACKAGE_HASH "808b791a6eac9ed78d32a7666804320e")
2014-04-10 13:42:57 +02:00
set(OPENCV_ICV_PLATFORM "linux")
2014-04-28 16:36:58 +02:00
set(OPENCV_ICV_PACKAGE_SUBDIR "/ippicv_lnx")
2014-04-10 13:42:57 +02:00
elseif(WIN32 AND NOT ARM)
2015-12-01 11:12:32 +01:00
set(OPENCV_ICV_PACKAGE_NAME "ippicv_windows_20151201.zip")
set(OPENCV_ICV_PACKAGE_HASH "04e81ce5d0e329c3fbc606ae32cad44d")
2014-04-10 13:42:57 +02:00
set(OPENCV_ICV_PLATFORM "windows")
2014-04-28 16:36:58 +02:00
set(OPENCV_ICV_PACKAGE_SUBDIR "/ippicv_win")
2014-04-10 13:42:57 +02:00
else()
return() # Not supported
endif()
2014-04-28 16:36:58 +02:00
set(OPENCV_ICV_UNPACK_PATH "${CMAKE_CURRENT_LIST_DIR}/unpack")
set(OPENCV_ICV_PATH "${OPENCV_ICV_UNPACK_PATH}${OPENCV_ICV_PACKAGE_SUBDIR}")
2014-04-10 13:42:57 +02:00
if(DEFINED OPENCV_ICV_PACKAGE_DOWNLOADED
AND OPENCV_ICV_PACKAGE_DOWNLOADED STREQUAL OPENCV_ICV_PACKAGE_HASH
AND EXISTS ${OPENCV_ICV_PATH})
# Package has been downloaded and checked by the previous build
set(OPENCV_ICV_PATH "${OPENCV_ICV_PATH}" PARENT_SCOPE)
return()
else()
2014-04-28 16:36:58 +02:00
if(EXISTS ${OPENCV_ICV_UNPACK_PATH})
message(STATUS "ICV: Removing previous unpacked package: ${OPENCV_ICV_UNPACK_PATH}")
file(REMOVE_RECURSE ${OPENCV_ICV_UNPACK_PATH})
2014-04-10 13:42:57 +02:00
endif()
endif()
unset(OPENCV_ICV_PACKAGE_DOWNLOADED CACHE)
2014-08-20 10:54:39 +02:00
2014-04-10 13:42:57 +02:00
set(OPENCV_ICV_PACKAGE_ARCHIVE "${CMAKE_CURRENT_LIST_DIR}/downloads/${OPENCV_ICV_PLATFORM}-${OPENCV_ICV_PACKAGE_HASH}/${OPENCV_ICV_PACKAGE_NAME}")
get_filename_component(OPENCV_ICV_PACKAGE_ARCHIVE_DIR "${OPENCV_ICV_PACKAGE_ARCHIVE}" PATH)
if(EXISTS "${OPENCV_ICV_PACKAGE_ARCHIVE}")
file(MD5 "${OPENCV_ICV_PACKAGE_ARCHIVE}" archive_md5)
if(NOT archive_md5 STREQUAL OPENCV_ICV_PACKAGE_HASH)
message(WARNING "ICV: Local copy of ICV package has invalid MD5 hash: ${archive_md5} (expected: ${OPENCV_ICV_PACKAGE_HASH})")
file(REMOVE "${OPENCV_ICV_PACKAGE_ARCHIVE}")
file(REMOVE_RECURSE "${OPENCV_ICV_PACKAGE_ARCHIVE_DIR}")
endif()
endif()
2014-08-20 10:54:39 +02:00
2014-04-10 13:42:57 +02:00
if(NOT EXISTS "${OPENCV_ICV_PACKAGE_ARCHIVE}")
if(NOT DEFINED OPENCV_ICV_URL)
2014-05-23 11:43:31 +02:00
if(DEFINED ENV{OPENCV_ICV_URL})
set(OPENCV_ICV_URL $ENV{OPENCV_ICV_URL})
else()
2016-06-14 15:01:36 +02:00
set(OPENCV_ICV_URL "https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_BINARIES_COMMIT}/ippicv")
2014-04-10 13:42:57 +02:00
endif()
endif()
2014-08-20 10:54:39 +02:00
2014-04-10 13:42:57 +02:00
file(MAKE_DIRECTORY ${OPENCV_ICV_PACKAGE_ARCHIVE_DIR})
message(STATUS "ICV: Downloading ${OPENCV_ICV_PACKAGE_NAME}...")
file(DOWNLOAD "${OPENCV_ICV_URL}/${OPENCV_ICV_PACKAGE_NAME}" "${OPENCV_ICV_PACKAGE_ARCHIVE}"
TIMEOUT 600 STATUS __status
EXPECTED_MD5 ${OPENCV_ICV_PACKAGE_HASH})
if(NOT __status EQUAL 0)
message(FATAL_ERROR "ICV: Failed to download ICV package: ${OPENCV_ICV_PACKAGE_NAME}. Status=${__status}")
else()
# Don't remove this code, because EXPECTED_MD5 parameter doesn't fail "file(DOWNLOAD)" step
2015-08-10 17:02:41 +02:00
# on wrong hash
2014-04-10 13:42:57 +02:00
file(MD5 "${OPENCV_ICV_PACKAGE_ARCHIVE}" archive_md5)
if(NOT archive_md5 STREQUAL OPENCV_ICV_PACKAGE_HASH)
message(FATAL_ERROR "ICV: Downloaded copy of ICV package has invalid MD5 hash: ${archive_md5} (expected: ${OPENCV_ICV_PACKAGE_HASH})")
endif()
endif()
endif()
2014-08-20 10:54:39 +02:00
2014-04-10 13:42:57 +02:00
ocv_assert(EXISTS "${OPENCV_ICV_PACKAGE_ARCHIVE}")
2014-04-28 16:36:58 +02:00
ocv_assert(NOT EXISTS "${OPENCV_ICV_UNPACK_PATH}")
file(MAKE_DIRECTORY ${OPENCV_ICV_UNPACK_PATH})
ocv_assert(EXISTS "${OPENCV_ICV_UNPACK_PATH}")
2014-08-20 10:54:39 +02:00
2014-04-28 16:36:58 +02:00
message(STATUS "ICV: Unpacking ${OPENCV_ICV_PACKAGE_NAME} to ${OPENCV_ICV_UNPACK_PATH}...")
2014-04-10 13:42:57 +02:00
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xz "${OPENCV_ICV_PACKAGE_ARCHIVE}"
2014-04-28 16:36:58 +02:00
WORKING_DIRECTORY "${OPENCV_ICV_UNPACK_PATH}"
2014-04-10 13:42:57 +02:00
RESULT_VARIABLE __result)
if(NOT __result EQUAL 0)
2014-04-28 16:36:58 +02:00
message(FATAL_ERROR "ICV: Failed to unpack ICV package from ${OPENCV_ICV_PACKAGE_ARCHIVE} to ${OPENCV_ICV_UNPACK_PATH} with error ${__result}")
2014-04-10 13:42:57 +02:00
endif()
2014-04-28 16:36:58 +02:00
ocv_assert(EXISTS "${OPENCV_ICV_PATH}")
2014-04-10 13:42:57 +02:00
set(OPENCV_ICV_PACKAGE_DOWNLOADED "${OPENCV_ICV_PACKAGE_HASH}" CACHE INTERNAL "ICV package hash")
2014-08-20 10:54:39 +02:00
2014-04-10 13:42:57 +02:00
message(STATUS "ICV: Package successfully downloaded")
set(OPENCV_ICV_PATH "${OPENCV_ICV_PATH}" PARENT_SCOPE)
endfunction()
_icv_downloader()