summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorDoris Verria <doris.verria@qt.io>2021-01-19 14:15:42 +0100
committerLars Knoll <lars.knoll@qt.io>2021-01-28 14:11:46 +0000
commitd4ab8c60a9ace4ca56d0babc7594fecaf17d9eab (patch)
treede697ffae093630c4c2858f82be8968f6f0e5f6c /cmake
parent79b6a7e5df28c7b2dbbf1270ce2f5a6b3d184fac (diff)
Add find modules for 3rd party libraries and fix CMake files
Detect gstreamer, avfoundation, pulseaudio, alsa, mmrenderer and wmf with cmake. Regenerate and adjust configure.cmake and CMakeLists.txt files accordingly. Change-Id: I550136909498d3870e0babd6294652774a718f64 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindAVFoundation.cmake11
-rw-r--r--cmake/FindGObject.cmake54
-rw-r--r--cmake/FindGSTREAMER.cmake140
-rw-r--r--cmake/FindMMRenderer.cmake26
-rw-r--r--cmake/FindWMF.cmake44
-rw-r--r--cmake/FindWrapPulseAudio.cmake32
6 files changed, 307 insertions, 0 deletions
diff --git a/cmake/FindAVFoundation.cmake b/cmake/FindAVFoundation.cmake
new file mode 100644
index 000000000..feefe3d77
--- /dev/null
+++ b/cmake/FindAVFoundation.cmake
@@ -0,0 +1,11 @@
+find_library(AVFoundation_LIBRARY NAMES AVFoundation)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(AVFoundation DEFAULT_MSG AVFoundation_LIBRARY)
+
+if(AVFoundation_FOUND AND NOT TARGET AVFoundation::AVFoundation)
+ add_library(AVFoundation::AVFoundation INTERFACE IMPORTED)
+ set_target_properties(AVFoundation::AVFoundation PROPERTIES
+ INTERFACE_LINK_LIBRARIES "${AVFoundation_LIBRARY}")
+endif()
+
+mark_as_advanced(AVFoundation_LIBRARY)
diff --git a/cmake/FindGObject.cmake b/cmake/FindGObject.cmake
new file mode 100644
index 000000000..0880665fd
--- /dev/null
+++ b/cmake/FindGObject.cmake
@@ -0,0 +1,54 @@
+# FindGObject
+# ---------
+#
+# Try to locate the gobject-2.0 library.
+# If found, this will define the following variables:
+#
+# ``GObject_FOUND``
+# True if the gobject-2.0 library is available
+#
+# If ``GObject_FOUND`` is TRUE, it will also define the following
+# imported target:
+#
+# ``GObject::GObject``
+# The gobject-2.0 library
+
+include(CMakeFindDependencyMacro)
+find_dependency(GLIB2)
+
+if(NOT TARGET GObject::GObject)
+ find_package(PkgConfig QUIET)
+ pkg_check_modules(PC_GOBJECT gobject-2.0 IMPORTED_TARGET)
+ if (TARGET PkgConfig::PC_GOBJECT)
+ add_library(GObject::GObject INTERFACE IMPORTED)
+ target_link_libraries(GObject::GObject INTERFACE
+ PkgConfig::PC_GOBJECT
+ GLIB2::GLIB2
+ )
+ else()
+ find_path(GGObject_INCLUDE_DIR
+ NAMES gobject.h
+ PATH_SUFFIXES glib-2.0/gobject/
+ )
+ find_library(GObject_LIBRARY NAMES gobject-2.0)
+ if (GObject_LIBRARY AND GObject_INCLUDE_DIR)
+ add_library(GObject::GObject IMPORTED)
+ target_include_directories(GObject::GObject INTERFACE
+ ${GObject_INCLUDE_DIR}
+ )
+ target_link_libraries(GObject::GObject INTERFACE
+ ${GObject_LIBRARY}
+ GLIB2::GLIB2
+ )
+ endif()
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(GObject REQUIRED_VARS
+ GObject_LIBRARY
+ GObject_INCLUDE_DIR
+ )
+ endif()
+endif()
+
+if(TARGET GObject::GObject)
+ set(GObject_FOUND TRUE)
+endif()
diff --git a/cmake/FindGSTREAMER.cmake b/cmake/FindGSTREAMER.cmake
new file mode 100644
index 000000000..ef9edd485
--- /dev/null
+++ b/cmake/FindGSTREAMER.cmake
@@ -0,0 +1,140 @@
+# FindGStreamer
+# ---------
+#
+# Locate the gstreamer-1.0 library and some of its plugins.
+# Defines the following imported target:
+#
+# ``GStreamer::GStreamer``
+# If the gstreamer-1.0 library is available and target GStreamer::Base,
+# GStreamer::Audio, GStreamer::Video, GStreamer::Pbutils and
+# GStreamer::Allocators exist
+#
+# If target GStreamer::GStreamer exists, the following targets may be defined:
+#
+# ``GStreamer::App``
+# If the gstapp-1.0 library is available and target GStreamer::GStreamer exists
+# ``GStreamer::Photography``
+# If the gstphotography-1.0 library is available and target GStreamer::GStreamer exists
+# ``GStreamer::Gl``
+# If the gstgl-1.0 library is available and target GStreamer::GStreamer exists
+#
+
+include(CMakeFindDependencyMacro)
+find_dependency(GObject)
+
+find_package(PkgConfig QUIET)
+function(find_gstreamer_component component prefix header library)
+ if(NOT TARGET GStreamer::${component})
+ string(TOUPPER ${component} upper)
+ pkg_check_modules(PC_GSTREAMER_${upper} ${prefix} IMPORTED_TARGET)
+ if(TARGET PkgConfig::PC_GSTREAMER_${upper})
+ add_library(GStreamer::${component} INTERFACE IMPORTED)
+ target_link_libraries(GStreamer::${component} INTERFACE PkgConfig::PC_GSTREAMER_${upper})
+ else()
+ find_path(GStreamer_${component}_INCLUDE_DIR
+ NAMES ${header}
+ PATH_SUFFIXES gstreamer-1.0
+ )
+ find_library(GStreamer_${component}_LIBRARY
+ NAMES ${library}
+ )
+ if(${component} STREQUAL "Gl")
+ # search the gstglconfig.h include dir under the same root where the library is found
+ get_filename_component(gstglLibDir "${GStreamer_Gl_LIBRARY}" PATH)
+ find_path(GStreamer_GlConfig_INCLUDE_DIR
+ NAMES gst/gl/gstglconfig.h
+ PATH_SUFFIXES gstreamer-1.0/include
+ HINTS ${PC_GSTREAMER_GL_INCLUDE_DIRS} ${PC_GSTREAMER_GL_INCLUDEDIR} "${gstglLibDir}"
+ )
+ if(GStreamer_GlConfig_INCLUDE_DIR)
+ list(APPEND GStreamer_Gl_INCLUDE_DIR "${GStreamer_GlConfig_INCLUDE_DIR}")
+ list(REMOVE_DUPLICATES GStreamer_Gl_INCLUDE_DIR)
+ endif()
+ endif()
+ if(GStreamer_${component}_LIBRARY AND GStreamer_${component}_INCLUDE_DIR)
+ add_library(GStreamer::${component} INTERFACE IMPORTED)
+ target_include_directories(GStreamer::${component} INTERFACE GStreamer_${component}_INCLUDE_DIR)
+ target_link_libraries(GStreamer::${component} INTERFACE GStreamer_${component}_LIBRARY)
+ endif()
+ mark_as_advanced(GStreamer_${component}_INCLUDE_DIR GStreamer_${component}_LIBRARY)
+ endif()
+ endif()
+
+ if(TARGET GStreamer::${component})
+ set(GStreamer_${component}_FOUND TRUE PARENT_SCOPE)
+ endif()
+endfunction()
+
+# GStreamer required dependencies
+find_gstreamer_component(Core gstreamer-1.0 gst/gst.h gstreamer-1.0)
+find_gstreamer_component(Base gstreamer-base-1.0 gst/gst.h gstbase-1.0)
+find_gstreamer_component(Audio gstreamer-audio-1.0 gst/audio/audio.h gstaudio-1.0)
+find_gstreamer_component(Video gstreamer-video-1.0 gst/video/video.h gstvideo-1.0)
+find_gstreamer_component(Pbutils gstreamer-pbutils-1.0 gst/pbutils/pbutils.h gstpbutils-1.0)
+find_gstreamer_component(Allocators gstreamer-allocators-1.0 gst/allocators/allocators.h gstallocators-1.0)
+
+if(TARGET GStreamer::Core)
+ target_link_libraries(GStreamer::Core INTERFACE GObject::GObject)
+endif()
+if(TARGET GStreamer::Base AND TARGET GStreamer::Core)
+ target_link_libraries(GStreamer::Base INTERFACE GStreamer::Core)
+endif()
+if(TARGET GStreamer::Audio AND TARGET GStreamer::Base)
+ target_link_libraries(GStreamer::Audio INTERFACE GStreamer::Base)
+endif()
+if(TARGET GStreamer::Video AND TARGET GStreamer::Base)
+ target_link_libraries(GStreamer::Video INTERFACE GStreamer::Base)
+endif()
+if(TARGET GStreamer::Pbutils AND TARGET GStreamer::Audio AND TARGET GStreamer::Video)
+ target_link_libraries(GStreamer::Pbutils INTERFACE GStreamer::Audio GStreamer::Video)
+endif()
+if(TARGET GStreamer::Allocators AND TARGET GStreamer::Core)
+ target_link_libraries(GStreamer::Allocators INTERFACE GStreamer::Core)
+endif()
+
+# GStreamer optional components
+foreach(component ${GStreamer_FIND_COMPONENTS})
+ if (${component} STREQUAL "App")
+ find_gstreamer_component(App gstreamer-app-1.0 gst/app/gstappsink.h gstapp-1.0)
+ if(TARGET GStreamer::App AND TARGET GStreamer::Base)
+ target_link_libraries(GStreamer::App INTERFACE GStreamer::Base)
+ endif()
+ elseif (${component} STREQUAL "Photography")
+ find_gstreamer_component(Photography gstreamer-photography-1.0 gst/interfaces/photography.h gstphotography-1.0)
+ if(TARGET GStreamer::Photography AND TARGET GStreamer::Core)
+ target_link_libraries(GStreamer::Photography INTERFACE GStreamer::Core)
+ endif()
+ elseif (${component} STREQUAL "Gl")
+ find_gstreamer_component(Gl gstreamer-gl-1.0 gst/gl/gl.h gstgl-1.0)
+ if(TARGET GStreamer::Gl AND TARGET GStreamer::Video AND TARGET GStreamer::Allocators)
+ target_link_libraries(GStreamer::Gl INTERFACE GStreamer::Video GStreamer::Allocators)
+ endif()
+ else()
+ message(WARNING "FindGStreamer.cmake: Invalid Gstreamer component \"${component}\" requested")
+ endif()
+endforeach()
+
+# Create target GStreamer::GStreamer
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GStreamer
+ REQUIRED_VARS
+ GStreamer_Core_FOUND
+ GStreamer_Base_FOUND
+ GStreamer_Audio_FOUND
+ GStreamer_Video_FOUND
+ GStreamer_Pbutils_FOUND
+ GStreamer_Allocators_FOUND
+ HANDLE_COMPONENTS
+)
+
+if(GStreamer_FOUND AND NOT TARGET GStreamer::GStreamer)
+ add_library(GStreamer::GStreamer INTERFACE IMPORTED)
+ target_link_libraries(GStreamer::GStreamer INTERFACE
+ GStreamer::Core
+ GStreamer::Base
+ GStreamer::Audio
+ GStreamer::Video
+ GStreamer::Pbutils
+ GStreamer::Allocators
+ )
+endif()
diff --git a/cmake/FindMMRenderer.cmake b/cmake/FindMMRenderer.cmake
new file mode 100644
index 000000000..dcc66c3d6
--- /dev/null
+++ b/cmake/FindMMRenderer.cmake
@@ -0,0 +1,26 @@
+# FindMMRenderer
+# ---------
+#
+# Try to locate the mm-renderer library.
+# If found, this will define the following variables:
+#
+# ``MMRenderer_FOUND``
+# True if the mm-renderer library is available
+# ``MMRenderer_LIBRARY``
+# The mm-renderer library
+#
+# If ``MMRenderer_FOUND`` is TRUE, it will also define the following
+# imported target:
+#
+# ``MMRenderer::MMRenderer``
+# The mm-renderer library to link to
+
+find_library(MMRenderer_LIBRARY NAMES mm-renderer)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(MMRenderer DEFAULT_MSG MMRenderer_LIBRARY)
+if(MMRenderer_FOUND AND NOT TARGET MMRenderer::MMRenderer)
+ add_library(MMRenderer::MMRenderer INTERFACE IMPORTED)
+ target_link_libraries(MMRenderer::MMRenderer
+ INTERFACE ${MMRenderer_LIBRARY})
+endif()
+mark_as_advanced(MMRenderer_LIBRARY)
diff --git a/cmake/FindWMF.cmake b/cmake/FindWMF.cmake
new file mode 100644
index 000000000..5ace0923f
--- /dev/null
+++ b/cmake/FindWMF.cmake
@@ -0,0 +1,44 @@
+# FindWMF
+# ---------
+#
+# Try to locate the Windows Media Foundation library.
+# If found, this will define the following variables:
+#
+# ``WMF_FOUND``
+# True if Windows Media Foundation is available
+# ``WMF_LIBRARIES``
+# The Windows Media Foundation set of libraries
+#
+# If ``WMF_FOUND`` is TRUE, it will also define the following
+# imported target:
+#
+# ``WMF::WMF``
+# The Windows Media Foundation library to link to
+
+find_library(WMF_STMIIDS_LIBRARY strmiids)
+find_library(WMF_DMOGUIDS_LIBRARY dmoguids)
+find_library(WMF_UUID_LIBRARY uuid)
+find_library(WMF_MSDMO_LIBRARY msdmo)
+find_library(WMF_OLE32_LIBRARY ole32)
+find_library(WMF_OLEAUT32_LIBRARY oleaut32)
+find_library(WMF_MF_LIBRARY Mf)
+find_library(WMF_MFUUID_LIBRARY Mfuuid)
+find_library(WMF_MFPLAT_LIBRARY Mfplat)
+find_library(WMF_PROPSYS_LIBRARY Propsys)
+
+set(WMF_LIBRARIES ${WMF_STMIIDS_LIBRARY} ${WMF_DMOGUIDS_LIBRARY} ${WMF_UUID_LIBRARY} ${WMF_MSDMO_LIBRARY}
+ ${WMF_OLE32_LIBRARY} ${WMF_OLEAUT32_LIBRARY} ${WMF_MF_LIBRARY}
+ ${WMF_MFUUID_LIBRARY} ${WMF_MFPLAT_LIBRARY} ${WMF_PROPSYS_LIBRARY})
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(WMF REQUIRED_VARS
+ WMF_STMIIDS_LIBRARY WMF_DMOGUIDS_LIBRARY WMF_UUID_LIBRARY WMF_MSDMO_LIBRARY
+ WMF_OLE32_LIBRARY WMF_OLEAUT32_LIBRARY WMF_MF_LIBRARY
+ WMF_MFUUID_LIBRARY WMF_MFPLAT_LIBRARY WMF_PROPSYS_LIBRARY)
+
+if(WMF_FOUND AND NOT TARGET WMF::WMF)
+ add_library(WMF::WMF INTERFACE IMPORTED)
+ set_target_properties(WMF::WMF PROPERTIES
+ INTERFACE_LINK_LIBRARIES "${WMF_LIBRARIES}")
+endif()
+
+mark_as_advanced(WMF_LIBRARIES)
diff --git a/cmake/FindWrapPulseAudio.cmake b/cmake/FindWrapPulseAudio.cmake
new file mode 100644
index 000000000..67fb7401d
--- /dev/null
+++ b/cmake/FindWrapPulseAudio.cmake
@@ -0,0 +1,32 @@
+# FindWrapPulseAudio
+# ---------
+#
+# Try to locate the pulseaudio library.
+# If found, this will define the following variables:
+#
+# ``WrapPulseAudio_FOUND``
+# True if the pulseaudio library is available
+#
+# If ``WrapPulseAduio_FOUND`` is TRUE, it will also define the following
+# imported target:
+#
+# ``WrapPulseAudio::WrapPulseAudio``
+# The pulseaudio library to link to
+
+if(TARGET WrapPulseAudio::WrapPulseAudio)
+ set(WrapPulseAudio_FOUND ON)
+ return()
+endif()
+find_package(PulseAudio QUIET)
+if(PulseAudio_FOUND)
+ set(WrapPulseAudio_FOUND 1)
+endif()
+if(WrapPulseAudio_FOUND AND NOT TARGET WrapPulseAudio::WrapPulseAudio)
+ add_library(WrapPulseAudio::WrapPulseAudio INTERFACE IMPORTED)
+ target_include_directories(WrapPulseAudio::WrapPulseAudio INTERFACE "${PULSEAUDIO_INCLUDE_DIR}")
+ target_link_libraries(WrapPulseAudio::WrapPulseAudio
+ INTERFACE "${PULSEAUDIO_LIBRARY}")
+endif()
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(WrapPulseAudio REQUIRED_VARS
+ PULSEAUDIO_LIBRARY PULSEAUDIO_INCLUDE_DIR WrapPulseAudio_FOUND)