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()
|
2012-04-30 22:33:52 +08:00
|
|
|
include(FindZLIB)
|
2012-06-26 00:03:45 +08:00
|
|
|
if(ZLIB_VERSION_STRING)
|
|
|
|
#cmake 2.8.2 bug - it fails to determine zlib version
|
|
|
|
unset(ZLIB_VERSION_STRING CACHE)
|
|
|
|
endif()
|
2012-05-07 22:01:36 +08:00
|
|
|
if(ZLIB_FOUND)
|
2012-04-30 22:33:52 +08:00
|
|
|
ocv_parse_header2(ZLIB "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_VERSION "")
|
|
|
|
endif()
|
|
|
|
if(ZLIB_FOUND AND ANDROID)
|
|
|
|
if(ZLIB_LIBRARY STREQUAL "${ANDROID_SYSROOT}/usr/lib/libz.so")
|
|
|
|
set(ZLIB_LIBRARY z)
|
|
|
|
set(ZLIB_LIBRARIES z)
|
2012-04-14 05:50:59 +08:00
|
|
|
endif()
|
2012-02-24 21:53:22 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT ZLIB_FOUND)
|
2012-05-25 21:12:02 +08:00
|
|
|
ocv_clear_vars(ZLIB_LIBRARY ZLIB_LIBRARIES ZLIB_INCLUDE_DIR)
|
2012-03-02 19:36:34 +08:00
|
|
|
|
2012-02-24 21:53:22 +08:00
|
|
|
set(ZLIB_LIBRARY zlib)
|
|
|
|
set(ZLIB_LIBRARIES ${ZLIB_LIBRARY})
|
|
|
|
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/zlib")
|
|
|
|
set(ZLIB_INCLUDE_DIR "${${ZLIB_LIBRARY}_SOURCE_DIR}" "${${ZLIB_LIBRARY}_BINARY_DIR}")
|
|
|
|
endif()
|
|
|
|
|
2012-05-25 21:12:02 +08:00
|
|
|
# --- libtiff (optional, should be searched after zlib) ---
|
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()
|
|
|
|
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()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_TIFF AND NOT TIFF_FOUND)
|
2012-05-25 21:12:02 +08:00
|
|
|
ocv_clear_vars(TIFF_LIBRARY TIFF_LIBRARIES TIFF_INCLUDE_DIR)
|
2012-03-02 19:36:34 +08:00
|
|
|
|
2012-02-24 21:53:22 +08:00
|
|
|
set(TIFF_LIBRARY libtiff)
|
|
|
|
set(TIFF_LIBRARIES ${TIFF_LIBRARY})
|
|
|
|
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libtiff")
|
2012-03-01 17:01:32 +08:00
|
|
|
set(TIFF_INCLUDE_DIR "${${TIFF_LIBRARY}_SOURCE_DIR}" "${${TIFF_LIBRARY}_BINARY_DIR}")
|
2012-04-14 05:50:59 +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()
|
|
|
|
|
|
|
|
if(TIFF_VERSION_CLASSIC AND NOT TIFF_VERSION)
|
|
|
|
set(TIFF_VERSION ${TIFF_VERSION_CLASSIC})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(TIFF_BIGTIFF_VERSION AND NOT TIFF_VERSION_BIG)
|
|
|
|
set(TIFF_VERSION_BIG ${TIFF_BIGTIFF_VERSION})
|
2012-02-24 21:53:22 +08:00
|
|
|
endif()
|
|
|
|
|
2012-06-08 14:19:17 +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)
|
|
|
|
endif()
|
|
|
|
|
2012-05-25 21:12:02 +08:00
|
|
|
# --- libjpeg (optional) ---
|
2012-02-24 21:53:22 +08:00
|
|
|
if(WITH_JPEG)
|
|
|
|
if(BUILD_JPEG)
|
2012-05-25 21:12:02 +08:00
|
|
|
ocv_clear_vars(JPEG_FOUND)
|
2012-02-24 21:53:22 +08:00
|
|
|
else()
|
|
|
|
include(FindJPEG)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_JPEG AND NOT JPEG_FOUND)
|
2012-05-25 21:12:02 +08:00
|
|
|
ocv_clear_vars(JPEG_LIBRARY JPEG_LIBRARIES JPEG_INCLUDE_DIR)
|
2012-03-02 19:36:34 +08:00
|
|
|
|
2012-02-24 21:53:22 +08:00
|
|
|
set(JPEG_LIBRARY libjpeg)
|
|
|
|
set(JPEG_LIBRARIES ${JPEG_LIBRARY})
|
|
|
|
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjpeg")
|
|
|
|
set(JPEG_INCLUDE_DIR "${${JPEG_LIBRARY}_SOURCE_DIR}")
|
|
|
|
endif()
|
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
ocv_parse_header("${JPEG_INCLUDE_DIR}/jpeglib.h" JPEG_VERSION_LINES JPEG_LIB_VERSION)
|
|
|
|
|
|
|
|
|
2012-05-25 21:12:02 +08:00
|
|
|
# --- libjasper (optional, should be searched after libjpeg) ---
|
2012-02-24 21:53:22 +08:00
|
|
|
if(WITH_JASPER)
|
|
|
|
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()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_JASPER AND NOT JASPER_FOUND)
|
2012-05-25 21:12:02 +08:00
|
|
|
ocv_clear_vars(JASPER_LIBRARY JASPER_LIBRARIES JASPER_INCLUDE_DIR)
|
2012-03-02 19:36:34 +08:00
|
|
|
|
2012-02-24 21:53:22 +08:00
|
|
|
set(JASPER_LIBRARY libjasper)
|
|
|
|
set(JASPER_LIBRARIES ${JASPER_LIBRARY})
|
|
|
|
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjasper")
|
|
|
|
set(JASPER_INCLUDE_DIR "${${JASPER_LIBRARY}_SOURCE_DIR}")
|
|
|
|
endif()
|
|
|
|
|
2012-04-30 22:33:52 +08:00
|
|
|
if(NOT JASPER_VERSION_STRING)
|
|
|
|
ocv_parse_header2(JASPER "${JASPER_INCLUDE_DIR}/jasper/jas_config.h" JAS_VERSION "")
|
|
|
|
endif()
|
2012-04-14 05:50:59 +08:00
|
|
|
|
2012-05-25 21:12:02 +08:00
|
|
|
# --- libpng (optional, should be searched after zlib) ---
|
2012-02-24 21:53:22 +08:00
|
|
|
if(WITH_PNG)
|
|
|
|
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()
|
|
|
|
include(FindPNG)
|
|
|
|
if(PNG_FOUND)
|
2012-04-14 05:50:59 +08:00
|
|
|
check_include_file("${PNG_PNG_INCLUDE_DIR}/png.h" HAVE_PNG_H)
|
|
|
|
check_include_file("${PNG_PNG_INCLUDE_DIR}/libpng/png.h" HAVE_LIBPNG_PNG_H)
|
|
|
|
if(HAVE_PNG_H)
|
|
|
|
ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
|
|
|
|
elseif(HAVE_LIBPNG_PNG_H)
|
|
|
|
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)
|
|
|
|
endif()
|
2012-02-24 21:53:22 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_PNG AND NOT PNG_FOUND)
|
2012-05-25 21:12:02 +08:00
|
|
|
ocv_clear_vars(PNG_LIBRARY PNG_LIBRARIES PNG_INCLUDE_DIR PNG_PNG_INCLUDE_DIR HAVE_PNG_H HAVE_LIBPNG_PNG_H PNG_DEFINITIONS)
|
2012-03-02 19:36:34 +08:00
|
|
|
|
2012-02-24 21:53:22 +08:00
|
|
|
set(PNG_LIBRARY libpng)
|
|
|
|
set(PNG_LIBRARIES ${PNG_LIBRARY})
|
|
|
|
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libpng")
|
|
|
|
set(PNG_INCLUDE_DIR "${${PNG_LIBRARY}_SOURCE_DIR}")
|
|
|
|
set(PNG_DEFINITIONS "")
|
2012-04-14 05:50:59 +08:00
|
|
|
ocv_parse_header("${PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
|
2012-02-24 21:53:22 +08:00
|
|
|
endif()
|
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
set(PNG_VERSION "${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VER_RELEASE}")
|
|
|
|
|
2012-05-25 21:12:02 +08:00
|
|
|
# --- OpenEXR (optional) ---
|
2012-02-24 21:53:22 +08:00
|
|
|
if(WITH_OPENEXR)
|
2012-02-27 14:23:14 +08:00
|
|
|
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenEXR.cmake")
|
2012-02-24 21:53:22 +08:00
|
|
|
endif()
|