1 # ----------------------------------------------------------------------------
2 # Detect 3rd-party image IO libraries
3 # ----------------------------------------------------------------------------
5 # --- zlib (required) ---
7 ocv_clear_vars(ZLIB_FOUND)
10 if(ZLIB_FOUND AND ANDROID)
11 if(ZLIB_LIBRARY STREQUAL "${ANDROID_SYSROOT}/usr/lib/libz.so")
19 ocv_clear_vars(ZLIB_LIBRARY ZLIB_LIBRARIES ZLIB_INCLUDE_DIR)
21 set(ZLIB_LIBRARY zlib)
22 set(ZLIB_LIBRARIES ${ZLIB_LIBRARY})
23 add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/zlib")
24 set(ZLIB_INCLUDE_DIR "${${ZLIB_LIBRARY}_SOURCE_DIR}" "${${ZLIB_LIBRARY}_BINARY_DIR}")
26 ocv_parse_header2(ZLIB "${${ZLIB_LIBRARY}_SOURCE_DIR}/zlib.h" ZLIB_VERSION)
29 # --- libtiff (optional, should be searched after zlib) ---
32 ocv_clear_vars(TIFF_FOUND)
36 ocv_parse_header("${TIFF_INCLUDE_DIR}/tiff.h" TIFF_VERSION_LINES TIFF_VERSION_CLASSIC TIFF_VERSION_BIG TIFF_VERSION TIFF_BIGTIFF_VERSION)
41 ocv_clear_vars(TIFF_LIBRARY TIFF_LIBRARIES TIFF_INCLUDE_DIR)
43 set(TIFF_LIBRARY libtiff)
44 set(TIFF_LIBRARIES ${TIFF_LIBRARY})
45 add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libtiff")
46 set(TIFF_INCLUDE_DIR "${${TIFF_LIBRARY}_SOURCE_DIR}" "${${TIFF_LIBRARY}_BINARY_DIR}")
47 ocv_parse_header("${${TIFF_LIBRARY}_SOURCE_DIR}/tiff.h" TIFF_VERSION_LINES TIFF_VERSION_CLASSIC TIFF_VERSION_BIG TIFF_VERSION TIFF_BIGTIFF_VERSION)
50 if(TIFF_VERSION_CLASSIC AND NOT TIFF_VERSION)
51 set(TIFF_VERSION ${TIFF_VERSION_CLASSIC})
54 if(TIFF_BIGTIFF_VERSION AND NOT TIFF_VERSION_BIG)
55 set(TIFF_VERSION_BIG ${TIFF_BIGTIFF_VERSION})
58 if(NOT TIFF_VERSION_STRING AND TIFF_INCLUDE_DIR)
59 list(GET TIFF_INCLUDE_DIR 0 _TIFF_INCLUDE_DIR)
60 if(EXISTS "${_TIFF_INCLUDE_DIR}/tiffvers.h")
61 file(STRINGS "${_TIFF_INCLUDE_DIR}/tiffvers.h" tiff_version_str REGEX "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version .*")
62 string(REGEX REPLACE "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version +([^ \\n]*).*" "\\1" TIFF_VERSION_STRING "${tiff_version_str}")
63 unset(tiff_version_str)
65 unset(_TIFF_INCLUDE_DIR)
71 # --- libjpeg (optional) ---
74 ocv_clear_vars(JPEG_FOUND)
80 ocv_clear_vars(JPEG_LIBRARY JPEG_LIBRARIES JPEG_INCLUDE_DIR)
82 set(JPEG_LIBRARY libjpeg)
83 set(JPEG_LIBRARIES ${JPEG_LIBRARY})
84 add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjpeg")
85 set(JPEG_INCLUDE_DIR "${${JPEG_LIBRARY}_SOURCE_DIR}")
88 ocv_parse_header("${JPEG_INCLUDE_DIR}/jpeglib.h" JPEG_VERSION_LINES JPEG_LIB_VERSION)
92 # --- libjasper (optional, should be searched after libjpeg) ---
95 ocv_clear_vars(JASPER_FOUND)
101 ocv_clear_vars(JASPER_LIBRARY JASPER_LIBRARIES JASPER_INCLUDE_DIR)
103 set(JASPER_LIBRARY libjasper)
104 set(JASPER_LIBRARIES ${JASPER_LIBRARY})
105 add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjasper")
106 set(JASPER_INCLUDE_DIR "${${JASPER_LIBRARY}_SOURCE_DIR}")
111 if(NOT JASPER_VERSION_STRING)
112 ocv_parse_header2(JASPER "${JASPER_INCLUDE_DIR}/jasper/jas_config.h" JAS_VERSION "")
116 # --- libpng (optional, should be searched after zlib) ---
119 ocv_clear_vars(PNG_FOUND)
123 include(CheckIncludeFile)
124 check_include_file("${PNG_PNG_INCLUDE_DIR}/libpng/png.h" HAVE_LIBPNG_PNG_H)
125 if(HAVE_LIBPNG_PNG_H)
126 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)
128 ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
134 ocv_clear_vars(PNG_LIBRARY PNG_LIBRARIES PNG_INCLUDE_DIR PNG_PNG_INCLUDE_DIR HAVE_LIBPNG_PNG_H PNG_DEFINITIONS)
136 set(PNG_LIBRARY libpng)
137 set(PNG_LIBRARIES ${PNG_LIBRARY})
138 add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libpng")
139 set(PNG_INCLUDE_DIR "${${PNG_LIBRARY}_SOURCE_DIR}")
140 set(PNG_DEFINITIONS "")
141 ocv_parse_header("${PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
145 set(PNG_VERSION "${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VER_RELEASE}")
148 # --- OpenEXR (optional) ---
151 ocv_clear_vars(OPENEXR_FOUND)
153 include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenEXR.cmake")
156 if(NOT OPENEXR_FOUND)
157 ocv_clear_vars(OPENEXR_INCLUDE_PATHS OPENEXR_LIBRARIES OPENEXR_ILMIMF_LIBRARY OPENEXR_VERSION)
159 set(OPENEXR_LIBRARIES IlmImf)
160 set(OPENEXR_ILMIMF_LIBRARY IlmImf)
161 add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/openexr")
164 set(HAVE_OPENEXR YES)
167 #cmake 2.8.2 bug - it fails to determine zlib version
169 ocv_parse_header2(ZLIB "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_VERSION)
172 # --- Apple ImageIO ---
174 set(HAVE_IMAGEIO YES)