1 set(the_description "High-level GUI and Media I/O")
2 ocv_add_module(highgui opencv_imgproc OPTIONAL opencv_androidcamera)
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 # ----------------------------------------------------------------------------
10 ocv_clear_vars(GRFMT_LIBS)
12 if(WITH_PNG OR WITH_TIFF OR WITH_OPENEXR)
13 ocv_include_directories(${ZLIB_INCLUDE_DIR})
14 list(APPEND GRFMT_LIBS ${ZLIB_LIBRARIES})
18 add_definitions(-DHAVE_JPEG)
19 ocv_include_directories(${JPEG_INCLUDE_DIR})
20 list(APPEND GRFMT_LIBS ${JPEG_LIBRARIES})
24 add_definitions(-DHAVE_PNG)
25 add_definitions(${PNG_DEFINITIONS})
26 ocv_include_directories(${PNG_INCLUDE_DIR})
27 list(APPEND GRFMT_LIBS ${PNG_LIBRARIES})
31 add_definitions(-DHAVE_TIFF)
32 ocv_include_directories(${TIFF_INCLUDE_DIR})
33 list(APPEND GRFMT_LIBS ${TIFF_LIBRARIES})
37 add_definitions(-DHAVE_JASPER)
38 ocv_include_directories(${JASPER_INCLUDE_DIR})
39 list(APPEND GRFMT_LIBS ${JASPER_LIBRARIES})
43 add_definitions(-DHAVE_OPENEXR)
44 include_directories(SYSTEM ${OPENEXR_INCLUDE_PATHS})
45 list(APPEND GRFMT_LIBS ${OPENEXR_LIBRARIES})
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)
53 source_group("Src\\grfmts" FILES ${grfmt_hdrs} ${grfmt_srcs})
58 src/cap_ffmpeg_impl.hpp
71 file(GLOB highgui_ext_hdrs "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
75 set(CMAKE_INCLUDE_CURRENT_DIR ON)
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})
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})
87 add_definitions(${Qt5OpenGL_DEFINITIONS})
88 include_directories(${Qt5OpenGL_INCLUDE_DIRS})
89 list(APPEND HIGHGUI_LIBRARIES ${Qt5OpenGL_LIBRARIES})
94 set(QT_USE_QTOPENGL TRUE)
96 include(${QT_USE_FILE})
98 QT4_ADD_RESOURCES(_RCC_OUTFILES src/window_QT.qrc)
99 QT4_WRAP_CPP(_MOC_OUTFILES src/window_QT.h)
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)
105 set_source_files_properties(${_RCC_OUTFILES} PROPERTIES COMPILE_FLAGS -Wno-missing-declarations)
108 list(APPEND highgui_srcs src/window_w32.cpp)
110 list(APPEND highgui_srcs src/window_gtk.cpp)
113 add_definitions(-DHAVE_CARBON=1)
114 list(APPEND highgui_srcs src/window_carbon.cpp)
115 list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime")
117 add_definitions(-DHAVE_COCOA=1)
118 list(APPEND highgui_srcs src/window_cocoa.mm)
119 list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
123 if(WIN32 AND NOT ARM)
124 list(APPEND highgui_srcs src/cap_cmu.cpp)
127 if (WIN32 AND HAVE_DSHOW)
128 list(APPEND highgui_srcs src/cap_dshow.cpp)
131 if (WIN32 AND HAVE_MSMF)
132 list(APPEND highgui_srcs src/cap_msmf.cpp)
135 if (WIN32 AND HAVE_VFW)
136 list(APPEND highgui_srcs src/cap_vfw.cpp)
140 list(APPEND highgui_srcs src/cap_xine.cpp)
144 list(APPEND highgui_srcs src/cap_dc1394_v2.cpp)
148 list(APPEND highgui_srcs src/cap_dc1394.cpp)
152 list(APPEND highgui_srcs src/cap_gstreamer.cpp)
153 endif(HAVE_GSTREAMER)
156 list(APPEND highgui_srcs src/cap_unicap.cpp)
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)
166 list(APPEND highgui_srcs src/cap_openni.cpp)
167 ocv_include_directories(${OPENNI_INCLUDE_DIR})
168 list(APPEND HIGHGUI_LIBRARIES ${OPENNI_LIBRARY})
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)
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})
183 list(APPEND HIGHGUI_LIBRARIES m3apiX64)
185 list(APPEND HIGHGUI_LIBRARIES m3api)
190 if(UNIX AND BZIP2_LIBRARIES)
191 list(APPEND HIGHGUI_LIBRARIES ${BZIP2_LIBRARIES})
194 list(APPEND HIGHGUI_LIBRARIES "-framework VideoDecodeAcceleration" bz2)
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})
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)
214 add_definitions(-DHAVE_IMAGEIO=1)
216 list(APPEND HIGHGUI_LIBRARIES "-framework ImageIO")
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")
225 add_definitions(-DHAVE_QUICKTIME=1)
227 list(APPEND highgui_srcs src/cap_qt.cpp)
228 list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime" "-framework CoreFoundation" "-framework QuartzCore")
230 list(APPEND highgui_srcs src/cap_qtkit.mm)
231 list(APPEND HIGHGUI_LIBRARIES "-framework QTKit" "-framework QuartzCore" "-framework AppKit")
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")
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
247 #these variables are set by CHECK_MODULE macro
248 foreach(P ${HIGHGUI_INCLUDE_DIRS})
249 ocv_include_directories(${P})
252 foreach(P ${HIGHGUI_LIBRARY_DIRS})
253 link_directories(${P})
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()
262 ocv_create_module(${GRFMT_LIBS} ${HIGHGUI_LIBRARIES})
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)
271 set(flags "${_flags} -fobjc-exceptions")
273 set(flags "-fobjc-exceptions")
276 set_source_files_properties("${source}" PROPERTIES COMPILE_FLAGS "${flags}")
282 if(BUILD_SHARED_LIBS)
283 add_definitions(-DHIGHGUI_EXPORTS)
287 set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
290 #stop automatic dependencies propagation for this module
291 set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "")
293 ocv_add_precompiled_headers(${the_module})
294 ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
296 if(WIN32 AND WITH_FFMPEG)
297 #copy ffmpeg dll to the output folder
298 if(MSVC64 OR MINGW64)
299 set(FFMPEG_SUFFIX _64)
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}")
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")
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")
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")
326 install(FILES "${ffmpeg_path}" DESTINATION bin COMPONENT main RENAME "${ffmpeg_bare_name_ver}")
329 ocv_add_accuracy_tests()