1 set(the_description "Image codecs") 2 ocv_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 10 ocv_clear_vars(GRFMT_LIBS) 11 12 if(HAVE_WINRT_CX AND NOT WINRT) 13 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW") 14 endif() 15 16 if(HAVE_PNG OR HAVE_TIFF OR HAVE_OPENEXR) 17 ocv_include_directories(${ZLIB_INCLUDE_DIRS}) 18 list(APPEND GRFMT_LIBS ${ZLIB_LIBRARIES}) 19 endif() 20 21 if(HAVE_JPEG) 22 ocv_include_directories(${JPEG_INCLUDE_DIR}) 23 list(APPEND GRFMT_LIBS ${JPEG_LIBRARIES}) 24 endif() 25 26 if(WITH_WEBP) 27 add_definitions(-DHAVE_WEBP) 28 ocv_include_directories(${WEBP_INCLUDE_DIR}) 29 list(APPEND GRFMT_LIBS ${WEBP_LIBRARIES}) 30 endif() 31 32 if(HAVE_PNG) 33 add_definitions(${PNG_DEFINITIONS}) 34 ocv_include_directories(${PNG_INCLUDE_DIR}) 35 list(APPEND GRFMT_LIBS ${PNG_LIBRARIES}) 36 endif() 37 38 if(HAVE_TIFF) 39 ocv_include_directories(${TIFF_INCLUDE_DIR}) 40 list(APPEND GRFMT_LIBS ${TIFF_LIBRARIES}) 41 endif() 42 43 if(HAVE_JASPER) 44 ocv_include_directories(${JASPER_INCLUDE_DIR}) 45 list(APPEND GRFMT_LIBS ${JASPER_LIBRARIES}) 46 endif() 47 48 if(HAVE_OPENEXR) 49 include_directories(SYSTEM ${OPENEXR_INCLUDE_PATHS}) 50 list(APPEND GRFMT_LIBS ${OPENEXR_LIBRARIES}) 51 endif() 52 53 if(HAVE_GDAL) 54 include_directories(SYSTEM ${GDAL_INCLUDE_DIR}) 55 list(APPEND GRFMT_LIBS ${GDAL_LIBRARY}) 56 endif() 57 58 file(GLOB grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/grfmt*.hpp) 59 file(GLOB grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/grfmt*.cpp) 60 list(APPEND grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/bitstrm.hpp) 61 list(APPEND grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/bitstrm.cpp) 62 list(APPEND grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/rgbe.hpp) 63 list(APPEND grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/rgbe.cpp) 64 65 source_group("Src\\grfmts" FILES ${grfmt_hdrs} ${grfmt_srcs}) 66 67 set(imgcodecs_hdrs 68 ${CMAKE_CURRENT_LIST_DIR}/src/precomp.hpp 69 ${CMAKE_CURRENT_LIST_DIR}/src/utils.hpp 70 ) 71 72 set(imgcodecs_srcs 73 ${CMAKE_CURRENT_LIST_DIR}/src/loadsave.cpp 74 ${CMAKE_CURRENT_LIST_DIR}/src/utils.cpp 75 ) 76 77 file(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 83 if(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") 87 endif() 88 89 if(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() 98 endif() 99 100 source_group("Src" FILES ${imgcodecs_srcs} ${imgcodecs_hdrs}) 101 source_group("Include" FILES ${imgcodecs_ext_hdrs}) 102 ocv_set_module_sources(HEADERS ${imgcodecs_ext_hdrs} SOURCES ${imgcodecs_srcs} ${imgcodecs_hdrs} ${grfmt_srcs} ${grfmt_hdrs}) 103 ocv_module_include_directories() 104 105 ocv_create_module(${GRFMT_LIBS} ${IMGCODECS_LIBRARIES}) 106 107 macro(ocv_imgcodecs_configure_target) 108 if(APPLE) 109 add_apple_compiler_options(the_module) 110 endif() 111 112 if(BUILD_SHARED_LIBS) 113 add_definitions(-DIMGCODECS_EXPORTS) 114 endif() 115 116 if(MSVC) 117 set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG") 118 endif() 119 120 #stop automatic dependencies propagation for this module 121 set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "") 122 123 ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations) 124 endmacro() 125 126 if(NOT BUILD_opencv_world) 127 ocv_imgcodecs_configure_target() 128 endif() 129 130 ocv_add_accuracy_tests() 131 ocv_add_perf_tests() 132