CLAHE Python bindings
[profile/ivi/opencv.git] / modules / highgui / CMakeLists.txt
1 set(the_description "High-level GUI and Media I/O")
2 ocv_add_module(highgui opencv_imgproc OPTIONAL opencv_androidcamera)
3
4 # ----------------------------------------------------------------------------
5 #  CMake file for highgui. 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(WITH_PNG OR WITH_TIFF OR WITH_OPENEXR)
13   ocv_include_directories(${ZLIB_INCLUDE_DIR})
14   list(APPEND GRFMT_LIBS ${ZLIB_LIBRARIES})
15 endif()
16
17 if(WITH_JPEG)
18   add_definitions(-DHAVE_JPEG)
19   ocv_include_directories(${JPEG_INCLUDE_DIR})
20   list(APPEND GRFMT_LIBS ${JPEG_LIBRARIES})
21 endif()
22
23 if(WITH_PNG)
24   add_definitions(-DHAVE_PNG)
25   add_definitions(${PNG_DEFINITIONS})
26   ocv_include_directories(${PNG_INCLUDE_DIR})
27   list(APPEND GRFMT_LIBS ${PNG_LIBRARIES})
28 endif()
29
30 if(WITH_TIFF)
31   add_definitions(-DHAVE_TIFF)
32   ocv_include_directories(${TIFF_INCLUDE_DIR})
33   list(APPEND GRFMT_LIBS ${TIFF_LIBRARIES})
34 endif()
35
36 if(WITH_JASPER)
37   add_definitions(-DHAVE_JASPER)
38   ocv_include_directories(${JASPER_INCLUDE_DIR})
39   list(APPEND GRFMT_LIBS ${JASPER_LIBRARIES})
40 endif()
41
42 if(WITH_OPENEXR)
43   add_definitions(-DHAVE_OPENEXR)
44   include_directories(SYSTEM ${OPENEXR_INCLUDE_PATHS})
45   list(APPEND GRFMT_LIBS ${OPENEXR_LIBRARIES})
46 endif()
47
48 file(GLOB grfmt_hdrs src/grfmt*.hpp)
49 file(GLOB grfmt_srcs src/grfmt*.cpp)
50 list(APPEND grfmt_hdrs src/bitstrm.hpp)
51 list(APPEND grfmt_srcs src/bitstrm.cpp)
52
53 source_group("Src\\grfmts" FILES ${grfmt_hdrs} ${grfmt_srcs})
54
55 set(highgui_hdrs
56     src/precomp.hpp
57     src/utils.hpp
58     src/cap_ffmpeg_impl.hpp
59     )
60
61 set(highgui_srcs
62     src/cap.cpp
63     src/cap_images.cpp
64     src/cap_ffmpeg.cpp
65     src/loadsave.cpp
66     src/precomp.cpp
67     src/utils.cpp
68     src/window.cpp
69     )
70
71 file(GLOB highgui_ext_hdrs "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
72
73 if(HAVE_QT5)
74   set(CMAKE_AUTOMOC ON)
75   set(CMAKE_INCLUDE_CURRENT_DIR ON)
76
77   QT5_ADD_RESOURCES(_RCC_OUTFILES src/window_QT.qrc)
78   list(APPEND highgui_srcs src/window_QT.cpp src/window_QT.h ${_RCC_OUTFILES})
79
80   foreach(dt5_dep Core Gui Widgets Test Concurrent)
81     add_definitions(${Qt5${dt5_dep}_DEFINITIONS})
82     include_directories(${Qt5${dt5_dep}_INCLUDE_DIRS})
83     list(APPEND HIGHGUI_LIBRARIES ${Qt5${dt5_dep}_LIBRARIES})
84   endforeach()
85
86   if(HAVE_QT_OPENGL)
87     add_definitions(${Qt5OpenGL_DEFINITIONS})
88     include_directories(${Qt5OpenGL_INCLUDE_DIRS})
89     list(APPEND HIGHGUI_LIBRARIES ${Qt5OpenGL_LIBRARIES})
90   endif()
91
92 elseif(HAVE_QT)
93   if (HAVE_QT_OPENGL)
94     set(QT_USE_QTOPENGL TRUE)
95   endif()
96   include(${QT_USE_FILE})
97
98   QT4_ADD_RESOURCES(_RCC_OUTFILES src/window_QT.qrc)
99   QT4_WRAP_CPP(_MOC_OUTFILES src/window_QT.h)
100
101   list(APPEND HIGHGUI_LIBRARIES ${QT_LIBRARIES})
102   list(APPEND highgui_srcs src/window_QT.cpp ${_MOC_OUTFILES} ${_RCC_OUTFILES})
103   ocv_check_flag_support(CXX -Wno-missing-declarations _have_flag)
104   if(${_have_flag})
105     set_source_files_properties(${_RCC_OUTFILES} PROPERTIES COMPILE_FLAGS -Wno-missing-declarations)
106   endif()
107 elseif(HAVE_WIN32UI)
108   list(APPEND highgui_srcs src/window_w32.cpp)
109 elseif(HAVE_GTK)
110   list(APPEND highgui_srcs src/window_gtk.cpp)
111 elseif(APPLE)
112   if(WITH_CARBON)
113     add_definitions(-DHAVE_CARBON=1)
114     list(APPEND highgui_srcs src/window_carbon.cpp)
115     list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime")
116   elseif(NOT IOS)
117     add_definitions(-DHAVE_COCOA=1)
118     list(APPEND highgui_srcs src/window_cocoa.mm)
119     list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
120   endif()
121 endif()
122
123 if(WIN32 AND NOT ARM)
124   list(APPEND highgui_srcs src/cap_cmu.cpp)
125 endif()
126
127 if (WIN32 AND HAVE_DSHOW)
128   list(APPEND highgui_srcs src/cap_dshow.cpp)
129 endif()
130
131 if (WIN32 AND HAVE_MSMF)
132   list(APPEND highgui_srcs src/cap_msmf.cpp)
133 endif()
134
135 if (WIN32 AND HAVE_VFW)
136   list(APPEND highgui_srcs src/cap_vfw.cpp)
137 endif()
138
139 if(HAVE_XINE)
140   list(APPEND highgui_srcs src/cap_xine.cpp)
141 endif(HAVE_XINE)
142
143 if(HAVE_DC1394_2)
144   list(APPEND highgui_srcs src/cap_dc1394_v2.cpp)
145 endif(HAVE_DC1394_2)
146
147 if(HAVE_DC1394)
148   list(APPEND highgui_srcs src/cap_dc1394.cpp)
149 endif(HAVE_DC1394)
150
151 if(HAVE_GSTREAMER)
152   list(APPEND highgui_srcs src/cap_gstreamer.cpp)
153 endif(HAVE_GSTREAMER)
154
155 if(HAVE_UNICAP)
156   list(APPEND highgui_srcs src/cap_unicap.cpp)
157 endif(HAVE_UNICAP)
158
159 if(HAVE_LIBV4L)
160   list(APPEND highgui_srcs src/cap_libv4l.cpp)
161 elseif(HAVE_CAMV4L OR HAVE_CAMV4L2 OR HAVE_VIDEOIO)
162   list(APPEND highgui_srcs src/cap_v4l.cpp)
163 endif()
164
165 if(HAVE_OPENNI)
166   list(APPEND highgui_srcs src/cap_openni.cpp)
167   ocv_include_directories(${OPENNI_INCLUDE_DIR})
168   list(APPEND HIGHGUI_LIBRARIES ${OPENNI_LIBRARY})
169 endif(HAVE_OPENNI)
170
171 if(HAVE_opencv_androidcamera)
172   list(APPEND highgui_srcs src/cap_android.cpp)
173   add_definitions(-DHAVE_ANDROID_NATIVE_CAMERA)#TODO: remove this line
174 endif(HAVE_opencv_androidcamera)
175
176 if(HAVE_XIMEA)
177   list(APPEND highgui_srcs src/cap_ximea.cpp)
178   ocv_include_directories(${XIMEA_PATH})
179   if(XIMEA_LIBRARY_DIR)
180     link_directories(${XIMEA_LIBRARY_DIR})
181   endif()
182   if(CMAKE_CL_64)
183     list(APPEND HIGHGUI_LIBRARIES m3apiX64)
184   else()
185     list(APPEND HIGHGUI_LIBRARIES m3api)
186   endif()
187 endif(HAVE_XIMEA)
188
189 if(HAVE_FFMPEG)
190   if(UNIX AND BZIP2_LIBRARIES)
191     list(APPEND HIGHGUI_LIBRARIES ${BZIP2_LIBRARIES})
192   endif()
193   if(APPLE)
194     list(APPEND HIGHGUI_LIBRARIES "-framework VideoDecodeAcceleration" bz2)
195   endif()
196 endif(HAVE_FFMPEG)
197
198 if(HAVE_PVAPI)
199   add_definitions(-DHAVE_PVAPI)
200   ocv_include_directories(${PVAPI_INCLUDE_PATH})
201   set(highgui_srcs src/cap_pvapi.cpp ${highgui_srcs})
202   list(APPEND HIGHGUI_LIBRARIES ${PVAPI_LIBRARY})
203 endif()
204
205 if(HAVE_GIGE_API)
206   add_definitions(-DHAVE_GIGE_API)
207   ocv_include_directories(${GIGEAPI_INCLUDE_PATH})
208   set(highgui_srcs src/cap_giganetix.cpp ${highgui_srcs})
209   list(APPEND HIGHGUI_LIBRARIES ${GIGEAPI_LIBRARIES})
210   list(APPEND highgui_srcs src/cap_giganetix.cpp)
211 endif(HAVE_GIGE_API)
212
213 if(WITH_IMAGEIO)
214   add_definitions(-DHAVE_IMAGEIO=1)
215   if(IOS)
216     list(APPEND HIGHGUI_LIBRARIES "-framework ImageIO")
217   endif()
218 endif(WITH_IMAGEIO)
219
220 if(WITH_AVFOUNDATION)
221   add_definitions(-DHAVE_AVFOUNDATION=1)
222   list(APPEND highgui_srcs src/cap_avfoundation.mm)
223   list(APPEND HIGHGUI_LIBRARIES "-framework AVFoundation" "-framework QuartzCore")
224 elseif(APPLE)
225   add_definitions(-DHAVE_QUICKTIME=1)
226   if(WITH_QUICKTIME)
227     list(APPEND highgui_srcs src/cap_qt.cpp)
228     list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime" "-framework CoreFoundation" "-framework QuartzCore")
229   else()
230     list(APPEND highgui_srcs src/cap_qtkit.mm)
231     list(APPEND HIGHGUI_LIBRARIES "-framework QTKit" "-framework QuartzCore" "-framework AppKit")
232   endif()
233 endif()
234
235 if(IOS)
236   add_definitions(-DHAVE_IOS=1)
237   list(APPEND highgui_srcs src/cap_ios_abstract_camera.mm src/cap_ios_photo_camera.mm src/cap_ios_video_camera.mm)
238   list(APPEND HIGHGUI_LIBRARIES "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreImage" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore" "-framework AssetsLibrary")
239 endif()
240
241 if(WIN32)
242   link_directories("${OpenCV_SOURCE_DIR}/3rdparty/lib") # for ffmpeg wrapper only
243   include_directories(AFTER SYSTEM "${OpenCV_SOURCE_DIR}/3rdparty/include") # for directshow in VS2005 and multi-monitor support on MinGW
244 endif()
245
246 if(UNIX)
247   #these variables are set by CHECK_MODULE macro
248   foreach(P ${HIGHGUI_INCLUDE_DIRS})
249     ocv_include_directories(${P})
250   endforeach()
251
252   foreach(P ${HIGHGUI_LIBRARY_DIRS})
253     link_directories(${P})
254   endforeach()
255 endif()
256
257 source_group("Src" FILES ${highgui_srcs} ${highgui_hdrs})
258 source_group("Include" FILES ${highgui_ext_hdrs})
259 ocv_set_module_sources(HEADERS ${highgui_ext_hdrs} SOURCES ${highgui_srcs} ${highgui_hdrs} ${grfmt_srcs} ${grfmt_hdrs})
260 ocv_module_include_directories()
261
262 ocv_create_module(${GRFMT_LIBS} ${HIGHGUI_LIBRARIES})
263
264 if(APPLE)
265   ocv_check_flag_support(OBJCXX "-fobjc-exceptions" HAVE_OBJC_EXCEPTIONS)
266   if(HAVE_OBJC_EXCEPTIONS)
267     foreach(source ${OPENCV_MODULE_${the_module}_SOURCES})
268       if("${source}" MATCHES "\\.mm$")
269         get_source_file_property(flags "${source}" COMPILE_FLAGS)
270         if(flags)
271           set(flags "${_flags} -fobjc-exceptions")
272         else()
273           set(flags "-fobjc-exceptions")
274         endif()
275
276         set_source_files_properties("${source}" PROPERTIES COMPILE_FLAGS "${flags}")
277       endif()
278     endforeach()
279   endif()
280 endif()
281
282 if(BUILD_SHARED_LIBS)
283   add_definitions(-DHIGHGUI_EXPORTS)
284 endif()
285
286 if(MSVC)
287   set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
288 endif()
289
290 #stop automatic dependencies propagation for this module
291 set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "")
292
293 ocv_add_precompiled_headers(${the_module})
294 ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
295
296 if(WIN32 AND WITH_FFMPEG)
297   #copy ffmpeg dll to the output folder
298   if(MSVC64 OR MINGW64)
299     set(FFMPEG_SUFFIX _64)
300   endif()
301
302   set(ffmpeg_bare_name "opencv_ffmpeg${FFMPEG_SUFFIX}.dll")
303   set(ffmpeg_bare_name_ver "opencv_ffmpeg${OPENCV_DLLVERSION}${FFMPEG_SUFFIX}.dll")
304   set(ffmpeg_path "${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/${ffmpeg_bare_name}")
305
306   #if(MSVC AND CMAKE_VERSION VERSION_GREATER "2.8.2")
307   #  add_custom_command(TARGET ${the_module} POST_BUILD
308   #                     COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/$<CONFIGURATION>/${ffmpeg_bare_name_ver}"
309   #                     COMMENT "Copying ${ffmpeg_path} to the output directory")
310   #else
311   if(MSVC_IDE)
312     add_custom_command(TARGET ${the_module} POST_BUILD
313                        COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Release/${ffmpeg_bare_name_ver}"
314                        COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Debug/${ffmpeg_bare_name_ver}"
315                        COMMENT "Copying ${ffmpeg_path} to the output directory")
316   elseif(MSVC AND (CMAKE_GENERATOR MATCHES "Visual"))
317     add_custom_command(TARGET ${the_module} POST_BUILD
318                        COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/${ffmpeg_bare_name_ver}"
319                        COMMENT "Copying ${ffmpeg_path} to the output directory")
320   else()
321     add_custom_command(TARGET ${the_module} POST_BUILD
322                        COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${ffmpeg_bare_name_ver}"
323                        COMMENT "Copying ${ffmpeg_path} to the output directory")
324   endif()
325
326   install(FILES "${ffmpeg_path}" DESTINATION bin COMPONENT main RENAME "${ffmpeg_bare_name_ver}")
327 endif()
328
329 ocv_add_accuracy_tests()
330 ocv_add_perf_tests()