1 set(the_description "High-level GUI and Media I/O")
2 ocv_add_module(highgui opencv_imgproc opencv_imgcodecs 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 # ----------------------------------------------------------------------------
11 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
15 ocv_include_directories(${ZLIB_INCLUDE_DIRS})
16 list(APPEND HIGHGUI_LIBRARIES ${ZLIB_LIBRARIES})
21 src/cap_ffmpeg_impl.hpp
31 file(GLOB highgui_ext_hdrs "include/opencv2/*.hpp" "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
35 set(CMAKE_INCLUDE_CURRENT_DIR ON)
37 QT5_ADD_RESOURCES(_RCC_OUTFILES src/window_QT.qrc)
38 list(APPEND highgui_srcs src/window_QT.cpp src/window_QT.h ${_RCC_OUTFILES})
40 foreach(dt5_dep Core Gui Widgets Test Concurrent)
41 add_definitions(${Qt5${dt5_dep}_DEFINITIONS})
42 include_directories(${Qt5${dt5_dep}_INCLUDE_DIRS})
43 list(APPEND HIGHGUI_LIBRARIES ${Qt5${dt5_dep}_LIBRARIES})
47 add_definitions(${Qt5OpenGL_DEFINITIONS})
48 include_directories(${Qt5OpenGL_INCLUDE_DIRS})
49 list(APPEND HIGHGUI_LIBRARIES ${Qt5OpenGL_LIBRARIES})
54 set(QT_USE_QTOPENGL TRUE)
56 include(${QT_USE_FILE})
58 QT4_ADD_RESOURCES(_RCC_OUTFILES src/window_QT.qrc)
59 QT4_WRAP_CPP(_MOC_OUTFILES src/window_QT.h)
61 list(APPEND HIGHGUI_LIBRARIES ${QT_LIBRARIES})
62 list(APPEND highgui_srcs src/window_QT.cpp ${_MOC_OUTFILES} ${_RCC_OUTFILES})
63 ocv_check_flag_support(CXX -Wno-missing-declarations _have_flag)
65 set_source_files_properties(${_RCC_OUTFILES} PROPERTIES COMPILE_FLAGS -Wno-missing-declarations)
68 list(APPEND highgui_srcs src/window_w32.cpp)
69 elseif(HAVE_GTK OR HAVE_GTK3)
70 list(APPEND highgui_srcs src/window_gtk.cpp)
72 list(APPEND highgui_srcs src/window_carbon.cpp)
73 list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime")
75 list(APPEND highgui_srcs src/window_cocoa.mm)
76 list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
80 list(APPEND highgui_srcs src/cap_cmu.cpp)
83 if (WIN32 AND HAVE_DSHOW)
84 list(APPEND highgui_srcs src/cap_dshow.cpp)
87 if (WIN32 AND HAVE_MSMF)
88 list(APPEND highgui_srcs src/cap_msmf.cpp)
91 if (WIN32 AND HAVE_VFW)
92 list(APPEND highgui_srcs src/cap_vfw.cpp)
96 list(APPEND highgui_srcs src/cap_xine.cpp)
100 list(APPEND highgui_srcs src/cap_dc1394_v2.cpp)
104 list(APPEND highgui_srcs src/cap_dc1394.cpp)
108 list(APPEND highgui_srcs src/cap_gstreamer.cpp)
109 endif(HAVE_GSTREAMER)
112 list(APPEND highgui_srcs src/cap_unicap.cpp)
116 list(APPEND highgui_srcs src/cap_libv4l.cpp)
117 elseif(HAVE_CAMV4L OR HAVE_CAMV4L2 OR HAVE_VIDEOIO)
118 list(APPEND highgui_srcs src/cap_v4l.cpp)
122 list(APPEND highgui_srcs src/cap_openni.cpp)
123 ocv_include_directories(${OPENNI_INCLUDE_DIR})
124 list(APPEND HIGHGUI_LIBRARIES ${OPENNI_LIBRARY})
128 list(APPEND highgui_srcs src/cap_openni2.cpp)
129 ocv_include_directories(${OPENNI2_INCLUDE_DIR})
130 list(APPEND HIGHGUI_LIBRARIES ${OPENNI2_LIBRARY})
133 if(HAVE_opencv_androidcamera)
134 list(APPEND highgui_srcs src/cap_android.cpp)
135 add_definitions(-DHAVE_ANDROID_NATIVE_CAMERA)#TODO: remove this line
136 endif(HAVE_opencv_androidcamera)
139 list(APPEND highgui_srcs src/cap_ximea.cpp)
140 ocv_include_directories(${XIMEA_PATH})
141 if(XIMEA_LIBRARY_DIR)
142 link_directories("${XIMEA_LIBRARY_DIR}")
145 list(APPEND HIGHGUI_LIBRARIES m3apiX64)
147 list(APPEND HIGHGUI_LIBRARIES m3api)
152 if(UNIX AND BZIP2_LIBRARIES)
153 list(APPEND HIGHGUI_LIBRARIES ${BZIP2_LIBRARIES})
156 list(APPEND HIGHGUI_LIBRARIES "-framework VideoDecodeAcceleration" bz2)
161 add_definitions(-DHAVE_PVAPI)
162 add_definitions(${PVAPI_DEFINITIONS})
163 ocv_include_directories(${PVAPI_INCLUDE_PATH})
164 set(highgui_srcs src/cap_pvapi.cpp ${highgui_srcs})
165 list(APPEND HIGHGUI_LIBRARIES ${PVAPI_LIBRARY})
169 add_definitions(-DHAVE_GIGE_API)
170 ocv_include_directories(${GIGEAPI_INCLUDE_PATH})
171 set(highgui_srcs src/cap_giganetix.cpp ${highgui_srcs})
172 list(APPEND HIGHGUI_LIBRARIES ${GIGEAPI_LIBRARIES})
173 list(APPEND highgui_srcs src/cap_giganetix.cpp)
176 if(HAVE_AVFOUNDATION)
177 list(APPEND highgui_srcs src/cap_avfoundation.mm)
178 list(APPEND HIGHGUI_LIBRARIES "-framework AVFoundation" "-framework QuartzCore")
182 list(APPEND highgui_srcs src/cap_qt.cpp)
183 list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime" "-framework CoreFoundation" "-framework QuartzCore")
185 list(APPEND highgui_srcs src/cap_qtkit.mm)
186 list(APPEND HIGHGUI_LIBRARIES "-framework QTKit" "-framework QuartzCore" "-framework AppKit")
190 list(APPEND highgui_srcs src/cap_intelperc.cpp)
191 ocv_include_directories(${INTELPERC_INCLUDE_DIR})
192 list(APPEND HIGHGUI_LIBRARIES ${INTELPERC_LIBRARIES})
193 endif(HAVE_INTELPERC)
196 add_definitions(-DHAVE_IOS=1)
197 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)
198 list(APPEND HIGHGUI_LIBRARIES "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreImage" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore" "-framework AssetsLibrary")
202 link_directories("${OpenCV_SOURCE_DIR}/3rdparty/lib") # for ffmpeg wrapper only
203 include_directories(AFTER SYSTEM "${OpenCV_SOURCE_DIR}/3rdparty/include") # for directshow in VS2005 and multi-monitor support on MinGW
204 include_directories(AFTER SYSTEM "${OpenCV_SOURCE_DIR}/3rdparty/include/ffmpeg_") # for tests
208 #these variables are set by CHECK_MODULE macro
209 foreach(P ${HIGHGUI_INCLUDE_DIRS})
210 ocv_include_directories(${P})
213 foreach(P ${HIGHGUI_LIBRARY_DIRS})
214 link_directories(${P})
218 source_group("Src" FILES ${highgui_srcs} ${highgui_hdrs})
219 source_group("Include" FILES ${highgui_ext_hdrs})
220 ocv_set_module_sources(HEADERS ${highgui_ext_hdrs} SOURCES ${highgui_srcs} ${highgui_hdrs})
221 ocv_module_include_directories()
223 ocv_create_module(${HIGHGUI_LIBRARIES})
226 ocv_check_flag_support(OBJCXX "-fobjc-exceptions" HAVE_OBJC_EXCEPTIONS)
227 if(HAVE_OBJC_EXCEPTIONS)
228 foreach(source ${OPENCV_MODULE_${the_module}_SOURCES})
229 if("${source}" MATCHES "\\.mm$")
230 get_source_file_property(flags "${source}" COMPILE_FLAGS)
232 set(flags "${_flags} -fobjc-exceptions")
234 set(flags "-fobjc-exceptions")
237 set_source_files_properties("${source}" PROPERTIES COMPILE_FLAGS "${flags}")
243 if(BUILD_SHARED_LIBS)
244 add_definitions(-DHIGHGUI_EXPORTS)
248 set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
251 #stop automatic dependencies propagation for this module
252 set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "")
254 ocv_add_precompiled_headers(${the_module})
255 ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
257 if(WIN32 AND WITH_FFMPEG)
258 #copy ffmpeg dll to the output folder
259 if(MSVC64 OR MINGW64)
260 set(FFMPEG_SUFFIX _64)
263 set(ffmpeg_bare_name "opencv_ffmpeg${FFMPEG_SUFFIX}.dll")
264 set(ffmpeg_bare_name_ver "opencv_ffmpeg${OPENCV_DLLVERSION}${FFMPEG_SUFFIX}.dll")
265 set(ffmpeg_path "${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/${ffmpeg_bare_name}")
268 add_custom_command(TARGET ${the_module} POST_BUILD
269 COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Release/${ffmpeg_bare_name_ver}"
270 COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Debug/${ffmpeg_bare_name_ver}"
271 COMMENT "Copying ${ffmpeg_path} to the output directory")
272 elseif(MSVC AND (CMAKE_GENERATOR MATCHES "Visual"))
273 add_custom_command(TARGET ${the_module} POST_BUILD
274 COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/${ffmpeg_bare_name_ver}"
275 COMMENT "Copying ${ffmpeg_path} to the output directory")
277 add_custom_command(TARGET ${the_module} POST_BUILD
278 COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${ffmpeg_bare_name_ver}"
279 COMMENT "Copying ${ffmpeg_path} to the output directory")
282 install(FILES "${ffmpeg_path}" DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs RENAME "${ffmpeg_bare_name_ver}")
285 ocv_add_accuracy_tests()