CMakeLists.txt 4.2 KB
Newer Older
1
set(the_description "Image I/O")
M
Maksim Shabunin 已提交
2
ocv_add_module(imgcodecs opencv_imgproc WRAP java python)
3 4 5 6 7 8 9 10 11

# ----------------------------------------------------------------------------
#  CMake file for imgcodecs. See root CMakeLists.txt
#   Some parts taken from version of Hartmut Seichter, HIT Lab NZ.
#   Jose Luis Blanco, 2008
# ----------------------------------------------------------------------------

ocv_clear_vars(GRFMT_LIBS)

12
if(HAVE_WINRT_CX AND NOT WINRT)
13 14 15 16 17 18 19 20 21
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
endif()

if(HAVE_PNG OR HAVE_TIFF OR HAVE_OPENEXR)
  ocv_include_directories(${ZLIB_INCLUDE_DIRS})
  list(APPEND GRFMT_LIBS ${ZLIB_LIBRARIES})
endif()

if(HAVE_JPEG)
22
  ocv_include_directories(${JPEG_INCLUDE_DIR} ${${JPEG_LIBRARY}_BINARY_DIR})
23 24 25
  list(APPEND GRFMT_LIBS ${JPEG_LIBRARIES})
endif()

26
if(HAVE_WEBP)
27 28 29 30 31 32 33 34 35 36 37
  add_definitions(-DHAVE_WEBP)
  ocv_include_directories(${WEBP_INCLUDE_DIR})
  list(APPEND GRFMT_LIBS ${WEBP_LIBRARIES})
endif()

if(HAVE_PNG)
  add_definitions(${PNG_DEFINITIONS})
  ocv_include_directories(${PNG_INCLUDE_DIR})
  list(APPEND GRFMT_LIBS ${PNG_LIBRARIES})
endif()

38 39 40 41 42
if(HAVE_GDCM)
  ocv_include_directories(${GDCM_INCLUDE_DIRS})
  list(APPEND GRFMT_LIBS ${GDCM_LIBRARIES})
endif()

43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
if(HAVE_TIFF)
  ocv_include_directories(${TIFF_INCLUDE_DIR})
  list(APPEND GRFMT_LIBS ${TIFF_LIBRARIES})
endif()

if(HAVE_JASPER)
  ocv_include_directories(${JASPER_INCLUDE_DIR})
  list(APPEND GRFMT_LIBS ${JASPER_LIBRARIES})
endif()

if(HAVE_OPENEXR)
  include_directories(SYSTEM ${OPENEXR_INCLUDE_PATHS})
  list(APPEND GRFMT_LIBS ${OPENEXR_LIBRARIES})
endif()

M
mshabunin 已提交
58 59 60 61 62
if(HAVE_GDAL)
  include_directories(SYSTEM ${GDAL_INCLUDE_DIR})
  list(APPEND GRFMT_LIBS ${GDAL_LIBRARY})
endif()

63 64 65 66 67 68 69 70 71 72 73 74
if(HAVE_IMGCODEC_HDR)
  add_definitions(-DHAVE_IMGCODEC_HDR)
endif()

if(HAVE_IMGCODEC_SUNRASTER)
  add_definitions(-DHAVE_IMGCODEC_SUNRASTER)
endif()

if(HAVE_IMGCODEC_PXM)
  add_definitions(-DHAVE_IMGCODEC_PXM)
endif()

A
Alexander Alekhin 已提交
75 76
file(GLOB grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/grfmt*.hpp)
file(GLOB grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/grfmt*.cpp)
77

A
Alexander Alekhin 已提交
78 79 80 81
list(APPEND grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/bitstrm.hpp)
list(APPEND grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/bitstrm.cpp)
list(APPEND grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/rgbe.hpp)
list(APPEND grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/rgbe.cpp)
82 83
list(APPEND grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/exif.hpp)
list(APPEND grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/exif.cpp)
84 85 86 87

source_group("Src\\grfmts" FILES ${grfmt_hdrs} ${grfmt_srcs})

set(imgcodecs_hdrs
A
Alexander Alekhin 已提交
88 89
    ${CMAKE_CURRENT_LIST_DIR}/src/precomp.hpp
    ${CMAKE_CURRENT_LIST_DIR}/src/utils.hpp
90 91 92
    )

set(imgcodecs_srcs
A
Alexander Alekhin 已提交
93 94
    ${CMAKE_CURRENT_LIST_DIR}/src/loadsave.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/utils.cpp
95 96
    )

A
Alexander Alekhin 已提交
97 98 99 100 101
file(GLOB imgcodecs_ext_hdrs
     "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/*.hpp"
     "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.hpp"
     "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h"
     )
102 103

if(IOS)
A
Alexander Alekhin 已提交
104
  list(APPEND imgcodecs_srcs ${CMAKE_CURRENT_LIST_DIR}/src/ios_conversions.mm)
105
  list(APPEND IMGCODECS_LIBRARIES "-framework Accelerate" "-framework CoreGraphics" "-framework QuartzCore" "-framework AssetsLibrary")
106
endif()
107 108 109
if(APPLE_FRAMEWORK)
  list(APPEND IMGCODECS_LIBRARIES "-framework UIKit")
endif()
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128

if(UNIX)
  #these variables are set by CHECK_MODULE macro
  foreach(P ${IMGCODECS_INCLUDE_DIRS})
    ocv_include_directories(${P})
  endforeach()

  foreach(P ${IMGCODECS_LIBRARY_DIRS})
    link_directories(${P})
  endforeach()
endif()

source_group("Src" FILES ${imgcodecs_srcs} ${imgcodecs_hdrs})
source_group("Include" FILES ${imgcodecs_ext_hdrs})
ocv_set_module_sources(HEADERS ${imgcodecs_ext_hdrs} SOURCES ${imgcodecs_srcs} ${imgcodecs_hdrs} ${grfmt_srcs} ${grfmt_hdrs})
ocv_module_include_directories()

ocv_create_module(${GRFMT_LIBS} ${IMGCODECS_LIBRARIES})

A
Alexander Alekhin 已提交
129
macro(ocv_imgcodecs_configure_target)
130
if(APPLE)
131
  add_apple_compiler_options(the_module)
132 133 134 135 136 137 138
endif()

if(MSVC)
  set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
endif()

ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
A
Alexander Alekhin 已提交
139 140 141 142 143
endmacro()

if(NOT BUILD_opencv_world)
  ocv_imgcodecs_configure_target()
endif()
144 145 146

ocv_add_accuracy_tests()
ocv_add_perf_tests()