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(HAVE_PNG OR HAVE_TIFF OR HAVE_OPENEXR)
13 ocv_include_directories(${ZLIB_INCLUDE_DIR})
14 list(APPEND GRFMT_LIBS ${ZLIB_LIBRARIES})
18 ocv_include_directories(${JPEG_INCLUDE_DIR})
19 list(APPEND GRFMT_LIBS ${JPEG_LIBRARIES})
23 add_definitions(${PNG_DEFINITIONS})
24 ocv_include_directories(${PNG_INCLUDE_DIR})
25 list(APPEND GRFMT_LIBS ${PNG_LIBRARIES})
29 ocv_include_directories(${TIFF_INCLUDE_DIR})
30 list(APPEND GRFMT_LIBS ${TIFF_LIBRARIES})
34 ocv_include_directories(${JASPER_INCLUDE_DIR})
35 list(APPEND GRFMT_LIBS ${JASPER_LIBRARIES})
39 include_directories(SYSTEM ${OPENEXR_INCLUDE_PATHS})
40 list(APPEND GRFMT_LIBS ${OPENEXR_LIBRARIES})
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)
48 source_group("Src\\grfmts" FILES ${grfmt_hdrs} ${grfmt_srcs})
53 src/cap_ffmpeg_impl.hpp
65 file(GLOB highgui_ext_hdrs "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
69 set(CMAKE_INCLUDE_CURRENT_DIR ON)
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})
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})
81 add_definitions(${Qt5OpenGL_DEFINITIONS})
82 include_directories(${Qt5OpenGL_INCLUDE_DIRS})
83 list(APPEND HIGHGUI_LIBRARIES ${Qt5OpenGL_LIBRARIES})
88 set(QT_USE_QTOPENGL TRUE)
90 include(${QT_USE_FILE})
92 QT4_ADD_RESOURCES(_RCC_OUTFILES src/window_QT.qrc)
93 QT4_WRAP_CPP(_MOC_OUTFILES src/window_QT.h)
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)
99 set_source_files_properties(${_RCC_OUTFILES} PROPERTIES COMPILE_FLAGS -Wno-missing-declarations)
102 list(APPEND highgui_srcs src/window_w32.cpp)
104 list(APPEND highgui_srcs src/window_gtk.cpp)
106 list(APPEND highgui_srcs src/window_carbon.cpp)
107 list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime")
109 list(APPEND highgui_srcs src/window_cocoa.mm)
110 list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
113 if(WIN32 AND NOT ARM)
114 list(APPEND highgui_srcs src/cap_cmu.cpp)
117 if (WIN32 AND HAVE_DSHOW)
118 list(APPEND highgui_srcs src/cap_dshow.cpp)
121 if (WIN32 AND HAVE_MSMF)
122 list(APPEND highgui_srcs src/cap_msmf.cpp)
125 if (WIN32 AND HAVE_VFW)
126 list(APPEND highgui_srcs src/cap_vfw.cpp)
130 list(APPEND highgui_srcs src/cap_xine.cpp)
134 list(APPEND highgui_srcs src/cap_dc1394_v2.cpp)
138 list(APPEND highgui_srcs src/cap_dc1394.cpp)
142 list(APPEND highgui_srcs src/cap_gstreamer.cpp)
143 endif(HAVE_GSTREAMER)
146 list(APPEND highgui_srcs src/cap_unicap.cpp)
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)
156 list(APPEND highgui_srcs src/cap_openni.cpp)
157 ocv_include_directories(${OPENNI_INCLUDE_DIR})
158 list(APPEND HIGHGUI_LIBRARIES ${OPENNI_LIBRARY})
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)
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})
173 list(APPEND HIGHGUI_LIBRARIES m3apiX64)
175 list(APPEND HIGHGUI_LIBRARIES m3api)
180 if(UNIX AND BZIP2_LIBRARIES)
181 list(APPEND HIGHGUI_LIBRARIES ${BZIP2_LIBRARIES})
184 list(APPEND HIGHGUI_LIBRARIES "-framework VideoDecodeAcceleration" bz2)
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})
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)
204 if(HAVE_IMAGEIO AND IOS)
205 list(APPEND HIGHGUI_LIBRARIES "-framework ImageIO")
208 if(HAVE_AVFOUNDATION)
209 list(APPEND highgui_srcs src/cap_avfoundation.mm)
210 list(APPEND HIGHGUI_LIBRARIES "-framework AVFoundation" "-framework QuartzCore")
214 list(APPEND highgui_srcs src/cap_qt.cpp)
215 list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime" "-framework CoreFoundation" "-framework QuartzCore")
217 list(APPEND highgui_srcs src/cap_qtkit.mm)
218 list(APPEND HIGHGUI_LIBRARIES "-framework QTKit" "-framework QuartzCore" "-framework AppKit")
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")
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
233 #these variables are set by CHECK_MODULE macro
234 foreach(P ${HIGHGUI_INCLUDE_DIRS})
235 ocv_include_directories(${P})
238 foreach(P ${HIGHGUI_LIBRARY_DIRS})
239 link_directories(${P})
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()
248 ocv_create_module(${GRFMT_LIBS} ${HIGHGUI_LIBRARIES})
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)
257 set(flags "${_flags} -fobjc-exceptions")
259 set(flags "-fobjc-exceptions")
262 set_source_files_properties("${source}" PROPERTIES COMPILE_FLAGS "${flags}")
268 if(BUILD_SHARED_LIBS)
269 add_definitions(-DHIGHGUI_EXPORTS)
273 set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
276 #stop automatic dependencies propagation for this module
277 set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "")
279 ocv_add_precompiled_headers(${the_module})
280 ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
282 if(WIN32 AND WITH_FFMPEG)
283 #copy ffmpeg dll to the output folder
284 if(MSVC64 OR MINGW64)
285 set(FFMPEG_SUFFIX _64)
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}")
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")
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")
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")
312 install(FILES "${ffmpeg_path}" DESTINATION bin COMPONENT main RENAME "${ffmpeg_bare_name_ver}")
315 ocv_add_accuracy_tests()