From ceda0dcf5e0ba5b1172cdcd953446d2d1c72e4be Mon Sep 17 00:00:00 2001 From: Holden Date: Sun, 6 Oct 2024 01:34:33 -0400 Subject: [PATCH] CMake: GStreamer Setup Improvements --- CMakeLists.txt | 10 +- android/src/AndroidInit.cpp | 2 +- cmake/FindFFMPEG.cmake | 195 --------- cmake/Qt6QGCConfiguration.cmake | 4 + .../ECMFindModuleHelpersStub.cmake | 1 + cmake/find-modules/FindEGL.cmake | 151 +++++++ cmake/find-modules/FindFFmpeg.cmake | 384 ++++++++++++++++++ cmake/find-modules/FindGLESv2.cmake | 87 ++++ cmake/find-modules/FindGLIB2.cmake | 151 +++++++ cmake/find-modules/FindGObject.cmake | 58 +++ cmake/{ => find-modules}/FindGStreamer.cmake | 380 ++++++++++++++--- cmake/find-modules/FindQtWaylandScanner.cmake | 212 ++++++++++ cmake/find-modules/FindVAAPI.cmake | 60 +++ cmake/find-modules/FindWayland.cmake | 137 +++++++ cmake/find-modules/FindWaylandProtocols.cmake | 38 ++ cmake/find-modules/FindWaylandScanner.cmake | 183 +++++++++ cmake/find-modules/FindX11_XCB.cmake | 96 +++++ cmake/find-modules/FindXCB.cmake | 168 ++++++++ cmake/find-modules/FindXKB.cmake | 101 +++++ cmake/find-modules/FindXKB_COMMON_X11.cmake | 10 + cmake/modules/ECMFindModuleHelpers.cmake | 277 +++++++++++++ .../VideoReceiver/GStreamer/CMakeLists.txt | 3 - .../VideoReceiver/GStreamer/GStreamer.cc | 2 +- .../GStreamer/gstqml6gl/CMakeLists.txt | 331 +++++---------- tools/setup/install-dependencies-debian.sh | 10 +- 25 files changed, 2549 insertions(+), 502 deletions(-) delete mode 100644 cmake/FindFFMPEG.cmake create mode 100644 cmake/find-modules/ECMFindModuleHelpersStub.cmake create mode 100644 cmake/find-modules/FindEGL.cmake create mode 100644 cmake/find-modules/FindFFmpeg.cmake create mode 100644 cmake/find-modules/FindGLESv2.cmake create mode 100644 cmake/find-modules/FindGLIB2.cmake create mode 100644 cmake/find-modules/FindGObject.cmake rename cmake/{ => find-modules}/FindGStreamer.cmake (62%) create mode 100644 cmake/find-modules/FindQtWaylandScanner.cmake create mode 100644 cmake/find-modules/FindVAAPI.cmake create mode 100644 cmake/find-modules/FindWayland.cmake create mode 100644 cmake/find-modules/FindWaylandProtocols.cmake create mode 100644 cmake/find-modules/FindWaylandScanner.cmake create mode 100644 cmake/find-modules/FindX11_XCB.cmake create mode 100644 cmake/find-modules/FindXCB.cmake create mode 100644 cmake/find-modules/FindXKB.cmake create mode 100644 cmake/find-modules/FindXKB_COMMON_X11.cmake create mode 100644 cmake/modules/ECMFindModuleHelpers.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index c3a021ef929..2b62b191958 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.22.1) -list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) +list(APPEND CMAKE_MODULE_PATH + ${CMAKE_SOURCE_DIR}/cmake + ${CMAKE_SOURCE_DIR}/cmake/modules + ${CMAKE_SOURCE_DIR}/cmake/find-modules +) ####################################################### # Custom Build Configuration @@ -106,6 +110,10 @@ endif() set(BUILD_SHARED_LIBS OFF) +if(CMAKE_BUILD_TYPE STREQUAL "Release") + add_compile_definitions(QGC_INSTALL_RELEASE) +endif() + ####################################################### # Qt6 Configuration ####################################################### diff --git a/android/src/AndroidInit.cpp b/android/src/AndroidInit.cpp index 7bde5cec4d7..b1833df3bd7 100644 --- a/android/src/AndroidInit.cpp +++ b/android/src/AndroidInit.cpp @@ -16,7 +16,7 @@ static jobject _class_loader = nullptr; #ifdef QGC_GST_STREAMING extern "C" { - void gst_amc_jni_set_java_vm(JavaVM *java_vm); + extern void gst_amc_jni_set_java_vm(JavaVM *java_vm); jobject gst_android_get_application_class_loader(void) { diff --git a/cmake/FindFFMPEG.cmake b/cmake/FindFFMPEG.cmake deleted file mode 100644 index f727ef2dddf..00000000000 --- a/cmake/FindFFMPEG.cmake +++ /dev/null @@ -1,195 +0,0 @@ -#[==[ -Provides the following variables: - - * `FFMPEG_INCLUDE_DIRS`: Include directories necessary to use FFMPEG. - * `FFMPEG_LIBRARIES`: Libraries necessary to use FFMPEG. Note that this only - includes libraries for the components requested. - * `FFMPEG_VERSION`: The version of FFMPEG found. - -The following components are supported: - - * `avcodec` - * `avdevice` - * `avfilter` - * `avformat` - * `avresample` - * `avutil` - * `swresample` - * `swscale` - -For each component, the following are provided: - - * `FFMPEG__FOUND`: Libraries for the component. - * `FFMPEG__INCLUDE_DIRS`: Include directories for - the component. - * `FFMPEG__LIBRARIES`: Libraries for the component. - * `FFMPEG::`: A target to use with `target_link_libraries`. - -Note that only components requested with `COMPONENTS` or `OPTIONAL_COMPONENTS` -are guaranteed to set these variables or provide targets. -#]==] - -function (_ffmpeg_find component headername) - find_path("FFMPEG_${component}_INCLUDE_DIR" - NAMES - "lib${component}/${headername}" - PATHS - "${FFMPEG_ROOT}/include" - ~/Library/Frameworks - /Library/Frameworks - /usr/local/include - /usr/include - /sw/include # Fink - /opt/local/include # DarwinPorts - /opt/csw/include # Blastwave - /opt/include - /usr/freeware/include - PATH_SUFFIXES - ffmpeg - DOC "FFMPEG's ${component} include directory") - mark_as_advanced("FFMPEG_${component}_INCLUDE_DIR") - - # On Windows, static FFMPEG is sometimes built as `lib.a`. - if (WIN32) - list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".lib") - list(APPEND CMAKE_FIND_LIBRARY_PREFIXES "" "lib") - endif () - - find_library("FFMPEG_${component}_LIBRARY" - NAMES - "${component}" - PATHS - "${FFMPEG_ROOT}/lib" - ~/Library/Frameworks - /Library/Frameworks - /usr/local/lib - /usr/local/lib64 - /usr/lib - /usr/lib64 - /sw/lib - /opt/local/lib - /opt/csw/lib - /opt/lib - /usr/freeware/lib64 - "${FFMPEG_ROOT}/bin" - DOC "FFMPEG's ${component} library") - mark_as_advanced("FFMPEG_${component}_LIBRARY") - - if (FFMPEG_${component}_LIBRARY AND FFMPEG_${component}_INCLUDE_DIR) - set(_deps_found TRUE) - set(_deps_link) - foreach (_ffmpeg_dep IN LISTS ARGN) - if (TARGET "FFMPEG::${_ffmpeg_dep}") - list(APPEND _deps_link "FFMPEG::${_ffmpeg_dep}") - else () - set(_deps_found FALSE) - endif () - endforeach () - if (_deps_found) - if (NOT TARGET "FFMPEG::${component}") - add_library("FFMPEG::${component}" UNKNOWN IMPORTED) - set_target_properties("FFMPEG::${component}" PROPERTIES - IMPORTED_LOCATION "${FFMPEG_${component}_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${FFMPEG_${component}_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LIBRARIES "${_deps_link}") - endif () - set("FFMPEG_${component}_FOUND" 1 - PARENT_SCOPE) - - set(version_header_path "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h") - if (EXISTS "${version_header_path}") - string(TOUPPER "${component}" component_upper) - file(STRINGS "${version_header_path}" version - REGEX "#define *LIB${component_upper}_VERSION_(MAJOR|MINOR|MICRO) ") - string(REGEX REPLACE ".*_MAJOR *\([0-9]*\).*" "\\1" major "${version}") - string(REGEX REPLACE ".*_MINOR *\([0-9]*\).*" "\\1" minor "${version}") - string(REGEX REPLACE ".*_MICRO *\([0-9]*\).*" "\\1" micro "${version}") - if (NOT major STREQUAL "" AND - NOT minor STREQUAL "" AND - NOT micro STREQUAL "") - set("FFMPEG_${component}_VERSION" "${major}.${minor}.${micro}" - PARENT_SCOPE) - endif () - endif () - else () - set("FFMPEG_${component}_FOUND" 0 - PARENT_SCOPE) - set(what) - if (NOT FFMPEG_${component}_LIBRARY) - set(what "library") - endif () - if (NOT FFMPEG_${component}_INCLUDE_DIR) - if (what) - string(APPEND what " or headers") - else () - set(what "headers") - endif () - endif () - set("FFMPEG_${component}_NOT_FOUND_MESSAGE" - "Could not find the ${what} for ${component}." - PARENT_SCOPE) - endif () - endif () -endfunction () - -_ffmpeg_find(avutil avutil.h) -_ffmpeg_find(avresample avresample.h - avutil) -_ffmpeg_find(swresample swresample.h - avutil) -_ffmpeg_find(swscale swscale.h - avutil) -_ffmpeg_find(avcodec avcodec.h - avutil) -_ffmpeg_find(avformat avformat.h - avcodec avutil) -_ffmpeg_find(avfilter avfilter.h - avutil) -_ffmpeg_find(avdevice avdevice.h - avformat avutil) - -if (TARGET FFMPEG::avutil) - set(_ffmpeg_version_header_path "${FFMPEG_avutil_INCLUDE_DIR}/libavutil/ffversion.h") - if (EXISTS "${_ffmpeg_version_header_path}") - file(STRINGS "${_ffmpeg_version_header_path}" _ffmpeg_version - REGEX "FFMPEG_VERSION") - string(REGEX REPLACE ".*\"n?\(.*\)\"" "\\1" FFMPEG_VERSION "${_ffmpeg_version}") - unset(_ffmpeg_version) - else () - set(FFMPEG_VERSION FFMPEG_VERSION-NOTFOUND) - endif () - unset(_ffmpeg_version_header_path) -endif () - -set(FFMPEG_INCLUDE_DIRS) -set(FFMPEG_LIBRARIES) -set(_ffmpeg_required_vars) -foreach (_ffmpeg_component IN LISTS FFMPEG_FIND_COMPONENTS) - if (TARGET "FFMPEG::${_ffmpeg_component}") - set(FFMPEG_${_ffmpeg_component}_INCLUDE_DIRS - "${FFMPEG_${_ffmpeg_component}_INCLUDE_DIR}") - set(FFMPEG_${_ffmpeg_component}_LIBRARIES - "${FFMPEG_${_ffmpeg_component}_LIBRARY}") - list(APPEND FFMPEG_INCLUDE_DIRS - "${FFMPEG_${_ffmpeg_component}_INCLUDE_DIRS}") - list(APPEND FFMPEG_LIBRARIES - "${FFMPEG_${_ffmpeg_component}_LIBRARIES}") - if (FFMEG_FIND_REQUIRED_${_ffmpeg_component}) - list(APPEND _ffmpeg_required_vars - "FFMPEG_${_ffmpeg_required_vars}_INCLUDE_DIRS" - "FFMPEG_${_ffmpeg_required_vars}_LIBRARIES") - endif () - endif () -endforeach () -unset(_ffmpeg_component) - -if (FFMPEG_INCLUDE_DIRS) - list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS) -endif () - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(FFMPEG - REQUIRED_VARS FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES ${_ffmpeg_required_vars} - VERSION_VAR FFMPEG_VERSION - HANDLE_COMPONENTS) -unset(_ffmpeg_required_vars) diff --git a/cmake/Qt6QGCConfiguration.cmake b/cmake/Qt6QGCConfiguration.cmake index a170f4f4399..f00bcf3ad39 100644 --- a/cmake/Qt6QGCConfiguration.cmake +++ b/cmake/Qt6QGCConfiguration.cmake @@ -54,3 +54,7 @@ endif() include(CMakePrintHelpers) cmake_print_variables(QT_VERSION QT_MKSPEC QT_LIBRARY_HINTS) + +# if(ANDROID) + # set(ENV{PKG_CONFIG_SYSROOT_DIR} ${CMAKE_SYSROOT}) +# endif() diff --git a/cmake/find-modules/ECMFindModuleHelpersStub.cmake b/cmake/find-modules/ECMFindModuleHelpersStub.cmake new file mode 100644 index 00000000000..bb8c9a62fc6 --- /dev/null +++ b/cmake/find-modules/ECMFindModuleHelpersStub.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/../modules/ECMFindModuleHelpers.cmake) diff --git a/cmake/find-modules/FindEGL.cmake b/cmake/find-modules/FindEGL.cmake new file mode 100644 index 00000000000..747901b3a94 --- /dev/null +++ b/cmake/find-modules/FindEGL.cmake @@ -0,0 +1,151 @@ +# SPDX-FileCopyrightText: 2014 Alex Merry +# SPDX-FileCopyrightText: 2014 Martin Gräßlin +# +# SPDX-License-Identifier: BSD-3-Clause + +#[=======================================================================[.rst: +FindEGL +------- + +Try to find EGL. + +This will define the following variables: + +``EGL_FOUND`` + True if (the requested version of) EGL is available +``EGL_VERSION`` + The version of EGL; note that this is the API version defined in the + headers, rather than the version of the implementation (eg: Mesa) +``EGL_LIBRARIES`` + This can be passed to target_link_libraries() instead of the ``EGL::EGL`` + target +``EGL_INCLUDE_DIRS`` + This should be passed to target_include_directories() if the target is not + used for linking +``EGL_DEFINITIONS`` + This should be passed to target_compile_options() if the target is not + used for linking + +If ``EGL_FOUND`` is TRUE, it will also define the following imported target: + +``EGL::EGL`` + The EGL library + +In general we recommend using the imported target, as it is easier to use. +Bear in mind, however, that if the target is in the link interface of an +exported library, it must be made available by the package config file. + +Since pre-1.0.0. +#]=======================================================================] + +include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) +include(CheckCXXSourceCompiles) +include(CMakePushCheckState) + +ecm_find_package_version_check(EGL) + +# Use pkg-config to get the directories and then use these values +# in the FIND_PATH() and FIND_LIBRARY() calls +find_package(PkgConfig QUIET) +pkg_check_modules(PKG_EGL QUIET egl) + +set(EGL_DEFINITIONS ${PKG_EGL_CFLAGS_OTHER}) + +find_path(EGL_INCLUDE_DIR + NAMES + EGL/egl.h + HINTS + ${PKG_EGL_INCLUDE_DIRS} +) +find_library(EGL_LIBRARY + NAMES + EGL + libEGL + HINTS + ${PKG_EGL_LIBRARY_DIRS} +) + +# NB: We do *not* use the version information from pkg-config, as that +# is the implementation version (eg: the Mesa version) +if(EGL_INCLUDE_DIR) + # egl.h has defines of the form EGL_VERSION_x_y for each supported + # version; so the header for EGL 1.1 will define EGL_VERSION_1_0 and + # EGL_VERSION_1_1. Finding the highest supported version involves + # finding all these defines and selecting the highest numbered. + file(READ "${EGL_INCLUDE_DIR}/EGL/egl.h" _EGL_header_contents) + string(REGEX MATCHALL + "[ \t]EGL_VERSION_[0-9_]+" + _EGL_version_lines + "${_EGL_header_contents}" + ) + unset(_EGL_header_contents) + foreach(_EGL_version_line ${_EGL_version_lines}) + string(REGEX REPLACE + "[ \t]EGL_VERSION_([0-9_]+)" + "\\1" + _version_candidate + "${_EGL_version_line}" + ) + string(REPLACE "_" "." _version_candidate "${_version_candidate}") + if(NOT DEFINED EGL_VERSION OR EGL_VERSION VERSION_LESS _version_candidate) + set(EGL_VERSION "${_version_candidate}") + endif() + endforeach() + unset(_EGL_version_lines) +endif() + +cmake_push_check_state(RESET) +list(APPEND CMAKE_REQUIRED_LIBRARIES "${EGL_LIBRARY}") +list(APPEND CMAKE_REQUIRED_INCLUDES "${EGL_INCLUDE_DIR}") + +check_cxx_source_compiles(" +#include + +int main(int argc, char *argv[]) { + EGLint x = 0; EGLDisplay dpy = 0; EGLContext ctx = 0; + eglDestroyContext(dpy, ctx); +}" HAVE_EGL) + +cmake_pop_check_state() + +set(required_vars EGL_INCLUDE_DIR HAVE_EGL) +if(NOT EMSCRIPTEN) + list(APPEND required_vars EGL_LIBRARY) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(EGL + FOUND_VAR + EGL_FOUND + REQUIRED_VARS + ${required_vars} + VERSION_VAR + EGL_VERSION +) + +if(EGL_FOUND AND NOT TARGET EGL::EGL) + if (EMSCRIPTEN) + add_library(EGL::EGL INTERFACE IMPORTED) + # Nothing further to be done, system include paths have headers and linkage is implicit. + else() + add_library(EGL::EGL UNKNOWN IMPORTED) + set_target_properties(EGL::EGL PROPERTIES + IMPORTED_LOCATION "${EGL_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${EGL_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}" + ) + endif() +endif() + +mark_as_advanced(EGL_LIBRARY EGL_INCLUDE_DIR HAVE_EGL) + +# compatibility variables +set(EGL_LIBRARIES ${EGL_LIBRARY}) +set(EGL_INCLUDE_DIRS ${EGL_INCLUDE_DIR}) +set(EGL_VERSION_STRING ${EGL_VERSION}) + +include(FeatureSummary) +set_package_properties(EGL PROPERTIES + URL "https://www.khronos.org/egl/" + DESCRIPTION "A platform-agnostic mechanism for creating rendering surfaces for use with other graphics libraries, such as OpenGL|ES and OpenVG." +) diff --git a/cmake/find-modules/FindFFmpeg.cmake b/cmake/find-modules/FindFFmpeg.cmake new file mode 100644 index 00000000000..27b49a2a509 --- /dev/null +++ b/cmake/find-modules/FindFFmpeg.cmake @@ -0,0 +1,384 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause +#.rst: +# FindFFmpeg +# ---------- +# +# Try to find the required ffmpeg components (default: AVFORMAT, AVUTIL, AVCODEC) +# +# Next variables can be used to hint FFmpeg libs search: +# +# :: +# +# PC__LIBRARY_DIRS +# PC_FFMPEG_LIBRARY_DIRS +# PC__INCLUDE_DIRS +# PC_FFMPEG_INCLUDE_DIRS +# +# Once done this will define +# +# :: +# +# FFMPEG_FOUND - System has the all required components. +# FFMPEG_INCLUDE_DIRS - Include directory necessary for using the required components headers. +# FFMPEG_LIBRARIES - Link these to use the required FFmpeg components. +# FFMPEG_LIBRARY_DIRS - Link directories +# FFMPEG_DEFINITIONS - Compiler switches required for using the required FFmpeg components. +# +# For each of the components it will additionally set. +# +# :: +# +# AVCODEC +# AVDEVICE +# AVFORMAT +# AVFILTER +# AVUTIL +# POSTPROC +# SWSCALE +# +# the following variables will be defined +# +# :: +# +# _FOUND - System has +# FFMPEG__FOUND - System has (as checked by FHSPA) +# _INCLUDE_DIRS - Include directory necessary for using the headers +# _LIBRARIES - Link these to use +# _LIBRARY_DIRS - Link directories +# _DEFINITIONS - Compiler switches required for using +# _VERSION - The components version +# +# the following import targets is created +# +# :: +# +# FFmpeg::FFmpeg - for all components +# FFmpeg:: - where in lower case (FFmpeg::avcodec) for each components +# +# Copyright (c) 2006, Matthias Kretz, +# Copyright (c) 2008, Alexander Neundorf, +# Copyright (c) 2011, Michael Jansen, +# Copyright (c) 2017, Alexander Drozdov, +# + +include(FindPackageHandleStandardArgs) + +# The default components were taken from a survey over other FindFFMPEG.cmake files +if (NOT FFmpeg_FIND_COMPONENTS) + set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL) +endif () + +if (QT_DEPLOY_FFMPEG AND BUILD_SHARED_LIBS) + set(shared_libs_desired TRUE) +endif() + +# finds FFmpeg libs, including symlinks, for the specified component. +macro(find_shared_libs_for_component _component) + # the searching pattern is pretty rough but it seems to be sufficient to gather dynamic libs + get_filename_component(name_we ${${_component}_LIBRARY} NAME_WE) + + if (WIN32) + get_filename_component(dir_name ${${_component}_LIBRARY_DIR} NAME) + if (${dir_name} STREQUAL "lib" AND EXISTS "${${_component}_LIBRARY_DIR}/../bin") + # llvm-mingv builds aux ffmpeg static libs like lib/libavutil.dll.a and cmake finds + # only them even though the folder bin/ contains proper *.dll and *.lib. + + string(REGEX REPLACE "^lib" "" name_we "${name_we}") + set(shared_lib_pattern "../bin/${name_we}*${CMAKE_SHARED_LIBRARY_SUFFIX}") + else() + set(shared_lib_pattern "${name_we}*${CMAKE_SHARED_LIBRARY_SUFFIX}") + endif() + + else() + set(shared_lib_pattern "${name_we}*${CMAKE_SHARED_LIBRARY_SUFFIX}*") + endif() + + file(GLOB ${_component}_SHARED_LIBRARIES "${${_component}_LIBRARY_DIR}/${shared_lib_pattern}") +endmacro() + +# +### Macro: set_component_found +# +# Marks the given component as found if both *_LIBRARY_NAME AND *_INCLUDE_DIRS is present. +# +macro(set_component_found _component) + if (${_component}_LIBRARY_NAME AND ${_component}_INCLUDE_DIR) + # message(STATUS " - ${_component} found.") + set(${_component}_FOUND TRUE) + set(${CMAKE_FIND_PACKAGE_NAME}_${_component}_FOUND TRUE) + else () + # message(STATUS " - ${_component} not found.") + endif () +endmacro() + +find_package(PkgConfig QUIET) +if (NOT PKG_CONFIG_FOUND AND NOT FFMPEG_DIR) + set(FFMPEG_DIR "/usr/local") +endif() +# +### Macro: find_component +# +# Checks for the given component by invoking pkgconfig and then looking up the libraries and +# include directories. +# +macro(find_component _component _pkgconfig _library _header) + + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + if (PKG_CONFIG_FOUND AND NOT FFMPEG_DIR) + pkg_check_modules(PC_${_component} ${_pkgconfig}) + endif () + + if (FFMPEG_DIR OR FFMPEG_ROOT) + set(__find_ffmpeg_backup_root_dir "${CMAKE_FIND_ROOT_PATH}") + endif() + + if(FFMPEG_DIR) + list(APPEND CMAKE_FIND_ROOT_PATH "${FFMPEG_DIR}") + endif() + + if(FFMPEG_ROOT) + list(APPEND CMAKE_FIND_ROOT_PATH "${FFMPEG_ROOT}") + endif() + + if (${_component}_INCLUDE_DIR AND NOT EXISTS ${${_component}_INCLUDE_DIR}) + message(STATUS "Cached include dir ${${_component}_INCLUDE_DIR} doesn't exist") + unset(${_component}_INCLUDE_DIR CACHE) + endif() + + find_path(${_component}_INCLUDE_DIR ${_header} + HINTS + ${PC_${_component}_INCLUDEDIR} + ${PC_${_component}_INCLUDE_DIRS} + ${PC_FFMPEG_INCLUDE_DIRS} + PATHS + ${FFMPEG_DIR} + PATH_SUFFIXES + ffmpeg include + ) + + if (shared_libs_desired AND NOT WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_SHARED_LIBRARY_SUFFIX};${CMAKE_STATIC_LIBRARY_SUFFIX}") + endif() + + if (${_component}_LIBRARY AND NOT EXISTS ${${_component}_LIBRARY}) + message(STATUS "Cached library ${${_component}_LIBRARY} doesn't exist") + unset(${_component}_LIBRARY CACHE) + endif() + + find_library(${_component}_LIBRARY + NAMES ${PC_${_component}_LIBRARIES} ${_library} + HINTS + ${PC_${_component}_LIBDIR} + ${PC_${_component}_LIBRARY_DIRS} + ${PC_FFMPEG_LIBRARY_DIRS} + PATHS + ${FFMPEG_DIR} + PATH_SUFFIXES + lib bin + ) + + if(FFMPEG_DIR OR FFMPEG_ROOT) + set(CMAKE_FIND_ROOT_PATH "${__find_ffmpeg_backup_root_dir}") + endif() + + if (${_component}_LIBRARY) + get_filename_component(${_component}_LIBRARY_DIR ${${_component}_LIBRARY} DIRECTORY) + get_filename_component(${_component}_LIBRARY_NAME ${${_component}_LIBRARY} NAME) + + # On Windows, shared linking goes through 'integration' static libs, so we should look for shared ones anyway + # On Unix, we gather symlinks as well so that we could install them. + if (WIN32 OR ${${_component}_LIBRARY_NAME} MATCHES "\\${CMAKE_SHARED_LIBRARY_SUFFIX}$") + find_shared_libs_for_component(${_component}) + endif() + + endif() + + set(${_component}_DEFINITIONS ${PC_${_component}_CFLAGS_OTHER}) + set_component_found(${_component}) + + mark_as_advanced(${_component}_LIBRARY) +endmacro() + +# Clear the previously cached variables, because they are recomputed every time +# the Find script is included. +unset(FFMPEG_INCLUDE_DIRS) +unset(FFMPEG_LIBRARIES) +unset(FFMPEG_SHARED_LIBRARIES) +unset(FFMPEG_DEFINITIONS) +unset(FFMPEG_LIBRARY_DIRS) + +# Check for components. +foreach (_component ${FFmpeg_FIND_COMPONENTS}) + string(TOLOWER ${_component} library) + find_component(${_component} "lib${library}" ${library} "lib${library}/${library}.h") + + if (${_component}_FOUND) + list(APPEND FFMPEG_LIBRARIES ${${_component}_LIBRARY_NAME}) + list(APPEND FFMPEG_DEFINITIONS ${${_component}_DEFINITIONS}) + list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIR}) + list(APPEND FFMPEG_LIBRARY_DIRS ${${_component}_LIBRARY_DIR}) + + if (${_component}_SHARED_LIBRARIES) + list(APPEND FFMPEG_SHARED_LIBRARIES ${${_component}_SHARED_LIBRARIES}) + list(APPEND FFMPEG_SHARED_COMPONENTS ${_component}) + else() + list(APPEND FFMPEG_STATIC_COMPONENTS ${_component}) + endif() + + mark_as_advanced(${_component}_LIBRARY_NAME ${_component}_DEFINITIONS ${_component}_INCLUDE_DIR + ${_component}_LIBRARY_DIR ${_component}_SHARED_LIBRARIES) + endif() +endforeach() + +if (NOT FFMPEG_SHARED_COMPONENTS AND (ANDROID OR LINUX)) + set(ENABLE_DYNAMIC_RESOLVE_OPENSSL_SYMBOLS TRUE CACHE INTERNAL "") +endif() + +set(ENABLE_DYNAMIC_RESOLVE_VAAPI_SYMBOLS ${LINUX} CACHE INTERNAL "") + +function(__try_add_dynamic_resolve_dependency dep added) + set(added TRUE PARENT_SCOPE) + + if(ENABLE_DYNAMIC_RESOLVE_OPENSSL_SYMBOLS AND + (${dep} STREQUAL "ssl" OR ${dep} STREQUAL "crypto")) + set(DYNAMIC_RESOLVE_OPENSSL_SYMBOLS TRUE CACHE INTERNAL "") + elseif(ENABLE_DYNAMIC_RESOLVE_VAAPI_SYMBOLS AND ${dep} STREQUAL "va") + set(DYNAMIC_RESOLVE_VAAPI_SYMBOLS TRUE CACHE INTERNAL "") + elseif(ENABLE_DYNAMIC_RESOLVE_VAAPI_SYMBOLS AND ${dep} STREQUAL "va-drm") + set(DYNAMIC_RESOLVE_VA_DRM_SYMBOLS TRUE CACHE INTERNAL "") + elseif(ENABLE_DYNAMIC_RESOLVE_VAAPI_SYMBOLS AND ${dep} STREQUAL "va-x11") + set(DYNAMIC_RESOLVE_VA_X11_SYMBOLS TRUE CACHE INTERNAL "") + else() + set(added FALSE PARENT_SCOPE) + endif() +endfunction() + +# Function parses package config file to find the static library dependencies +# and adds them to the target library. +function(__ffmpeg_internal_set_dependencies lib) + set(PC_FILE ${FFMPEG_DIR}/lib/pkgconfig/lib${lib}.pc) + if(EXISTS ${PC_FILE}) + file(READ ${PC_FILE} pcfile) + + set(prefix_l "(^| )\\-l") + set(suffix_lib "\\.lib($| )") + + string(REGEX REPLACE ".*Libs:([^\n\r]+).*" "\\1" out "${pcfile}") + string(REGEX MATCHALL "${prefix_l}[^ ]+" libs_dependency ${out}) + string(REGEX MATCHALL "[^ ]+${suffix_lib}" libs_dependency_lib ${out}) + + string(REGEX REPLACE ".*Libs.private:([^\n\r]+).*" "\\1" out "${pcfile}") + string(REGEX MATCHALL "${prefix_l}[^ ]+" libs_private_dependency ${out}) + string(REGEX MATCHALL "[^ ]+${suffix_lib}" libs_private_dependency_lib ${out}) + + list(APPEND deps_no_suffix ${libs_dependency} ${libs_private_dependency}) + foreach(dependency ${deps_no_suffix}) + string(REGEX REPLACE ${prefix_l} "" dependency ${dependency}) + if(NOT ${lib} STREQUAL ${dependency}) + __try_add_dynamic_resolve_dependency(${dependency} added) + if(NOT added) + target_link_libraries(FFmpeg::${lib} INTERFACE ${dependency}) + endif() + endif() + endforeach() + + list(APPEND deps_lib_suffix ${libs_dependency_lib} ${libs_private_dependency_lib}) + foreach(dependency ${deps_lib_suffix}) + string(REGEX REPLACE ${suffix_lib} "" dependency ${dependency}) + target_link_libraries(FFmpeg::${lib} INTERFACE ${dependency}) + endforeach() + endif() +endfunction() + +# Check for cached results. If there are skip the costly part. +#if (NOT FFMPEG_LIBRARIES) + + # Check if the required components were found and add their stuff to the FFMPEG_* vars. + + + foreach (_component ${FFmpeg_FIND_COMPONENTS}) + if (${_component}_FOUND) + string(TOLOWER ${_component} _lowerComponent) + if (NOT TARGET FFmpeg::${_lowerComponent}) + add_library(FFmpeg::${_lowerComponent} INTERFACE IMPORTED) + set_target_properties(FFmpeg::${_lowerComponent} PROPERTIES + INTERFACE_COMPILE_OPTIONS "${${_component}_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES ${${_component}_INCLUDE_DIR} + INTERFACE_LINK_LIBRARIES "${${_component}_LIBRARY_NAME}" + INTERFACE_LINK_DIRECTORIES "${${_component}_LIBRARY_DIR}" + ) + if(NOT ${_component}_SHARED_LIBRARIES) + __ffmpeg_internal_set_dependencies(${_lowerComponent}) + endif() + target_link_libraries(FFmpeg::${_lowerComponent} INTERFACE "${${_component}_LIBRARY_NAME}") + if (UNIX AND NOT APPLE) + target_link_options(FFmpeg::${_lowerComponent} INTERFACE "-Wl,--exclude-libs=lib${_lowerComponent}") + endif () + endif() + endif() + endforeach () + + # Build the include path with duplicates removed. + list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS) + list(REMOVE_DUPLICATES FFMPEG_LIBRARY_DIRS) + list(REMOVE_DUPLICATES FFMPEG_SHARED_LIBRARIES) + + message(STATUS "FFmpeg shared libs: ${FFMPEG_SHARED_LIBRARIES}") + + # cache the vars. + set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFmpeg include directories." FORCE) + set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFmpeg libraries." FORCE) + set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} CACHE STRING "The FFmpeg cflags." FORCE) + set(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBRARY_DIRS} CACHE STRING "The FFmpeg library dirs." FORCE) + set(FFMPEG_SHARED_LIBRARIES ${FFMPEG_SHARED_LIBRARIES} CACHE STRING "The FFmpeg dynamic libraries." FORCE) + + mark_as_advanced(FFMPEG_INCLUDE_DIRS + FFMPEG_LIBRARIES + FFMPEG_DEFINITIONS + FFMPEG_LIBRARY_DIRS + FFMPEG_SHARED_LIBRARIES + ) +# endif () + +list(LENGTH FFMPEG_LIBRARY_DIRS DIRS_COUNT) +if (${DIRS_COUNT} GREATER 1) + message(WARNING "One ffmpeg library dir is expected, found dirs: ${FFMPEG_LIBRARY_DIRS}") +endif() + +if(FFMPEG_SHARED_COMPONENTS AND FFMPEG_STATIC_COMPONENTS) + message(WARNING + "Only static or shared components are expected\n" + " static components: ${FFMPEG_STATIC_COMPONENTS}\n" + " shared components: ${FFMPEG_SHARED_COMPONENTS}") +endif() + +if (shared_libs_desired AND NOT FFMPEG_SHARED_COMPONENTS) + message(WARNING + "Shared FFmpeg libs are desired as QT_DEPLOY_FFMPEG=TRUE, but haven't been found!\n" + "Remove QT_DEPLOY_FFMPEG or set the proper path to shared FFmpeg via FFMPEG_DIR.") +endif() + +if (NOT TARGET FFmpeg::FFmpeg) + add_library(FFmpeg INTERFACE) + set_target_properties(FFmpeg PROPERTIES + INTERFACE_COMPILE_OPTIONS "${FFMPEG_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${FFMPEG_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${FFMPEG_LIBRARIES}" + INTERFACE_LINK_DIRECTORIES "${FFMPEG_LIBRARY_DIRS}" + ) + add_library(FFmpeg::FFmpeg ALIAS FFmpeg) +endif() + +# Compile the list of required vars +set(_FFmpeg_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS) +foreach (_component ${FFmpeg_FIND_COMPONENTS}) + list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARY ${_component}_INCLUDE_DIR) +endforeach () + +# Give a nice error message if some of the required vars are missing. +find_package_handle_standard_args(FFmpeg + REQUIRED_VARS ${_FFmpeg_REQUIRED_VARS} + HANDLE_COMPONENTS +) diff --git a/cmake/find-modules/FindGLESv2.cmake b/cmake/find-modules/FindGLESv2.cmake new file mode 100644 index 00000000000..4730418209a --- /dev/null +++ b/cmake/find-modules/FindGLESv2.cmake @@ -0,0 +1,87 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +include(CheckCXXSourceCompiles) + +# No library linkage is necessary to use GLESv2 with Emscripten. The headers are also +# system headers, so we don't need to search for them. +if(EMSCRIPTEN) + set(HAVE_GLESv2 ON) +else() + find_library(GLESv2_LIBRARY NAMES GLESv2 OpenGLES) + find_path(GLESv2_INCLUDE_DIR NAMES "GLES2/gl2.h" "OpenGLES/ES2/gl.h" DOC "The OpenGLES 2 include path") + find_package(EGL) + set(_libraries "${CMAKE_REQUIRED_LIBRARIES}") + if(GLESv2_LIBRARY) + list(APPEND CMAKE_REQUIRED_LIBRARIES "${GLESv2_LIBRARY}") + endif () + if(EGL_LIBRARY) + list(APPEND CMAKE_REQUIRED_LIBRARIES "${EGL_LIBRARY}") + endif() + if(_qt_igy_gui_libs) + list(APPEND CMAKE_REQUIRED_LIBRARIES "${_qt_igy_gui_libs}") + endif() + set(_includes "${CMAKE_REQUIRED_INCLUDES}") + list(APPEND CMAKE_REQUIRED_INCLUDES "${GLESv2_INCLUDE_DIR}") + + check_cxx_source_compiles(" +#ifdef __APPLE__ +# include +#else +# define GL_GLEXT_PROTOTYPES +# include +#endif + +int main(int, char **) { + glUniform1f(1, GLfloat(1.0)); + glClear(GL_COLOR_BUFFER_BIT); +}" HAVE_GLESv2) + + set(CMAKE_REQUIRED_LIBRARY "${_libraries}") + unset(_libraries) + set(CMAKE_REQUIRED_INCLUDES "${_includes}") + unset(_includes) + set(package_args GLESv2_INCLUDE_DIR GLESv2_LIBRARY HAVE_GLESv2) +endif() + +# Framework handling partially inspired by FindGLUT.cmake. +if(GLESv2_LIBRARY MATCHES "/([^/]+)\\.framework$") + # TODO: Might need to handle non .tbd suffixes, but didn't find an + # example like that. + # TODO: Might need to handle INTERFACE_INCLUDE_DIRECTORIES differently. + set(_library_imported_location "${GLESv2_LIBRARY}/${CMAKE_MATCH_1}.tbd") + if(NOT EXISTS "${_library_imported_location}") + set(_library_imported_location "") + endif() +else() + set(_library_imported_location "${GLESv2_LIBRARY}") +endif() +set(GLESv2_LIBRARY "${_library_imported_location}") + +list(APPEND package_args HAVE_GLESv2) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GLESv2 DEFAULT_MSG ${package_args}) + +mark_as_advanced(${package_args}) + +if(GLESv2_FOUND AND NOT TARGET GLESv2::GLESv2) + if(EMSCRIPTEN OR IOS) + add_library(GLESv2::GLESv2 INTERFACE IMPORTED) + if(IOS) + # For simulator_and_device builds we can't specify the full library path, because + # it's specific to either the device or the simulator. Resort to passing a link + # flag instead. + target_link_libraries(GLESv2::GLESv2 INTERFACE "-framework OpenGLES") + endif() + else() + add_library(GLESv2::GLESv2 UNKNOWN IMPORTED) + set_target_properties(GLESv2::GLESv2 PROPERTIES + IMPORTED_LOCATION "${GLESv2_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${GLESv2_INCLUDE_DIR}") + + if(EGL_LIBRARY) + target_link_libraries(GLESv2::GLESv2 INTERFACE "${EGL_LIBRARY}") + endif() + endif() +endif() diff --git a/cmake/find-modules/FindGLIB2.cmake b/cmake/find-modules/FindGLIB2.cmake new file mode 100644 index 00000000000..01d1c0cfe69 --- /dev/null +++ b/cmake/find-modules/FindGLIB2.cmake @@ -0,0 +1,151 @@ +# SPDX-FileCopyrightText: 2008 Laurent Montel +# +# SPDX-License-Identifier: BSD-3-Clause + + +#[=======================================================================[.rst: +FindGLIB2 +--------- + +Try to locate the GLib2 library. +If found, this will define the following variables: + +``GLIB2_FOUND`` + True if the GLib2 library is available +``GLIB2_INCLUDE_DIRS`` + The GLib2 include directories +``GLIB2_LIBRARIES`` + The GLib2 libraries for linking +``GLIB2_INCLUDE_DIR`` + Deprecated, use ``GLIB2_INCLUDE_DIRS`` +``GLIB2_LIBRARY`` + Deprecated, use ``GLIB2_LIBRARIES`` + +If ``GLIB2_FOUND`` is TRUE, it will also define the following +imported target: + +``GLIB2::GLIB2`` + The GLIB2 library +``GLIB2::GTHREAD2`` + The GThread2 library (since 6.7.0) +``GLIB2::GOBJECT`` + The GObject library (since 6.7.0) +``GLIB2::GIO`` + The GIO library (since 6.7.0) + +Since 5.41.0. +#]=======================================================================] + +find_package(PkgConfig QUIET) +pkg_check_modules(PC_GLIB2 QUIET glib-2.0) + +find_path(GLIB2_INCLUDE_DIRS + NAMES glib.h + HINTS ${PC_GLIB2_INCLUDEDIR} + PATH_SUFFIXES glib-2.0) + +find_library(GLIB2_LIBRARIES + NAMES glib-2.0 + HINTS ${PC_GLIB2_LIBDIR} +) + +pkg_check_modules(PC_GTHREAD2 QUIET gthread-2.0) + +find_library(GTHREAD2_LIBRARIES + NAMES gthread-2.0 + HINTS ${PC_GTHREAD2_LIBDIR} +) + +pkg_check_modules(PC_GOBJECT QUIET gobject-2.0) + +find_path(GLIB2_GOBJECT_INCLUDE_DIRS + NAMES glib-object.h + HINTS ${PC_GOBJECT_INCLUDEDIR} + PATH_SUFFIXES glib-2.0) + +find_library(GLIB2_GOBJECT_LIBRARIES + NAMES gobject-2.0 + HINTS ${PC_GOBJECT_LIBDIR} +) + +pkg_check_modules(PC_GIO QUIET gio-2.0) + +find_path(GLIB2_GIO_INCLUDE_DIRS + NAMES gio/gio.h + HINTS ${PC_GIO_INCLUDEDIR} + PATH_SUFFIXES glib-2.0) + +find_library(GLIB2_GIO_LIBRARIES + NAMES gio-2.0 + HINTS ${PC_GIO_LIBDIR} +) + +# search the glibconfig.h include dir under the same root where the library is found +get_filename_component(glib2LibDir "${GLIB2_LIBRARIES}" PATH) + +find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h + PATH_SUFFIXES glib-2.0/include + HINTS ${PC_GLIB2_INCLUDEDIR} "${glib2LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH}) + +# not sure if this include dir is optional or required +# for now it is optional +if(GLIB2_INTERNAL_INCLUDE_DIR) + list(APPEND GLIB2_INCLUDE_DIRS "${GLIB2_INTERNAL_INCLUDE_DIR}") + list(APPEND GLIB2_GOBJECT_INCLUDE_DIRS "${GLIB2_INTERNAL_INCLUDE_DIR}") + list(APPEND GLIB2_GIO_INCLUDE_DIRS "${GLIB2_INTERNAL_INCLUDE_DIR}") +endif() + +# Deprecated synonyms +set(GLIB2_INCLUDE_DIR "${GLIB2_INCLUDE_DIRS}") +set(GLIB2_LIBRARY "${GLIB2_LIBRARIES}") +set(GLIB2_GOBJECT_INCLUDE_DIR "${GLIB2_GOBJECT_INCLUDE_DIRS}") +set(GLIB2_GOBJECT_LIBRARY "${GLIB2_GOBJECT_LIBRARIES}") +set(GLIB2_GIO_INCLUDE_DIR "${GLIB2_GIO_INCLUDE_DIRS}") +set(GLIB2_GIO_LIBRARY "${GLIB2_GIO_LIBRARIES}") + +if(GLIB2_GOBJECT_LIBRARIES AND GLIB2_GOBJECT_INCLUDE_DIRS) + set(GLIB2_GOBJECT_FOUND TRUE) +endif() + +if(GLIB2_GIO_LIBRARIES AND GLIB2_GIO_INCLUDE_DIRS) + set(GLIB2_GIO_FOUND TRUE) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GLIB2 + REQUIRED_VARS GLIB2_LIBRARIES GTHREAD2_LIBRARIES GLIB2_INCLUDE_DIRS + HANDLE_COMPONENTS) + +if(GLIB2_FOUND AND NOT TARGET GLIB2::GLIB2) + add_library(GLIB2::GLIB2 UNKNOWN IMPORTED) + set_target_properties(GLIB2::GLIB2 PROPERTIES + IMPORTED_LOCATION "${GLIB2_LIBRARIES}" + INTERFACE_LINK_LIBRARIES "${GTHREAD2_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${GLIB2_INCLUDE_DIRS}") +endif() + +if(GLIB2_GOBJECT_FOUND AND NOT TARGET GLIB2::GOBJECT) + add_library(GLIB2::GOBJECT UNKNOWN IMPORTED) + set_target_properties(GLIB2::GOBJECT PROPERTIES + IMPORTED_LOCATION "${GLIB2_GOBJECT_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${GLIB2_GOBJECT_INCLUDE_DIRS}") +endif() + +if(GLIB2_GIO_FOUND AND NOT TARGET GLIB2::GIO) + add_library(GLIB2::GIO UNKNOWN IMPORTED) + set_target_properties(GLIB2::GIO PROPERTIES + IMPORTED_LOCATION "${GLIB2_GIO_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${GLIB2_GIO_INCLUDE_DIRS}") +endif() + +mark_as_advanced(GLIB2_INCLUDE_DIRS GLIB2_INCLUDE_DIR + GLIB2_LIBRARIES GLIB2_LIBRARY + GLIB2_GOBJECT_INCLUDE_DIRS GLIB2_GOBJECT_INCLUDE_DIR + GLIB2_GOBJECT_LIBRARIES GLIB2_GOBJECT_LIBRARY + GLIB2_GIO_INCLUDE_DIRS GLIB2_GIO_INCLUDE_DIR + GLIB2_GIO_LIBRARIES GLIB2_GIO_LIBRARY) + +include(FeatureSummary) +set_package_properties(GLIB2 PROPERTIES + URL "https://wiki.gnome.org/Projects/GLib" + DESCRIPTION "Event loop and utility library") diff --git a/cmake/find-modules/FindGObject.cmake b/cmake/find-modules/FindGObject.cmake new file mode 100644 index 00000000000..54dd35eadb7 --- /dev/null +++ b/cmake/find-modules/FindGObject.cmake @@ -0,0 +1,58 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# 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) +qt_internal_disable_find_package_global_promotion(GLIB2::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(GObject_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 INTERFACE 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/find-modules/FindGStreamer.cmake similarity index 62% rename from cmake/FindGStreamer.cmake rename to cmake/find-modules/FindGStreamer.cmake index ed0b86f947b..a7f9b9f23d9 100644 --- a/cmake/FindGStreamer.cmake +++ b/cmake/find-modules/FindGStreamer.cmake @@ -1,35 +1,6 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -# 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 -# - -################################################################################ - -if(ANDROID) - set(QGC_GST_STATIC_BUILD ON) - list(APPEND PKG_CONFIG_ARGN --static) -endif() - if(ANDROID OR IOS) + set(QGC_GST_STATIC_BUILD ON CACHE BOOL "Build GST Statically") + if(DEFINED ENV{GST_VERSION}) set(QGC_GST_TARGET_VERSION $ENV{GST_VERSION} CACHE STRING "Environment Provided GStreamer Version") else() @@ -37,6 +8,10 @@ if(ANDROID OR IOS) endif() endif() +if(QGC_GST_STATIC_BUILD) + list(APPEND PKG_CONFIG_ARGN --static) +endif() + ################################################################################ # NOTE: CMP0144 in regards to GSTREAMER_ROOT @@ -52,12 +27,8 @@ if(WIN32) find_program(PKG_CONFIG_PROGRAM pkg-config PATHS ${GSTREAMER_PREFIX}/bin) if(PKG_CONFIG_PROGRAM) set(PKG_CONFIG_EXECUTABLE ${PKG_CONFIG_PROGRAM}) - cmake_print_variables(PKG_CONFIG_EXECUTABLE) endif() set(ENV{PKG_CONFIG_PATH} "${GSTREAMER_PREFIX}/lib/pkgconfig;${GSTREAMER_PREFIX}/lib/gstreamer-1.0/pkgconfig;$ENV{PKG_CONFIG_PATH}") - # cmake_path(CONVERT "${GSTREAMER_PREFIX}/lib/pkgconfig;${GSTREAMER_PREFIX}/lib/gstreamer-1.0/pkgconfig;$ENV{PKG_CONFIG_PATH}" TO_NATIVE_PATH_LIST PKG_CONFIG_PATH NORMALIZE) - # cmake_print_variables(PKG_CONFIG_PATH) - # set(ENV{PKG_CONFIG_PATH} "${PKG_CONFIG_PATH}") cmake_path(CONVERT "${GSTREAMER_PREFIX}" TO_CMAKE_PATH_LIST PREFIX_PATH NORMALIZE) cmake_path(CONVERT "${GSTREAMER_PREFIX}/lib" TO_CMAKE_PATH_LIST LIBDIR_PATH NORMALIZE) cmake_path(CONVERT "${GSTREAMER_PREFIX}/include" TO_CMAKE_PATH_LIST INCLUDE_PATH NORMALIZE) @@ -67,37 +38,46 @@ if(WIN32) --define-variable=libdir=${LIBDIR_PATH} --define-variable=includedir=${INCLUDE_PATH} ) - cmake_print_variables(PKG_CONFIG_ARGN) elseif(MACOS) + list(APPEND CMAKE_FRAMEWORK_PATH "/Library/Frameworks") set(GSTREAMER_PREFIX "/Library/Frameworks/GStreamer.framework") set(ENV{PKG_CONFIG_PATH} "${GSTREAMER_PREFIX}/Versions/Current/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}") elseif(LINUX) set(GSTREAMER_PREFIX "/usr") set(ENV{PKG_CONFIG_PATH} "${GSTREAMER_PREFIX}/lib/pkgconfig:${GSTREAMER_PREFIX}/lib/x86_64-linux-gnu/pkgconfig:$ENV{PKG_CONFIG_PATH}") elseif(IOS) - set(GSTREAMER_PREFIX "~/Library/Developer/GStreamer/iPhone.sdk/GStreamer.framework") + list(APPEND CMAKE_FRAMEWORK_PATH "~/Library/Developer/GStreamer/iPhone.sdk") if(DEFINED ENV{GSTREAMER_PREFIX_IOS} AND EXISTS $ENV{GSTREAMER_PREFIX_IOS}) set(GSTREAMER_PREFIX_IOS $ENV{GSTREAMER_PREFIX_IOS}) + elseif(EXISTS "~/Library/Developer/GStreamer/iPhone.sdk/GStreamer.framework") + set(GSTREAMER_PREFIX_IOS "~/Library/Developer/GStreamer/iPhone.sdk/GStreamer.framework") else() FetchContent_Declare(gstreamer URL "https://gstreamer.freedesktop.org/data/pkg/ios/${QGC_GST_TARGET_VERSION}/gstreamer-1.0-devel-${QGC_GST_TARGET_VERSION}-ios-universal.pkg" - DOWNLOAD_EXTRACT_TIMESTAMP true ) FetchContent_MakeAvailable(gstreamer) set(GSTREAMER_PREFIX_IOS ${gstreamer_SOURCE_DIR}) endif() - # TODO: set(GSTREAMER_PREFIX ${GSTREAMER_PREFIX_IOS}/) + set(GSTREAMER_PREFIX ${GSTREAMER_PREFIX_IOS}) elseif(ANDROID) set(GSTREAMER_PREFIX_ANDROID) if(DEFINED ENV{GSTREAMER_PREFIX_ANDROID} AND EXISTS $ENV{GSTREAMER_PREFIX_ANDROID}) set(GSTREAMER_PREFIX_ANDROID $ENV{GSTREAMER_PREFIX_ANDROID}) else() - FetchContent_Declare(gstreamer - URL "https://gstreamer.freedesktop.org/data/pkg/android/${QGC_GST_TARGET_VERSION}/gstreamer-1.0-android-universal-${QGC_GST_TARGET_VERSION}.tar.xz" - DOWNLOAD_EXTRACT_TIMESTAMP true - ) - FetchContent_MakeAvailable(gstreamer) - set(GSTREAMER_PREFIX_ANDROID ${gstreamer_SOURCE_DIR}) + set(GSTREAMER_ARCHIVE "gstreamer-1.0-android-universal-${QGC_GST_TARGET_VERSION}.tar.xz") + set(GSTREAMER_URL "https://gstreamer.freedesktop.org/data/pkg/android/${QGC_GST_TARGET_VERSION}/${GSTREAMER_ARCHIVE}") + set(GSTREAMER_TARBALL "${CMAKE_BINARY_DIR}/_deps/gstreamer/${GSTREAMER_ARCHIVE}") + set(GSTREAMER_INSTALL_DIR "${CMAKE_BINARY_DIR}/_deps/gstreamer/install/gstreamer") + if(NOT EXISTS ${GSTREAMER_TARBALL}) + message(STATUS "Downloading GStreamer from ${GSTREAMER_URL}") + file(DOWNLOAD ${GSTREAMER_URL} ${GSTREAMER_TARBALL} SHOW_PROGRESS) + endif() + if(NOT EXISTS ${GSTREAMER_INSTALL_DIR}) + message(STATUS "Extracting GStreamer to ${GSTREAMER_INSTALL_DIR}") + file(MAKE_DIRECTORY ${GSTREAMER_INSTALL_DIR}) + file(ARCHIVE_EXTRACT INPUT ${GSTREAMER_TARBALL} DESTINATION ${GSTREAMER_INSTALL_DIR}) + endif() + set(GSTREAMER_PREFIX_ANDROID ${GSTREAMER_INSTALL_DIR}) endif() if(${CMAKE_ANDROID_ARCH_ABI} STREQUAL armeabi-v7a) set(GSTREAMER_PREFIX ${GSTREAMER_PREFIX_ANDROID}/armv7) @@ -108,24 +88,19 @@ elseif(ANDROID) elseif(${CMAKE_ANDROID_ARCH_ABI} STREQUAL x86_64) set(GSTREAMER_PREFIX ${GSTREAMER_PREFIX_ANDROID}/x86_64) endif() - set(ENV{PKG_CONFIG_PATH} "${GSTREAMER_PREFIX}/lib/pkgconfig:${GSTREAMER_PREFIX}/lib/gstreamer-1.0/pkgconfig:$ENV{PKG_CONFIG_PATH}") + set(ENV{PKG_CONFIG_PATH} "") set(ENV{PKG_CONFIG_LIBDIR} "${GSTREAMER_PREFIX}/lib/pkgconfig:${GSTREAMER_PREFIX}/lib/gstreamer-1.0/pkgconfig") - # set(ENV{PKG_CONFIG_SYSROOT_DIR} "${GSTREAMER_PREFIX}") - message(STATUS "PKG_CONFIG_PATH $ENV{PKG_CONFIG_PATH}") - # message(STATUS "PKG_CONFIG_SYSROOT_DIR $ENV{PKG_CONFIG_SYSROOT_DIR}") list(APPEND PKG_CONFIG_ARGN --dont-define-prefix --define-variable=prefix=${GSTREAMER_PREFIX} --define-variable=libdir=${GSTREAMER_PREFIX}/lib --define-variable=includedir=${GSTREAMER_PREFIX}/include ) - cmake_print_variables(PKG_CONFIG_ARGN) if(CMAKE_HOST_WIN32) find_program(PKG_CONFIG_PROGRAM pkg-config PATHS ${GSTREAMER_PREFIX}/share/gst-android/ndk-build/tools/windows) if(PKG_CONFIG_PROGRAM) set(PKG_CONFIG_EXECUTABLE ${PKG_CONFIG_PROGRAM}) - cmake_print_variables(PKG_CONFIG_EXECUTABLE) endif() endif() endif() @@ -140,6 +115,10 @@ find_dependency(GObject) set(GStreamer_VERSION ${QGC_GST_TARGET_VERSION}) find_package(PkgConfig QUIET) if(PkgConfig_FOUND) + message(STATUS "PKG_CONFIG_PATH $ENV{PKG_CONFIG_PATH}") + message(STATUS "PKG_CONFIG_LIBDIR $ENV{PKG_CONFIG_LIBDIR}") + # message(STATUS "PKG_CONFIG_SYSROOT_DIR $ENV{PKG_CONFIG_SYSROOT_DIR}") + cmake_print_variables(PKG_CONFIG_EXECUTABLE PKG_CONFIG_ARGN) pkg_check_modules(GStreamer gstreamer-1.0) else() find_file(GStreamer_VERSION_HEADER @@ -172,6 +151,8 @@ else() endif() cmake_print_variables(GStreamer_VERSION) +################################################################################ + function(find_gstreamer_component component prefix header library) if(NOT TARGET GStreamer::${component}) string(TOUPPER ${component} upper) @@ -336,18 +317,71 @@ foreach(component ${GStreamer_FIND_COMPONENTS}) endif() elseif (${component} STREQUAL "X11") find_gstreamer_component(X11 gstreamer-gl-x11-1.0 gst/gl/x11/x11.h x11-xcb) - if(TARGET GStreamer::X11 AND TARGET GStreamer::Gl) - target_link_libraries(GStreamer::X11 INTERFACE GStreamer::Gl) + if(TARGET GStreamer::X11) + if(GStreamer::Gl) + target_link_libraries(GStreamer::X11 INTERFACE GStreamer::Gl) + endif() + find_package(X11) + if(X11_FOUND) + target_link_libraries(GStreamer::X11 INTERFACE X11::X11) + endif() + find_package(XCB COMPONENTS XCB GLX) + if(XCB_FOUND) + target_link_libraries(GStreamer::X11 INTERFACE XCB::XCB XCB::GLX) + endif() + find_package(X11_XCB) + if(X11_XCB_FOUND) + target_link_libraries(GStreamer::X11 INTERFACE X11::XCB) + endif() endif() elseif (${component} STREQUAL "EGL") find_gstreamer_component(EGL gstreamer-gl-egl-1.0 gst/gl/egl/egl.h egl) - if(TARGET GStreamer::EGL AND TARGET GStreamer::Gl) - target_link_libraries(GStreamer::EGL INTERFACE GStreamer::Gl) + if(TARGET GStreamer::EGL) + if(TARGET GStreamer::Gl) + target_link_libraries(GStreamer::EGL INTERFACE GStreamer::Gl) + endif() + find_package(EGL) + if(EGL_FOUND) + target_link_libraries(GStreamer::EGL INTERFACE EGL::EGL) + endif() endif() elseif (${component} STREQUAL "Wayland") find_gstreamer_component(Wayland gstreamer-gl-wayland-1.0 gst/gl/wayland/wayland.h wayland-egl) - if(TARGET GStreamer::Wayland AND TARGET GStreamer::Gl) - target_link_libraries(GStreamer::Wayland INTERFACE GStreamer::Gl) + if(TARGET GStreamer::Wayland) + if(TARGET GStreamer::Gl) + target_link_libraries(GStreamer::Wayland INTERFACE GStreamer::Gl) + endif() + find_package(Wayland COMPONENTS Client Cursor Egl) + if(Wayland_FOUND) + target_link_libraries(GStreamer::Wayland INTERFACE Wayland::Client Wayland::Cursor Wayland::Egl) + endif() + find_package(WaylandProtocols) + if(WaylandProtocols_FOUND) + # WaylandProtocols_DATADIR + endif() + find_package(WaylandScanner) + if(WaylandScanner_FOUND) + # target_link_libraries(GStreamer::Wayland INTERFACE Wayland::Scanner) + endif() + find_package(Qt6 COMPONENTS WaylandClient) + if(Qt6WaylandClient_FOUND) + target_link_libraries(GStreamer::Wayland INTERFACE Qt6::WaylandClient) + endif() + endif() + elseif (${component} STREQUAL "PluginsBase") + find_gstreamer_component(PluginsBase gstreamer-plugins-base-1.0 gst/gst.h ) + if(TARGET GStreamer::PluginsBase AND TARGET GStreamer::Core) + target_link_libraries(GStreamer::PluginsBase INTERFACE GStreamer::Core) + endif() + elseif (${component} STREQUAL "PluginsGood") + find_gstreamer_component(PluginsGood gstreamer-plugins-good-1.0 gst/gst.h ) + if(TARGET GStreamer::PluginsGood AND TARGET GStreamer::Base) + target_link_libraries(GStreamer::PluginsGood INTERFACE GStreamer::Base) + endif() + elseif (${component} STREQUAL "PluginsBad") + find_gstreamer_component(PluginsBad gstreamer-plugins-bad-1.0 gst/gst.h ) + if(TARGET GStreamer::PluginsBad AND TARGET GStreamer::PluginsGood) + target_link_libraries(GStreamer::PluginsBad INTERFACE GStreamer::PluginsGood) endif() else() message(WARNING "FindGStreamer.cmake: Invalid Gstreamer component \"${component}\" requested") @@ -356,6 +390,19 @@ endforeach() ################################################################################ +if(TARGET PkgConfig::PC_GSTREAMER_GL) + get_target_property(_qt_incs PkgConfig::PC_GSTREAMER_GL INTERFACE_INCLUDE_DIRECTORIES) + set(__qt_fixed_incs) + foreach(path IN LISTS _qt_incs) + if(IS_DIRECTORY "${path}") + list(APPEND __qt_fixed_incs "${path}") + endif() + endforeach() + set_property(TARGET PkgConfig::PC_GSTREAMER_GL PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${__qt_fixed_incs}") +endif() + +################################################################################ + # Create target GStreamer::GStreamer include(FindPackageHandleStandardArgs) find_package_handle_standard_args(GStreamer @@ -375,19 +422,218 @@ if(GStreamer_FOUND AND NOT TARGET GStreamer::GStreamer) GStreamer::Video GStreamer::Gl ) - set_target_properties(GStreamer::GStreamer PROPERTIES VERSION ${GStreamer_Core_VERSION}) - set(GStreamer_VERSION ${GStreamer_Core_VERSION}) + set_target_properties(GStreamer::GStreamer PROPERTIES VERSION ${GStreamer_VERSION}) endif() -if(TARGET PkgConfig::PC_GSTREAMER_GL) - get_target_property(_qt_incs PkgConfig::PC_GSTREAMER_GL INTERFACE_INCLUDE_DIRECTORIES) - set(__qt_fixed_incs) - foreach(path IN LISTS _qt_incs) - if(IS_DIRECTORY "${path}") - list(APPEND __qt_fixed_incs "${path}") +################################################################################ + +set(GST_TARGET_PLUGINS + gstcoreelements + gstisomp4 + gstlibav + gstmatroska + gstmpegtsdemux + gstopengl + gstplayback + gstrtp + gstrtpmanager + gstrtsp + gstsdpelem + gsttcp + gstudp + gstvideoparsersbad + gstx264 + # gstqml6 + gstasf + gstva +) +if(ANDROID) + list(APPEND GST_TARGET_PLUGINS gstandroidmedia) +elseif(IOS) + list(APPEND GST_TARGET_PLUGINS gstapplemedia) +endif() + +find_package(PkgConfig QUIET) +foreach(plugin IN LISTS GST_TARGET_PLUGINS) + if(PkgConfig_FOUND) + pkg_check_modules(GST_PLUGIN_${plugin} IMPORTED_TARGET GST_PLUGIN_${plugin} QUIET) + if(GST_PLUGIN_${plugin}_FOUND) + cmake_print_variables(plugin) + target_link_libraries(GStreamer::GStreamer INTERFACE PkgConfig::GST_PLUGIN_${plugin}) endif() - endforeach() - set_property(TARGET PkgConfig::PC_GSTREAMER_GL PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${__qt_fixed_incs}") + endif() + if(NOT GST_PLUGIN_${plugin}_FOUND) + find_library(GST_PLUGIN_${plugin}_LIBRARY + NAMES ${plugin} + PATHS + ${GSTREAMER_PREFIX}/lib + ${GSTREAMER_PREFIX}/lib/gstreamer-1.0 + ${GSTREAMER_PREFIX}/lib/x86_64-linux-gnu + ${GSTREAMER_PREFIX}/lib/x86_64-linux-gnu/gstreamer-1.0 + ) + if(GST_PLUGIN_${plugin}_LIBRARY) + cmake_print_variables(plugin) + target_link_libraries(GStreamer::GStreamer INTERFACE ${GST_PLUGIN_${plugin}_LIBRARY}) + endif() + endif() +endforeach() + +# set(GST_DEPENDENCIES +# gstreamer-plugins-base-1.0 +# gstreamer-plugins-good-1.0 +# gstreamer-plugins-bad-1.0 +# glib-2.0 +# gio +# gobject-2.0 +# gthread-2.0 +# gmodule-2.0 +# gmodule-no-export-2.0 +# zlib +# drm +# graphene-1.0 +# opus +# ffi +# egl +# dl +# m +# pcre2-8 +# gudev-1.0 +# avcodec +# avdevice +# avfilter +# avformat +# avutil +# postproc +# swscale +# va +# va-drm +# va-glx +# va-wayland +# va-x11 +# orc +# pango +# vpl +# vdpau +# vpx +# x11 +# x264 +# x265 +# x11-xcb +# drm +# png +# zlib +# ) + +pkg_check_modules(GRAPHENE IMPORTED_TARGET graphene-1.0) +if(GRAPHENE_FOUND) + target_link_libraries(GStreamer::GStreamer INTERFACE PkgConfig::GRAPHENE) +endif() + +pkg_check_modules(X264 IMPORTED_TARGET x264) +if(X264_FOUND) + target_link_libraries(GStreamer::GStreamer INTERFACE PkgConfig::X264) +endif() + +find_package(VAAPI) +if(VAAPI_FOUND) + target_link_libraries(GStreamer::GStreamer INTERFACE VAAPI::VAAPI) +endif() + +find_package(ZLIB) +if(ZLIB_FOUND) + target_link_libraries(GStreamer::GStreamer INTERFACE ZLIB::ZLIB) +endif() + +find_package(OpenGL) +if(OpenGL_FOUND) + target_link_libraries(GStreamer::GStreamer INTERFACE OpenGL::GL) +endif() + +find_package(GLESv2) +if(GLESv2_FOUND) + target_link_libraries(GStreamer::GStreamer INTERFACE GLESv2::GLESv2) +endif() + +find_package(FFmpeg COMPONENTS AVCODEC AVFORMAT AVUTIL AVFILTER SWRESAMPLE) # AVDEVICE POSTPROC SWSCALE +if(FFMPEG_FOUND) + target_link_libraries(GStreamer::GStreamer INTERFACE FFmpeg::FFmpeg) +endif() + +find_package(BZip2) +if(BZIP2_FOUND) + target_link_libraries(GStreamer::GStreamer INTERFACE BZip2::BZip2) +endif() + +find_package(JPEG) +if(JPEG_FOUND) + target_link_libraries(GStreamer::GStreamer INTERFACE JPEG::JPEG) +endif() + +find_package(PNG) +if(PNG_FOUND) + target_link_libraries(GStreamer::GStreamer INTERFACE PNG::PNG) +endif() + +find_package(Intl) +if(Intl_FOUND) + target_link_libraries(GStreamer::GStreamer INTERFACE Intl::Intl) +endif() + +find_package(Iconv) +if(Iconv_FOUND) + target_link_libraries(GStreamer::GStreamer INTERFACE Iconv::Iconv) +endif() + +find_package(Threads) +if(Threads_FOUND) + target_link_libraries(GStreamer::GStreamer INTERFACE Threads::Threads) +endif() + +if(ANDROID) + target_link_options(GStreamer::GStreamer INTERFACE "-Wl,-Bsymbolic") +endif() + +if(QGC_GST_STATIC_BUILD) + target_compile_definitions(GStreamer::GStreamer INTERFACE QGC_GST_STATIC_BUILD) +endif() + +if(ANDROID OR WIN32) + # find_path(GStreamer_INCLUDE_DIR + # NAMES GStreamer + # PATH_SUFFIXES gstreamer-1.0 + # PATHS ${GSTREAMER_PREFIX}/include + # ) + # target_include_directories(GStreamer::GStreamer + # INTERFACE + # ${GSTREAMER_PREFIX}/include/gstreamer-1.0 + # ${GSTREAMER_PREFIX}/include/glib-2.0 + # ${GSTREAMER_PREFIX}/lib/glib-2.0/include + # ${GSTREAMER_PREFIX}/lib/graphene-1.0/include + # ${GSTREAMER_PREFIX}/lib/gstreamer-1.0/include + # ${GSTREAMER_PREFIX}/include + # ) endif() ################################################################################ + +# Use Latest Revisions for each minor version: 1.16.3, 1.18.6, 1.20.7, 1.22.12, 1.24.7 +string(REPLACE "." ";" GST_VERSION_LIST ${GStreamer_VERSION}) +list(GET GST_VERSION_LIST 0 GST_VERSION_MAJOR) +list(GET GST_VERSION_LIST 1 GST_VERSION_MINOR) +list(GET GST_VERSION_LIST 2 GST_VERSION_PATCH) +cmake_print_variables(GST_VERSION_MAJOR GST_VERSION_MINOR GST_VERSION_PATCH) + +if(GST_VERSION_MINOR EQUAL 16) + set(GST_VERSION_PATCH 3) +elseif(GST_VERSION_MINOR EQUAL 18) + set(GST_VERSION_PATCH 6) +elseif(GST_VERSION_MINOR EQUAL 20) + set(GST_VERSION_PATCH 7) +elseif(GST_VERSION_MINOR EQUAL 22) + set(GST_VERSION_PATCH 12) +elseif(GST_VERSION_MINOR EQUAL 24) + set(GST_VERSION_PATCH 7) +endif() + +set(GST_PLUGINS_VERSION ${GST_VERSION_MAJOR}.${GST_VERSION_MINOR}.${GST_VERSION_PATCH}) +cmake_print_variables(GST_PLUGINS_VERSION) diff --git a/cmake/find-modules/FindQtWaylandScanner.cmake b/cmake/find-modules/FindQtWaylandScanner.cmake new file mode 100644 index 00000000000..1a73b80facd --- /dev/null +++ b/cmake/find-modules/FindQtWaylandScanner.cmake @@ -0,0 +1,212 @@ +# SPDX-FileCopyrightText: 2012-2014 Pier Luigi Fiorini +# +# SPDX-License-Identifier: BSD-3-Clause + +#[=======================================================================[.rst: +FindQtWaylandScanner +-------------------- + +Try to find qtwaylandscanner. + +If the qtwaylandscanner executable is not in your PATH, you can provide +an alternative name or full path location with the ``QtWaylandScanner_EXECUTABLE`` +variable. + +This will define the following variables: + +``QtWaylandScanner_FOUND`` + True if qtwaylandscanner is available + +``QtWaylandScanner_EXECUTABLE`` + The qtwaylandscanner executable. + +If ``QtWaylandScanner_FOUND`` is TRUE, it will also define the following imported +target: + +``Wayland::QtScanner`` + The qtwaylandscanner executable. + +This module provides the following functions to generate C++ protocol +implementations: + + - ``ecm_add_qtwayland_client_protocol`` + - ``ecm_add_qtwayland_server_protocol`` + +:: + + ecm_add_qtwayland_client_protocol( + PROTOCOL + BASENAME + [PREFIX ] + [PRIVATE_CODE]) + + ecm_add_qtwayland_client_protocol( + PROTOCOL + BASENAME + [PREFIX ] + [PRIVATE_CODE]) + +Generate C++ wrapper to Wayland client protocol files from ```` +XML definition for the ```` interface and append those files +to ```` or ````. Pass the ```` argument if the interface +names don't start with ``qt_`` or ``wl_``. +``PRIVATE_CODE`` instructs wayland-scanner to hide marshalling code +from the compiled DSO for use in other DSOs. The default is to +export this code. + +WaylandScanner is required and will be searched for. + +:: + + ecm_add_qtwayland_server_protocol( + PROTOCOL + BASENAME + [PREFIX ] + [PRIVATE_CODE]) + + ecm_add_qtwayland_server_protocol( + PROTOCOL + BASENAME + [PREFIX ] + [PRIVATE_CODE]) + +Generate C++ wrapper to Wayland server protocol files from ```` +XML definition for the ```` interface and append those files +to ```` or ````. Pass the ```` argument if the interface +names don't start with ``qt_`` or ``wl_``. +``PRIVATE_CODE`` instructs wayland-scanner to hide marshalling code +from the compiled DSO for use in other DSOs. The default is to +export this code. + +WaylandScanner is required and will be searched for. + +Since 1.4.0. +#]=======================================================================] + +include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) +include("${ECM_MODULE_DIR}/ECMQueryQt.cmake") + +ecm_find_package_version_check(QtWaylandScanner) + +if (QT_MAJOR_VERSION STREQUAL "5") + ecm_query_qt(qtwaylandscanner_dir QT_HOST_BINS) +else() + ecm_query_qt(qtwaylandscanner_dir QT_HOST_LIBEXECS) +endif() + +# Find qtwaylandscanner +find_program(QtWaylandScanner_EXECUTABLE NAMES qtwaylandscanner HINTS ${qtwaylandscanner_dir}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(QtWaylandScanner + FOUND_VAR + QtWaylandScanner_FOUND + REQUIRED_VARS + QtWaylandScanner_EXECUTABLE +) + +mark_as_advanced(QtWaylandScanner_EXECUTABLE) + +if(NOT TARGET Wayland::QtScanner AND QtWaylandScanner_FOUND) + add_executable(Wayland::QtScanner IMPORTED) + set_target_properties(Wayland::QtScanner PROPERTIES + IMPORTED_LOCATION "${QtWaylandScanner_EXECUTABLE}" + ) +endif() + +include(FeatureSummary) +set_package_properties(QtWaylandScanner PROPERTIES + URL "https://qt.io/" + DESCRIPTION "Executable that converts XML protocol files to C++ code" +) + +function(ecm_add_qtwayland_client_protocol target_or_sources_var) + # Parse arguments + set(oneValueArgs PROTOCOL BASENAME PREFIX) + set(options PRIVATE_CODE) + cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "" ${ARGN}) + + if(ARGS_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to ecm_add_qtwayland_client_protocol(): \"${ARGS_UNPARSED_ARGUMENTS}\"") + endif() + + set(_prefix "${ARGS_PREFIX}") + if(ARGS_PRIVATE_CODE) + set(_private_code_option PRIVATE_CODE) + endif() + + find_package(WaylandScanner REQUIRED QUIET) + ecm_add_wayland_client_protocol(${target_or_sources_var} + PROTOCOL ${ARGS_PROTOCOL} + BASENAME ${ARGS_BASENAME} + ${_private_code_option}) + + get_filename_component(_infile ${ARGS_PROTOCOL} ABSOLUTE) + set(_header "${CMAKE_CURRENT_BINARY_DIR}/qwayland-${ARGS_BASENAME}.h") + set(_code "${CMAKE_CURRENT_BINARY_DIR}/qwayland-${ARGS_BASENAME}.cpp") + + set_source_files_properties(${_header} ${_code} GENERATED) + + add_custom_command(OUTPUT "${_header}" + COMMAND ${QtWaylandScanner_EXECUTABLE} client-header ${_infile} "" ${_prefix} > ${_header} + DEPENDS ${_infile} ${_cheader} VERBATIM) + + add_custom_command(OUTPUT "${_code}" + COMMAND ${QtWaylandScanner_EXECUTABLE} client-code ${_infile} "" ${_prefix} > ${_code} + DEPENDS ${_infile} ${_header} VERBATIM) + + set_property(SOURCE ${_header} ${_code} PROPERTY SKIP_AUTOMOC ON) + + if (TARGET ${target_or_sources_var}) + target_sources(${target_or_sources_var} PRIVATE "${_code}") + else() + list(APPEND ${target_or_sources_var} "${_code}") + set(${target_or_sources_var} ${${target_or_sources_var}} PARENT_SCOPE) + endif() +endfunction() + + +function(ecm_add_qtwayland_server_protocol target_or_sources_var) + # Parse arguments + set(oneValueArgs PROTOCOL BASENAME PREFIX) + set(options PRIVATE_CODE) + cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "" ${ARGN}) + + if(ARGS_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to ecm_add_qtwayland_server_protocol(): \"${ARGS_UNPARSED_ARGUMENTS}\"") + endif() + + set(_prefix "${ARGS_PREFIX}") + if(ARGS_PRIVATE_CODE) + set(_private_code_option PRIVATE_CODE) + endif() + + find_package(WaylandScanner REQUIRED QUIET) + ecm_add_wayland_server_protocol(${target_or_sources_var} + PROTOCOL ${ARGS_PROTOCOL} + BASENAME ${ARGS_BASENAME} + ${_private_code_option}) + + get_filename_component(_infile ${ARGS_PROTOCOL} ABSOLUTE) + set(_header "${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-${ARGS_BASENAME}.h") + set(_code "${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-${ARGS_BASENAME}.cpp") + + set_source_files_properties(${_header} ${_code} GENERATED) + + add_custom_command(OUTPUT "${_header}" + COMMAND ${QtWaylandScanner_EXECUTABLE} server-header ${_infile} "" ${_prefix} > ${_header} + DEPENDS ${_infile} VERBATIM) + + add_custom_command(OUTPUT "${_code}" + COMMAND ${QtWaylandScanner_EXECUTABLE} server-code ${_infile} "" ${_prefix} > ${_code} + DEPENDS ${_infile} ${_header} VERBATIM) + + set_property(SOURCE ${_header} ${_code} PROPERTY SKIP_AUTOMOC ON) + + if (TARGET ${target_or_sources_var}) + target_sources(${target_or_sources_var} PRIVATE "${_code}") + else() + list(APPEND ${target_or_sources_var} "${_code}") + set(${target_or_sources_var} ${${target_or_sources_var}} PARENT_SCOPE) + endif() +endfunction() diff --git a/cmake/find-modules/FindVAAPI.cmake b/cmake/find-modules/FindVAAPI.cmake new file mode 100644 index 00000000000..a3ea6cd586e --- /dev/null +++ b/cmake/find-modules/FindVAAPI.cmake @@ -0,0 +1,60 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + + +find_package(PkgConfig QUIET) + +function(find_component component prefix header library) + if(NOT TARGET VAAPI::${component}) + string(TOUPPER ${component} upper) + pkg_check_modules(PC_VAAPI_${upper} ${prefix} IMPORTED_TARGET) + if(TARGET PkgConfig::PC_VAAPI_${upper}) + add_library(VAAPI::${component} INTERFACE IMPORTED) + target_link_libraries(VAAPI::${component} INTERFACE PkgConfig::PC_VAAPI_${upper}) + else() + find_path(VAAPI_${component}_INCLUDE_DIR + NAMES ${header} + PATH_SUFFIXES VAAPI-1.0 + ) + find_library(VAAPI_${component}_LIBRARY + NAMES ${library} + ) + if(VAAPI_${component}_LIBRARY AND VAAPI_${component}_INCLUDE_DIR) + add_library(VAAPI::${component} INTERFACE IMPORTED) + target_include_directories(VAAPI::${component} INTERFACE ${VAAPI_${component}_INCLUDE_DIR}) + target_link_libraries(VAAPI::${component} INTERFACE ${VAAPI_${component}_LIBRARY}) + endif() + mark_as_advanced(VAAPI_${component}_INCLUDE_DIR VAAPI_${component}_LIBRARY) + endif() + endif() + + if(TARGET VAAPI::${component}) + set(VAAPI_${component}_FOUND TRUE PARENT_SCOPE) + endif() +endfunction() + +find_component(VA libva va/va.h libva) +find_component(DRM libva-drm va/va-drm.h libva-drm) + +if(TARGET VAAPI::VA) + target_link_libraries(VAAPI::VA) +endif() +if(TARGET VAAPI::VA AND TARGET VAAPI::DRM) + target_link_libraries(VAAPI::DRM INTERFACE VAAPI::VA) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(VAAPI + REQUIRED_VARS + VAAPI_VA_FOUND + VAAPI_DRM_FOUND + HANDLE_COMPONENTS +) + +if(VAAPI_FOUND AND NOT TARGET VAAPI::VAAPI) + add_library(VAAPI::VAAPI INTERFACE IMPORTED) + target_link_libraries(VAAPI::VAAPI INTERFACE + VAAPI::VA + VAAPI::DRM + ) +endif() diff --git a/cmake/find-modules/FindWayland.cmake b/cmake/find-modules/FindWayland.cmake new file mode 100644 index 00000000000..926fd485528 --- /dev/null +++ b/cmake/find-modules/FindWayland.cmake @@ -0,0 +1,137 @@ +# SPDX-FileCopyrightText: 2014 Alex Merry +# SPDX-FileCopyrightText: 2014 Martin Gräßlin +# +# SPDX-License-Identifier: BSD-3-Clause + +#[=======================================================================[.rst: +FindWayland +----------- + +Try to find Wayland. + +This is a component-based find module, which makes use of the COMPONENTS +and OPTIONAL_COMPONENTS arguments to find_module. The following components +are available:: + + Client Server Cursor Egl + +If no components are specified, this module will act as though all components +were passed to OPTIONAL_COMPONENTS. + +This module will define the following variables, independently of the +components searched for or found: + +``Wayland_FOUND`` + TRUE if (the requested version of) Wayland is available +``Wayland_VERSION`` + Found Wayland version +``Wayland_TARGETS`` + A list of all targets imported by this module (note that there may be more + than the components that were requested) +``Wayland_LIBRARIES`` + This can be passed to target_link_libraries() instead of the imported + targets +``Wayland_INCLUDE_DIRS`` + This should be passed to target_include_directories() if the targets are + not used for linking +``Wayland_DEFINITIONS`` + This should be passed to target_compile_options() if the targets are not + used for linking +``Wayland_DATADIR`` + The core wayland protocols data directory + Since 5.73.0 + +For each searched-for components, ``Wayland__FOUND`` will be set to +TRUE if the corresponding Wayland library was found, and FALSE otherwise. If +``Wayland__FOUND`` is TRUE, the imported target +``Wayland::`` will be defined. This module will also attempt to +determine ``Wayland_*_VERSION`` variables for each imported target, although +``Wayland_VERSION`` should normally be sufficient. + +In general we recommend using the imported targets, as they are easier to use +and provide more control. Bear in mind, however, that if any target is in the +link interface of an exported library, it must be made available by the +package config file. + +Since pre-1.0.0. +#]=======================================================================] + +include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) + +ecm_find_package_version_check(Wayland) + +set(Wayland_known_components + Client + Server + Cursor + Egl +) +foreach(_comp ${Wayland_known_components}) + string(TOLOWER "${_comp}" _lc_comp) + set(Wayland_${_comp}_component_deps) + set(Wayland_${_comp}_pkg_config "wayland-${_lc_comp}") + set(Wayland_${_comp}_lib "wayland-${_lc_comp}") + set(Wayland_${_comp}_header "wayland-${_lc_comp}.h") +endforeach() +set(Wayland_Egl_component_deps Client) + +ecm_find_package_parse_components(Wayland + RESULT_VAR Wayland_components + KNOWN_COMPONENTS ${Wayland_known_components} +) +ecm_find_package_handle_library_components(Wayland + COMPONENTS ${Wayland_components} +) + +# If pkg-config didn't provide us with version information, +# try to extract it from wayland-version.h +# (Note that the version from wayland-egl.pc will probably be +# the Mesa version, rather than the Wayland version, but that +# version will be ignored as we always find wayland-client.pc +# first). +if(NOT Wayland_VERSION) + find_file(Wayland_VERSION_HEADER + NAMES wayland-version.h + HINTS ${Wayland_INCLUDE_DIRS} + ) + mark_as_advanced(Wayland_VERSION_HEADER) + if(Wayland_VERSION_HEADER) + file(READ ${Wayland_VERSION_HEADER} _wayland_version_header_contents) + string(REGEX REPLACE + "^.*[ \t]+WAYLAND_VERSION[ \t]+\"([0-9.]*)\".*$" + "\\1" + Wayland_VERSION + "${_wayland_version_header_contents}" + ) + unset(_wayland_version_header_contents) + endif() +endif() + +find_package_handle_standard_args(Wayland + FOUND_VAR + Wayland_FOUND + REQUIRED_VARS + Wayland_LIBRARIES + VERSION_VAR + Wayland_VERSION + HANDLE_COMPONENTS +) + +pkg_get_variable(Wayland_DATADIR wayland-scanner pkgdatadir) +if (CMAKE_CROSSCOMPILING AND (NOT EXISTS "${Wayland_DATADIR}/wayland.xml")) + # PKG_CONFIG_SYSROOT_DIR only applies to -I and -L flags, so pkg-config + # does not prepend CMAKE_SYSROOT when cross-compiling unless you pass + # --define-prefix explicitly. Therefore we have to manually do prepend + # it here when cross-compiling. + # See https://gitlab.kitware.com/cmake/cmake/-/issues/16647#note_844761 + set(Wayland_DATADIR ${CMAKE_SYSROOT}${Wayland_DATADIR}) +endif() +if (NOT EXISTS "${Wayland_DATADIR}/wayland.xml") + message(WARNING "Could not find wayland.xml in ${Wayland_DATADIR}") +endif() + +include(FeatureSummary) +set_package_properties(Wayland PROPERTIES + URL "https://wayland.freedesktop.org/" + DESCRIPTION "C library implementation of the Wayland protocol: a protocol for a compositor to talk to its clients" +) diff --git a/cmake/find-modules/FindWaylandProtocols.cmake b/cmake/find-modules/FindWaylandProtocols.cmake new file mode 100644 index 00000000000..a4449885d99 --- /dev/null +++ b/cmake/find-modules/FindWaylandProtocols.cmake @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2019 Vlad Zahorodnii +# +# SPDX-License-Identifier: BSD-3-Clause + +#[=======================================================================[.rst: +FindWaylandProtocols +-------------------- + +Try to find wayland-protocols on a Unix system. + +This will define the following variables: + +``WaylandProtocols_FOUND`` + True if (the requested version of) wayland-protocols is available +``WaylandProtocols_VERSION`` + The version of wayland-protocols +``WaylandProtocols_DATADIR`` + The wayland protocols data directory +#]=======================================================================] + +find_package(PkgConfig QUIET) +pkg_check_modules(PKG_wayland_protocols QUIET wayland-protocols) + +set(WaylandProtocols_VERSION ${PKG_wayland_protocols_VERSION}) +pkg_get_variable(WaylandProtocols_DATADIR wayland-protocols pkgdatadir) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(WaylandProtocols + FOUND_VAR WaylandProtocols_FOUND + REQUIRED_VARS WaylandProtocols_DATADIR + VERSION_VAR WaylandProtocols_VERSION +) + +include(FeatureSummary) +set_package_properties(WaylandProtocols PROPERTIES + DESCRIPTION "Specifications of extended Wayland protocols" + URL "https://wayland.freedesktop.org/" +) diff --git a/cmake/find-modules/FindWaylandScanner.cmake b/cmake/find-modules/FindWaylandScanner.cmake new file mode 100644 index 00000000000..2fa1fd6e8bc --- /dev/null +++ b/cmake/find-modules/FindWaylandScanner.cmake @@ -0,0 +1,183 @@ +# SPDX-FileCopyrightText: 2012-2014 Pier Luigi Fiorini +# +# SPDX-License-Identifier: BSD-3-Clause + +#[=======================================================================[.rst: +FindWaylandScanner +------------------ + +Try to find wayland-scanner. + +If the wayland-scanner executable is not in your PATH, you can provide +an alternative name or full path location with the ``WaylandScanner_EXECUTABLE`` +variable. + +This will define the following variables: + +``WaylandScanner_FOUND`` + True if wayland-scanner is available. + +``WaylandScanner_EXECUTABLE`` + The wayland-scanner executable. + +If ``WaylandScanner_FOUND`` is TRUE, it will also define the following imported +target: + +``Wayland::Scanner`` + The wayland-scanner executable. + +This module provides the following functions to generate C protocol +implementations: + + - ``ecm_add_wayland_client_protocol`` + - ``ecm_add_wayland_server_protocol`` + +:: + + ecm_add_wayland_client_protocol( + PROTOCOL + BASENAME + [PRIVATE_CODE]) + + ecm_add_wayland_client_protocol( + PROTOCOL + BASENAME + [PRIVATE_CODE]) + +Generate Wayland client protocol files from ```` XML +definition for the ```` interface and append those files +to ```` or ````. + +``PRIVATE_CODE`` instructs wayland-scanner to hide marshalling code +from the compiled DSO for use in other DSOs. The default is to +export this code. + +:: + + ecm_add_wayland_server_protocol( + PROTOCOL + BASENAME + [PRIVATE_CODE]) + + ecm_add_wayland_server_protocol( + PROTOCOL + BASENAME + [PRIVATE_CODE]) + +Generate Wayland server protocol files from ```` XML +definition for the ```` interface and append those files +to ```` or ````. + +``PRIVATE_CODE`` instructs wayland-scanner to hide marshalling code +from the compiled DSO for use in other DSOs. The default is to +export this code. + +Since 1.4.0. +#]=======================================================================] + +include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) + +ecm_find_package_version_check(WaylandScanner) + +# Find wayland-scanner +find_program(WaylandScanner_EXECUTABLE NAMES wayland-scanner) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(WaylandScanner + FOUND_VAR + WaylandScanner_FOUND + REQUIRED_VARS + WaylandScanner_EXECUTABLE +) + +mark_as_advanced(WaylandScanner_EXECUTABLE) + +if(NOT TARGET Wayland::Scanner AND WaylandScanner_FOUND) + add_executable(Wayland::Scanner IMPORTED) + set_target_properties(Wayland::Scanner PROPERTIES + IMPORTED_LOCATION "${WaylandScanner_EXECUTABLE}" + ) +endif() + +include(FeatureSummary) +set_package_properties(WaylandScanner PROPERTIES + URL "https://wayland.freedesktop.org/" + DESCRIPTION "Executable that converts XML protocol files to C code" +) + +function(ecm_add_wayland_client_protocol target_or_sources_var) + # Parse arguments + set(options PRIVATE_CODE) + set(oneValueArgs PROTOCOL BASENAME) + cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "" ${ARGN}) + + if(ARGS_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to ecm_add_wayland_client_protocol(): \"${ARGS_UNPARSED_ARGUMENTS}\"") + endif() + + get_filename_component(_infile ${ARGS_PROTOCOL} ABSOLUTE) + set(_client_header "${CMAKE_CURRENT_BINARY_DIR}/wayland-${ARGS_BASENAME}-client-protocol.h") + set(_code "${CMAKE_CURRENT_BINARY_DIR}/wayland-${ARGS_BASENAME}-protocol.c") + if(ARGS_PRIVATE_CODE) + set(_code_type private-code) + else() + set(_code_type public-code) + endif() + + set_source_files_properties(${_client_header} GENERATED) + set_source_files_properties(${_code} GENERATED) + set_property(SOURCE ${_client_header} ${_code} PROPERTY SKIP_AUTOMOC ON) + + add_custom_command(OUTPUT "${_client_header}" + COMMAND ${WaylandScanner_EXECUTABLE} client-header ${_infile} ${_client_header} + DEPENDS ${_infile} VERBATIM) + + add_custom_command(OUTPUT "${_code}" + COMMAND ${WaylandScanner_EXECUTABLE} ${_code_type} ${_infile} ${_code} + DEPENDS ${_infile} ${_client_header} VERBATIM) + + if (TARGET ${target_or_sources_var}) + target_sources(${target_or_sources_var} PRIVATE "${_client_header}" "${_code}") + else() + list(APPEND ${target_or_sources_var} "${_client_header}" "${_code}") + set(${target_or_sources_var} ${${target_or_sources_var}} PARENT_SCOPE) + endif() +endfunction() + + +function(ecm_add_wayland_server_protocol target_or_sources_var) + # Parse arguments + set(options PRIVATE_CODE) + set(oneValueArgs PROTOCOL BASENAME) + cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "" ${ARGN}) + + if(ARGS_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to ecm_add_wayland_server_protocol(): \"${ARGS_UNPARSED_ARGUMENTS}\"") + endif() + + if(ARGS_PRIVATE_CODE) + set(_private_code_option PRIVATE_CODE) + endif() + + ecm_add_wayland_client_protocol(${target_or_sources_var} + PROTOCOL ${ARGS_PROTOCOL} + BASENAME ${ARGS_BASENAME} + ${_private_code_option}) + + get_filename_component(_infile ${ARGS_PROTOCOL} ABSOLUTE) + set(_server_header "${CMAKE_CURRENT_BINARY_DIR}/wayland-${ARGS_BASENAME}-server-protocol.h") + set(_server_code "${CMAKE_CURRENT_BINARY_DIR}/wayland-${ARGS_BASENAME}-protocol.c") + set_property(SOURCE ${_server_header} ${_server_code} PROPERTY SKIP_AUTOMOC ON) + set_source_files_properties(${_server_header} GENERATED) + + add_custom_command(OUTPUT "${_server_header}" + COMMAND ${WaylandScanner_EXECUTABLE} server-header ${_infile} ${_server_header} + DEPENDS ${_infile} VERBATIM) + + if (TARGET ${target_or_sources_var}) + target_sources(${target_or_sources_var} PRIVATE "${_server_header}") + else() + list(APPEND ${target_or_sources_var} "${_server_header}") + set(${target_or_sources_var} ${${target_or_sources_var}} PARENT_SCOPE) + endif() +endfunction() diff --git a/cmake/find-modules/FindX11_XCB.cmake b/cmake/find-modules/FindX11_XCB.cmake new file mode 100644 index 00000000000..f571bacff46 --- /dev/null +++ b/cmake/find-modules/FindX11_XCB.cmake @@ -0,0 +1,96 @@ +# SPDX-FileCopyrightText: 2014 Alex Merry +# SPDX-FileCopyrightText: 2011 Fredrik Höglund +# SPDX-FileCopyrightText: 2008 Helio Chissini de Castro +# SPDX-FileCopyrightText: 2007 Matthias Kretz +# +# SPDX-License-Identifier: BSD-3-Clause + +#[=======================================================================[.rst: +FindX11_XCB +----------- + +Try to find the X11 XCB compatibility library. + +This will define the following variables: + +``X11_XCB_FOUND`` + True if (the requested version of) libX11-xcb is available +``X11_XCB_VERSION`` + The version of libX11-xcb (this is not guaranteed to be set even when + X11_XCB_FOUND is true) +``X11_XCB_LIBRARIES`` + This can be passed to target_link_libraries() instead of the ``EGL::EGL`` + target +``X11_XCB_INCLUDE_DIR`` + This should be passed to target_include_directories() if the target is not + used for linking +``X11_XCB_DEFINITIONS`` + This should be passed to target_compile_options() if the target is not + used for linking + +If ``X11_XCB_FOUND`` is TRUE, it will also define the following imported +target: + +``X11::XCB`` + The X11 XCB compatibility library + +In general we recommend using the imported target, as it is easier to use. +Bear in mind, however, that if the target is in the link interface of an +exported library, it must be made available by the package config file. + +Since pre-1.0.0. +#]=======================================================================] + +include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) + +ecm_find_package_version_check(X11_XCB) + +# use pkg-config to get the directories and then use these values +# in the FIND_PATH() and FIND_LIBRARY() calls +find_package(PkgConfig QUIET) +pkg_check_modules(PKG_X11_XCB QUIET x11-xcb) + +set(X11_XCB_DEFINITIONS ${PKG_X11_XCB_CFLAGS_OTHER}) +set(X11_XCB_VERSION ${PKG_X11_XCB_VERSION}) + +find_path(X11_XCB_INCLUDE_DIR + NAMES X11/Xlib-xcb.h + HINTS ${PKG_X11_XCB_INCLUDE_DIRS} +) +find_library(X11_XCB_LIBRARY + NAMES X11-xcb + HINTS ${PKG_X11_XCB_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(X11_XCB + FOUND_VAR + X11_XCB_FOUND + REQUIRED_VARS + X11_XCB_LIBRARY + X11_XCB_INCLUDE_DIR + VERSION_VAR + X11_XCB_VERSION +) + +if(X11_XCB_FOUND AND NOT TARGET X11::XCB) + add_library(X11::XCB UNKNOWN IMPORTED) + set_target_properties(X11::XCB PROPERTIES + IMPORTED_LOCATION "${X11_XCB_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${X11_XCB_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${X11_XCB_INCLUDE_DIR}" + ) +endif() + +mark_as_advanced(X11_XCB_INCLUDE_DIR X11_XCB_LIBRARY) + +# compatibility variables +set(X11_XCB_LIBRARIES ${X11_XCB_LIBRARY}) +set(X11_XCB_INCLUDE_DIRS ${X11_XCB_INCLUDE_DIR}) +set(X11_XCB_VERSION_STRING ${X11_XCB_VERSION}) + +include(FeatureSummary) +set_package_properties(X11_XCB PROPERTIES + URL "https://xorg.freedesktop.org/" + DESCRIPTION "A compatibility library for code that translates Xlib API calls into XCB calls" +) diff --git a/cmake/find-modules/FindXCB.cmake b/cmake/find-modules/FindXCB.cmake new file mode 100644 index 00000000000..f18c2fd0959 --- /dev/null +++ b/cmake/find-modules/FindXCB.cmake @@ -0,0 +1,168 @@ +# SPDX-FileCopyrightText: 2011 Fredrik Höglund +# SPDX-FileCopyrightText: 2013 Martin Gräßlin +# SPDX-FileCopyrightText: 2014-2015 Alex Merry +# +# SPDX-License-Identifier: BSD-3-Clause + +#[=======================================================================[.rst: +FindXCB +------- + +Try to find XCB. + +This is a component-based find module, which makes use of the COMPONENTS and +OPTIONAL_COMPONENTS arguments to find_module. The following components are +available:: + + XCB + ATOM AUX COMPOSITE CURSOR DAMAGE + DPMS DRI2 DRI3 EVENT EWMH + GLX ICCCM IMAGE KEYSYMS PRESENT + RANDR RECORD RENDER RENDERUTIL RES + SCREENSAVER SHAPE SHM SYNC UTIL + XF86DRI XFIXES XINERAMA XINPUT XKB + XTEST XV XVMC + +If no components are specified, this module will act as though all components +were passed to OPTIONAL_COMPONENTS. Before 5.82 this excluded XINPUT. Since 5.82 +all components are searched for. + +This module will define the following variables, independently of the +components searched for or found: + +``XCB_FOUND`` + True if (the requestion version of) xcb is available +``XCB_VERSION`` + Found xcb version +``XCB_TARGETS`` + A list of all targets imported by this module (note that there may be more + than the components that were requested) +``XCB_LIBRARIES`` + This can be passed to target_link_libraries() instead of the imported + targets +``XCB_INCLUDE_DIRS`` + This should be passed to target_include_directories() if the targets are + not used for linking +``XCB_DEFINITIONS`` + This should be passed to target_compile_options() if the targets are not + used for linking + +For each searched-for components, ``XCB__FOUND`` will be set to +true if the corresponding xcb library was found, and false otherwise. If +``XCB__FOUND`` is true, the imported target ``XCB::`` +will be defined. This module will also attempt to determine +``XCB_*_VERSION`` variables for each imported target, although +``XCB_VERSION`` should normally be sufficient. + +In general we recommend using the imported targets, as they are easier to use +and provide more control. Bear in mind, however, that if any target is in the +link interface of an exported library, it must be made available by the +package config file. + +Since pre-1.0.0. +#]=======================================================================] + +include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) + +ecm_find_package_version_check(XCB) + +# Note that this list needs to be ordered such that any component +# appears after its dependencies +set(XCB_known_components + XCB + RENDER + SHAPE + XFIXES + SHM + ATOM + AUX + COMPOSITE + CURSOR + DAMAGE + DPMS + DRI2 + DRI3 + EVENT + EWMH + GLX + ICCCM + IMAGE + KEYSYMS + PRESENT + RANDR + RECORD + RENDERUTIL + RES + SCREENSAVER + SYNC + UTIL + XF86DRI + XINERAMA + XINPUT + XKB + XTEST + XV + XVMC +) + +# default component info: xcb components have fairly predictable +# header files, library names and pkg-config names +foreach(_comp ${XCB_known_components}) + string(TOLOWER "${_comp}" _lc_comp) + set(XCB_${_comp}_component_deps XCB) + set(XCB_${_comp}_pkg_config "xcb-${_lc_comp}") + set(XCB_${_comp}_lib "xcb-${_lc_comp}") + set(XCB_${_comp}_header "xcb/${_lc_comp}.h") +endforeach() +# exceptions +set(XCB_XCB_component_deps) +set(XCB_COMPOSITE_component_deps XCB XFIXES) +set(XCB_DAMAGE_component_deps XCB XFIXES) +set(XCB_IMAGE_component_deps XCB SHM) +set(XCB_RENDERUTIL_component_deps XCB RENDER) +set(XCB_XFIXES_component_deps XCB RENDER SHAPE) +set(XCB_XVMC_component_deps XCB XV) +set(XCB_XV_component_deps XCB SHM) +set(XCB_XCB_pkg_config "xcb") +set(XCB_XCB_lib "xcb") +set(XCB_ATOM_header "xcb/xcb_atom.h") +set(XCB_ATOM_lib "xcb-util") +set(XCB_AUX_header "xcb/xcb_aux.h") +set(XCB_AUX_lib "xcb-util") +set(XCB_CURSOR_header "xcb/xcb_cursor.h") +set(XCB_EVENT_header "xcb/xcb_event.h") +set(XCB_EVENT_lib "xcb-util") +set(XCB_EWMH_header "xcb/xcb_ewmh.h") +set(XCB_ICCCM_header "xcb/xcb_icccm.h") +set(XCB_IMAGE_header "xcb/xcb_image.h") +set(XCB_KEYSYMS_header "xcb/xcb_keysyms.h") +set(XCB_PIXEL_header "xcb/xcb_pixel.h") +set(XCB_RENDERUTIL_header "xcb/xcb_renderutil.h") +set(XCB_RENDERUTIL_lib "xcb-render-util") +set(XCB_UTIL_header "xcb/xcb_util.h") + +ecm_find_package_parse_components(XCB + RESULT_VAR XCB_components + KNOWN_COMPONENTS ${XCB_known_components} + DEFAULT_COMPONENTS ${XCB_default_components} +) + +ecm_find_package_handle_library_components(XCB + COMPONENTS ${XCB_components} +) + +find_package_handle_standard_args(XCB + FOUND_VAR + XCB_FOUND + REQUIRED_VARS + XCB_LIBRARIES + VERSION_VAR + XCB_VERSION + HANDLE_COMPONENTS +) + +include(FeatureSummary) +set_package_properties(XCB PROPERTIES + URL "https://xcb.freedesktop.org/" + DESCRIPTION "X protocol C-language Binding" +) diff --git a/cmake/find-modules/FindXKB.cmake b/cmake/find-modules/FindXKB.cmake new file mode 100644 index 00000000000..295580abee2 --- /dev/null +++ b/cmake/find-modules/FindXKB.cmake @@ -0,0 +1,101 @@ +# Try to find xkbcommon on a Unix system +# +# This will define: +# +# XKB_FOUND - True if XKB is available +# XKB_LIBRARIES - Link these to use XKB +# XKB_INCLUDE_DIRS - Include directory for XKB +# XKB_DEFINITIONS - Compiler flags for using XKB +# +# Additionally, the following imported targets will be defined: +# +# XKB::XKB +# +# Copyright (c) 2014 Martin Gräßlin +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +if(CMAKE_VERSION VERSION_LESS 2.8.12) + message(FATAL_ERROR "CMake 2.8.12 is required by FindXKB.cmake") +endif() +if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12) + message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindXKB.cmake") +endif() + +if(NOT WIN32) + # Use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + find_package(PkgConfig QUIET) + pkg_check_modules(PKG_XKB QUIET xkbcommon) + + set(XKB_DEFINITIONS ${PKG_XKB_CFLAGS_OTHER}) + + find_path(XKB_INCLUDE_DIR + NAMES + xkbcommon/xkbcommon.h + HINTS + ${PKG_XKB_INCLUDE_DIRS} + ) + find_library(XKB_LIBRARY + NAMES + xkbcommon + HINTS + ${PKG_XKB_LIBRARY_DIRS} + ) + + set(XKB_LIBRARIES ${XKB_LIBRARY}) + set(XKB_INCLUDE_DIRS ${XKB_INCLUDE_DIR}) + set(XKB_VERSION ${PKG_XKB_VERSION}) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(XKB + FOUND_VAR + XKB_FOUND + REQUIRED_VARS + XKB_LIBRARY + XKB_INCLUDE_DIR + VERSION_VAR + XKB_VERSION + ) + + if(XKB_FOUND AND NOT TARGET XKB::XKB) + add_library(XKB::XKB UNKNOWN IMPORTED) + set_target_properties(XKB::XKB PROPERTIES + IMPORTED_LOCATION "${XKB_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${XKB_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${XKB_INCLUDE_DIR}" + ) + endif() + +else() + message(STATUS "FindXKB.cmake cannot find XKB on Windows systems.") + set(XKB_FOUND FALSE) +endif() + +include(FeatureSummary) +set_package_properties(XKB PROPERTIES + URL "http://xkbcommon.org" + DESCRIPTION "XKB API common to servers and clients." +) diff --git a/cmake/find-modules/FindXKB_COMMON_X11.cmake b/cmake/find-modules/FindXKB_COMMON_X11.cmake new file mode 100644 index 00000000000..a00acb3cb01 --- /dev/null +++ b/cmake/find-modules/FindXKB_COMMON_X11.cmake @@ -0,0 +1,10 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +find_package(PkgConfig QUIET) + +pkg_check_modules(XKB_COMMON_X11 IMPORTED_TARGET "xkbcommon-x11>=0.4.1") + +if (NOT TARGET PkgConfig::XKB_COMMON_X11) + set(XKB_COMMON_X11_FOUND 0) +endif() diff --git a/cmake/modules/ECMFindModuleHelpers.cmake b/cmake/modules/ECMFindModuleHelpers.cmake new file mode 100644 index 00000000000..92c796e6bdd --- /dev/null +++ b/cmake/modules/ECMFindModuleHelpers.cmake @@ -0,0 +1,277 @@ +# SPDX-FileCopyrightText: 2014 Alex Merry +# +# SPDX-License-Identifier: BSD-3-Clause + +#[=======================================================================[.rst: +ECMFindModuleHelpers +-------------------- + +Helper macros for find modules: ``ecm_find_package_version_check()``, +``ecm_find_package_parse_components()`` and +``ecm_find_package_handle_library_components()``. + +:: + + ecm_find_package_version_check() + +Prints warnings if the CMake version or the project's required CMake version +is older than that required by extra-cmake-modules. + +:: + + ecm_find_package_parse_components( + RESULT_VAR + KNOWN_COMPONENTS [ [...]] + [SKIP_DEPENDENCY_HANDLING]) + +This macro will populate with a list of components found in +_FIND_COMPONENTS, after checking that all those components are in the +list of ``KNOWN_COMPONENTS``; if there are any unknown components, it will print +an error or warning (depending on the value of _FIND_REQUIRED) and call +``return()``. + +The order of components in is guaranteed to match the order they +are listed in the ``KNOWN_COMPONENTS`` argument. + +If ``SKIP_DEPENDENCY_HANDLING`` is not set, for each component the variable +__component_deps will be checked for dependent components. +If is listed in _FIND_COMPONENTS, then all its (transitive) +dependencies will also be added to . + +:: + + ecm_find_package_handle_library_components( + COMPONENTS [ [...]] + [SKIP_DEPENDENCY_HANDLING]) + [SKIP_PKG_CONFIG]) + +Creates an imported library target for each component. The operation of this +macro depends on the presence of a number of CMake variables. + +The __lib variable should contain the name of this library, +and __header variable should contain the name of a header +file associated with it (whatever relative path is normally passed to +'#include'). __header_subdir variable can be used to specify +which subdirectory of the include path the headers will be found in. +``ecm_find_package_components()`` will then search for the library +and include directory (creating appropriate cache variables) and create an +imported library target named ::. + +Additional variables can be used to provide additional information: + +If ``SKIP_PKG_CONFIG``, the __pkg_config variable is set, and +pkg-config is found, the pkg-config module given by +__pkg_config will be searched for and used to help locate the +library and header file. It will also be used to set +__VERSION. + +Note that if version information is found via pkg-config, +__FIND_VERSION can be set to require a particular version +for each component. + +If ``SKIP_DEPENDENCY_HANDLING`` is not set, the ``INTERFACE_LINK_LIBRARIES`` property +of the imported target for will be set to contain the imported +targets for the components listed in __component_deps. +_FOUND will also be set to ``FALSE`` if any of the components in +__component_deps are not found. This requires the components +in __component_deps to be listed before in the +``COMPONENTS`` argument. + +The following variables will be set: + +``_TARGETS`` + the imported targets +``_LIBRARIES`` + the found libraries +``_INCLUDE_DIRS`` + the combined required include directories for the components +``_DEFINITIONS`` + the "other" CFLAGS provided by pkg-config, if any +``_VERSION`` + the value of ``__VERSION`` for the first component that + has this variable set (note that components are searched for in the order + they are passed to the macro), although if it is already set, it will not + be altered + +.. note:: + These variables are never cleared, so if + ``ecm_find_package_handle_library_components()`` is called multiple times with + different components (typically because of multiple ``find_package()`` calls) then + ``_TARGETS``, for example, will contain all the targets found in any + call (although no duplicates). + +Since pre-1.0.0. +#]=======================================================================] + +macro(ecm_find_package_version_check module_name) + if(CMAKE_VERSION VERSION_LESS 3.16.0) + message(FATAL_ERROR "CMake 3.16.0 is required by Find${module_name}.cmake") + endif() + if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.16.0) + message(AUTHOR_WARNING "Your project should require at least CMake 3.16.0 to use Find${module_name}.cmake") + endif() +endmacro() + +macro(ecm_find_package_parse_components module_name) + set(ecm_fppc_options SKIP_DEPENDENCY_HANDLING) + set(ecm_fppc_oneValueArgs RESULT_VAR) + set(ecm_fppc_multiValueArgs KNOWN_COMPONENTS DEFAULT_COMPONENTS) + cmake_parse_arguments(ECM_FPPC "${ecm_fppc_options}" "${ecm_fppc_oneValueArgs}" "${ecm_fppc_multiValueArgs}" ${ARGN}) + + if(ECM_FPPC_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unexpected arguments to ecm_find_package_parse_components: ${ECM_FPPC_UNPARSED_ARGUMENTS}") + endif() + if(NOT ECM_FPPC_RESULT_VAR) + message(FATAL_ERROR "Missing RESULT_VAR argument to ecm_find_package_parse_components") + endif() + if(NOT ECM_FPPC_KNOWN_COMPONENTS) + message(FATAL_ERROR "Missing KNOWN_COMPONENTS argument to ecm_find_package_parse_components") + endif() + if(NOT ECM_FPPC_DEFAULT_COMPONENTS) + set(ECM_FPPC_DEFAULT_COMPONENTS ${ECM_FPPC_KNOWN_COMPONENTS}) + endif() + + if(${module_name}_FIND_COMPONENTS) + set(ecm_fppc_requestedComps ${${module_name}_FIND_COMPONENTS}) + + if(NOT ECM_FPPC_SKIP_DEPENDENCY_HANDLING) + # Make sure deps are included + foreach(ecm_fppc_comp ${ecm_fppc_requestedComps}) + foreach(ecm_fppc_dep_comp ${${module_name}_${ecm_fppc_comp}_component_deps}) + list(FIND ecm_fppc_requestedComps "${ecm_fppc_dep_comp}" ecm_fppc_index) + if("${ecm_fppc_index}" STREQUAL "-1") + if(NOT ${module_name}_FIND_QUIETLY) + message(STATUS "${module_name}: ${ecm_fppc_comp} requires ${${module_name}_${ecm_fppc_comp}_component_deps}") + endif() + list(APPEND ecm_fppc_requestedComps "${ecm_fppc_dep_comp}") + endif() + endforeach() + endforeach() + else() + message(STATUS "Skipping dependency handling for ${module_name}") + endif() + list(REMOVE_DUPLICATES ecm_fppc_requestedComps) + + # This makes sure components are listed in the same order as + # KNOWN_COMPONENTS (potentially important for inter-dependencies) + set(${ECM_FPPC_RESULT_VAR}) + foreach(ecm_fppc_comp ${ECM_FPPC_KNOWN_COMPONENTS}) + list(FIND ecm_fppc_requestedComps "${ecm_fppc_comp}" ecm_fppc_index) + if(NOT "${ecm_fppc_index}" STREQUAL "-1") + list(APPEND ${ECM_FPPC_RESULT_VAR} "${ecm_fppc_comp}") + list(REMOVE_AT ecm_fppc_requestedComps ${ecm_fppc_index}) + endif() + endforeach() + # if there are any left, they are unknown components + if(ecm_fppc_requestedComps) + set(ecm_fppc_msgType STATUS) + if(${module_name}_FIND_REQUIRED) + set(ecm_fppc_msgType FATAL_ERROR) + endif() + if(NOT ${module_name}_FIND_QUIETLY) + message(${ecm_fppc_msgType} "${module_name}: requested unknown components ${ecm_fppc_requestedComps}") + endif() + return() + endif() + else() + set(${ECM_FPPC_RESULT_VAR} ${ECM_FPPC_DEFAULT_COMPONENTS}) + endif() +endmacro() + +macro(ecm_find_package_handle_library_components module_name) + set(ecm_fpwc_options SKIP_PKG_CONFIG SKIP_DEPENDENCY_HANDLING) + set(ecm_fpwc_oneValueArgs) + set(ecm_fpwc_multiValueArgs COMPONENTS) + cmake_parse_arguments(ECM_FPWC "${ecm_fpwc_options}" "${ecm_fpwc_oneValueArgs}" "${ecm_fpwc_multiValueArgs}" ${ARGN}) + + if(ECM_FPWC_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unexpected arguments to ecm_find_package_handle_components: ${ECM_FPWC_UNPARSED_ARGUMENTS}") + endif() + if(NOT ECM_FPWC_COMPONENTS) + message(FATAL_ERROR "Missing COMPONENTS argument to ecm_find_package_handle_components") + endif() + + include(FindPackageHandleStandardArgs) + find_package(PkgConfig QUIET) + foreach(ecm_fpwc_comp ${ECM_FPWC_COMPONENTS}) + set(ecm_fpwc_dep_vars) + set(ecm_fpwc_dep_targets) + if(NOT SKIP_DEPENDENCY_HANDLING) + foreach(ecm_fpwc_dep ${${module_name}_${ecm_fpwc_comp}_component_deps}) + list(APPEND ecm_fpwc_dep_vars "${module_name}_${ecm_fpwc_dep}_FOUND") + list(APPEND ecm_fpwc_dep_targets "${module_name}::${ecm_fpwc_dep}") + endforeach() + endif() + + if(NOT ECM_FPWC_SKIP_PKG_CONFIG AND ${module_name}_${ecm_fpwc_comp}_pkg_config) + pkg_check_modules(PKG_${module_name}_${ecm_fpwc_comp} QUIET + ${${module_name}_${ecm_fpwc_comp}_pkg_config}) + endif() + + find_path(${module_name}_${ecm_fpwc_comp}_INCLUDE_DIR + NAMES ${${module_name}_${ecm_fpwc_comp}_header} + HINTS ${PKG_${module_name}_${ecm_fpwc_comp}_INCLUDE_DIRS} + PATH_SUFFIXES ${${module_name}_${ecm_fpwc_comp}_header_subdir} + ) + find_library(${module_name}_${ecm_fpwc_comp}_LIBRARY + NAMES ${${module_name}_${ecm_fpwc_comp}_lib} + HINTS ${PKG_${module_name}_${ecm_fpwc_comp}_LIBRARY_DIRS} + ) + + set(${module_name}_${ecm_fpwc_comp}_VERSION "${PKG_${module_name}_${ecm_fpwc_comp}_VERSION}") + if(NOT ${module_name}_VERSION) + set(${module_name}_VERSION ${${module_name}_${ecm_fpwc_comp}_VERSION}) + endif() + + set(FPHSA_NAME_MISMATCHED 1) + find_package_handle_standard_args(${module_name}_${ecm_fpwc_comp} + FOUND_VAR + ${module_name}_${ecm_fpwc_comp}_FOUND + REQUIRED_VARS + ${module_name}_${ecm_fpwc_comp}_LIBRARY + ${module_name}_${ecm_fpwc_comp}_INCLUDE_DIR + ${ecm_fpwc_dep_vars} + VERSION_VAR + ${module_name}_${ecm_fpwc_comp}_VERSION + ) + unset(FPHSA_NAME_MISMATCHED) + + mark_as_advanced( + ${module_name}_${ecm_fpwc_comp}_LIBRARY + ${module_name}_${ecm_fpwc_comp}_INCLUDE_DIR + ) + + if(${module_name}_${ecm_fpwc_comp}_FOUND) + list(APPEND ${module_name}_LIBRARIES + "${${module_name}_${ecm_fpwc_comp}_LIBRARY}") + list(APPEND ${module_name}_INCLUDE_DIRS + "${${module_name}_${ecm_fpwc_comp}_INCLUDE_DIR}") + set(${module_name}_DEFINITIONS + ${${module_name}_DEFINITIONS} + ${PKG_${module_name}_${ecm_fpwc_comp}_DEFINITIONS}) + if(NOT TARGET ${module_name}::${ecm_fpwc_comp}) + add_library(${module_name}::${ecm_fpwc_comp} UNKNOWN IMPORTED) + set_target_properties(${module_name}::${ecm_fpwc_comp} PROPERTIES + IMPORTED_LOCATION "${${module_name}_${ecm_fpwc_comp}_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PKG_${module_name}_${ecm_fpwc_comp}_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${${module_name}_${ecm_fpwc_comp}_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${ecm_fpwc_dep_targets}" + ) + endif() + list(APPEND ${module_name}_TARGETS + "${module_name}::${ecm_fpwc_comp}") + endif() + endforeach() + if(${module_name}_LIBRARIES) + list(REMOVE_DUPLICATES ${module_name}_LIBRARIES) + endif() + if(${module_name}_INCLUDE_DIRS) + list(REMOVE_DUPLICATES ${module_name}_INCLUDE_DIRS) + endif() + if(${module_name}_DEFINITIONS) + list(REMOVE_DUPLICATES ${module_name}_DEFINITIONS) + endif() + if(${module_name}_TARGETS) + list(REMOVE_DUPLICATES ${module_name}_TARGETS) + endif() +endmacro() diff --git a/src/VideoManager/VideoReceiver/GStreamer/CMakeLists.txt b/src/VideoManager/VideoReceiver/GStreamer/CMakeLists.txt index f1f723be955..bf4b14e47c4 100644 --- a/src/VideoManager/VideoReceiver/GStreamer/CMakeLists.txt +++ b/src/VideoManager/VideoReceiver/GStreamer/CMakeLists.txt @@ -47,6 +47,3 @@ target_link_libraries(GStreamerReceiver ) target_compile_definitions(QGC PUBLIC QGC_GST_STREAMING) -if(CMAKE_BUILD_TYPE STREQUAL "Release") - target_compile_definitions(GStreamerReceiver PRIVATE QGC_INSTALL_RELEASE) -endif() diff --git a/src/VideoManager/VideoReceiver/GStreamer/GStreamer.cc b/src/VideoManager/VideoReceiver/GStreamer/GStreamer.cc index 0e2784c9831..00b3c502432 100644 --- a/src/VideoManager/VideoReceiver/GStreamer/GStreamer.cc +++ b/src/VideoManager/VideoReceiver/GStreamer/GStreamer.cc @@ -192,7 +192,7 @@ GStreamer::initialize(int argc, char* argv[], int debuglevel) // qgcputenv("GST_PLUGIN_SYSTEM_PATH", "C:/gstreamer/1.0/msvc_x86_64", "/lib/gstreamer-1.0"); qgcputenv("GST_PLUGIN_PATH_1_0", currentDir, ""); qgcputenv("GST_PLUGIN_PATH", currentDir, ""); -#elif defined(Q_OS_LINUX) +#elif defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) // const QString currentDir = QCoreApplication::applicationDirPath(); // qgcputenv("GST_REGISTRY_REUSE_PLUGIN_SCANNER", "no", ""); // qgcputenv("GST_PLUGIN_SCANNER", currentDir, "/../lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"); diff --git a/src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt b/src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt index dcb51a009be..f4e8fb30b53 100644 --- a/src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt +++ b/src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt @@ -1,30 +1,51 @@ -find_package(GStreamer REQUIRED COMPONENTS Allocators Audio Codecparsers Controller Mpegts Net Pbutils Riff Rtp Rtsp Sdp Tag OPTIONAL_COMPONENTS Va Photography X11 EGL Wayland) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick) +find_package(GStreamer REQUIRED COMPONENTS Allocators Audio Codecparsers Controller Fft Mpegts Net Pbutils Riff Rtp Rtsp Sdp Tag OPTIONAL_COMPONENTS Photography Prototypes Va X11 EGL Wayland) -# Use Latest Revisions for each minor version: 1.16.3, 1.18.6, 1.20.7, 1.22.12, 1.24.7 -string(REPLACE "." ";" GST_VERSION_LIST ${GStreamer_VERSION}) -list(GET GST_VERSION_LIST 0 GST_VERSION_MAJOR) -list(GET GST_VERSION_LIST 1 GST_VERSION_MINOR) -list(GET GST_VERSION_LIST 2 GST_VERSION_PATCH) -cmake_print_variables(GST_VERSION_MAJOR GST_VERSION_MINOR GST_VERSION_PATCH) +qt_add_library(gstqml6gl STATIC) -if(GST_VERSION_MINOR EQUAL 16) - set(GST_VERSION_PATCH 3) -elseif(GST_VERSION_MINOR EQUAL 18) - set(GST_VERSION_PATCH 6) -elseif(GST_VERSION_MINOR EQUAL 20) - set(GST_VERSION_PATCH 7) -elseif(GST_VERSION_MINOR EQUAL 22) - set(GST_VERSION_PATCH 12) -elseif(GST_VERSION_MINOR EQUAL 24) - set(GST_VERSION_PATCH 7) +target_link_libraries(gstqml6gl + PRIVATE + Qt6::GuiPrivate + PUBLIC + Qt6::Core + Qt6::Gui + Qt6::Qml + Qt6::Quick + GStreamer::GStreamer + GStreamer::Allocators + GStreamer::Audio + GStreamer::Codecparsers + GStreamer::Controller + GStreamer::Fft + GStreamer::Mpegts + GStreamer::Net + GStreamer::Pbutils + GStreamer::Riff + GStreamer::Rtp + GStreamer::Rtsp + GStreamer::Sdp + GStreamer::Tag +) + +# Photography not found on ubuntu 20.04? +if(GStreamer_Photography_FOUND) + target_link_libraries(gstqml6gl PUBLIC GStreamer::Photography) +endif() + +if(GStreamer_Prototypes_FOUND) + target_link_libraries(gstqml6gl PUBLIC GStreamer::Prototypes) +endif() + +if(GStreamer_Va_FOUND) + target_link_libraries(gstqml6gl PUBLIC GStreamer::Va) endif() -set(GST_PLUGINS_VERSION ${GST_VERSION_MAJOR}.${GST_VERSION_MINOR}.${GST_VERSION_PATCH}) -cmake_print_variables(GST_PLUGINS_VERSION) +################################################################################ +# TODO: Don't Download & Build if gstreamer1.0-qt6 was found if(GStreamer_VERSION VERSION_GREATER_EQUAL 1.22) FetchContent_Declare(gstreamer_good_plugins - # https://gitlab.freedesktop.org/gstreamer/gstreamer/-/archive/${GST_PLUGINS_VERSION}/gstreamer-${GST_PLUGINS_VERSION}.zip?path=subprojects/gst-plugins-good/ext/qt6 + # URL https://gitlab.freedesktop.org/gstreamer/gstreamer/-/archive/${GStreamer_VERSION}/gstreamer-${GStreamer_VERSION}.zip?path=subprojects/gst-plugins-good/ext/qt6 URL https://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-${GST_PLUGINS_VERSION}.tar.xz DOWNLOAD_EXTRACT_TIMESTAMP true ) @@ -50,77 +71,31 @@ file(GLOB gstqml6gl_SRCS ${QGC_GST_QT6_PLUGIN_PATH}/*.cc ${QGC_GST_QT6_PLUGIN_PATH}/*.h ) -qt_add_library(gstqml6gl STATIC ${gstqml6gl_SRCS}) +target_sources(gstqml6gl PRIVATE ${gstqml6gl_SRCS}) target_include_directories(gstqml6gl PUBLIC ${QGC_GST_QT6_PLUGIN_PATH}) -find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick) - -target_link_libraries(gstqml6gl - PRIVATE - Qt6::GuiPrivate - PUBLIC - Qt6::Core - Qt6::Gui - Qt6::Qml - Qt6::Quick - GStreamer::GStreamer - GStreamer::Allocators - GStreamer::Audio - GStreamer::Codecparsers - GStreamer::Controller - GStreamer::Mpegts - GStreamer::Net - GStreamer::Pbutils - GStreamer::Riff - GStreamer::Rtp - GStreamer::Rtsp - GStreamer::Sdp - GStreamer::Tag -) - -# Photography not found on ubuntu 20.04? -if(GStreamer_Photography_FOUND) - target_link_libraries(gstqml6gl PUBLIC GStreamer::Photography) -endif() - -if(GStreamer_Va_FOUND) - target_link_libraries(gstqml6gl PUBLIC GStreamer::Va) -endif() +################################################################################ if(GStreamer_X11_FOUND) - # X11, XCB, X11_XCB, GLX target_link_libraries(gstqml6gl PUBLIC GStreamer::X11) target_compile_definitions(gstqml6gl PRIVATE HAVE_QT_X11) endif() if(GStreamer_EGL_FOUND) - # EGL target_link_libraries(gstqml6gl PUBLIC GStreamer::EGL) target_compile_definitions(gstqml6gl PRIVATE HAVE_QT_EGLFS) endif() if(GStreamer_Wayland_FOUND) - # find_package(Wayland COMPONENTS Client Cursor Egl) - # find_package(WaylandProtocols) - # find_package(WaylandScanner) - find_package(Qt6 COMPONENTS WaylandClient) - if(Qt6WaylandClient_FOUND) - target_link_libraries(gstqml6gl PUBLIC GStreamer::Wayland Qt6::WaylandClient) - target_compile_definitions(gstqml6gl PRIVATE HAVE_QT_WAYLAND) - endif() + target_link_libraries(gstqml6gl PUBLIC GStreamer::Wayland) + target_compile_definitions(gstqml6gl PRIVATE HAVE_QT_WAYLAND) endif() if(ANDROID) - # GLESv2, egl target_compile_definitions(gstqml6gl PRIVATE HAVE_QT_ANDROID) elseif(WIN32) - # GDI32, egl, GLESv2 - find_package(OpenGL) - if(OpenGL_FOUND) - target_link_libraries(gstqml6gl PUBLIC OpenGL::GL) - target_compile_definitions(gstqml6gl PRIVATE HAVE_QT_WIN32) - endif() + target_compile_definitions(gstqml6gl PRIVATE HAVE_QT_WIN32) elseif(MACOS) # appleframeworks # Foundation, QuartzCore, CoreFoundation @@ -138,39 +113,44 @@ target_compile_definitions(gstqml6gl QT_QPA_HEADER= ) +################################################################################ + if(EXISTS "${QGC_GST_QT6_PLUGIN_PATH}/resources.qrc") find_package(Qt6 REQUIRED COMPONENTS ShaderTools) - - set(SHADERS - ${QGC_GST_QT6_PLUGIN_PATH}/vertex.vert - ${QGC_GST_QT6_PLUGIN_PATH}/YUV_TRIPLANAR.frag - ${QGC_GST_QT6_PLUGIN_PATH}/RGBA.frag - ) - set(OUTPUTS - vertex.vert.qsb - YUV_TRIPLANAR.frag.qsb - RGBA.frag.qsb - ) - if(EXISTS "${QGC_GST_QT6_PLUGIN_PATH}/YUV_BIPLANAR.frag") - LIST(APPEND SHADERS ${QGC_GST_QT6_PLUGIN_PATH}/YUV_BIPLANAR.frag) - LIST(APPEND OUTPUTS YUV_BIPLANAR.frag.qsb) - endif() - if(EXISTS "${QGC_GST_QT6_PLUGIN_PATH}/RGBA_gles.frag") - LIST(APPEND SHADERS ${QGC_GST_QT6_PLUGIN_PATH}/RGBA.frag@glsl,100es,${QGC_GST_QT6_PLUGIN_PATH}/RGBA_gles.frag) - LIST(APPEND OUTPUTS RGBA_gles.frag.qsb) - # file(COPY_FILE RGBA_gles.frag RGBA_gles.frag.qsb) - # LIST(APPEND OUTPUTS RGBA_gles.frag.qsb.external) + if(Qt6ShaderTools_FOUND) + set(SHADERS + ${QGC_GST_QT6_PLUGIN_PATH}/vertex.vert + ${QGC_GST_QT6_PLUGIN_PATH}/YUV_TRIPLANAR.frag + ${QGC_GST_QT6_PLUGIN_PATH}/RGBA.frag + ) + set(OUTPUTS + vertex.vert.qsb + YUV_TRIPLANAR.frag.qsb + RGBA.frag.qsb + ) + if(EXISTS "${QGC_GST_QT6_PLUGIN_PATH}/YUV_BIPLANAR.frag") + LIST(APPEND SHADERS ${QGC_GST_QT6_PLUGIN_PATH}/YUV_BIPLANAR.frag) + LIST(APPEND OUTPUTS YUV_BIPLANAR.frag.qsb) + endif() + if(EXISTS "${QGC_GST_QT6_PLUGIN_PATH}/RGBA_gles.frag") + LIST(APPEND SHADERS ${QGC_GST_QT6_PLUGIN_PATH}/RGBA.frag@glsl,100es,${QGC_GST_QT6_PLUGIN_PATH}/RGBA_gles.frag) + LIST(APPEND OUTPUTS RGBA_gles.frag.qsb) + # file(COPY_FILE RGBA_gles.frag RGBA_gles.frag.qsb) + # LIST(APPEND OUTPUTS RGBA_gles.frag.qsb.external) + endif() + qt6_add_shaders(gstqml6gl "gstqml6gl_shaders" + PREFIX "/org/freedesktop/gstreamer/qml6" + GLSL "100 es,120,330" + OUTPUT_TARGETS gstqml6gl_shaders + FILES ${SHADERS} + OUTPUTS ${OUTPUTS} + BATCHABLE + ) endif() - qt6_add_shaders(gstqml6gl "gstqml6gl_shaders" - PREFIX "/org/freedesktop/gstreamer/qml6" - GLSL "100 es,120,330" - OUTPUT_TARGETS gstqml6gl_shaders - FILES ${SHADERS} - OUTPUTS ${OUTPUTS} - BATCHABLE - ) endif() +################################################################################ + if(UNIX) target_compile_options(gstqml6gl PRIVATE @@ -180,150 +160,35 @@ if(UNIX) ) endif() -# gstva, gstasf -set(GST_TARGET_PLUGINS - gstcoreelements - gstisomp4 - gstlibav - gstmatroska - gstmpegtsdemux - gstopengl - gstplayback - gstrtp - gstrtpmanager - gstrtsp - gstsdpelem - gsttcp - gstudp - gstvideoparsersbad - gstx264 -) -if(ANDROID) - list(APPEND GST_TARGET_PLUGINS gstandroidmedia) -elseif(IOS) - list(APPEND GST_TARGET_PLUGINS gstapplemedia) -endif() - -find_package(PkgConfig QUIET) -if(PkgConfig_FOUND) - pkg_check_modules(GST_PLUGINS IMPORTED_TARGET ${GST_TARGET_PLUGINS}) - if(GST_PLUGINS_FOUND) - target_link_libraries(gstqml6gl PUBLIC PkgConfig::GST_PLUGINS) - if(WIN32) - # install(FILES ${GST_PLUGINS_LIBRARIES} DESTINATION ${CMAKE_INSTALL_BINDIR}) - elseif(LINUX) - install(FILES ${GST_PLUGINS_LIBRARIES} DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() - endif() - - pkg_check_modules(GSTREAMER_PLUGINS_BASE IMPORTED_TARGET gstreamer-plugins-base-1.0) - if(GSTREAMER_PLUGINS_BASE_FOUND) - target_link_libraries(gstqml6gl PUBLIC PkgConfig::GSTREAMER_PLUGINS_BASE) - endif() -endif() - -if(NOT GST_PLUGINS_FOUND) - foreach(plugin IN LISTS GST_TARGET_PLUGINS) - find_library(GStreamer_${plugin}_LIBRARY - NAMES ${plugin} - PATHS - ${GSTREAMER_PREFIX}/lib - ${GSTREAMER_PREFIX}/lib/gstreamer-1.0 - ${GSTREAMER_PREFIX}/lib/x86_64-linux-gnu - ${GSTREAMER_PREFIX}/lib/x86_64-linux-gnu/gstreamer-1.0 - ${GSTREAMER_PREFIX}/Versions/Current/lib - ${GSTREAMER_PREFIX}/Versions/Current/lib/gstreamer-1.0 - ) - if(GStreamer_${plugin}_LIBRARY) - cmake_print_variables(GStreamer_${plugin}_LIBRARY) - target_link_libraries(gstqml6gl PUBLIC ${GStreamer_${plugin}_LIBRARY}) - if(WIN32) - # install(FILES ${GStreamer_${plugin}_LIBRARY} DESTINATION ${CMAKE_INSTALL_BINDIR}) - elseif(LINUX) - install(FILES ${GStreamer_${plugin}_LIBRARY} DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() - endif() - endforeach() - - if(ANDROID) - target_include_directories(gstqml6gl - PUBLIC - ${GSTREAMER_PREFIX}/include/gstreamer-1.0 - ${GSTREAMER_PREFIX}/include/glib-2.0 - ${GSTREAMER_PREFIX}/lib/glib-2.0/include - ${GSTREAMER_PREFIX}/lib/graphene-1.0/include - ${GSTREAMER_PREFIX}/lib/gstreamer-1.0/include - ${GSTREAMER_PREFIX}/include - ) - - find_package(FFMPEG REQUIRED COMPONENTS avcodec avfilter avformat avutil swresample) - if(FFMPEG_FOUND) - target_link_libraries(gstqml6gl PUBLIC ${FFMPEG_LIBRARIES}) - target_include_directories(gstqml6gl PUBLIC ${FFMPEG_INCLUDE_DIRS}) - endif() - - find_package(BZip2) - if(BZIP2_FOUND) - target_link_libraries(gstqml6gl PUBLIC BZip2::BZip2) - endif() - - find_library(graphene_LIBRARY graphene-1.0) - if(graphene_LIBRARY) - target_link_libraries(gstqml6gl PUBLIC ${graphene_LIBRARY}) - endif() - - find_library(x264_LIBRARY x264) - if(x264_LIBRARY) - target_link_libraries(gstqml6gl PUBLIC ${x264_LIBRARY}) - endif() - - find_package(JPEG) - if(JPEG_FOUND) - target_link_libraries(gstqml6gl PUBLIC JPEG::JPEG) - endif() - - find_package(PNG) - if(PNG_FOUND) - target_link_libraries(gstqml6gl PUBLIC PNG::PNG) - endif() - - endif() -endif() - -if(ANDROID) - target_link_options(gstqml6gl PUBLIC "-Wl,-Bsymbolic") -endif() - -if(QGC_GST_STATIC_BUILD) - target_compile_definitions(gstqml6gl PUBLIC QGC_GST_STATIC_BUILD) -endif() +################################################################################ if(LINUX) install(DIRECTORY ${GSTREAMER_PREFIX}/lib/x86_64-linux-gnu/gstreamer1.0 DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(DIRECTORY ${GSTREAMER_PREFIX}/lib/x86_64-linux-gnu/gio DESTINATION ${CMAKE_INSTALL_LIBDIR}) elseif(WIN32) - cmake_path(CONVERT "${GSTREAMER_PREFIX}/libexec/gstreamer-1.0/*.exe" TO_CMAKE_PATH_LIST GST_HELPER_BINS_PATH) - file(GLOB GST_HELPER_BINS ${GST_HELPER_BINS_PATH}) - install(FILES ${GST_HELPER_BINS} DESTINATION ${CMAKE_INSTALL_BINDIR}) - - cmake_path(CONVERT "${GSTREAMER_PREFIX}/lib/gio" TO_CMAKE_PATH_LIST GST_GIO_PATH) - install(DIRECTORY ${GST_GIO_PATH} DESTINATION ${CMAKE_INSTALL_BINDIR}) - - # cmake_path(CONVERT "${GSTREAMER_PREFIX}/share/gstreamer/gst-env" TO_CMAKE_PATH_LIST GST_SHARE_ENV_PATH) - # TODO: update GSTREAMER_ROOT & install - # install(CODE GST_SHARE_ENV_PATH) -endif() - -if(WIN32) cmake_path(CONVERT "${GSTREAMER_PREFIX}/bin/*.dll" TO_CMAKE_PATH_LIST GST_WIN_BINS_PATH) file(GLOB GST_WIN_BINS ${GST_WIN_BINS_PATH}) install(FILES ${GST_WIN_BINS} DESTINATION ${CMAKE_INSTALL_BINDIR}) - cmake_path(CONVERT "${GSTREAMER_PREFIX}/lib/*.dll" TO_CMAKE_PATH_LIST GST_WIN_LIBS_PATH) - file(GLOB GST_WIN_LIBS ${GST_WIN_LIBS_PATH}) - install(FILES ${GST_WIN_LIBS} DESTINATION ${CMAKE_INSTALL_BINDIR}) + cmake_path(CONVERT "${GSTREAMER_PREFIX}/lib/gio/modules/*.dll" TO_CMAKE_PATH_LIST GST_GIO_MODULES_PATH) + file(GLOB GST_GIO_MODULES ${GST_GIO_MODULES_PATH}) + install(FILES ${GST_GIO_MODULES} DESTINATION ${CMAKE_INSTALL_LIBDIR}/gio/modules) cmake_path(CONVERT "${GSTREAMER_PREFIX}/lib/gstreamer-1.0/*.dll" TO_CMAKE_PATH_LIST GST_WIN_PLUGINS_PATH) file(GLOB GST_WIN_PLUGINS ${GST_WIN_PLUGINS_PATH}) - install(FILES ${GST_WIN_PLUGINS} DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(FILES ${GST_WIN_PLUGINS} DESTINATION ${CMAKE_INSTALL_LIBDIR}/gstreamer-1.0) + + cmake_path(CONVERT "${GSTREAMER_PREFIX}/libexec/gstreamer-1.0/*.exe" TO_CMAKE_PATH_LIST GST_HELPER_BINS_PATH) + file(GLOB GST_HELPER_BINS ${GST_HELPER_BINS_PATH}) + install(FILES ${GST_HELPER_BINS} DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/gstreamer-1.0) +elseif(ANDROID) + # install(DIRECTORY ${GSTREAMER_PREFIX}/share/gst-android/ndk-build/androidmedia DESTINATION ${CMAKE_SOURCE_DIR}/android/src/org/freedesktop/androidmedia) + # install(FILES ${GSTREAMER_PREFIX}/share/gst-android/ndk-build/GStreamer.java DESTINATION ${CMAKE_SOURCE_DIR}/android/src/org/freedesktop/androidmedia) + if(CMAKE_HOST_WIN32) + cmake_path(CONVERT "${GSTREAMER_PREFIX}/share/gst-android/ndk-build/tools/windows/*.dll" TO_CMAKE_PATH_LIST GST_WIN_TOOLS_PATH) + file(GLOB GST_WIN_TOOLS ${GST_WIN_TOOLS_PATH}) + install(FILES ${GST_WIN_TOOLS} DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() endif() + +################################################################################ diff --git a/tools/setup/install-dependencies-debian.sh b/tools/setup/install-dependencies-debian.sh index 5213a1a04ed..7dae7f1a9ce 100755 --- a/tools/setup/install-dependencies-debian.sh +++ b/tools/setup/install-dependencies-debian.sh @@ -78,9 +78,14 @@ DEBIAN_FRONTEND=noninteractive apt -y --quiet install \ gstreamer1.0-vaapi \ gstreamer1.0-x +if apt-cache show gstreamer1.0-qt6 >/dev/null 2>&1 && apt-cache show gstreamer1.0-qt6 2>/dev/null | grep -q "^Package: gstreamer1.0-qt6"; then + DEBIAN_FRONTEND=noninteractive apt-get install -y --quiet gstreamer1.0-qt6 +fi + # Additional DEBIAN_FRONTEND=noninteractive apt -y --quiet install \ flite1-dev \ + intel-media-va-driver \ libasound2-dev \ libass-dev \ libdrm-dev \ @@ -88,6 +93,8 @@ DEBIAN_FRONTEND=noninteractive apt -y --quiet install \ libexiv2-dev \ libgbm-dev \ libgl1-mesa-dev \ + libgl-dev \ + libglx-dev \ libgles2-mesa-dev \ libglu1-mesa-dev \ libglfw3-dev \ @@ -97,8 +104,9 @@ DEBIAN_FRONTEND=noninteractive apt -y --quiet install \ libspeechd-dev \ libunwind-dev \ libva-dev \ - libvpx-dev \ libvdpau-dev \ + libvpx-dev \ + libvpl-dev \ libwayland-dev \ libx11-dev \ libzstd-dev \