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