1set(the_description "Image codecs")
2ocv_add_module(imgcodecs opencv_imgproc WRAP java python)
3
4# ----------------------------------------------------------------------------
5#  CMake file for imgcodecs. See root CMakeLists.txt
6#   Some parts taken from version of Hartmut Seichter, HIT Lab NZ.
7#   Jose Luis Blanco, 2008
8# ----------------------------------------------------------------------------
9
10ocv_clear_vars(GRFMT_LIBS)
11
12if(HAVE_WINRT_CX AND NOT WINRT)
13  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
14endif()
15
16if(HAVE_PNG OR HAVE_TIFF OR HAVE_OPENEXR)
17  ocv_include_directories(${ZLIB_INCLUDE_DIRS})
18  list(APPEND GRFMT_LIBS ${ZLIB_LIBRARIES})
19endif()
20
21if(HAVE_JPEG)
22  ocv_include_directories(${JPEG_INCLUDE_DIR})
23  list(APPEND GRFMT_LIBS ${JPEG_LIBRARIES})
24endif()
25
26if(WITH_WEBP)
27  add_definitions(-DHAVE_WEBP)
28  ocv_include_directories(${WEBP_INCLUDE_DIR})
29  list(APPEND GRFMT_LIBS ${WEBP_LIBRARIES})
30endif()
31
32if(HAVE_PNG)
33  add_definitions(${PNG_DEFINITIONS})
34  ocv_include_directories(${PNG_INCLUDE_DIR})
35  list(APPEND GRFMT_LIBS ${PNG_LIBRARIES})
36endif()
37
38if(HAVE_TIFF)
39  ocv_include_directories(${TIFF_INCLUDE_DIR})
40  list(APPEND GRFMT_LIBS ${TIFF_LIBRARIES})
41endif()
42
43if(HAVE_JASPER)
44  ocv_include_directories(${JASPER_INCLUDE_DIR})
45  list(APPEND GRFMT_LIBS ${JASPER_LIBRARIES})
46endif()
47
48if(HAVE_OPENEXR)
49  include_directories(SYSTEM ${OPENEXR_INCLUDE_PATHS})
50  list(APPEND GRFMT_LIBS ${OPENEXR_LIBRARIES})
51endif()
52
53if(HAVE_GDAL)
54  include_directories(SYSTEM ${GDAL_INCLUDE_DIR})
55  list(APPEND GRFMT_LIBS ${GDAL_LIBRARY})
56endif()
57
58file(GLOB grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/grfmt*.hpp)
59file(GLOB grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/grfmt*.cpp)
60list(APPEND grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/bitstrm.hpp)
61list(APPEND grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/bitstrm.cpp)
62list(APPEND grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/rgbe.hpp)
63list(APPEND grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/rgbe.cpp)
64
65source_group("Src\\grfmts" FILES ${grfmt_hdrs} ${grfmt_srcs})
66
67set(imgcodecs_hdrs
68    ${CMAKE_CURRENT_LIST_DIR}/src/precomp.hpp
69    ${CMAKE_CURRENT_LIST_DIR}/src/utils.hpp
70    )
71
72set(imgcodecs_srcs
73    ${CMAKE_CURRENT_LIST_DIR}/src/loadsave.cpp
74    ${CMAKE_CURRENT_LIST_DIR}/src/utils.cpp
75    )
76
77file(GLOB imgcodecs_ext_hdrs
78     "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/*.hpp"
79     "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.hpp"
80     "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h"
81     )
82
83if(IOS)
84  add_definitions(-DHAVE_IOS=1)
85  list(APPEND imgcodecs_srcs ${CMAKE_CURRENT_LIST_DIR}/src/ios_conversions.mm)
86  list(APPEND IMGCODECS_LIBRARIES "-framework Accelerate" "-framework CoreGraphics" "-framework CoreImage" "-framework QuartzCore" "-framework AssetsLibrary")
87endif()
88
89if(UNIX)
90  #these variables are set by CHECK_MODULE macro
91  foreach(P ${IMGCODECS_INCLUDE_DIRS})
92    ocv_include_directories(${P})
93  endforeach()
94
95  foreach(P ${IMGCODECS_LIBRARY_DIRS})
96    link_directories(${P})
97  endforeach()
98endif()
99
100source_group("Src" FILES ${imgcodecs_srcs} ${imgcodecs_hdrs})
101source_group("Include" FILES ${imgcodecs_ext_hdrs})
102ocv_set_module_sources(HEADERS ${imgcodecs_ext_hdrs} SOURCES ${imgcodecs_srcs} ${imgcodecs_hdrs} ${grfmt_srcs} ${grfmt_hdrs})
103ocv_module_include_directories()
104
105ocv_create_module(${GRFMT_LIBS} ${IMGCODECS_LIBRARIES})
106
107macro(ocv_imgcodecs_configure_target)
108if(APPLE)
109  add_apple_compiler_options(the_module)
110endif()
111
112if(BUILD_SHARED_LIBS)
113  add_definitions(-DIMGCODECS_EXPORTS)
114endif()
115
116if(MSVC)
117  set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
118endif()
119
120#stop automatic dependencies propagation for this module
121set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "")
122
123ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
124endmacro()
125
126if(NOT BUILD_opencv_world)
127  ocv_imgcodecs_configure_target()
128endif()
129
130ocv_add_accuracy_tests()
131ocv_add_perf_tests()
132