2012-05-25 21:12:02 +08:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# Detect 3rd-party image IO libraries
|
|
|
|
# ----------------------------------------------------------------------------
|
2012-03-02 19:36:34 +08:00
|
|
|
|
2012-05-25 21:12:02 +08:00
|
|
|
# --- zlib (required) ---
|
2012-02-24 21:53:22 +08:00
|
|
|
if(BUILD_ZLIB)
|
2012-05-25 21:12:02 +08:00
|
|
|
ocv_clear_vars(ZLIB_FOUND)
|
2012-02-24 21:53:22 +08:00
|
|
|
else()
|
2020-12-02 20:34:24 +08:00
|
|
|
ocv_clear_internal_cache_vars(ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
|
Merge pull request #19522 from zchrissirhcz:3.4-fix-android-find-zlib-shared-since-ndk19
* fix find zlib.so instead of zlib.a when NDK >= 19
On Android platform, `libopencv_imgcodecs.a` is built, expected to
depend on `libz.so`. However, since Android NDK r19, NDK's `libz.a`
is found instead of `libz.so`, leading to link error
(not found libz.a) on machines without same NDK version & direcotry.
Since Android NDK-r19, toolchain pieces are installed to
`$NDK/toolchains/llvm/prebuilt/<host-tag>/...`, including `libz.so`.
Also installed to old paths (`<NDK>/platforms` and `<NDK>/sysroot`)
in NDK r19, r20, r21, but since NDK 22, old paths are removed.
- https://github.com/android/ndk/wiki/Changelog-r19
- https://github.com/android/ndk/wiki/Changelog-r22
With this commit, `libz.so` can be correctly found in NDK<19 and NDK>=19.
`ZLIB_LIBRARIES` is also simplified as `z`, by appending match (regex)
patterns for new toolchain installation directory's libz.so's paths.
* simplify libz.so match pattern for abbreviation
2021-02-15 02:38:53 +08:00
|
|
|
if(ANDROID)
|
|
|
|
set(_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
|
|
|
set(CMAKE_FIND_LIBRARY_SUFFIXES .so)
|
|
|
|
endif()
|
2013-08-22 22:06:07 +08:00
|
|
|
find_package(ZLIB "${MIN_VER_ZLIB}")
|
Merge pull request #19522 from zchrissirhcz:3.4-fix-android-find-zlib-shared-since-ndk19
* fix find zlib.so instead of zlib.a when NDK >= 19
On Android platform, `libopencv_imgcodecs.a` is built, expected to
depend on `libz.so`. However, since Android NDK r19, NDK's `libz.a`
is found instead of `libz.so`, leading to link error
(not found libz.a) on machines without same NDK version & direcotry.
Since Android NDK-r19, toolchain pieces are installed to
`$NDK/toolchains/llvm/prebuilt/<host-tag>/...`, including `libz.so`.
Also installed to old paths (`<NDK>/platforms` and `<NDK>/sysroot`)
in NDK r19, r20, r21, but since NDK 22, old paths are removed.
- https://github.com/android/ndk/wiki/Changelog-r19
- https://github.com/android/ndk/wiki/Changelog-r22
With this commit, `libz.so` can be correctly found in NDK<19 and NDK>=19.
`ZLIB_LIBRARIES` is also simplified as `z`, by appending match (regex)
patterns for new toolchain installation directory's libz.so's paths.
* simplify libz.so match pattern for abbreviation
2021-02-15 02:38:53 +08:00
|
|
|
if(ANDROID)
|
|
|
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
|
|
|
|
unset(_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES)
|
|
|
|
endif()
|
2012-04-30 22:33:52 +08:00
|
|
|
if(ZLIB_FOUND AND ANDROID)
|
2022-01-24 20:52:23 +08:00
|
|
|
if(ZLIB_LIBRARY MATCHES "/usr/lib.*/libz.so$")
|
|
|
|
set(ZLIB_LIBRARY z)
|
2012-04-30 22:33:52 +08:00
|
|
|
set(ZLIB_LIBRARIES z)
|
2022-01-24 20:52:23 +08:00
|
|
|
set(ZLIB_LIBRARY_RELEASE z)
|
2012-04-14 05:50:59 +08:00
|
|
|
endif()
|
2012-02-24 21:53:22 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT ZLIB_FOUND)
|
2020-11-27 06:56:59 +08:00
|
|
|
ocv_clear_vars(ZLIB_LIBRARY ZLIB_LIBRARIES ZLIB_INCLUDE_DIR)
|
2012-03-02 19:36:34 +08:00
|
|
|
|
2020-11-27 06:56:59 +08:00
|
|
|
set(ZLIB_LIBRARY zlib CACHE INTERNAL "")
|
2012-02-24 21:53:22 +08:00
|
|
|
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/zlib")
|
2020-11-27 06:56:59 +08:00
|
|
|
set(ZLIB_INCLUDE_DIR "${${ZLIB_LIBRARY}_SOURCE_DIR}" "${${ZLIB_LIBRARY}_BINARY_DIR}" CACHE INTERNAL "")
|
|
|
|
set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR})
|
2013-08-22 22:04:50 +08:00
|
|
|
set(ZLIB_LIBRARIES ${ZLIB_LIBRARY})
|
2012-07-10 03:16:38 +08:00
|
|
|
|
|
|
|
ocv_parse_header2(ZLIB "${${ZLIB_LIBRARY}_SOURCE_DIR}/zlib.h" ZLIB_VERSION)
|
2012-02-24 21:53:22 +08:00
|
|
|
endif()
|
|
|
|
|
2017-12-08 20:47:54 +08:00
|
|
|
# --- libjpeg (optional) ---
|
|
|
|
if(WITH_JPEG)
|
|
|
|
if(BUILD_JPEG)
|
|
|
|
ocv_clear_vars(JPEG_FOUND)
|
|
|
|
else()
|
2020-12-02 20:34:24 +08:00
|
|
|
ocv_clear_internal_cache_vars(JPEG_LIBRARY JPEG_INCLUDE_DIR)
|
2017-12-08 20:47:54 +08:00
|
|
|
include(FindJPEG)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT JPEG_FOUND)
|
2020-12-02 20:34:24 +08:00
|
|
|
ocv_clear_vars(JPEG_LIBRARY JPEG_INCLUDE_DIR)
|
2017-12-08 20:47:54 +08:00
|
|
|
|
2018-05-10 22:02:24 +08:00
|
|
|
if(NOT BUILD_JPEG_TURBO_DISABLE)
|
2020-11-27 06:56:59 +08:00
|
|
|
set(JPEG_LIBRARY libjpeg-turbo CACHE INTERNAL "")
|
2018-05-10 22:02:24 +08:00
|
|
|
set(JPEG_LIBRARIES ${JPEG_LIBRARY})
|
|
|
|
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjpeg-turbo")
|
2020-11-27 06:56:59 +08:00
|
|
|
set(JPEG_INCLUDE_DIR "${${JPEG_LIBRARY}_SOURCE_DIR}/src" CACHE INTERNAL "")
|
2018-05-10 22:02:24 +08:00
|
|
|
else()
|
2020-11-27 06:56:59 +08:00
|
|
|
set(JPEG_LIBRARY libjpeg CACHE INTERNAL "")
|
2018-05-10 22:02:24 +08:00
|
|
|
set(JPEG_LIBRARIES ${JPEG_LIBRARY})
|
|
|
|
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjpeg")
|
2020-11-27 06:56:59 +08:00
|
|
|
set(JPEG_INCLUDE_DIR "${${JPEG_LIBRARY}_SOURCE_DIR}" CACHE INTERNAL "")
|
2018-05-10 22:02:24 +08:00
|
|
|
endif()
|
2020-11-27 06:56:59 +08:00
|
|
|
set(JPEG_INCLUDE_DIRS "${JPEG_INCLUDE_DIR}")
|
2017-12-08 20:47:54 +08:00
|
|
|
endif()
|
|
|
|
|
2018-05-10 22:02:24 +08:00
|
|
|
macro(ocv_detect_jpeg_version header_file)
|
|
|
|
if(NOT DEFINED JPEG_LIB_VERSION AND EXISTS "${header_file}")
|
|
|
|
ocv_parse_header("${header_file}" JPEG_VERSION_LINES JPEG_LIB_VERSION)
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
ocv_detect_jpeg_version("${JPEG_INCLUDE_DIR}/jpeglib.h")
|
|
|
|
if(DEFINED CMAKE_CXX_LIBRARY_ARCHITECTURE)
|
|
|
|
ocv_detect_jpeg_version("${JPEG_INCLUDE_DIR}/${CMAKE_CXX_LIBRARY_ARCHITECTURE}/jconfig.h")
|
|
|
|
endif()
|
|
|
|
# no needed for strict platform check here, both files 64/32 should contain the same version
|
|
|
|
ocv_detect_jpeg_version("${JPEG_INCLUDE_DIR}/jconfig-64.h")
|
|
|
|
ocv_detect_jpeg_version("${JPEG_INCLUDE_DIR}/jconfig-32.h")
|
|
|
|
ocv_detect_jpeg_version("${JPEG_INCLUDE_DIR}/jconfig.h")
|
|
|
|
ocv_detect_jpeg_version("${${JPEG_LIBRARY}_BINARY_DIR}/jconfig.h")
|
|
|
|
if(NOT DEFINED JPEG_LIB_VERSION)
|
|
|
|
set(JPEG_LIB_VERSION "unknown")
|
|
|
|
endif()
|
2017-12-08 20:47:54 +08:00
|
|
|
set(HAVE_JPEG YES)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# --- libtiff (optional, should be searched after zlib and libjpeg) ---
|
2012-02-24 21:53:22 +08:00
|
|
|
if(WITH_TIFF)
|
|
|
|
if(BUILD_TIFF)
|
2012-05-25 21:12:02 +08:00
|
|
|
ocv_clear_vars(TIFF_FOUND)
|
2012-02-24 21:53:22 +08:00
|
|
|
else()
|
2020-12-02 20:34:24 +08:00
|
|
|
ocv_clear_internal_cache_vars(TIFF_LIBRARY TIFF_INCLUDE_DIR)
|
2012-02-24 21:53:22 +08:00
|
|
|
include(FindTIFF)
|
2012-04-14 05:50:59 +08:00
|
|
|
if(TIFF_FOUND)
|
|
|
|
ocv_parse_header("${TIFF_INCLUDE_DIR}/tiff.h" TIFF_VERSION_LINES TIFF_VERSION_CLASSIC TIFF_VERSION_BIG TIFF_VERSION TIFF_BIGTIFF_VERSION)
|
|
|
|
endif()
|
2012-02-24 21:53:22 +08:00
|
|
|
endif()
|
|
|
|
|
2013-07-11 16:40:16 +08:00
|
|
|
if(NOT TIFF_FOUND)
|
|
|
|
ocv_clear_vars(TIFF_LIBRARY TIFF_LIBRARIES TIFF_INCLUDE_DIR)
|
2012-03-02 19:36:34 +08:00
|
|
|
|
2020-11-27 06:56:59 +08:00
|
|
|
set(TIFF_LIBRARY libtiff CACHE INTERNAL "")
|
2013-07-11 16:40:16 +08:00
|
|
|
set(TIFF_LIBRARIES ${TIFF_LIBRARY})
|
|
|
|
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libtiff")
|
2020-11-27 06:56:59 +08:00
|
|
|
set(TIFF_INCLUDE_DIR "${${TIFF_LIBRARY}_SOURCE_DIR}" "${${TIFF_LIBRARY}_BINARY_DIR}" CACHE INTERNAL "")
|
2013-07-11 16:40:16 +08:00
|
|
|
ocv_parse_header("${${TIFF_LIBRARY}_SOURCE_DIR}/tiff.h" TIFF_VERSION_LINES TIFF_VERSION_CLASSIC TIFF_VERSION_BIG TIFF_VERSION TIFF_BIGTIFF_VERSION)
|
|
|
|
endif()
|
2012-04-14 05:50:59 +08:00
|
|
|
|
2013-07-11 16:40:16 +08:00
|
|
|
if(TIFF_VERSION_CLASSIC AND NOT TIFF_VERSION)
|
|
|
|
set(TIFF_VERSION ${TIFF_VERSION_CLASSIC})
|
|
|
|
endif()
|
2012-04-14 05:50:59 +08:00
|
|
|
|
2013-07-11 16:40:16 +08:00
|
|
|
if(TIFF_BIGTIFF_VERSION AND NOT TIFF_VERSION_BIG)
|
|
|
|
set(TIFF_VERSION_BIG ${TIFF_BIGTIFF_VERSION})
|
|
|
|
endif()
|
2012-02-24 21:53:22 +08:00
|
|
|
|
2013-07-11 16:40:16 +08:00
|
|
|
if(NOT TIFF_VERSION_STRING AND TIFF_INCLUDE_DIR)
|
|
|
|
list(GET TIFF_INCLUDE_DIR 0 _TIFF_INCLUDE_DIR)
|
|
|
|
if(EXISTS "${_TIFF_INCLUDE_DIR}/tiffvers.h")
|
|
|
|
file(STRINGS "${_TIFF_INCLUDE_DIR}/tiffvers.h" tiff_version_str REGEX "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version .*")
|
|
|
|
string(REGEX REPLACE "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version +([^ \\n]*).*" "\\1" TIFF_VERSION_STRING "${tiff_version_str}")
|
|
|
|
unset(tiff_version_str)
|
|
|
|
endif()
|
|
|
|
unset(_TIFF_INCLUDE_DIR)
|
2012-06-08 14:19:17 +08:00
|
|
|
endif()
|
2013-07-11 16:40:16 +08:00
|
|
|
|
|
|
|
set(HAVE_TIFF YES)
|
2012-06-08 14:19:17 +08:00
|
|
|
endif()
|
|
|
|
|
2013-03-07 23:29:19 +08:00
|
|
|
# --- libwebp (optional) ---
|
|
|
|
|
|
|
|
if(WITH_WEBP)
|
|
|
|
if(BUILD_WEBP)
|
|
|
|
ocv_clear_vars(WEBP_FOUND WEBP_LIBRARY WEBP_LIBRARIES WEBP_INCLUDE_DIR)
|
|
|
|
else()
|
2020-12-02 20:34:24 +08:00
|
|
|
ocv_clear_internal_cache_vars(WEBP_LIBRARY WEBP_INCLUDE_DIR)
|
2013-03-07 23:29:19 +08:00
|
|
|
include(cmake/OpenCVFindWebP.cmake)
|
2017-06-13 00:10:13 +08:00
|
|
|
if(WEBP_FOUND)
|
|
|
|
set(HAVE_WEBP 1)
|
|
|
|
endif()
|
2013-03-07 23:29:19 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# --- Add libwebp to 3rdparty/libwebp and compile it if not available ---
|
2017-06-13 00:10:13 +08:00
|
|
|
if(WITH_WEBP AND NOT WEBP_FOUND
|
|
|
|
AND (NOT ANDROID OR HAVE_CPUFEATURES)
|
|
|
|
)
|
2020-11-27 06:56:59 +08:00
|
|
|
ocv_clear_vars(WEBP_LIBRARY WEBP_INCLUDE_DIR)
|
|
|
|
set(WEBP_LIBRARY libwebp CACHE INTERNAL "")
|
2013-03-07 23:29:19 +08:00
|
|
|
set(WEBP_LIBRARIES ${WEBP_LIBRARY})
|
|
|
|
|
|
|
|
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libwebp")
|
2020-11-27 06:56:59 +08:00
|
|
|
set(WEBP_INCLUDE_DIR "${${WEBP_LIBRARY}_SOURCE_DIR}/src" CACHE INTERNAL "")
|
2017-06-13 00:10:13 +08:00
|
|
|
set(HAVE_WEBP 1)
|
2013-03-07 23:29:19 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT WEBP_VERSION AND WEBP_INCLUDE_DIR)
|
|
|
|
ocv_clear_vars(ENC_MAJ_VERSION ENC_MIN_VERSION ENC_REV_VERSION)
|
|
|
|
if(EXISTS "${WEBP_INCLUDE_DIR}/enc/vp8enci.h")
|
|
|
|
ocv_parse_header("${WEBP_INCLUDE_DIR}/enc/vp8enci.h" WEBP_VERSION_LINES ENC_MAJ_VERSION ENC_MIN_VERSION ENC_REV_VERSION)
|
|
|
|
set(WEBP_VERSION "${ENC_MAJ_VERSION}.${ENC_MIN_VERSION}.${ENC_REV_VERSION}")
|
|
|
|
elseif(EXISTS "${WEBP_INCLUDE_DIR}/webp/encode.h")
|
|
|
|
file(STRINGS "${WEBP_INCLUDE_DIR}/webp/encode.h" WEBP_ENCODER_ABI_VERSION REGEX "#define[ \t]+WEBP_ENCODER_ABI_VERSION[ \t]+([x0-9a-f]+)" )
|
|
|
|
if(WEBP_ENCODER_ABI_VERSION MATCHES "#define[ \t]+WEBP_ENCODER_ABI_VERSION[ \t]+([x0-9a-f]+)")
|
|
|
|
set(WEBP_ENCODER_ABI_VERSION "${CMAKE_MATCH_1}")
|
|
|
|
set(WEBP_VERSION "encoder: ${WEBP_ENCODER_ABI_VERSION}")
|
|
|
|
else()
|
|
|
|
unset(WEBP_ENCODER_ABI_VERSION)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2012-04-14 05:50:59 +08:00
|
|
|
|
2020-03-27 15:18:58 +08:00
|
|
|
# --- libopenjp2 (optional, check before libjasper) ---
|
|
|
|
if(WITH_OPENJPEG)
|
2020-08-25 18:11:08 +08:00
|
|
|
if(BUILD_OPENJPEG)
|
|
|
|
ocv_clear_vars(OpenJPEG_FOUND)
|
|
|
|
else()
|
|
|
|
find_package(OpenJPEG QUIET)
|
|
|
|
endif()
|
2020-03-27 15:18:58 +08:00
|
|
|
|
|
|
|
if(NOT OpenJPEG_FOUND OR OPENJPEG_MAJOR_VERSION LESS 2)
|
|
|
|
ocv_clear_vars(OPENJPEG_MAJOR_VERSION OPENJPEG_MINOR_VERSION OPENJPEG_BUILD_VERSION OPENJPEG_LIBRARIES OPENJPEG_INCLUDE_DIRS)
|
2020-08-25 18:11:08 +08:00
|
|
|
message(STATUS "Could NOT find OpenJPEG (minimal suitable version: 2.0, "
|
|
|
|
"recommended version >= 2.3.1). OpenJPEG will be built from sources")
|
|
|
|
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/openjpeg")
|
|
|
|
if(OCV_CAN_BUILD_OPENJPEG)
|
|
|
|
set(HAVE_OPENJPEG YES)
|
|
|
|
message(STATUS "OpenJPEG libraries will be built from sources: ${OPENJPEG_LIBRARIES} "
|
|
|
|
"(version \"${OPENJPEG_VERSION}\")")
|
|
|
|
else()
|
|
|
|
set(HAVE_OPENJPEG NO)
|
|
|
|
message(STATUS "OpenJPEG libraries can't be built from sources. System requirements are not fulfilled.")
|
|
|
|
endif()
|
2020-03-27 15:18:58 +08:00
|
|
|
else()
|
|
|
|
set(HAVE_OPENJPEG YES)
|
2020-08-25 18:11:08 +08:00
|
|
|
message(STATUS "Found system OpenJPEG: ${OPENJPEG_LIBRARIES} "
|
|
|
|
"(found version \"${OPENJPEG_VERSION}\")")
|
2020-03-27 15:18:58 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2012-05-25 21:12:02 +08:00
|
|
|
# --- libjasper (optional, should be searched after libjpeg) ---
|
2020-03-27 15:18:58 +08:00
|
|
|
if(WITH_JASPER AND NOT HAVE_OPENJPEG)
|
2012-02-24 21:53:22 +08:00
|
|
|
if(BUILD_JASPER)
|
2012-05-25 21:12:02 +08:00
|
|
|
ocv_clear_vars(JASPER_FOUND)
|
2012-02-24 21:53:22 +08:00
|
|
|
else()
|
|
|
|
include(FindJasper)
|
|
|
|
endif()
|
|
|
|
|
2013-07-11 16:40:16 +08:00
|
|
|
if(NOT JASPER_FOUND)
|
|
|
|
ocv_clear_vars(JASPER_LIBRARY JASPER_LIBRARIES JASPER_INCLUDE_DIR)
|
2012-03-02 19:36:34 +08:00
|
|
|
|
2020-11-27 06:56:59 +08:00
|
|
|
set(JASPER_LIBRARY libjasper CACHE INTERNAL "")
|
2013-07-11 16:40:16 +08:00
|
|
|
set(JASPER_LIBRARIES ${JASPER_LIBRARY})
|
|
|
|
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjasper")
|
2020-11-27 06:56:59 +08:00
|
|
|
set(JASPER_INCLUDE_DIR "${${JASPER_LIBRARY}_SOURCE_DIR}" CACHE INTERNAL "")
|
2013-07-11 16:40:16 +08:00
|
|
|
endif()
|
2012-02-24 21:53:22 +08:00
|
|
|
|
2013-07-11 16:40:16 +08:00
|
|
|
set(HAVE_JASPER YES)
|
2012-02-24 21:53:22 +08:00
|
|
|
|
2013-07-11 16:40:16 +08:00
|
|
|
if(NOT JASPER_VERSION_STRING)
|
|
|
|
ocv_parse_header2(JASPER "${JASPER_INCLUDE_DIR}/jasper/jas_config.h" JAS_VERSION "")
|
|
|
|
endif()
|
2012-04-30 22:33:52 +08:00
|
|
|
endif()
|
2012-04-14 05:50:59 +08:00
|
|
|
|
2022-06-11 04:23:42 +08:00
|
|
|
if(WITH_SPNG)
|
|
|
|
set(SPNG_LIBRARY libspng CACHE INTERNAL "")
|
|
|
|
set(SPNG_LIBRARIES ${SPNG_LIBRARY})
|
|
|
|
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libspng")
|
|
|
|
set(SPNG_INCLUDE_DIR "${${SPNG_LIBRARY}_SOURCE_DIR}" CACHE INTERNAL "")
|
|
|
|
set(SPNG_DEFINITIONS "")
|
|
|
|
ocv_parse_header("${SPNG_INCLUDE_DIR}/spng.h" SPNG_VERSION_LINES SPNG_VERSION_MAJOR SPNG_VERSION_MINOR SPNG_VERSION_PATCH)
|
|
|
|
|
|
|
|
set(HAVE_SPNG YES)
|
|
|
|
set(SPNG_VERSION "${SPNG_VERSION_MAJOR}.${SPNG_VERSION_MINOR}.${SPNG_VERSION_PATCH}")
|
|
|
|
message(STATUS "imgcodecs: PNG codec will use SPNG, version: ${SPNG_VERSION} ")
|
|
|
|
endif()
|
|
|
|
|
2012-05-25 21:12:02 +08:00
|
|
|
# --- libpng (optional, should be searched after zlib) ---
|
2022-06-11 04:23:42 +08:00
|
|
|
if(NOT HAVE_SPNG AND WITH_PNG)
|
2012-02-24 21:53:22 +08:00
|
|
|
if(BUILD_PNG)
|
2012-05-25 21:12:02 +08:00
|
|
|
ocv_clear_vars(PNG_FOUND)
|
2012-02-24 21:53:22 +08:00
|
|
|
else()
|
2020-12-02 20:34:24 +08:00
|
|
|
ocv_clear_internal_cache_vars(PNG_LIBRARY PNG_INCLUDE_DIR)
|
2012-02-24 21:53:22 +08:00
|
|
|
include(FindPNG)
|
|
|
|
if(PNG_FOUND)
|
2013-04-04 15:04:51 +08:00
|
|
|
include(CheckIncludeFile)
|
2012-04-14 05:50:59 +08:00
|
|
|
check_include_file("${PNG_PNG_INCLUDE_DIR}/libpng/png.h" HAVE_LIBPNG_PNG_H)
|
2013-07-11 16:40:16 +08:00
|
|
|
if(HAVE_LIBPNG_PNG_H)
|
2012-04-14 05:50:59 +08:00
|
|
|
ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/libpng/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
|
2013-07-11 16:40:16 +08:00
|
|
|
else()
|
|
|
|
ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
|
2012-04-14 05:50:59 +08:00
|
|
|
endif()
|
2012-02-24 21:53:22 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2013-07-11 16:40:16 +08:00
|
|
|
if(NOT PNG_FOUND)
|
|
|
|
ocv_clear_vars(PNG_LIBRARY PNG_LIBRARIES PNG_INCLUDE_DIR PNG_PNG_INCLUDE_DIR HAVE_LIBPNG_PNG_H PNG_DEFINITIONS)
|
2012-03-02 19:36:34 +08:00
|
|
|
|
2020-11-27 06:56:59 +08:00
|
|
|
set(PNG_LIBRARY libpng CACHE INTERNAL "")
|
2013-07-11 16:40:16 +08:00
|
|
|
set(PNG_LIBRARIES ${PNG_LIBRARY})
|
|
|
|
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libpng")
|
2020-11-27 06:56:59 +08:00
|
|
|
set(PNG_INCLUDE_DIR "${${PNG_LIBRARY}_SOURCE_DIR}" CACHE INTERNAL "")
|
2013-07-11 16:40:16 +08:00
|
|
|
set(PNG_DEFINITIONS "")
|
|
|
|
ocv_parse_header("${PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
|
|
|
|
endif()
|
2012-02-24 21:53:22 +08:00
|
|
|
|
2013-07-11 16:40:16 +08:00
|
|
|
set(HAVE_PNG YES)
|
|
|
|
set(PNG_VERSION "${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VER_RELEASE}")
|
|
|
|
endif()
|
2012-04-14 05:50:59 +08:00
|
|
|
|
2022-06-11 04:23:42 +08:00
|
|
|
|
2012-05-25 21:12:02 +08:00
|
|
|
# --- OpenEXR (optional) ---
|
2012-02-24 21:53:22 +08:00
|
|
|
if(WITH_OPENEXR)
|
2019-06-11 01:04:23 +08:00
|
|
|
ocv_clear_vars(HAVE_OPENEXR)
|
|
|
|
if(NOT BUILD_OPENEXR)
|
2020-12-02 20:34:24 +08:00
|
|
|
ocv_clear_internal_cache_vars(OPENEXR_INCLUDE_PATHS OPENEXR_LIBRARIES OPENEXR_ILMIMF_LIBRARY OPENEXR_VERSION)
|
2012-08-25 04:31:49 +08:00
|
|
|
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenEXR.cmake")
|
|
|
|
endif()
|
|
|
|
|
2019-06-11 01:04:23 +08:00
|
|
|
if(OPENEXR_FOUND)
|
|
|
|
set(HAVE_OPENEXR YES)
|
|
|
|
else()
|
2013-07-11 16:40:16 +08:00
|
|
|
ocv_clear_vars(OPENEXR_INCLUDE_PATHS OPENEXR_LIBRARIES OPENEXR_ILMIMF_LIBRARY OPENEXR_VERSION)
|
|
|
|
|
|
|
|
set(OPENEXR_LIBRARIES IlmImf)
|
|
|
|
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/openexr")
|
2019-06-11 01:04:23 +08:00
|
|
|
if(OPENEXR_VERSION) # check via TARGET doesn't work
|
2021-12-23 17:58:56 +08:00
|
|
|
set(BUILD_OPENEXR ON)
|
2019-06-11 01:04:23 +08:00
|
|
|
set(HAVE_OPENEXR YES)
|
2021-12-23 18:39:43 +08:00
|
|
|
set(BUILD_OPENEXR ON)
|
2019-06-11 01:04:23 +08:00
|
|
|
endif()
|
2013-07-11 16:40:16 +08:00
|
|
|
endif()
|
2012-02-24 21:53:22 +08:00
|
|
|
endif()
|
2014-07-02 07:29:11 +08:00
|
|
|
|
|
|
|
# --- GDAL (optional) ---
|
|
|
|
if(WITH_GDAL)
|
2016-10-29 20:48:26 +08:00
|
|
|
find_package(GDAL QUIET)
|
2014-07-02 07:29:11 +08:00
|
|
|
|
|
|
|
if(NOT GDAL_FOUND)
|
|
|
|
set(HAVE_GDAL NO)
|
2017-10-01 02:39:50 +08:00
|
|
|
ocv_clear_vars(GDAL_VERSION GDAL_LIBRARIES)
|
2014-07-02 07:29:11 +08:00
|
|
|
else()
|
|
|
|
set(HAVE_GDAL YES)
|
2015-05-12 11:27:50 +08:00
|
|
|
ocv_include_directories(${GDAL_INCLUDE_DIR})
|
2014-07-02 07:29:11 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
2015-04-20 20:27:57 +08:00
|
|
|
|
2020-11-27 06:56:59 +08:00
|
|
|
if(WITH_GDCM)
|
2016-10-29 20:48:26 +08:00
|
|
|
find_package(GDCM QUIET)
|
2015-04-20 20:27:57 +08:00
|
|
|
if(NOT GDCM_FOUND)
|
|
|
|
set(HAVE_GDCM NO)
|
|
|
|
ocv_clear_vars(GDCM_VERSION GDCM_LIBRARIES)
|
|
|
|
else()
|
|
|
|
set(HAVE_GDCM YES)
|
|
|
|
# include(${GDCM_USE_FILE})
|
|
|
|
set(GDCM_LIBRARIES gdcmMSFF) # GDCM does not set this variable for some reason
|
|
|
|
endif()
|
|
|
|
endif()
|
2018-05-22 23:10:15 +08:00
|
|
|
|
|
|
|
if(WITH_IMGCODEC_HDR)
|
|
|
|
set(HAVE_IMGCODEC_HDR ON)
|
|
|
|
elseif(DEFINED WITH_IMGCODEC_HDR)
|
|
|
|
set(HAVE_IMGCODEC_HDR OFF)
|
|
|
|
endif()
|
|
|
|
if(WITH_IMGCODEC_SUNRASTER)
|
|
|
|
set(HAVE_IMGCODEC_SUNRASTER ON)
|
|
|
|
elseif(DEFINED WITH_IMGCODEC_SUNRASTER)
|
|
|
|
set(HAVE_IMGCODEC_SUNRASTER OFF)
|
|
|
|
endif()
|
|
|
|
if(WITH_IMGCODEC_PXM)
|
|
|
|
set(HAVE_IMGCODEC_PXM ON)
|
|
|
|
elseif(DEFINED WITH_IMGCODEC_PXM)
|
|
|
|
set(HAVE_IMGCODEC_PXM OFF)
|
|
|
|
endif()
|
2018-08-13 18:14:12 +08:00
|
|
|
if(WITH_IMGCODEC_PFM)
|
|
|
|
set(HAVE_IMGCODEC_PFM ON)
|
|
|
|
elseif(DEFINED WITH_IMGCODEC_PFM)
|
|
|
|
set(HAVE_IMGCODEC_PFM OFF)
|
2020-03-27 15:18:58 +08:00
|
|
|
endif()
|