diff --git a/.cirrus.yml b/.cirrus.yml index 69ab5c1456397c..c2d2ca7d94394e 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -9,19 +9,21 @@ env: task: install_script: - - pkg install -y - alsa-lib - v4l_compat swig ffmpeg curl dbus fdk-aac fontconfig - freetype2 jackit jansson luajit mbedtls pulseaudio speexdsp - libpci librist libsysinfo libudev-devd libv4l libx264 cmake ninja - mesa-libs lua52 pkgconf - srt - qt5-svg qt5-qmake qt5-buildtools qt5-x11extras qt5-xml - pipewire + - pkg-install -y + cmake ninja binutils pkgconf curl + ffmpeg qt6-base qt6-svg jansson libsysinfo e2fsprogs-libuuid pulseaudio + alsa-lib pipewire v4l_compat libpci librist srt nlohmann-json uthash + qr-code-generator websocketpp asio vlc swig luajit jackit sndio fdk-aac script: - - mkdir build - - cd build - cmake - -DENABLE_AJA=OFF - -GNinja .. - - ninja + -S $(pwd) + -B build + -G Ninja + -DOBS_CMAKE_VERSION=3.0 + -DENABLE_JACK:BOOL=ON + -DENABLE_SNDIO:BOOL=ON + -DENABLE_LIBFDK:BOOL=ON + -DENABLE_WEBRTC:BOOL=OFF + - cmake + --build build + --config RelWithDebInfo diff --git a/.github/actions/build-obs/action.yaml b/.github/actions/build-obs/action.yaml index 16a65763982be0..bfe88ac52b223b 100644 --- a/.github/actions/build-obs/action.yaml +++ b/.github/actions/build-obs/action.yaml @@ -73,12 +73,12 @@ runs: local -a build_args=( --config ${{ inputs.config }} - --target linux-${{ inputs.target }} + --target ubuntu-${{ inputs.target }} ) if (( ${+RUNNER_DEBUG} )) build_args+=(--debug) git fetch origin --no-tags --no-recurse-submodules -q - .github/scripts/build-linux ${build_args} + .github/scripts/build-ubuntu ${build_args} - name: Run Windows Build if: runner.os == 'Windows' diff --git a/.github/actions/package-obs/action.yaml b/.github/actions/package-obs/action.yaml index 0c5fa42e51e279..7247e469716d4c 100644 --- a/.github/actions/package-obs/action.yaml +++ b/.github/actions/package-obs/action.yaml @@ -81,14 +81,14 @@ runs: : Run Ubuntu Packaging local -a package_args=( - --target linux-${{ inputs.target }} + --target ubuntu-${{ inputs.target }} --config ${{ inputs.config }} ) if (( ${+RUNNER_DEBUG} )) build_args+=(--debug) if [[ '${{ inputs.package }}' == true ]] package_args+=(--package) - ${{ inputs.workingDirectory }}/.github/scripts/package-linux ${package_args} + ${{ inputs.workingDirectory }}/.github/scripts/package-ubuntu ${package_args} - name: Run Windows packaging if: runner.os == 'Windows' diff --git a/.github/scripts/.build.zsh b/.github/scripts/.build.zsh index b54ec882f3554d..1f9d690330adc6 100755 --- a/.github/scripts/.build.zsh +++ b/.github/scripts/.build.zsh @@ -56,7 +56,8 @@ build() { local -r -a _valid_targets=( macos-x86_64 macos-arm64 - linux-x86_64 + ubuntu-x86_64 + ubuntu-aarch64 ) local config='RelWithDebInfo' @@ -66,7 +67,7 @@ build() { local -a args while (( # )) { case ${1} { - -t|--target|--generator|-c|--config) + -t|--target|-c|--config) if (( # == 1 )) || [[ ${2:0:1} == '-' ]] { log_error "Missing value for option %B${1}%b" exit 2 @@ -104,8 +105,8 @@ build() { check_${host_os} setup_ccache - if [[ ${host_os} == linux ]] { - autoload -Uz setup_linux && setup_linux + if [[ ${host_os} == ubuntu ]] { + autoload -Uz setup_ubuntu && setup_ubuntu } local product_name @@ -188,21 +189,20 @@ build() { } popd ;; - linux-*) + ubuntu-*) local cmake_bin='/usr/bin/cmake' cmake_args+=( - -S ${PWD} -B build_${target##*-} - -G Ninja - -DCMAKE_BUILD_TYPE:STRING=${config} - -DCEF_ROOT_DIR:PATH="${project_root}/.deps/cef_binary_${CEF_VERSION}_${target//-/_}" - -DENABLE_AJA:BOOL=OFF - -DENABLE_WEBRTC:BOOL=OFF - -DENABLE_NATIVE_NVENC:BOOL=OFF + --preset ubuntu-ci + --toolchain ${project_root}/cmake/linux/toolchain-${target##*-}-gcc.cmake + -DENABLE_BROWSER:BOOL=ON + -DCEF_ROOT_DIR:PATH="${project_root}/.deps/cef_binary_${CEF_VERSION}_${target//ubuntu-/linux_}" ) + if (( ! UBUNTU_2210_OR_LATER )) cmake_args+=(-DENABLE_NEW_MPEGTS_OUTPUT:BOOL=OFF) + if [[ ${target##*-} == aarch64 ]] cmake-args+=(-DENABLE_QSV11:BOOL=OFF) - cmake_build_args+=(build_${target##*-} --config ${config} --parallel) - cmake_install_args+=(build_${target##*-} --prefix ${project_root}/build_${target##*-}/install/${config}) + cmake_build_args+=(build_${target%%-*} --config ${config} --parallel) + cmake_install_args+=(build_${target%%-*} --prefix ${project_root}/build_${target%%-*}/install/${config}) log_group "Configuring ${product_name}..." ${cmake_bin} -S ${project_root} ${cmake_args} diff --git a/.github/scripts/.package.zsh b/.github/scripts/.package.zsh index b9411bec193a19..85c23bfd2217ad 100755 --- a/.github/scripts/.package.zsh +++ b/.github/scripts/.package.zsh @@ -51,7 +51,7 @@ package() { local -r -a _valid_targets=( macos-x86_64 macos-arm64 - linux-x86_64 + ubuntu-x86_64 ) local config='RelWithDebInfo' @@ -208,7 +208,7 @@ package() { log_group - } elif [[ ${host_os} == linux ]] { + } elif [[ ${host_os} == ubuntu ]] { local cmake_bin='/usr/bin/cmake' local -a cmake_args=() if (( debug )) cmake_args+=(--verbose) @@ -216,11 +216,11 @@ package() { if (( package )) { log_group "Packaging obs-studio..." pushd ${project_root} - ${cmake_bin} --build build_${target##*-} --config ${config} -t package ${cmake_args} - output_name="${output_name}-${target##*-}-linux-gnu" + ${cmake_bin} --build build_${target%%-*} --config ${config} --target package ${cmake_args} + output_name="${output_name}-${target##*-}-ubuntu-gnu" - pushd ${project_root}/build_${target##*-} - local -a files=(obs-studio-*-Linux*.(ddeb|deb)) + pushd ${project_root}/build_${target%%-*} + local -a files=(obs-studio-*-Linux*.(ddeb|deb|ddeb.sha256|deb.sha256)) for file (${files}) { mv ${file} ${file//obs-studio-*-Linux/${output_name}} } @@ -228,12 +228,25 @@ package() { popd } else { log_group "Archiving obs-studio..." - output_name="${output_name}-${target##*-}-linux-gnu" + output_name="${output_name}-${target##*-}-ubuntu-gnu" - pushd ${project_root}/build_${target##*-}/install/${config} - XZ_OPT=-T0 tar -cvJf ${project_root}/build_${target##*-}/${output_name}.tar.xz (bin|lib|share) + pushd ${project_root}/build_${target%%-*}/install/${config} + XZ_OPT=-T0 tar -cvJf ${project_root}/build_${target%%-*}/${output_name}.tar.xz (bin|lib|share) popd } + + pushd ${project_root} + ${cmake_bin} --build build_${target%%-*} --config ${config} --target package_source ${cmake_args} + output_name="${output_name}-sources" + + pushd ${project_root}/build_${target%%-*} + local -a files=(obs-studio-*-sources.tar.*) + for file (${files}) { + mv ${file} ${file//obs-studio-*-sources/${output_name}} + } + popd + popd + log_group } } diff --git a/.github/scripts/build-linux b/.github/scripts/build-ubuntu similarity index 100% rename from .github/scripts/build-linux rename to .github/scripts/build-ubuntu diff --git a/.github/scripts/package-linux b/.github/scripts/package-ubuntu similarity index 100% rename from .github/scripts/package-linux rename to .github/scripts/package-ubuntu diff --git a/.github/scripts/utils.zsh/check_linux b/.github/scripts/utils.zsh/check_ubuntu similarity index 64% rename from .github/scripts/utils.zsh/check_linux rename to .github/scripts/utils.zsh/check_ubuntu index dc35be12b5d272..bb6509cf7b88f2 100644 --- a/.github/scripts/utils.zsh/check_linux +++ b/.github/scripts/utils.zsh/check_ubuntu @@ -1,19 +1,29 @@ autoload -Uz log_debug log_group -log_group 'Check Linux build requirements' -log_debug 'Checking Linux distribution name and version...' +log_group 'Check Ubuntu build requirements' +log_debug 'Checking Ubuntu distribution name and version...' # Check for Ubuntu version 22.10 or later, which have srt and librist available via apt-get typeset -g -i UBUNTU_2210_OR_LATER=0 -if [[ -f /etc/os_release ]] { +if [[ -f /etc/os-release ]] { local dist_name local dist_version - read -r dist_name dist_version <<< "$(source /etc/os_release; print "${NAME} ${VERSION_ID}")" + read -r dist_name dist_version <<< "$(source /etc/os-release; print "${NAME} ${VERSION_ID}")" + + if [[ ${dist_name} != Ubuntu ]] { + log_error "Not running on an Ubuntu distribution. Aborting" + log_group + return 2 + } autoload -Uz is-at-least - if [[ ${dist_name} == Ubuntu ]] && is-at-least 22.10 ${dist_version}; then + if is-at-least 22.10 ${dist_version}; then typeset -g -i UBUNTU_2210_OR_LATER=1 fi +} else { + log_error "Unable to determine local Linux distribution, but Ubuntu is required. Aborting" + log_group + return 2 } local -a dependencies=("${(fA)$(<${SCRIPT_HOME}/.Aptfile)}") diff --git a/.github/scripts/utils.zsh/setup_linux b/.github/scripts/utils.zsh/setup_ubuntu similarity index 86% rename from .github/scripts/utils.zsh/setup_linux rename to .github/scripts/utils.zsh/setup_ubuntu index fa7ec35490762b..b8df083461218c 100644 --- a/.github/scripts/utils.zsh/setup_linux +++ b/.github/scripts/utils.zsh/setup_ubuntu @@ -40,9 +40,9 @@ if (( ! deps_version )) { log_group 'Setting up pre-built Chromium Embedded Framework...' pushd ${project_root}/.deps -local _filename="cef_binary_${deps_version}_${target//-/_}${deps_revision:+"_v${deps_revision}"}.tar.xz" +local _filename="cef_binary_${deps_version}_${target//ubuntu-/linux_}${deps_revision:+"_v${deps_revision}"}.tar.xz" local _url=${deps_baseurl}/${_filename} -local _target="cef_binary_${deps_version}_${target//-/_}" +local _target="cef_binary_${deps_version}_${target//ubuntu-/linux_}" typeset -g CEF_VERSION=${deps_version} log_debug "Running curl ${curl_opts} ${_url}" @@ -75,14 +75,14 @@ if [[ ${CPUTYPE} != ${target##*-} ]] { } sudo apt-get install -y --no-install-recommends \ - build-essential \ + build-essential libglib2.0-dev \ lsb-release dh-cmake \ libcurl4-openssl-dev \ libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev \ libswresample-dev libswscale-dev \ libjansson-dev \ libx11-xcb-dev \ - libgles2-mesa-dev libgles2-mesa \ + libgles2-mesa-dev \ libwayland-dev \ libpipewire-0.3-dev \ libpulse-dev \ @@ -95,11 +95,13 @@ sudo apt-get install -y --no-install-recommends \ libx11-dev libxcb-randr0-dev libxcb-shm0-dev libxcb-xinerama0-dev \ libxcb-composite0-dev libxinerama-dev libxcb1-dev libx11-xcb-dev libxcb-xfixes0-dev \ swig libcmocka-dev libxss-dev libglvnd-dev \ - libxkbcommon-dev \ + libxkbcommon-dev libatk1.0-dev libatk-bridge2.0-dev libxcomposite-dev libxdamage-dev \ libasound2-dev libfdk-aac-dev libfontconfig-dev libfreetype6-dev libjack-jackd2-dev \ libpulse-dev libsndio-dev libspeexdsp-dev libudev-dev libv4l-dev libva-dev libvlc-dev \ libpci-dev libdrm-dev \ - nlohmann-json3-dev libwebsocketpp-dev libasio-dev libvpl-dev libvpl2 libqrcodegencpp-dev + nlohmann-json3-dev libwebsocketpp-dev libasio-dev libqrcodegencpp-dev + +if [[ ${target##*-} == x86_64 ]] sudo apt-get install -y --no-install-recommends libvpl-dev libvpl2 if (( UBUNTU_2210_OR_LATER )) sudo apt-get install -y --no-install-recommends librist-dev libsrt-openssl-dev diff --git a/.github/workflows/build-project.yaml b/.github/workflows/build-project.yaml index 41d11aa0b407e4..63bd85ad6517fa 100644 --- a/.github/workflows/build-project.yaml +++ b/.github/workflows/build-project.yaml @@ -213,23 +213,22 @@ jobs: - name: Upload Source Tarball 🗜️ uses: actions/upload-artifact@v4 - if: ${{ ! always() }} with: - name: obs-studio-*-sources-${{ needs.check-event.outputs.commitHash }} - path: ${{ github.workspace }}/build_x86_64/obs-studio-*-sources.* + name: obs-studio-ubuntu-22.04-sources-${{ needs.check-event.outputs.commitHash }} + path: ${{ github.workspace }}/build_ubuntu/obs-studio-*-sources.* - name: Upload Artifacts 📡 uses: actions/upload-artifact@v4 with: name: obs-studio-ubuntu-22.04-x86_64-${{ needs.check-event.outputs.commitHash }} - path: ${{ github.workspace }}/build_x86_64/obs-studio-*-x86_64-linux-gnu.* + path: ${{ github.workspace }}/build_ubuntu/obs-studio-*-x86_64-ubuntu-gnu.* - name: Upload Debug Symbol Artifacts 🪲 uses: actions/upload-artifact@v4 if: ${{ fromJSON(needs.check-event.outputs.package) }} with: name: obs-studio-ubuntu-22.04-x86_64-${{ needs.check-event.outputs.commitHash }}-dbgsym - path: ${{ github.workspace }}/build_x86_64/obs-studio-*-x86_64-linux-gnu-dbgsym.ddeb + path: ${{ github.workspace }}/build_ubuntu/obs-studio-*-x86_64-ubuntu-gnu-dbgsym.ddeb - uses: actions/cache/save@v4 if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true' diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 1dbda16d32a42a..1bcd71fc670469 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -264,6 +264,7 @@ jobs: macos_intel_dsym_artifact_name="obs-studio-macos-x86_64-${commit_hash}-dSYMs" ubuntu_x86_64_artifact_name="obs-studio-ubuntu-22.04-x86_64-${commit_hash}" ubuntu_x86_64_debug_name="obs-studio-ubuntu-22.04-x86_64-${commit_hash}-dbgsym" + ubuntu_sources_name="obs-studio-ubuntu-22.04-sources-${commit_hash}" echo '::group::Renaming Artifacts' mv -v "${macos_arm64_artifact_name}/"obs-studio-*-macos-apple.dmg \ @@ -278,6 +279,8 @@ jobs: "${root_dir}"/OBS-Studio-${{ steps.check.outputs.version }}-Ubuntu-x86_64.deb mv -v "${ubuntu_x86_64_debug_name}/"obs-studio-*-x86_64-linux-gnu-dbgsym.ddeb \ "${root_dir}"/OBS-Studio-${{ steps.check.outputs.version }}-Ubuntu-x86_64-dbsym.ddeb + mv -v "${ubuntu_sources_name}/"obs-studio-*-sources.tar.gz \ + "${root_dir}"/OBS-Studio-${{ steps.check.outputs.version }}-Sources.tar.gz echo '::endgroup::' - name: Generate Checksums 🪪 @@ -288,7 +291,7 @@ jobs: shopt -s extglob echo "### Checksums" > ${{ github.workspace }}/CHECKSUMS.txt - for file in ${{ github.workspace }}/@(*.deb|*.ddeb|*.dmg|*.tar.xz); do + for file in ${{ github.workspace }}/@(*.deb|*.ddeb|*.dmg|*.tar.xz|*.tar.gz); do echo " ${file##*/}: $(sha256sum "${file}" | cut -d " " -f 1)" >> ${{ github.workspace }}/CHECKSUMS.txt done @@ -307,3 +310,4 @@ jobs: ${{ github.workspace }}/OBS-Studio-${{ steps.check.outputs.version }}-macOS-*-dSYMs.tar.xz ${{ github.workspace }}/OBS-Studio-${{ steps.check.outputs.version }}-Ubuntu-*.deb ${{ github.workspace }}/OBS-Studio-${{ steps.check.outputs.version }}-Ubuntu-*.ddeb + ${{ github.workspace }}/OBS-Studio-${{ steps.check.outputs.version }}-Sources.tar.gz diff --git a/CI/build-freebsd.sh b/CI/build-freebsd.sh deleted file mode 100755 index 36b615a4c46957..00000000000000 --- a/CI/build-freebsd.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -# FreeBSD full build script -############################################################################## -# -# This script contains all steps necessary to: -# -# * Build OBS with all default plugins and dependencies -# * Package a FreeBSD package -# -# Parameters: -# -h, --help : Print usage help -# -q, --quiet : Suppress most build process output -# -v, --verbose : Enable more verbose build process output -# -d, --skip-dependency-checks : Skip dependency checks (default: off) -# -p, --portable : Create portable build (default: off) -# -pkg, --package : Create distributable archive -# (default: off) -# --build-dir : Specify alternative build directory -# (default: build)" -# -############################################################################## - -# Halt on errors -set -eE - -## SET UP ENVIRONMENT ## -_RUN_OBS_BUILD_SCRIPT=TRUE -PRODUCT_NAME="OBS-Studio" - -CHECKOUT_DIR="$(git rev-parse --show-toplevel)" -DEPS_BUILD_DIR="${CHECKOUT_DIR}/../obs-build-dependencies" -source "${CHECKOUT_DIR}/CI/include/build_support.sh" -source "${CHECKOUT_DIR}/CI/include/build_support_freebsd.sh" - -## DEPENDENCY INSTALLATION -source "${CHECKOUT_DIR}/CI/freebsd/01_install_dependencies.sh" - -## BUILD OBS ## -source "${CHECKOUT_DIR}/CI/freebsd/02_build_obs.sh" - -## PACKAGE OBS AND NOTARIZE ## -source "${CHECKOUT_DIR}/CI/freebsd/03_package_obs.sh" - -## MAIN SCRIPT FUNCTIONS ## -print_usage() { - echo "build-linux.sh - Build script for OBS-Studio\n" - echo -e "Usage: ${0}\n" \ - "-h, --help : Print this help\n" \ - "-q, --quiet : Suppress most build process output\n" \ - "-v, --verbose : Enable more verbose build process output\n" \ - "-d, --skip-dependency-checks : Skip dependency checks (default: off)\n" \ - "-p, --portable : Create portable build (default: off)\n" \ - "-pkg, --package : Create distributable disk image (default: off)\n" \ - "--build-dir : Specify alternative build directory (default: build)\n" -} - -obs-build-main() { - while true; do - case "${1}" in - -h | --help ) print_usage; exit 0 ;; - -q | --quiet ) export QUIET=TRUE; shift ;; - -v | --verbose ) export VERBOSE=TRUE; shift ;; - -d | --skip-dependency-checks ) SKIP_DEP_CHECKS=TRUE; shift ;; - -p | --portable ) PORTABLE=TRUE; shift ;; - -pkg | --package ) PACKAGE=TRUE; shift ;; - --disable-pipewire ) DISABLE_PIPEWIRE=TRUE; shift ;; - --build-dir ) BUILD_DIR="${2}"; shift 2 ;; - -- ) shift; break ;; - * ) break ;; - esac - done - - ensure_dir "${CHECKOUT_DIR}" - step "Fetching OBS tags..." - git fetch origin --tags - - GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) - GIT_HASH=$(git rev-parse --short HEAD) - GIT_TAG=$(git describe --tags --abbrev=0) - - FILE_NAME="obs-studio-${GIT_TAG}-${GIT_HASH}-FreeBSD" - - if [ -z "${SKIP_DEP_CHECKS}" ]; then - install_dependencies - fi - - build_obs - - if [ "${PACKAGE}" ]; then - package_obs - fi - - cleanup -} - -obs-build-main $* diff --git a/CI/freebsd/01_install_dependencies.sh b/CI/freebsd/01_install_dependencies.sh deleted file mode 100644 index bfd0252e75216b..00000000000000 --- a/CI/freebsd/01_install_dependencies.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -# FreeBSD dependency management function -############################################################################## -# -# This script file can be included in build scripts or run directly -# -############################################################################## - -# Halt on errors -set -eE - -install_build-deps() { - shift - status "Install OBS build dependencies" - trap "caught_error 'install_build-deps'" ERR - - sudo pkg install -U -y $@ -} - -install_obs-deps() { - shift - status "Install OBS dependencies" - trap "caught_error 'install_obs-deps'" ERR - - if [ -z "${DISABLE_PIPEWIRE}" ]; then - sudo pkg install -U -y $@ pipewire - else - sudo pkg install -U -y $@ - fi -} - -install_qt-deps() { - shift - status "Install Qt dependencies" - trap "caught_error 'install_qt-deps'" ERR - - sudo pkg install -U -y $@ -} - -install_plugin-deps() { - shift - status "Install plugin dependencies" - trap "caught_error 'install_plugin-deps'" ERR - - sudo pkg install -U -y $@ -} - -install_dependencies() { - status "Set up apt" - trap "caught_error 'install_dependencies'" ERR - - BUILD_DEPS=( - "build-deps cmake ninja pkgconf curl ccache" - "obs-deps ffmpeg libx264 mbedtls mesa-libs jansson lua52 luajit python37 libX11 xorgproto libxcb \ - libXcomposite libXext libXfixes libXinerama libXrandr swig dbus jansson libICE libSM libsysinfo" - "qt-deps qt5-buildtools qt5-qmake qt5-imageformats qt5-core qt5-gui qt5-svg qt5-widgets qt5-xml" - "plugin-deps v4l_compat fdk-aac fontconfig freetype2 speexdsp libudev-devd libv4l vlc audio/jack pulseaudio sndio" - ) - - for DEPENDENCY in "${BUILD_DEPS[@]}"; do - set -- ${DEPENDENCY} - trap "caught_error ${DEPENDENCY}" ERR - FUNC_NAME="install_${1}" - ${FUNC_NAME} ${@} - done -} - -install-dependencies-standalone() { - CHECKOUT_DIR="$(git rev-parse --show-toplevel)" - PRODUCT_NAME="OBS-Studio" - DEPS_BUILD_DIR="${CHECKOUT_DIR}/../obs-build-dependencies" - source "${CHECKOUT_DIR}/CI/include/build_support.sh" - source "${CHECKOUT_DIR}/CI/include/build_support_freebsd.sh" - - status "Setup of OBS build dependencies" - install_dependencies -} - -print_usage() { - echo -e "Usage: ${0}\n" \ - "-h, --help : Print this help\n" \ - "-q, --quiet : Suppress most build process output\n" \ - "-v, --verbose : Enable more verbose build process output\n" - "--disable-pipewire : Disable building with PipeWire support (default: off)\n" -} - -install-dependencies-main() { - if [ -z "${_RUN_OBS_BUILD_SCRIPT}" ]; then - while true; do - case "${1}" in - -h | --help ) print_usage; exit 0 ;; - -q | --quiet ) export QUIET=TRUE; shift ;; - -v | --verbose ) export VERBOSE=TRUE; shift ;; - --disable-pipewire ) DISABLE_PIPEWIRE=TRUE; shift ;; - -- ) shift; break ;; - * ) break ;; - esac - done - - install-dependencies-standalone - fi -} - -install-dependencies-main $* diff --git a/CI/freebsd/02_build_obs.sh b/CI/freebsd/02_build_obs.sh deleted file mode 100644 index 8563cefea50de6..00000000000000 --- a/CI/freebsd/02_build_obs.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -# FreeBSD build function -############################################################################## -# -# This script file can be included in build scripts for FreeBSD or run -# directly -# -############################################################################## - -# Halt on errors -set -eE - -build_obs() { - status "Build OBS" - if [ -z "${CI}" ]; then - _backup_artifacts - fi - - step "Configure OBS..." - _configure_obs - - ensure_dir "${CHECKOUT_DIR}/" - step "Build OBS targets..." - cmake --build ${BUILD_DIR} -} - -# Function to configure OBS build -_configure_obs() { - ensure_dir "${CHECKOUT_DIR}" - status "Configuration of OBS build system..." - check_ccache - - if [ "${TWITCH_CLIENTID}" -a "${TWITCH_HASH}" ]; then - TWITCH_OPTIONS="-DTWITCH_CLIENTID='${TWITCH_CLIENTID}' -DTWITCH_HASH='${TWITCH_HASH}'" - fi - - if [ "${RESTREAM_CLIENTID}" -a "${RESTREAM_HASH}" ]; then - RESTREAM_OPTIONS="-DRESTREAM_CLIENTID='${RESTREAM_CLIENTID}' -DRESTREAM_HASH='${RESTREAM_HASH}'" - fi - - if [ "${YOUTUBE_CLIENTID}" -a "${YOUTUBE_CLIENTID_HASH}" -a "${YOUTUBE_SECRET}" -a "{YOUTUBE_SECRET_HASH}" ]; then - YOUTUBE_OPTIONS="-DYOUTUBE_CLIENTID='${YOUTUBE_CLIENTID}' -DYOUTUBE_CLIENTID_HASH='${YOUTUBE_CLIENTID_HASH}' -DYOUTUBE_SECRET='${YOUTUBE_SECRET}' -DYOUTUBE_SECRET_HASH='${YOUTUBE_SECRET_HASH}'" - fi - - if [ "${PORTABLE}" ]; then - PORTABLE_BUILD="ON" - fi - - if [ "${DISABLE_PIPEWIRE}" ]; then - PIPEWIRE_OPTION="-DENABLE_PIPEWIRE=OFF" - fi - - cmake -S . -B ${BUILD_DIR} -G Ninja \ - -DCMAKE_BUILD_TYPE=${BUILD_CONFIG} \ - -DLINUX_PORTABLE=${PORTABLE_BUILD:-OFF} \ - ${PIPEWIRE_OPTION} \ - ${CCACHE_OPTIONS} \ - ${TWITCH_OPTIONS} \ - ${YOUTUBE_OPTIONS} \ - ${RESTREAM_OPTIONS} \ - ${CI:+-DENABLE_UNIT_TESTS=ON -DBUILD_FOR_DISTRIBUTION=${BUILD_FOR_DISTRIBUTION} -DOBS_BUILD_NUMBER=${GITHUB_RUN_ID}} \ - ${QUIET:+-Wno-deprecated -Wno-dev --log-level=ERROR} -} - -# Function to backup previous build artifacts -_backup_artifacts() { - ensure_dir "${CHECKOUT_DIR}" - if [ -d "${BUILD_DIR}" ]; then - status "Backup of old OBS build artifacts" - - CUR_DATE=$(/bin/date +"%Y-%m-%d@%H%M%S") - NIGHTLY_DIR="${CHECKOUT_DIR}/nightly-${CUR_DATE}" - PACKAGE_NAME=$(/usr/bin/find ${BUILD_DIR} -maxdepth 1 -name "*.tar.gz" | sort -rn | head -1) - - if [ "${PACKAGE_NAME}" ]; then - step "Back up $(basename "${PACKAGE_NAME}")..." - ensure_dir "${NIGHTLY_DIR}" - ensure_dir "${CHECKOUT_DIR}" - /usr/bin/find "${BUILD_DIR}" -maxdepth 1 \( -name "obs-studio-*.sh" -o -name "obs-studio-*.tar.gz" -o -name "obs-studio-*.tar.Z" \) -print0 | /usr/bin/xargs -0 -I {} /bin/mv {} ${NIGHTLY_DIR}/ - info "You can find $(basename "${PACKAGE_NAME}") in ${NIGHTLY_DIR}" - fi - fi -} - -build-obs-standalone() { - CHECKOUT_DIR="$(git rev-parse --show-toplevel)" - PRODUCT_NAME="OBS-Studio" - DEPS_BUILD_DIR="${CHECKOUT_DIR}/../obs-build-dependencies" - source "${CHECKOUT_DIR}/CI/include/build_support.sh" - source "${CHECKOUT_DIR}/CI/include/build_support_freebsd.sh" - - build_obs -} - -print_usage() { - echo -e "Usage: ${0}\n" \ - "-h, --help : Print this help\n" \ - "-q, --quiet : Suppress most build process output\n" \ - "-v, --verbose : Enable more verbose build process output\n" \ - "-p, --portable : Create portable build (default: off)\n" \ - "--disable-pipewire : Disable building with PipeWire support (default: off)\n" \ - "--build-dir : Specify alternative build directory (default: build)\n" -} - -build-obs-main() { - if [ -z "${_RUN_OBS_BUILD_SCRIPT}" ]; then - while true; do - case "${1}" in - -h | --help ) print_usage; exit 0 ;; - -q | --quiet ) export QUIET=TRUE; shift ;; - -v | --verbose ) export VERBOSE=TRUE; shift ;; - -p | --portable ) export PORTABLE=TRUE; shift ;; - --disable-pipewire ) DISABLE_PIPEWIRE=TRUE; shift ;; - --build-dir ) BUILD_DIR="${2}"; shift 2 ;; - -- ) shift; break ;; - * ) break ;; - esac - done - - build-obs-standalone - fi -} - -build-obs-main $* diff --git a/CI/freebsd/03_package_obs.sh b/CI/freebsd/03_package_obs.sh deleted file mode 100644 index 99faeca590e6a7..00000000000000 --- a/CI/freebsd/03_package_obs.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -# FreeBSD OBS package function -############################################################################## -# -# This script file can be included in build scripts for FreeBSD or run directly -# -############################################################################## - -# Halt on errors -set -eE - -package_obs() { - status "Create FreeBSD debian package" - trap "caught_error 'package app'" ERR - - ensure_dir "${CHECKOUT_DIR}" - - step "Package OBS..." - cmake --build ${BUILD_DIR} -t package - - ZIP_NAME="$(/usr/bin/find "${BUILD_DIR}" -maxdepth 1 -type f -name "obs-studio-*.sh" | sort -rn | head -1)" - - if [ "${ZIP_NAME}" ]; then - mv "${ZIP_NAME%.*}.sh" "${BUILD_DIR}/${FILE_NAME}.sh" - mv "${ZIP_NAME%.*}.tar.gz" "${BUILD_DIR}/${FILE_NAME}.tar.gz" - mv "${ZIP_NAME%.*}.tar.Z" "${BUILD_DIR}/${FILE_NAME}.tar.Z" - else - error "ERROR No suitable OBS debian package generated" - fi -} - -package-obs-standalone() { - PRODUCT_NAME="OBS-Studio" - - CHECKOUT_DIR="$(git rev-parse --show-toplevel)" - DEPS_BUILD_DIR="${CHECKOUT_DIR}/../obs-build-dependencies" - source ${CHECKOUT_DIR}/CI/include/build_support.sh - source ${CHECKOUT_DIR}/CI/include/build_support_freebsd.sh - - step "Fetch OBS tags..." - git fetch origin --tags - - GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) - GIT_HASH=$(git rev-parse --short=9 HEAD) - GIT_TAG=$(git describe --tags --abbrev=0) - - FILE_NAME="obs-studio-${GIT_TAG}-${GIT_HASH}-freebsd" - package_obs -} - -print_usage() { - echo -e "Usage: ${0}\n" \ - "-h, --help : Print this help\n" \ - "-q, --quiet : Suppress most build process output\n" \ - "-v, --verbose : Enable more verbose build process output\n" \ - "--build-dir : Specify alternative build directory (default: build)\n" -} - -package-obs-main() { - if [ -z "${_RUN_OBS_BUILD_SCRIPT}" ]; then - while true; do - case "${1}" in - -h | --help ) print_usage; exit 0 ;; - -q | --quiet ) export QUIET=TRUE; shift ;; - -v | --verbose ) export VERBOSE=TRUE; shift ;; - --build-dir ) BUILD_DIR="${2}"; shift 2 ;; - -- ) shift; break ;; - * ) break ;; - esac - done - - package-obs-standalone - fi -} - -package-obs-main $* diff --git a/CI/include/build_support.sh b/CI/include/build_support.sh deleted file mode 100644 index 736782ffa920a3..00000000000000 --- a/CI/include/build_support.sh +++ /dev/null @@ -1,219 +0,0 @@ -#!/bin/bash - -############################################################################## -# Unix support functions -############################################################################## -# -# This script file can be included in build scripts for UNIX-compatible -# shells to compose build scripts. -# -############################################################################## - -## DEFINE UTILITIES ## - -if [ -z "${QUIET}" ]; then - status() { - echo -e "${COLOR_BLUE}[${PRODUCT_NAME}] ${1}${COLOR_RESET}" - } - - step() { - echo -e "${COLOR_GREEN} + ${1}${COLOR_RESET}" - } - - info() { - echo -e "${COLOR_ORANGE} + ${1}${COLOR_RESET}" - } - - error() { - echo -e "${COLOR_RED} + ${1}${COLOR_RESET}" - } -else - status() { - : - } - - step() { - : - } - - info() { - : - } - - error() { - echo -e "${COLOR_RED} + ${1}${COLOR_RESET}" - } -fi - -exists() { - /usr/bin/command -v "$1" >/dev/null 2>&1 -} - -ensure_dir() { - [ -n "${1}" ] && /bin/mkdir -p "${1}" && builtin cd "${1}" -} - -cleanup() { - : -} - -caught_error() { - error "ERROR during build step: ${1}" - cleanup - exit 1 -} - -# Setup build environment -BUILD_DIR="${BUILD_DIR:-build}" -BUILD_CONFIG="${BUILD_CONFIG:-RelWithDebInfo}" -CI_WORKFLOW="${CHECKOUT_DIR}/.github/workflows/main.yml" -CURRENT_ARCH="$(uname -m)" -CURRENT_DATE="$(date +"%Y-%m-%d")" - -## Utility functions ## - -check_ccache() { - step "Check CCache..." - if ccache -V >/dev/null 2>&1; then - info "CCache available" - CMAKE_CCACHE_OPTIONS="-DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache" - - if [ "${CI}" ]; then - ccache --set-config=compiler_check=content - ccache --set-config=cache_dir=${GITHUB_WORKSPACE:-${HOME}}/.ccache - ccache --set-config=max_size=${CCACHE_SIZE:-1G} - ccache --set-config=compression=false - ccache --set-config=sloppiness=include_file_mtime,include_file_ctime,file_stat_matches,system_headers - ccache -z - fi - else - info "CCache not available" - fi -} - -safe_fetch() { - if [ $# -lt 2 ]; then - error "Usage: safe_fetch URL HASH" - return 1 - fi - - while true; do - case "${1}" in - -n | --nocontinue ) NOCONTINUE=TRUE; shift ;; - -- ) shift; break ;; - * ) break ;; - esac - done - - DOWNLOAD_URL="${1}" - DOWNLOAD_HASH="${2}" - DOWNLOAD_FILE="$(basename ${DOWNLOAD_URL})" - CURLCMD=${CURLCMD:-curl} - - if [ "${NOCONTINUE}" ]; then - ${CURLCMD/--continue-at -/} "${DOWNLOAD_URL}" - else - ${CURLCMD} "${DOWNLOAD_URL}" - fi - - if [ "${DOWNLOAD_HASH}" = "$(sha256sum "${DOWNLOAD_FILE}" | cut -d " " -f 1)" ]; then - info "${DOWNLOAD_FILE} downloaded successfully and passed hash check" - return 0 - else - error "${DOWNLOAD_FILE} downloaded successfully and failed hash check" - return 1 - fi -} - -check_and_fetch() { - if [ $# -lt 2 ]; then - caught_error "Usage: check_and_fetch URL HASH" - fi - - while true; do - case "${1}" in - -n | --nocontinue ) NOCONTINUE=TRUE; shift ;; - -- ) shift; break ;; - * ) break ;; - esac - done - - DOWNLOAD_URL="${1}" - DOWNLOAD_HASH="${2}" - DOWNLOAD_FILE="$(basename "${DOWNLOAD_URL}")" - - if [ -f "${DOWNLOAD_FILE}" ] && [ "${DOWNLOAD_HASH}" = "$(sha256sum "${DOWNLOAD_FILE}" | cut -d " " -f 1)" ]; then - info "${DOWNLOAD_FILE} exists and passed hash check" - return 0 - else - safe_fetch "${DOWNLOAD_URL}" "${DOWNLOAD_HASH}" - fi -} - -github_fetch() { - if [ $# -ne 3 ]; then - error "Usage: github_fetch GITHUB_USER GITHUB_REPOSITORY GITHUB_COMMIT_HASH" - return 1 - fi - - GH_USER="${1}" - GH_REPO="${2}" - GH_REF="${3}" - - if [ -d "./.git" ]; then - info "Repository ${GH_USER}/${GH_REPO} already exists, updating..." - git config advice.detachedHead false - git config remote.origin.url "https://github.com/${GH_USER}/${GH_REPO}.git" - git config remote.origin.fetch "+refs/heads/master:refs/remotes/origin/master" - git config remote.origin.tapOpt --no-tags - - if ! git rev-parse -q --verify "${GH_COMMIT}^{commit}"; then - git fetch origin - fi - - git checkout -f "${GH_REF}" -- - git reset --hard "${GH_REF}" -- - if [ -d "./.gitmodules" ]; then - git submodule foreach --recursive git submodule sync - git submodule update --init --recursive - fi - - else - git clone "https://github.com/${GH_USER}/${GH_REPO}.git" "$(pwd)" - git config advice.detachedHead false - info "Checking out commit ${GH_REF}..." - git checkout -f "${GH_REF}" -- - - if [ -d "./.gitmodules" ]; then - git submodule foreach --recursive git submodule sync - git submodule update --init --recursive - fi - fi -} - -apply_patch() { - if [ $# -ne 2 ]; then - error "Usage: apply_patch PATCH_URL PATCH_HASH" - return 1 - fi - - COMMIT_URL="${1}" - COMMIT_HASH="${2}" - PATCH_FILE="$(basename ${COMMIT_URL})" - - if [ "${COMMIT_URL:0:5}" = "https" ]; then - ${CURLCMD:-curl} "${COMMIT_URL}" - if [ "${COMMIT_HASH}" = "$(sha256sum ${PATCH_FILE} | cut -d " " -f 1)" ]; then - info "${PATCH_FILE} downloaded successfully and passed hash check" - else - error "${PATCH_FILE} downloaded successfully and failed hash check" - return 1 - fi - - info "Applying patch ${COMMIT_URL}" - else - PATCH_FILE="${COMMIT_URL}" - fi - - patch -g 0 -f -p1 -i "${PATCH_FILE}" -} diff --git a/CI/include/build_support_freebsd.sh b/CI/include/build_support_freebsd.sh deleted file mode 100644 index 67209416b7f677..00000000000000 --- a/CI/include/build_support_freebsd.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -# FreeBSD support functions -############################################################################## -# -# This script file can be included in build scripts for FreeBSD. -# -############################################################################## - -# Setup build environment - -if [ "${TERM-}" -a -x /usr/local/bin/tput ]; then - COLOR_RED=$(/usr/local/bin/tput setaf 1) - COLOR_GREEN=$(/usr/local/bin/tput setaf 2) - COLOR_BLUE=$(/usr/local/bin/tput setaf 4) - COLOR_ORANGE=$(/usr/local/bin/tput setaf 3) - COLOR_RESET=$(/usr/local/bin/tput sgr0) -else - COLOR_RED="" - COLOR_GREEN="" - COLOR_BLUE="" - COLOR_ORANGE="" - COLOR_RESET="" -fi - -if [ "${CI}" -o "${QUIET}" ]; then - export CURLCMD="curl --silent --show-error --location -O" -else - export CURLCMD="curl --progress-bar --location --continue-at - -O" -fi - -_add_ccache_to_path() { - if [ "${CMAKE_CCACHE_OPTIONS}" ]; then - PATH="/usr/local/opt/ccache/libexec:${PATH}" - status "Compiler Info:" - local IFS=$'\n' - for COMPILER_INFO in $(type cc c++ gcc g++ clang clang++ || true); do - info "${COMPILER_INFO}" - done - fi -} diff --git a/CMakeLists.txt b/CMakeLists.txt index b6f157fbe76011..1e02244ece9ac2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ if(CMAKE_HOST_SYSTEM_NAME MATCHES "(Darwin)" OR OBS_CMAKE_VERSION VERSION_GREATE project(obs-studio VERSION ${OBS_VERSION_CANONICAL}) - if(CMAKE_SIZEOF_VOID_P EQUAL 4) + if(CMAKE_HOST_SYSTEM_NAME MATCHES "(Windows)" AND CMAKE_SIZEOF_VOID_P EQUAL 4) include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/32bit/projects.cmake") return() endif() @@ -34,6 +34,22 @@ if(CMAKE_HOST_SYSTEM_NAME MATCHES "(Darwin)" OR OBS_CMAKE_VERSION VERSION_GREATE return() endif() +if(CMAKE_HOST_SYSTEM_NAME MATCHES "(Windows|Darwin)") + message( + DEPRECATION + "\n" + "============ LEGACY BUILD SYSTEM IS DEPRECATED ============" + "\n" + "You are using the legacy build system to build OBS Studio. " + "The legacy build system is unsupported and will be removed in the near future." + "\n" + "To migrate to the new build system, familiarize yourself with CMake presets " + "(https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html) and create " + "a user preset with your customized build settings, inheriting from one of the default presets." + "\n" + "============ LEGACY BUILD SYSTEM IS DEPRECATED ============") +endif() + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules") include(VersionConfig) diff --git a/CMakePresets.json b/CMakePresets.json index 184d1cfd823a94..3869d53a327b01 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,5 +1,5 @@ { - "version": 5, + "version": 3, "cmakeMinimumRequired": { "major": 3, "minor": 22, @@ -10,10 +10,10 @@ "name": "environmentVars", "hidden": true, "cacheVariables": { - "TWITCH_CLIENTID": {"type": "STRING", "value": "$penv{TWITCH_CLIENTID}"}, - "TWITCH_HASH": {"type": "STRING", "value": "$penv{TWITCH_HASH}"}, "RESTREAM_CLIENTID": {"type": "STRING", "value": "$penv{RESTREAM_CLIENTID}"}, "RESTREAM_HASH": {"type": "STRING", "value": "$penv{RESTREAM_HASH}"}, + "TWITCH_CLIENTID": {"type": "STRING", "value": "$penv{TWITCH_CLIENTID}"}, + "TWITCH_HASH": {"type": "STRING", "value": "$penv{TWITCH_HASH}"}, "YOUTUBE_CLIENTID": {"type": "STRING", "value": "$penv{YOUTUBE_CLIENTID}"}, "YOUTUBE_CLIENTID_HASH": {"type": "STRING", "value": "$penv{YOUTUBE_CLIENTID_HASH}"}, "YOUTUBE_SECRET": {"type": "STRING", "value": "$penv{YOUTUBE_SECRET}"}, @@ -33,16 +33,16 @@ "generator": "Xcode", "binaryDir": "${sourceDir}/build_macos", "cacheVariables": { - "ENABLE_BROWSER": true, "CMAKE_OSX_DEPLOYMENT_TARGET": {"type": "STRING", "value": "11.0"}, - "OBS_CODESIGN_TEAM": {"type": "STRING", "value": "$penv{CODESIGN_TEAM}"}, "OBS_CODESIGN_IDENTITY": {"type": "STRING", "value": "$penv{CODESIGN_IDENT}"}, + "OBS_CODESIGN_TEAM": {"type": "STRING", "value": "$penv{CODESIGN_TEAM}"}, "OBS_PROVISIONING_PROFILE": {"type": "STRING", "value": "$penv{PROVISIONING_PROFILE}"}, "VIRTUALCAM_DEVICE_UUID": {"type": "STRING", "value": "7626645E-4425-469E-9D8B-97E0FA59AC75"}, - "VIRTUALCAM_SOURCE_UUID": {"type": "STRING", "value": "A8D7B8AA-65AD-4D21-9C42-66480DBFA8E1"}, "VIRTUALCAM_SINK_UUID": {"type": "STRING", "value": "A3F16177-7044-4DD8-B900-72E2419F7A9A"}, + "VIRTUALCAM_SOURCE_UUID": {"type": "STRING", "value": "A8D7B8AA-65AD-4D21-9C42-66480DBFA8E1"}, "SPARKLE_APPCAST_URL": {"type": "STRING", "value": "https://obsproject.com/osx_update/updates_$(ARCHS)_v2.xml"}, - "SPARKLE_PUBLIC_KEY": {"type": "STRING", "value": "HQ5/Ba9VHOuEWaM0jtVjZzgHKFJX9YTl+HNVpgNF0iM="} + "SPARKLE_PUBLIC_KEY": {"type": "STRING", "value": "HQ5/Ba9VHOuEWaM0jtVjZzgHKFJX9YTl+HNVpgNF0iM="}, + "ENABLE_BROWSER": true } }, { @@ -56,75 +56,35 @@ } }, { - "name": "linux-aarch64", - "displayName": "Linux aarch64", - "description": "obs-studio for Linux (aarch64)", + "name": "ubuntu", + "displayName": "Ubuntu", + "description": "obs-studio for Ubuntu", "inherits": ["environmentVars"], "condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "Linux" }, - "binaryDir": "${sourceDir}/build_aarch64", + "binaryDir": "${sourceDir}/build_ubuntu", "generator": "Ninja", "warnings": {"dev": true, "deprecated": true}, "cacheVariables": { - "ENABLE_WAYLAND": true, + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_INSTALL_LIBDIR": "lib/CMAKE_SYSTEM_PROCESSOR-linux-gnu", + "OBS_CMAKE_VERSION": {"type": "STRING", "value": "3.0.0"}, + "ENABLE_AJA": false, + "ENABLE_NATIVE_NVENC": false, "ENABLE_VLC": true, - "CMAKE_BUILD_TYPE": "Debug" - } - }, - { - "name": "linux-ci-aarch64", - "inherits": ["linux-aarch64"], - "hidden": true, - "cacheVariables": { - "CMAKE_BUILD_TYPE": "RelWithDebInfo" - } - }, - { - "name": "linux-release-aarch64", - "displayName": "Linux aarch64 (Release)", - "description": "obs-studio for Linux (aarch64) - Release Configuration", - "inherits": "linux-aarch64", - "cacheVariables": { - "ENABLE_RELEASE_BUILD": true - } - }, - { - "name": "linux-x86_64", - "displayName": "Linux x86_64", - "description": "obs-studio for Linux (x86_64)", - "inherits": ["environmentVars"], - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Linux" - }, - "binaryDir": "${sourceDir}/build_x86_64", - "generator": "Ninja", - "warnings": {"dev": true, "deprecated": true}, - "cacheVariables": { "ENABLE_WAYLAND": true, - "ENABLE_VLC": true, - "CMAKE_BUILD_TYPE": {"type": "STRING", "value": "Debug"} - } - }, - { - "name": "linux-ci-x86_64", - "inherits": ["linux-x86_64"], - "cacheVariables": { - "CMAKE_BUILD_TYPE": "RelWithDebInfo" + "ENABLE_WEBRTC": false } }, { - "name": "linux-release-x86_64", - "displayName": "Linux x86_64 (Release)", - "description": "obs-studio for Linux (x86_64) - Release Configuration", - "inherits": "linux-x86_64", + "name": "ubuntu-ci", + "inherits": ["ubuntu"], "cacheVariables": { - "ENABLE_RELEASE_BUILD": true, - "ENABLE_BROWSER": true + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "CMAKE_COMPILE_WARNING_AS_ERROR": true } }, { @@ -142,9 +102,9 @@ "generator": "Visual Studio 17 2022", "cacheVariables": { "OBS_CMAKE_VERSION": {"type": "STRING", "value": "3.0.0"}, - "ENABLE_BROWSER": true, - "VIRTUALCAM_GUID": {"type": "STRING", "value": "A3FCE0F5-3493-419F-958A-ABA1250EC20B"}, "GPU_PRIORITY_VAL": {"type": "STRING", "value": "$penv{GPU_PRIORITY_VAL}"}, + "VIRTUALCAM_GUID": {"type": "STRING", "value": "A3FCE0F5-3493-419F-958A-ABA1250EC20B"}, + "ENABLE_BROWSER": true, "ENABLE_CCACHE": false } }, @@ -161,20 +121,6 @@ } ], "buildPresets": [ - { - "name": "linux-aarch64", - "configurePreset": "linux-aarch64", - "displayName": "Linux aarch64", - "description": "Linux build for aarch64 (aka arm64)", - "configuration": "RelWithDebInfo" - }, - { - "name": "linux-x86_64", - "configurePreset": "linux-x86_64", - "displayName": "Linux x86_64", - "description": "Linux build for x86_64 (aka amd64)", - "configuration": "RelWithDebInfo" - }, { "name": "windows-x64", "configurePreset": "windows-x64", diff --git a/UI/CMakeLists.txt b/UI/CMakeLists.txt index c50416bce0689f..1dbc267e4d7cee 100644 --- a/UI/CMakeLists.txt +++ b/UI/CMakeLists.txt @@ -48,7 +48,6 @@ endif() include(cmake/feature-twitch.cmake) include(cmake/feature-restream.cmake) include(cmake/feature-youtube.cmake) -include(cmake/feature-sparkle.cmake) include(cmake/feature-whatsnew.cmake) add_subdirectory(frontend-plugins) diff --git a/UI/cmake/feature-whatsnew.cmake b/UI/cmake/feature-whatsnew.cmake index 3d093ae46cc059..487494cddc2639 100644 --- a/UI/cmake/feature-whatsnew.cmake +++ b/UI/cmake/feature-whatsnew.cmake @@ -8,6 +8,11 @@ if(ENABLE_WHATSNEW AND TARGET OBS::browser-panels) elseif(OS_LINUX) find_package(MbedTLS REQUIRED) find_package(nlohmann_json REQUIRED) + + if(NOT TARGET OBS::blake2) + add_subdirectory("${CMAKE_SOURCE_DIR}/deps/blake2" "${CMAKE_BINARY_DIR}/deps/blake2") + endif() + target_link_libraries(obs-studio PRIVATE MbedTLS::MbedTLS nlohmann_json::nlohmann_json OBS::blake2) target_sources( diff --git a/UI/cmake/legacy.cmake b/UI/cmake/legacy.cmake index 8221b9b8e506b7..650638163fe02a 100644 --- a/UI/cmake/legacy.cmake +++ b/UI/cmake/legacy.cmake @@ -475,6 +475,7 @@ elseif(OS_POSIX) if(OS_FREEBSD) target_link_libraries(obs PRIVATE procstat) + target_compile_options(obs PRIVATE -Wno-unqualified-std-cast-call) endif() if(OS_LINUX AND ENABLE_WHATSNEW) diff --git a/UI/cmake/os-macos.cmake b/UI/cmake/os-macos.cmake index 0c74c683dcd2b4..d9354ec4db6467 100644 --- a/UI/cmake/os-macos.cmake +++ b/UI/cmake/os-macos.cmake @@ -1,3 +1,5 @@ +include(cmake/feature-sparkle.cmake) + target_sources(obs-studio PRIVATE platform-osx.mm forms/OBSPermissions.ui window-permissions.cpp window-permissions.hpp) target_compile_options(obs-studio PRIVATE -Wno-quoted-include-in-framework-header -Wno-comma) diff --git a/UI/cmake/ui-elements.cmake b/UI/cmake/ui-elements.cmake index 39082b694e8865..3c2dc437ad0d3d 100644 --- a/UI/cmake/ui-elements.cmake +++ b/UI/cmake/ui-elements.cmake @@ -24,6 +24,7 @@ target_sources( vertical-scroll-area.hpp) target_include_directories(obs-ui-support INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}") +target_compile_options(obs-ui-support INTERFACE $<$:-Wno-error=enum-conversion>) target_link_libraries(obs-studio PRIVATE OBS::ui-support) diff --git a/UI/obs-frontend-api/CMakeLists.txt b/UI/obs-frontend-api/CMakeLists.txt index f9193dc2592d2c..ba0df55e968bc0 100644 --- a/UI/obs-frontend-api/CMakeLists.txt +++ b/UI/obs-frontend-api/CMakeLists.txt @@ -19,7 +19,11 @@ elseif(OS_MACOS) endif() # cmake-format: off -set_target_properties_obs(obs-frontend-api PROPERTIES FOLDER frontend PREFIX "" PUBLIC_HEADER obs-frontend-api.h) +set_target_properties_obs(obs-frontend-api PROPERTIES FOLDER frontend PUBLIC_HEADER obs-frontend-api.h) + +if (OS_WINDOWS OR OS_MACOS) + set_property(TARGET obs-frontend-api PROPERTY PREFIX "") +endif() # cmake-format: on target_export(obs-frontend-api) diff --git a/UI/obs-frontend-api/cmake/linux/obs-frontend-api.pc.in b/UI/obs-frontend-api/cmake/linux/obs-frontend-api.pc.in new file mode 100644 index 00000000000000..cf099bd12cce80 --- /dev/null +++ b/UI/obs-frontend-api/cmake/linux/obs-frontend-api.pc.in @@ -0,0 +1,13 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: obs-frontend-api +Description: OBS Studio frontend API library +Version: @OBS_VERSION_CANONICAL@ + +Requires: +Libs: -L${libdir} -lobs-frontend-api -lobs +Libs.private: -lobs -lm -pthread +Cflags: -I${includedir} -std=gnu@CMAKE_C_STANDARD@ -fPIC -fvisibility=hidden -fopenmp-simd -Werror diff --git a/UI/platform-x11.cpp b/UI/platform-x11.cpp index f45f7f63ce632d..1794f2ff601d87 100644 --- a/UI/platform-x11.cpp +++ b/UI/platform-x11.cpp @@ -194,8 +194,18 @@ bool GetDataFilePath(const char *data, string &output) return true; } + char *relative_data_path = + os_get_executable_path_ptr("../" OBS_DATA_PATH "/obs-studio/"); + + if (relative_data_path) { + bool result = check_path(data, relative_data_path, output); + bfree(relative_data_path); + return result; + } + if (check_path(data, OBS_DATA_PATH "/obs-studio/", output)) return true; + if (check_path(data, INSTALL_DATA_PATH, output)) return true; diff --git a/buildspec.json b/buildspec.json index da45f724e330a9..2832be1bd6cfe7 100644 --- a/buildspec.json +++ b/buildspec.json @@ -29,15 +29,15 @@ "hashes": { "macos-x86_64": "140bfd517b4b9d12343ac000abba7bb16eecefe80ecbd7225993d03f0b9c0603", "macos-arm64": "3970a781132b033bb9be6a9fe328a07e97fa7737fdf1575b1c5db24a3e130da1", - "linux-x86_64": "1253a6a36c3b8ac5b5ece9bfdb6eae6ab75e49516375fc475e2e871795ad9bea", - "linux-aarch64": "66ebcfce94a4527c8dd085a685691d0c43291adab9f2be4f8a0762f4a614083a", + "ubuntu-x86_64": "1253a6a36c3b8ac5b5ece9bfdb6eae6ab75e49516375fc475e2e871795ad9bea", + "ubuntu-aarch64": "66ebcfce94a4527c8dd085a685691d0c43291adab9f2be4f8a0762f4a614083a", "windows-x64": "7480e9ed5688e09919db67237d130eef9a4c24df32ba2a7b8a5587de45ff8e69" }, "revision": { "macos-x86_64": 4, "macos-arm64": 4, - "linux-x86_64": 3, - "linux-aarch64": 3, + "ubuntu-x86_64": 3, + "ubuntu-aarch64": 3, "windows-x64": 3 } } @@ -57,13 +57,11 @@ } }, "platformConfig": { - "macos-universal": { - "qtVersion": 6 - }, - "windows-x64": { - "qtVersion": 6 + "ubuntu-x86_64": { + "qtVersion": 6, + "generator": "Ninja" }, - "linux-x86_64": { + "ubuntu-aarch64": { "qtVersion": 6, "generator": "Ninja" } diff --git a/cmake/Modules/ObsDefaults_Linux.cmake b/cmake/Modules/ObsDefaults_Linux.cmake index d1e58a0838c576..fe8d72364e85c6 100644 --- a/cmake/Modules/ObsDefaults_Linux.cmake +++ b/cmake/Modules/ObsDefaults_Linux.cmake @@ -73,7 +73,7 @@ macro(setup_obs_project) set(OBS_DATA_DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/obs") set(OBS_CMAKE_DESTINATION "${OBS_LIBRARY_DESTINATION}/cmake") - set(OBS_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/") + set(OBS_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") set(OBS_DATA_PATH "${OBS_DATA_DESTINATION}") set(OBS_SCRIPT_PLUGIN_PATH "${CMAKE_INSTALL_PREFIX}/${OBS_SCRIPT_PLUGIN_DESTINATION}") diff --git a/cmake/common/buildnumber.cmake b/cmake/common/buildnumber.cmake index 5f1bee564fa5a1..4d509adc12557f 100644 --- a/cmake/common/buildnumber.cmake +++ b/cmake/common/buildnumber.cmake @@ -12,7 +12,7 @@ if(NOT DEFINED OBS_BUILD_NUMBER AND EXISTS "${_BUILD_NUMBER_CACHE}") file(READ "${_BUILD_NUMBER_CACHE}" OBS_BUILD_NUMBER) math(EXPR OBS_BUILD_NUMBER "${OBS_BUILD_NUMBER}+1") elseif(NOT DEFINED OBS_BUILD_NUMBER) - if($ENV{CI} AND $ENV{GITHUB_RUN_ID}) + if("$ENV{CI}" AND "$ENV{GITHUB_RUN_ID}") set(OBS_BUILD_NUMBER "$ENV{GITHUB_RUN_ID}") else() set(OBS_BUILD_NUMBER "1") diff --git a/cmake/common/compiler_common.cmake b/cmake/common/compiler_common.cmake index 885b8e5ded5c0b..ccae3d2201bdc8 100644 --- a/cmake/common/compiler_common.cmake +++ b/cmake/common/compiler_common.cmake @@ -2,6 +2,9 @@ include_guard(GLOBAL) +option(OBS_COMPILE_DEPRECATION_AS_WARNING "Downgrade deprecation warnings to actual warnings" FALSE) +mark_as_advanced(OBS_COMPILE_DEPRECATION_AS_WARNING) + # Set C and C++ language standards to C17 and C++17 if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.21) set(CMAKE_C_STANDARD 17) @@ -57,7 +60,8 @@ set(_obs_clang_common_options -Wno-semicolon-before-method-body -Wformat-security -Wvla - -Wno-error=shorten-64-to-32) + -Wno-error=shorten-64-to-32 + $<$:-Wno-error=deprecated-declarations>) # clang options for C set(_obs_clang_c_options ${_obs_clang_common_options} -Wno-shadow -Wno-float-conversion) diff --git a/cmake/finders/FindFFmpeg.cmake b/cmake/finders/FindFFmpeg.cmake index 9e2cdc8ac3eff0..bf28f8ab95b5dc 100644 --- a/cmake/finders/FindFFmpeg.cmake +++ b/cmake/finders/FindFFmpeg.cmake @@ -277,8 +277,8 @@ endif() if(EXISTS "${FFmpeg_avutil_INCLUDE_DIR}/libavutil/ffversion.h") file(STRINGS "${FFmpeg_avutil_INCLUDE_DIR}/libavutil/ffversion.h" _version_string - REGEX "^.*FFMPEG_VERSION[ \t]+\"n[0-9a-z\\.-]+\"[ \t]*$") - string(REGEX REPLACE ".*FFMPEG_VERSION[ \t]+\"n([0-9]+\\.[0-9]).+\".*" "\\1" FFmpeg_VERSION "${_version_string}") + REGEX "^.*FFMPEG_VERSION[ \t]+\"n?[0-9a-z\\.-]+\"[ \t]*$") + string(REGEX REPLACE ".*FFMPEG_VERSION[ \t]+\"n?([0-9]+\\.[0-9]).*\".*" "\\1" FFmpeg_VERSION "${_version_string}") endif() list(REMOVE_DUPLICATES FFmpeg_INCLUDE_DIRS) diff --git a/cmake/finders/FindGio.cmake b/cmake/finders/FindGio.cmake new file mode 100644 index 00000000000000..a134dc2f807074 --- /dev/null +++ b/cmake/finders/FindGio.cmake @@ -0,0 +1,121 @@ +#[=======================================================================[.rst +FindGio +------- + +FindModule for gio and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``gio::gio``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Gio_FOUND`` + True, if all required components and the core library were found. +``Gio_VERSION`` + Detected version of found gio libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Gio_LIBRARY`` + Path to the library component of gio. +``Gio_INCLUDE_DIR`` + Directory containing ``gio.h`` + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Gio QUIET gio-2.0 gio) + pkg_search_module(PC_GioUnix QUIET gio-unix-2.0) +endif() + +find_path( + Gio_INCLUDE_DIR + NAMES gio/gio.h + HINTS ${PC_Gio_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + PATH_SUFFIXES glib-2.0 + DOC "gio-2.0 include directory") + +find_path( + GioUnix_INCLUDE_DIR + NAMES gio/gunixfdmessage.h + HINTS ${PC_GioUnix_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + PATH_SUFFIXES gio-unix-2.0 + DOC "gio-unix-2.0 include directory") + +find_library( + Gio_LIBRARY + NAMES libgio-2.0 gio-2.0 gio-unix-2.0 + HINTS ${PC_Gio_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "gio-2.0 location") + +find_path( + Glib_INCLUDE_DIR + NAMES glibconfig.h + HINTS ${PC_Gio_INCLUDE_DIRS} + PATHS /usr/lib /usr/local/lib + PATH_SUFFIXES glib-2.0/include) + +if(PC_Gio_VERSION VERSION_GREATER 0) + set(Gio_VERSION ${PC_Gio_VERSION}) +else() + if(NOT Gio_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find gio version.") + endif() + set(Gio_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Gio + REQUIRED_VARS Gio_LIBRARY Gio_INCLUDE_DIR GioUnix_INCLUDE_DIR Glib_INCLUDE_DIR + VERSION_VAR Gio_VERSION REASON_FAILURE_MESSAGE "Ensure that glib is installed on the system.") +mark_as_advanced(Gio_INCLUDE_DIR Gio_LIBRARY Glib_INCLUDE_DIR) + +if(Gio_FOUND) + if(NOT TARGET gio::gio) + if(IS_ABSOLUTE "${Gio_LIBRARY}") + add_library(gio::gio UNKNOWN IMPORTED) + set_property(TARGET gio::gio PROPERTY IMPORTED_LOCATION "${Gio_LIBRARY}") + else() + add_library(gio::gio INTERFACE IMPORTED) + set_property(TARGET gio::gio PROPERTY IMPORTED_LIBNAME "${Gio_LIBRARY}") + endif() + + set_target_properties( + gio::gio + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Gio_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Gio_INCLUDE_DIR};${GioUnix_INCLUDE_DIR};${Glib_INCLUDE_DIR}" + VERSION ${Gio_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Gio PROPERTIES + URL "https://docs.gtk.org/gio" + DESCRIPTION + "A library providing useful classes for general purpose I/O, networking, IPC, settings, and other high level application functionality." +) diff --git a/cmake/finders/FindJack.cmake b/cmake/finders/FindJack.cmake new file mode 100644 index 00000000000000..a7547d0d9ffe28 --- /dev/null +++ b/cmake/finders/FindJack.cmake @@ -0,0 +1,104 @@ +#[=======================================================================[.rst +FindJack +-------- + +FindModule for Jack and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``Jack::Jack``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Jack_FOUND`` + True, if all required components and the core library were found. +``Jack_VERSION`` + Detected version of found Jack libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Jack_LIBRARY`` + Path to the library component of Jack. +``Jack_INCLUDE_DIR`` + Directory containing ``jack.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Jack QUIET jack) +endif() + +find_path( + Jack_INCLUDE_DIR + NAMES jack/jack.h + HINTS ${PC_Jack_INCLUDE_DIR} + PATHS /usr/include /usr/local/include + DOC "Jack include directory") + +find_library( + Jack_LIBRARY + NAMES jack + HINTS ${PC_Jack_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Jack location") + +if(PC_Jack_VERSION VERSION_GREATER 0) + set(Jack_VERSION ${PC_Jack_VERSION}) +else() + if(NOT Jack_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Jack version.") + endif() + set(Jack_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Jack + REQUIRED_VARS Jack_LIBRARY Jack_INCLUDE_DIR + VERSION_VAR Jack_VERSION REASON_FAILURE_MESSAGE "Ensure that Jack is installed on the system.") +mark_as_advanced(Jack_INCLUDE_DIR Jack_LIBRARY) + +if(Jack_FOUND) + if(NOT TARGET Jack::Jack) + if(IS_ABSOLUTE "${Jack_LIBRARY}") + add_library(Jack::Jack UNKNOWN IMPORTED) + set_property(TARGET Jack::Jack PROPERTY IMPORTED_LOCATION "${Jack_LIBRARY}") + else() + add_library(Jack::Jack INTERFACE IMPORTED) + set_property(TARGET Jack::Jack PROPERTY IMPORTED_LIBNAME "${Jack_LIBRARY}") + endif() + + set_target_properties( + Jack::Jack + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Jack_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Jack_INCLUDE_DIR}" + VERSION ${Jack_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Jack PROPERTIES + URL "https://www.jackaudio.org" + DESCRIPTION + "JACK Audio Connection Kit (or JACK) is a professional sound server API and pair of daemon implementations to provide real-time, low-latency connections for both audio and MIDI data between applications." +) diff --git a/cmake/finders/FindLibUUID.cmake b/cmake/finders/FindLibUUID.cmake new file mode 100644 index 00000000000000..5bd4c9d369324f --- /dev/null +++ b/cmake/finders/FindLibUUID.cmake @@ -0,0 +1,103 @@ +#[=======================================================================[.rst +FindLibUUID +----------- + +FindModule for LibUUID and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``LibUUID::LibUUID``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``LibUUID_FOUND`` + True, if all required components and the core library were found. +``LibUUID_VERSION`` + Detected version of found LibUUID libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``LibUUID_LIBRARY`` + Path to the library component of LibUUID. +``LibUUID_INCLUDE_DIR`` + Directory containing ``LibUUID.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_LibUUID QUIET LibUUID uuid) +endif() + +find_path( + LibUUID_INCLUDE_DIR + NAMES uuid/uuid.h + HINTS ${PC_LibUUID_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "LibUUID include directory") + +find_library( + LibUUID_LIBRARY + NAMES uuid + HINTS ${PC_LibUUID_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "LibUUID location") + +if(PC_LibUUID_VERSION VERSION_GREATER 0) + set(LibUUID_VERSION ${PC_LibUUID_VERSION}) +else() + if(NOT LibUUID_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find LibUUID version.") + endif() + set(LibUUID_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + LibUUID + REQUIRED_VARS LibUUID_LIBRARY LibUUID_INCLUDE_DIR + VERSION_VAR LibUUID_VERSION REASON_FAILURE_MESSAGE "Ensure that e2fsprogs is installed on the system.") +mark_as_advanced(LibUUID_INCLUDE_DIR LibUUID_LIBRARY) + +if(LibUUID_FOUND) + if(NOT TARGET LibUUID::LibUUID) + if(IS_ABSOLUTE "${LibUUID_LIBRARY}") + add_library(LibUUID::LibUUID UNKNOWN IMPORTED) + set_property(TARGET LibUUID::LibUUID PROPERTY IMPORTED_LOCATION "${LibUUID_LIBRARY}") + else() + add_library(LibUUID::LibUUID INTERFACE IMPORTED) + set_property(TARGET LibUUID::LibUUID PROPERTY IMPORTED_LIBNAME "${LibUUID_LIBRARY}") + endif() + + set_target_properties( + LibUUID::LibUUID + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_LibUUID_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${LibUUID_INCLUDE_DIR}" + VERSION ${LibUUID_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + LibUUID PROPERTIES + URL "http://e2fsprogs.sourceforge.net/" + DESCRIPTION + "The libuuid library is used to generate unique identifiers for objects that may be accessible beyond the local system." +) diff --git a/cmake/finders/FindLibdrm.cmake b/cmake/finders/FindLibdrm.cmake new file mode 100644 index 00000000000000..de5a25bc8b3af3 --- /dev/null +++ b/cmake/finders/FindLibdrm.cmake @@ -0,0 +1,105 @@ +#[=======================================================================[.rst +FindLibdrm +---------- + +FindModule for Libdrm and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``Libdrm::Libdrm``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Libdrm_FOUND`` + True, if all required components and the core library were found. +``Libdrm_VERSION`` + Detected version of found Libdrm libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Libdrm_LIBRARY`` + Path to the library component of Libdrm. +``Libdrm_INCLUDE_DIR`` + Directory containing ``drm_fourcc.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Libdrm QUIET libdrm) +endif() + +find_path( + Libdrm_INCLUDE_DIR + NAMES drm_fourcc.h + HINTS ${PC_Libdrm_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + PATH_SUFFIXES libdrm + DOC "Libdrm include directory") + +find_library( + Libdrm_LIBRARY + NAMES drm libdrm + HINTS ${PC_Libdrm_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Libdrm location") + +if(PC_Libdrm_VERSION VERSION_GREATER 0) + set(Libdrm_VERSION ${PC_Libdrm_VERSION}) +else() + if(NOT Libdrm_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Libdrm version.") + endif() + set(Libdrm_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Libdrm + REQUIRED_VARS Libdrm_LIBRARY Libdrm_INCLUDE_DIR + VERSION_VAR Libdrm_VERSION REASON_FAILURE_MESSAGE "Ensure that libdrm is installed on the system.") +mark_as_advanced(Libdrm_INCLUDE_DIR Libdrm_LIBRARY) + +if(Libdrm_FOUND) + if(NOT TARGET Libdrm::Libdrm) + if(IS_ABSOLUTE "${Libdrm_LIBRARY}") + add_library(Libdrm::Libdrm UNKNOWN IMPORTED) + set_property(TARGET Libdrm::Libdrm PROPERTY IMPORTED_LOCATION "${Libdrm_LIBRARY}") + else() + add_library(Libdrm::Libdrm INTERFACE IMPORTED) + set_property(TARGET Libdrm::Libdrm PROPERTY IMPORTED_LIBNAME "${Libdrm_LIBRARY}") + endif() + + set_target_properties( + Libdrm::Libdrm + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Libdrm_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libdrm_INCLUDE_DIR}" + VERSION ${Libdrm_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Libdrm PROPERTIES + URL "https://gitlab.freedesktop.org/mesa/drm" + DESCRIPTION + "A low-level library, typically used by graphics drivers such as the Mesa drivers, the X drivers, libva and similar projects." +) diff --git a/cmake/finders/FindLibfdk.cmake b/cmake/finders/FindLibfdk.cmake new file mode 100644 index 00000000000000..ee345b72c6e345 --- /dev/null +++ b/cmake/finders/FindLibfdk.cmake @@ -0,0 +1,101 @@ +#[=======================================================================[.rst +FindLibfdk +---------- + +FindModule for Libfdk and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``Libfdk::Libfdk``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Libfdk_FOUND`` + True, if all required components and the core library were found. +``Libfdk_VERSION`` + Detected version of found Libfdk libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Libfdk_LIBRARY`` + Path to the library component of Libfdk. +``Libfdk_INCLUDE_DIR`` + Directory containing ``fdk-aac/aacenc_lib.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Libfdk QUIET fdk-aac Libfdk-aac) +endif() + +find_path( + Libfdk_INCLUDE_DIR + NAMES fdk-aac/aacenc_lib.h + HINTS ${PC_Libfdk_INCLUDE_DIRS} + PATHS /usr/include/ /usr/local/include + DOC "Libfdk include directory") + +find_library( + Libfdk_LIBRARY + NAMES fdk-aac Libfdk-aac + HINTS ${PC_Libfdk_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Libfdk location") + +if(PC_Libfdk_VERSION VERSION_GREATER 0) + set(Libfdk_VERSION ${PC_Libfdk_VERSION}) +else() + if(NOT Libfdk_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Libfdk version.") + endif() + set(Libfdk_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Libfdk + REQUIRED_VARS Libfdk_LIBRARY Libfdk_INCLUDE_DIR + VERSION_VAR Libfdk_VERSION REASON_FAILURE_MESSAGE "Ensure that Libfdk is installed on the system.") +mark_as_advanced(Libfdk_INCLUDE_DIR Libfdk_LIBRARY) + +if(Libfdk_FOUND) + if(NOT TARGET Libfdk::Libfdk) + if(IS_ABSOLUTE "${Libfdk_LIBRARY}") + add_library(Libfdk::Libfdk UNKNOWN IMPORTED) + set_property(TARGET Libfdk::Libfdk PROPERTY IMPORTED_LOCATION "${Libfdk_LIBRARY}") + else() + add_library(Libfdk::Libfdk INTERFACE IMPORTED) + set_property(TARGET Libfdk::Libfdk PROPERTY IMPORTED_LIBNAME "${Libfdk_LIBRARY}") + endif() + + set_target_properties( + Libfdk::Libfdk + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Libfdk_CFLAFGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libfdk_INCLUDE_DIR}" + VERSION ${Libfdk_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Libfdk PROPERTIES + URL "https://github.com/mstorsjo/fdk-aac" + DESCRIPTION "A standalone library of the Fraunhofer FDK AAC code from Android.") diff --git a/cmake/finders/FindLibpci.cmake b/cmake/finders/FindLibpci.cmake new file mode 100644 index 00000000000000..18ebe6ed90f21c --- /dev/null +++ b/cmake/finders/FindLibpci.cmake @@ -0,0 +1,105 @@ +#[=======================================================================[.rst +FindLibpci +---------- + +FindModule for Libpci and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``Libpci::pci``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Libpci_FOUND`` + True, if all required components and the core library were found. +``Libpci_VERSION`` + Detected version of found Libpci libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Libpci_LIBRARY`` + Path to the library component of Libpci. +``Libpci_INCLUDE_DIR`` + Directory containing ``Libpci.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Libpci QUIET libpci) +endif() + +find_path( + Libpci_INCLUDE_DIR + NAMES pci.h + HINTS ${PC_Libpci_INCLUDE_DIRS} + PATHS /usr/include/ /usr/local/include + PATH_SUFFIXES pci + DOC "Libpci include directory") + +find_library( + Libpci_LIBRARY + NAMES libpci pci + HINTS ${PC_Libpci_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Libpci location") + +if(PC_Libpci_VERSION VERSION_GREATER 0) + set(Libpci_VERSION ${PC_Libpci_VERSION}) +elseif(EXISTS "${Libpci_INCLUDE_DIR}/config.h") + file(STRINGS "${Libpci_INCLUDE_DIR}/config.h" _VERSION_STRING REGEX "^.*PCILIB_VERSION[ \t]+\"[0-9\\.]+\"[ \t]*$") + string(REGEX REPLACE ".*PCILIB_VERSION[ \t]+\"([0-9\\.]+)\".*" "\\1" Libpci_VERSION "${_VERSION_STRING}") +else() + if(NOT Libpci_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Libpci version.") + endif() + set(Libpci_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Libpci + REQUIRED_VARS Libpci_LIBRARY Libpci_INCLUDE_DIR + VERSION_VAR Libpci_VERSION REASON_FAILURE_MESSAGE "Ensure that libpci is installed on the system.") +mark_as_advanced(Libpci_INCLUDE_DIR Libpci_LIBRARY) + +if(Libpci_FOUND) + if(NOT TARGET Libpci::pci) + if(IS_ABSOLUTE "${Libpci_LIBRARY}") + add_library(Libpci::pci UNKNOWN IMPORTED) + set_property(TARGET Libpci::pci PROPERTY IMPORTED_LOCATION "${Libpci_LIBRARY}") + else() + add_library(Libpci::pci INTERFACE IMPORTED) + set_property(TARGET Libpci::pci PROPERTY IMPORTED_LIBNAME "${Libpci_LIBRARY}") + endif() + + set_target_properties( + Libpci::pci + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Libpci_CFLAFGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libpci_INCLUDE_DIR}" + VERSION ${Libpci_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Libpci PROPERTIES + URL "https://mj.ucw.cz/sw/pciutils" + DESCRIPTION "Offers access to the PCI configuration space on a variety of operating systems.") diff --git a/cmake/finders/FindLibudev.cmake b/cmake/finders/FindLibudev.cmake new file mode 100644 index 00000000000000..5d7cc6601fd9c8 --- /dev/null +++ b/cmake/finders/FindLibudev.cmake @@ -0,0 +1,101 @@ +#[=======================================================================[.rst +FindLibudev +----------- + +FindModule for Libudev and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``Libudev::Libudev``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Libudev_FOUND`` + True, if all required components and the core library were found. +``Libudev_VERSION`` + Detected version of found Libudev libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Libudev_LIBRARY`` + Path to the library component of Libudev. +``Libudev_INCLUDE_DIR`` + Directory containing ``libudev.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Libudev QUIET libudev) +endif() + +find_path( + Libudev_INCLUDE_DIR + NAMES libudev.h + HINTS ${PC_Libudev_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "Libudev include directory") + +find_library( + Libudev_LIBRARY + NAMES udev libudev + HINTS ${PC_Libudev_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Libudev location") + +if(PC_Libudev_VERSION VERSION_GREATER 0) + set(Libudev_VERSION ${PC_Libudev_VERSION}) +else() + if(NOT Libudev_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Libudev version.") + endif() + set(Libudev_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Libudev + REQUIRED_VARS Libudev_LIBRARY Libudev_INCLUDE_DIR + VERSION_VAR Libudev_VERSION REASON_FAILURE_MESSAGE "Ensure that Libudev is installed on the system.") +mark_as_advanced(Libudev_INCLUDE_DIR Libudev_LIBRARY) + +if(Libudev_FOUND) + if(NOT TARGET Libudev::Libudev) + if(IS_ABSOLUTE "${Libudev_LIBRARY}") + add_library(Libudev::Libudev UNKNOWN IMPORTED) + set_property(TARGET Libudev::Libudev PROPERTY IMPORTED_LOCATION "${Libudev_LIBRARY}") + else() + add_library(Libudev::Libudev INTERFACE IMPORTED) + set_property(TARGET Libudev::Libudev PROPERTY IMPORTED_LIBNAME "${Libudev_LIBRARY}") + endif() + + set_target_properties( + Libudev::Libudev + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Libudev_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libudev_INCLUDE_DIR}" + VERSION ${Libudev_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Libudev PROPERTIES + URL "https://www.freedesktop.org/wiki/Software/systemd/" + DESCRIPTION "API for enumerating and introspecting local devices.") diff --git a/cmake/finders/FindLibv4l2.cmake b/cmake/finders/FindLibv4l2.cmake new file mode 100644 index 00000000000000..45bf1a7496593c --- /dev/null +++ b/cmake/finders/FindLibv4l2.cmake @@ -0,0 +1,101 @@ +#[=======================================================================[.rst +FindLibv4l2 +----------- + +FindModule for Libv4l2 and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``Libv4l2::Libv4l2``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Libv4l2_FOUND`` + True, if all required components and the core library were found. +``Libv4l2_VERSION`` + Detected version of found Libv4l2 libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Libv4l2_LIBRARY`` + Path to the library component of Libv4l2. +``Libv4l2_INCLUDE_DIR`` + Directory containing ``libv4l2.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Libv4l2 QUIET libv4l2 v4l2 v4l-utils) +endif() + +find_path( + Libv4l2_INCLUDE_DIR + NAMES libv4l2.h + HINTS ${PC_Libv4l2_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "Libv4l2 include directory") + +find_library( + Libv4l2_LIBRARY + NAMES v4l2 + HINTS ${PC_Libv4l2_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Libv4l2 location") + +if(PC_Libv4l2_VERSION VERSION_GREATER 0) + set(Libv4l2_VERSION ${PC_Libv4l2_VERSION}) +else() + if(NOT Libv4l2_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Libv4l2 version.") + endif() + set(Libv4l2_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Libv4l2 + REQUIRED_VARS Libv4l2_LIBRARY Libv4l2_INCLUDE_DIR + VERSION_VAR Libv4l2_VERSION REASON_FAILURE_MESSAGE "Ensure that v4l-utils is installed on the system.") +mark_as_advanced(Libv4l2_INCLUDE_DIR Libv4l2_LIBRARY) + +if(Libv4l2_FOUND) + if(NOT TARGET Libv4l2::Libv4l2) + if(IS_ABSOLUTE "${Libv4l2_LIBRARY}") + add_library(Libv4l2::Libv4l2 UNKNOWN IMPORTED) + set_property(TARGET Libv4l2::Libv4l2 PROPERTY IMPORTED_LOCATION "${Libv4l2_LIBRARY}") + else() + add_library(Libv4l2::Libv4l2 INTERFACE IMPORTED) + set_property(TARGET Libv4l2::Libv4l2 PROPERTY IMPORTED_LIBNAME "${Libv4l2_LIBRARY}") + endif() + + set_target_properties( + Libv4l2::Libv4l2 + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Libv4l2_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libv4l2_INCLUDE_DIR}" + VERSION ${Libv4l2_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Lib4l2 PROPERTIES + URL "https://linuxtv.org/wiki/index.php/V4l-utils" + DESCRIPTION "The v4l-utils are a series of packages for handling media devices.") diff --git a/cmake/finders/FindLibva.cmake b/cmake/finders/FindLibva.cmake new file mode 100644 index 00000000000000..0ead897a893199 --- /dev/null +++ b/cmake/finders/FindLibva.cmake @@ -0,0 +1,145 @@ +#[=======================================================================[.rst +FindLibva +--------- + +FindModule for Libva and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the following :prop_tgt:`IMPORTED` targets: + +``Libva::va`` + Video Acceleration (VA) API for Linux -- runtime + +``Libva::drm`` + Video Acceleration (VA) API for Linux -- DRM runtime + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Libva_FOUND`` + True, if all required components and the core library were found. +``Libva_VERSION`` + Detected version of found Libva libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Libva_LIBRARY`` + Path to the library component of Libva. +``Libva_INCLUDE_DIR`` + Directory containing ``libva.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Libva QUIET libva) + pkg_search_module(PC_LibvaDrm QUIET libva-drm) +endif() + +find_path( + Libva_INCLUDE_DIR + NAMES va.h + HINTS ${PC_Libva_INCLUDE_DIRS} + PATHS /usr/include/ /usr/local/include + PATH_SUFFIXES va + DOC "Libva include directory") + +find_library( + Libva_LIBRARY + NAMES libva va + HINTS ${PC_Libva_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Libva location") + +find_library( + LibvaDrm_LIBRARY + NAMES libva-drm va-drm + HINTS ${PC_LibvaDrm_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Libva-drm location") + +if(PC_Libva_VERSION VERSION_GREATER 0) + set(Libva_VERSION ${PC_Libva_VERSION}) +elseif(EXISTS "${Libva_INCLUDE_DIR}/va_version.h") + file(STRINGS "${Libva_INCLUDE_DIR}/va_version.h" _VERSION_STRING + REGEX "^.*(MAJOR|MINOR|MICRO)_VERSION[ \t]+[0-9]+[ \t]*$") + string(REGEX REPLACE ".*MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" VERSION_MAJOR "${_VERSION_STRING}") + string(REGEX REPLACE ".*MINOR_VERSION[ \t]+([0-9]+).*" "\\1" VERSION_MINOR "${_VERSION_STRING}") + string(REGEX REPLACE ".*MICRO_VERSION[ \t]+([0-9]+).*" "\\1" VERSION_MICRO "${_VERSION_STRING}") + + set(Libva_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}") +else() + if(NOT Libva_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Libva version.") + endif() + set(Libva_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Libva + REQUIRED_VARS Libva_LIBRARY Libva_INCLUDE_DIR + VERSION_VAR Libva_VERSION REASON_FAILURE_MESSAGE "Ensure that libva is installed on the system.") +mark_as_advanced(Libva_INCLUDE_DIR Libva_LIBRARY) + +if(Libva_FOUND) + if(NOT TARGET Libva::va) + if(IS_ABSOLUTE "${Libva_LIBRARY}") + add_library(Libva::va UNKNOWN IMPORTED) + set_property(TARGET Libva::va PROPERTY IMPORTED_LOCATION "${Libva_LIBRARY}") + else() + add_library(Libva::va INTERFACE IMPORTED) + set_property(TARGET Libva::va PROPERTY IMPORTED_LIBNAME "${Libva_LIBRARY}") + endif() + + set_target_properties( + Libva::va + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Libva_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libva_INCLUDE_DIR}" + VERSION ${Libva_VERSION}) + endif() + + if(LibvaDrm_LIBRARY) + if(NOT TARGET Libva::drm) + if(IS_ABSOLUTE "${LibvaDrm_LIBRARY}") + add_library(Libva::drm UNKNOWN IMPORTED) + set_property(TARGET Libva::drm PROPERTY IMPORTED_LOCATION "${LibvaDrm_LIBRARY}") + else() + add_library(Libva::drm INTERFACE IMPORTED) + set_property(TARGET Libva::drm PROPERTY IMPORTED_LIBNAME "${LibvaDrm_LIBRARY}") + endif() + + set_target_properties( + Libva::drm + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_LibvaDrm_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libva_INCLUDE_DIR}" + VERSION ${Libva_VERSION}) + endif() + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Libva PROPERTIES + URL "https://01.org/intel-media-for-linux" + DESCRIPTION + "An implementation for VA-API (Video Acceleration API) - an open-source library which provides access to graphics hardware acceleration capabilities." +) diff --git a/cmake/finders/FindLibx264.cmake b/cmake/finders/FindLibx264.cmake index 123a3265324c0e..a09c3f0c8933e4 100644 --- a/cmake/finders/FindLibx264.cmake +++ b/cmake/finders/FindLibx264.cmake @@ -107,8 +107,7 @@ if(PC_Libx264_VERSION VERSION_GREATER 0) set(Libx264_VERSION ${PC_Libx264_VERSION}) elseif(EXISTS "${Libx264_INCLUDE_DIR}/x264_config.h") file(STRINGS "${Libx264_INCLUDE_DIR}/x264_config.h" _VERSION_STRING REGEX "#define[ \t]+X264_POINTVER[ \t]+.+") - string(REGEX REPLACE ".*#define[ \t]+X264_POINTVER[ \t]+\"(.+)[ \t]+.+\".*" "\\1" Libx264_VERSION - "${_VERSION_STRING}") + string(REGEX REPLACE ".*#define[ \t]+X264_POINTVER[ \t]+\"([^ \t]+).*\".*" "\\1" Libx264_VERSION "${_VERSION_STRING}") else() if(NOT Libx264_FIND_QUIETLY) message(AUTHOR_WARNING "Failed to find Libx264 version.") diff --git a/cmake/finders/FindLuajit.cmake b/cmake/finders/FindLuajit.cmake index a329dddb3ebb31..28e4ff33c089ad 100644 --- a/cmake/finders/FindLuajit.cmake +++ b/cmake/finders/FindLuajit.cmake @@ -79,14 +79,14 @@ find_path( NAMES lua.h luajit.h HINTS ${PC_Luajit_INCLUDE_DIRS} PATHS /usr/include /usr/local/include - PATH_SUFFIXES luajit-2.1 luajit + PATH_SUFFIXES luajit-2.1 luajit-2.0 luajit DOC "Luajit include directory") if(PC_Luajit_VERSION VERSION_GREATER 0) set(Luajit_VERSION ${PC_Luajit_VERSION}) -elseif(EXISTS "${Luajit_INCLUDE_DIR}/lua.h") - file(STRINGS "${Luajit_INCLUDE_DIR}/lua.h" _VERSION_STRING REGEX "#define[ \t]+LUA_RELEASE[ \t]+.+") - string(REGEX REPLACE ".*#define[ \t]+LUA_RELEASE[ \t]+\"Lua (.+)\".*" "\\1" Luajit_VERSION "${_VERSION_STRING}") +elseif(EXISTS "${Luajit_INCLUDE_DIR}/luajit.h") + file(STRINGS "${Luajit_INCLUDE_DIR}/luajit.h" _VERSION_STRING REGEX "#define[ \t]+LUAJIT_VERSION[ \t]+\".+\".*") + string(REGEX REPLACE ".*#define[ \t]+LUAJIT_VERSION[ \t]+\"LuaJIT (.+)\".*" "\\1" Luajit_VERSION "${_VERSION_STRING}") else() if(NOT Luajit_FIND_QUIETLY) message(AUTHOR_WARNING "Failed to find Luajit version.") diff --git a/cmake/finders/FindMbedTLS.cmake b/cmake/finders/FindMbedTLS.cmake index 272ff2b1bcb3b4..0bec57d53d5095 100644 --- a/cmake/finders/FindMbedTLS.cmake +++ b/cmake/finders/FindMbedTLS.cmake @@ -115,6 +115,11 @@ elseif(EXISTS "${MbedTLS_INCLUDE_DIR}/mbedtls/build_info.h") REGEX "#define[ \t]+MBEDTLS_VERSION_STRING[ \t]+.+") string(REGEX REPLACE ".*#define[ \t]+MBEDTLS_VERSION_STRING[ \t]+\"(.+)\".*" "\\1" MbedTLS_VERSION "${_VERSION_STRING}") +elseif(EXISTS "${MbedTLS_INCLUDE_DIR}/mbedtls/version.h") + file(STRINGS "${MbedTLS_INCLUDE_DIR}/mbedtls/version.h" _VERSION_STRING + REGEX "#define[ \t]+MBEDTLS_VERSION_STRING[ \t]+.+") + string(REGEX REPLACE ".*#define[ \t]+MBEDTLS_VERSION_STRING[ \t]+\"(.+)\".*" "\\1" MbedTLS_VERSION + "${_VERSION_STRING}") else() if(NOT MbedTLS_FIND_QUIETLY) message(AUTHOR_WARNING "Failed to find MbedTLS version.") diff --git a/cmake/finders/FindOSS.cmake b/cmake/finders/FindOSS.cmake new file mode 100644 index 00000000000000..c32d51946f2051 --- /dev/null +++ b/cmake/finders/FindOSS.cmake @@ -0,0 +1,64 @@ +#[=======================================================================[.rst +FindOSS +------- + +FindModule for OSS and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``OSS::OSS``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``OSS_FOUND`` + True, if all required components and the core library were found. +``OSS_VERSION`` + Detected version of found OSS libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``OSS_INCLUDE_DIR`` + Directory containing ``sys/soundcard.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_path( + OSS_INCLUDE_DIR + NAMES sys/soundcard.h + HINTS ${PC_OSS_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "OSS include directory") + +set(OSS_VERSION ${CMAKE_HOST_SYSTEM_VERSION}) + +find_package_handle_standard_args( + OSS + REQUIRED_VARS OSS_INCLUDE_DIR + VERSION_VAR OSS_VERSION REASON_FAILURE_MESSAGE "Ensure that OSS is installed on the system.") +mark_as_advanced(OSS_INCLUDE_DIR OSS_LIBRARY) + +if(OSS_FOUND) + if(NOT TARGET OSS::OSS) + add_library(OSS::OSS INTERFACE IMPORTED) + + set_target_properties(OSS::OSS PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${OSS_INCLUDE_DIR}" VERSION ${OSS_VERSION}) + endif() +endif() diff --git a/cmake/finders/FindPipeWire.cmake b/cmake/finders/FindPipeWire.cmake new file mode 100644 index 00000000000000..d7c225027e7a91 --- /dev/null +++ b/cmake/finders/FindPipeWire.cmake @@ -0,0 +1,122 @@ +#[=======================================================================[.rst +FindPipeWire +------------ + +FindModule for PipeWire and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``PipeWire::PipeWire``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``PipeWire_FOUND`` + True, if all required components and the core library were found. +``PipeWire_VERSION`` + Detected version of found PipeWire libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``PipeWire_LIBRARY`` + Path to the library component of PipeWire. +``PipeWire_INCLUDE_DIR`` + Directory containing ``PipeWire.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_PipeWire libpipewire-0.3 QUIET) + pkg_search_module(PC_Libspa libspa-0.2 QUIET) +endif() + +find_path( + PipeWire_INCLUDE_DIR + NAMES pipewire/pipewire.h + HINTS ${PC_PipeWire_INCLUDE_DIRS} + PATH_SUFFIXES pipewire-0.3 + PATHS /usr/include /usr/local/include + DOC "PipeWire include directory") + +find_path( + Libspa_INCLUDE_DIR + NAMES spa/param/props.h + HINTS ${PC_Libspa_INCLUDE_DIRS} + PATH_SUFFIXES spa-0.2 + PATHS /usr/include /usr/local/include + DOC "Libspa include directory") + +find_library( + PipeWire_LIBRARY + NAMES pipewire-0.3 + HINTS ${PC_PipeWire_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "PipeWire location") + +if(PC_PipeWire_VERSION VERSION_GREATER 0) + set(PipeWire_VERSION ${PC_PipeWire_VERSION}) +elseif(EXISTS "${PipeWire_INCLUDE_DIR}/pipewire/version.h") + file(STRINGS "${PipeWire_INCLUDE_DIR}/pipewire/version.h" _version_string + REGEX "^.*PW_(MAJOR|MINOR|MICRO)[ \t]+[0-9]+[ \t]*$") + string(REGEX REPLACE ".*PW_MAJOR[ \t]+([0-9]+).*" "\\1" _version_major "${_version_string}") + string(REGEX REPLACE ".*PW_MINOR[ \t]+([0-9]+).*" "\\1" _version_minor "${_version_string}") + string(REGEX REPLACE ".*PW_MICRO[ \t]+([0-9]+).*" "\\1" _version_micro "${_version_string}") + + set(PipeWire_VERSION "${_version_major}.${_version_minor}.${_version_micro}") + unset(_version_major) + unset(_version_minor) + unset(_version_micro) +else() + if(NOT PipeWire_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find PipeWire version.") + endif() + set(PipeWire_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + PipeWire + REQUIRED_VARS PipeWire_LIBRARY PipeWire_INCLUDE_DIR Libspa_INCLUDE_DIR + VERSION_VAR PipeWire_VERSION REASON_FAILURE_MESSAGE "Ensure that PipeWire is installed on the system.") +mark_as_advanced(PipeWire_LIBRARY PipeWire_INCLUDE_DIR) + +if(PipeWire_FOUND) + if(NOT TARGET PipeWire::PipeWire) + if(IS_ABSOLUTE "${PipeWire_LIBRARY}") + add_library(PipeWire::PipeWire UNKNOWN IMPORTED) + set_property(TARGET PipeWire::PipeWire PROPERTY IMPORTED_LOCATION "${PipeWire_LIBRARY}") + else() + add_library(PipeWire::PipeWire INTERFACE IMPORTED) + set_property(TARGET PipeWire::PipeWire PROPERTY IMPORTED_LIBNAME "${PipeWire_LIBRARY}") + endif() + + set_target_properties( + PipeWire::PipeWire + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_PipeWire_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${PipeWire_INCLUDE_DIR};${Libspa_INCLUDE_DIR}" + VERSION ${PipeWire_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + PipeWire PROPERTIES + URL "https://www.pipewire.org" + DESCRIPTION "PipeWire - multimedia processing") diff --git a/cmake/finders/FindPulseAudio.cmake b/cmake/finders/FindPulseAudio.cmake new file mode 100644 index 00000000000000..cbb035f6d858c3 --- /dev/null +++ b/cmake/finders/FindPulseAudio.cmake @@ -0,0 +1,108 @@ +#[=======================================================================[.rst +FindPulseAudio +-------------- + +FindModule for PulseAudio and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``PulseAudio::PulseAudio``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``PulseAudio_FOUND`` + True, if all required components and the core library were found. +``PulseAudio_VERSION`` + Detected version of found PulseAudio libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``PulseAudio_LIBRARY`` + Path to the library component of PulseAudio. +``PulseAudio_INCLUDE_DIR`` + Directory containing ``pulseaudio.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_PulseAudio QUIET libpulse) +endif() + +find_path( + PulseAudio_INCLUDE_DIR + NAMES pulse/pulseaudio.h + HINTS ${PC_PulseAudio_INCLUDE_DIRS} + PATHS /usr/include/ /usr/local/include + DOC "PulseAudio include directory") + +find_library( + PulseAudio_LIBRARY + NAMES pulse + HINTS ${PC_PulseAudio_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "PulseAudio location") + +if(PC_PulseAudio_VERSION VERSION_GREATER 0) + set(PulseAudio_VERSION ${PC_PulseAudio_VERSION}) +elseif(EXISTS "${PulseAudio_INCLUDE_DIR}/version.h") + file(STRINGS "${PulseAudio_INCLUDE_DIR}/version.h" _VERSION_STRING + REGEX "^.*pa_get_headers_version\\(\\)[\t ]+\\(\".*\"\\)[ \t]*$") + string(REGEX REPLACE ".*pa_get_headers_version\\(\\)[\t ]+\\(\"([^\"]*)\"\\).*" "\\1" PulseAudio_VERSION + "${_VERSION_STRING}") +else() + if(NOT PulseAudio_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find PulseAudio version.") + endif() + set(PulseAudio_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + PulseAudio + REQUIRED_VARS PulseAudio_INCLUDE_DIR PulseAudio_LIBRARY + VERSION_VAR PulseAudio_VERSION REASON_FAILURE_MESSAGE "Ensure that PulseAudio is installed on the system.") +mark_as_advanced(PulseAudio_INCLUDE_DIR PulseAudio_LIBRARY) + +if(PulseAudio_FOUND) + if(NOT TARGET PulseAudio::PulseAudio) + if(IS_ABSOLUTE "${PulseAudio_LIBRARY}") + add_library(PulseAudio::PulseAudio UNKNOWN IMPORTED) + set_property(TARGET PulseAudio::PulseAudio PROPERTY IMPORTED_LOCATION "${PulseAudio_LIBRARY}") + else() + add_library(PulseAudio::PulseAudio INTERFACE IMPORTED) + set_property(TARGET PulseAudio::PulseAudio PROPERTY IMPORTED_LIBNAME "${PulseAudio_LIBRARY}") + endif() + + set_target_properties( + PulseAudio::PulseAudio + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_PulseAudio_CFLAFGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${PulseAudio_INCLUDE_DIR}" + VERSION ${PulseAudio_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + PulseAudio PROPERTIES + URL "https://www.freedesktop.org/wiki/Software/PulseAudio/" + DESCRIPTION + "PulseAudio is a sound server system for POSIX OSes, meaning that it is a proxy for your sound applications.") diff --git a/cmake/finders/FindSndio.cmake b/cmake/finders/FindSndio.cmake new file mode 100644 index 00000000000000..66702ba141506c --- /dev/null +++ b/cmake/finders/FindSndio.cmake @@ -0,0 +1,101 @@ +#[=======================================================================[.rst +FindSndio +--------- + +FindModule for Sndio and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``Sndio::Sndio``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Sndio_FOUND`` + True, if all required components and the core library were found. +``Sndio_VERSION`` + Detected version of found Sndio libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Sndio_LIBRARY`` + Path to the library component of Sndio. +``Sndio_INCLUDE_DIR`` + Directory containing ``sndio.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Sndio QUIET sndio) +endif() + +find_path( + Sndio_INCLUDE_DIR + NAMES sndio.h + HINTS ${PC_Sndio_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "Sndio include directory") + +find_library( + Sndio_LIBRARY + NAMES sndio + HINTS ${PC_Sndio_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Sndio location") + +if(PC_Sndio_VERSION VERSION_GREATER 0) + set(Sndio_VERSION ${PC_Sndio_VERSION}) +else() + if(NOT Sndio_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Sndio version.") + endif() + set(Sndio_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Sndio + REQUIRED_VARS Sndio_LIBRARY Sndio_INCLUDE_DIR + VERSION_VAR Sndio_VERSION REASON_FAILURE_MESSAGE "Ensure that Sndio is installed on the system.") +mark_as_advanced(Sndio_INCLUDE_DIR Sndio_LIBRARY) + +if(Sndio_FOUND) + if(NOT TARGET Sndio::Sndio) + if(IS_ABSOLUTE "${Sndio_LIBRARY}") + add_library(Sndio::Sndio UNKNOWN IMPORTED) + set_property(TARGET Sndio::Sndio PROPERTY IMPORTED_LOCATION "${Sndio_LIBRARY}") + else() + add_library(Sndio::Sndio INTERFACE IMPORTED) + set_property(TARGET Sndio::Sndio PROPERTY IMPORTED_LIBNAME "${Sndio_LIBRARY}") + endif() + + set_target_properties( + Sndio::Sndio + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Sndio_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Sndio_INCLUDE_DIR}" + VERSION ${Sndio_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Sndio PROPERTIES + URL "https://www.sndio.org" + DESCRIPTION "Sndio is a small audio and MIDI framework part of the OpenBSD project and ported to FreeBSD.") diff --git a/cmake/finders/FindSysinfo.cmake b/cmake/finders/FindSysinfo.cmake new file mode 100644 index 00000000000000..a2c101cf1da3f7 --- /dev/null +++ b/cmake/finders/FindSysinfo.cmake @@ -0,0 +1,95 @@ +#[=======================================================================[.rst +FindSysinfo +----------- + +FindModule for Sysinfo and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``Sysinfo::Sysinfo``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Sysinfo_FOUND`` + True, if all required components and the core library were found. +``Sysinfo_VERSION`` + Detected version of found Sysinfo libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Sysinfo_LIBRARY`` + Path to the library component of Sysinfo. +``Sysinfo_INCLUDE_DIR`` + Directory containing ``sys/sysinfo.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Sysinfo QUIET sysinfo) +endif() + +find_path( + Sysinfo_INCLUDE_DIR + NAMES sys/sysinfo.h + HINTS ${PC_Sysinfo_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "Sysinfo include directory") + +find_library( + Sysinfo_LIBRARY + NAMES sysinfo libsysinfo + HINTS ${PC_Sysinfo_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Sysinfo location") + +if(PC_Sysinfo_VERSION VERSION_GREATER 0) + set(Sysinfo_VERSION ${PC_Sysinfo_VERSION}) +else() + if(NOT Sysinfo_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Sysinfo version.") + endif() + set(Sysinfo_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Sysinfo + REQUIRED_VARS Sysinfo_LIBRARY Sysinfo_INCLUDE_DIR + VERSION_VAR Sysinfo_VERSION REASON_FAILURE_MESSAGE "Ensure that Sysinfo is installed on the system.") +mark_as_advanced(Sysinfo_INCLUDE_DIR Sysinfo_LIBRARY) + +if(Sysinfo_FOUND) + if(NOT TARGET Sysinfo::Sysinfo) + if(IS_ABSOLUTE "${Sysinfo_LIBRARY}") + add_library(Sysinfo::Sysinfo UNKNOWN IMPORTED) + set_property(TARGET Sysinfo::Sysinfo PROPERTY IMPORTED_LOCATION "${Sysinfo_LIBRARY}") + else() + add_library(Sysinfo::Sysinfo INTERFACE IMPORTED) + set_property(TARGET Sysinfo::Sysinfo PROPERTY IMPORTED_LIBNAME "${Sysinfo_LIBRARY}") + endif() + + set_target_properties( + Sysinfo::Sysinfo + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Sysinfo_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Sysinfo_INCLUDE_DIR}" + VERSION ${Sysinfo_VERSION}) + endif() +endif() diff --git a/cmake/finders/FindWayland.cmake b/cmake/finders/FindWayland.cmake new file mode 100644 index 00000000000000..ed43398c3cfb27 --- /dev/null +++ b/cmake/finders/FindWayland.cmake @@ -0,0 +1,177 @@ +#[=======================================================================[.rst +FindWayland +----------- + +FindModule for Wayland and and associated components + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Components +^^^^^^^^^^ + +.. versionadded:: 1.0 + +This module contains provides several components: + +``Client`` +``Server`` +``EGL`` +``Cursor`` + +Import targets exist for each component. + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` targets: + +``Wayland::Client`` + Wayland client component + +``Wayland::Server`` + Wayland server component + +``Wayland::EGL`` + Wayland EGL component + +``Wayland::Cursor`` + Wayland cursor component + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Wayland__FOUND`` + True, if required component was found. +``Wayland__VERSION`` + Detected version of Wayland component. +``Wayland__INCLUDE_DIRS`` + Include directories needed for Wayland component. +``Wayland__LIBRARIES`` + Libraries needed to link to Wayland component. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Wayland__LIBRARY`` + Path to the component of Wayland. +``Wayland__INCLUDE_DIR`` + Directory containing ``.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) + +list(APPEND _Wayland_DEFAULT_COMPONENTS Client Server EGL Cursor) +list(APPEND _Wayland_LIBRARIES wayland-client wayland-server wayland-egl wayland-cursor) + +if(NOT Wayland_FIND_COMPONENTS) + set(Wayland_FIND_COMPONENTS ${_Wayland_DEFAULT_COMPONENTS}) +endif() + +# Wayland_find_component: Macro to setup targets for specified Wayland component +macro(Wayland_find_component component) + list(GET _Wayland_DEFAULT_COMPONENTS ${component} COMPONENT_NAME) + list(GET _Wayland_LIBRARIES ${component} COMPONENT_LIBRARY) + + if(NOT TARGET Wayland::${COMPONENT_NAME}) + if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Wayland_${COMPONENT_NAME} QUIET ${COMPONENT_LIBRARY}) + endif() + + find_path( + Wayland_${COMPONENT_NAME}_INCLUDE_DIR + NAMES ${COMPONENT_LIBRARY}.h + HINTS ${PC_Wayland_${COMPONENT_NAME}_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "Wayland ${COMPONENT_NAME} include directory") + + find_library( + Wayland_${COMPONENT_NAME}_LIBRARY + NAMES ${COMPONENT_LIBRARY} + HINTS ${PC_Wayland_${COMPONENT_NAME}_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Wayland ${COMPONENT_NAME} location") + + if(PC_Wayland_${COMPONENT_NAME}_VERSION VERSION_GREATER 0) + set(Wayland_${COMPONENT_NAME}_VERSION ${PC_Wayland_${COMPONENT_NAME}_VERSION}) + else() + if(NOT Wayland_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Wayland ${COMPONENT_NAME} version.") + endif() + set(Wayland_${COMPONENT_NAME}_VERSION 0.0.0) + endif() + + if(Wayland_${COMPONENT_NAME}_LIBRARY AND Wayland_${COMPONENT_NAME}_INCLUDE_DIR) + set(Wayland_${COMPONENT_NAME}_FOUND TRUE) + set(Wayland_${COMPONENT_NAME}_LIBRARIES ${Wayland_${COMPONENT_NAME}_LIBRARY}) + set(Wayland_${COMPONENT_NAME}_INCLUDE_DIRS ${Wayland_${COMPONENT_NAME}_INCLUDE_DIR}) + set(Wayland_${COMPONENT_NAME}_DEFINITIONS ${PC_Wayland_${COMPONENT_NAME}_CFLAGS_OTHER}) + mark_as_advanced(Wayland_${COMPONENT_NAME}_LIBRARY Wayland_${COMPONENT_NAME}_INCLUDE_DIR) + + if(IS_ABSOLUTE "${Wayland_${COMPONENT_NAME}_LIBRARY}") + add_library(Wayland::${COMPONENT_NAME} UNKNOWN IMPORTED) + set_property(TARGET Wayland::${COMPONENT_NAME} PROPERTY IMPORTED_LOCATION + "${Wayland_${COMPONENT_NAME}_LIBRARY}") + else() + add_library(Wayland::${COMPONENT_NAME} INTERFACE IMPORTED) + set_property(TARGET Wayland::${COMPONENT_NAME} PROPERTY IMPORTED_LIBNAME "${Wayland_${COMPONENT_NAME}_LIBRARY}") + endif() + + set_target_properties( + Wayland::${COMPONENT_NAME} + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Wayland_${COMPONENT_NAME}_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Wayland_${COMPONENT_NAME}_INCLUDE_DIR}" + VERSION ${Wayland_${COMPONENT_NAME}_VERSION}) + list(APPEND Wayland_COMPONENTS Wayland::${COMPONENT_NAME}) + list(APPEND Wayland_INCLUDE_DIRS ${Wayland_${COMPONENT_NAME}_INCLUDE_DIR}) + list(APPEND Wayland_LIBRARIES ${Wayland_${COMPONENT_NAME}_LIBRARY}) + + if(NOT Wayland_VERSION) + set(Wayland_VERSION ${Wayland_${COMPONENT_NAME}_VERSION}) + endif() + endif() + else() + list(APPEND Wayland_COMPONENTS Wayland::${COMPONENT_NAME}) + endif() +endmacro() + +foreach(component IN LISTS Wayland_FIND_COMPONENTS) + list(FIND _Wayland_DEFAULT_COMPONENTS "${component}" valid_component) + + if(valid_component GREATER_EQUAL 0) + wayland_find_component(${valid_component}) + else() + message(FATAL_ERROR "Unknown Wayland component required: ${component}.") + endif() +endforeach() + +find_package_handle_standard_args( + Wayland + REQUIRED_VARS Wayland_LIBRARIES Wayland_INCLUDE_DIRS + VERSION_VAR Wayland_VERSION + HANDLE_COMPONENTS REASON_FAILURE_MESSAGE "Ensure that Wayland is installed on the system.") + +unset(_Wayland_DEFAULT_COMPONENTS) +unset(_Wayland_LIBRARIES) + +include(FeatureSummary) +set_package_properties( + Wayland PROPERTIES + URL "https://wayland.freedesktop.org" + DESCRIPTION + "A replacement for the X11 window system protocol and architecture with the aim to be easier to develop, extend, and maintain." +) diff --git a/cmake/finders/FindX11-xcb.cmake b/cmake/finders/FindX11-xcb.cmake new file mode 100644 index 00000000000000..3d7281f9fa86c4 --- /dev/null +++ b/cmake/finders/FindX11-xcb.cmake @@ -0,0 +1,104 @@ +#[=======================================================================[.rst +FindX11-xcb +----------- + +FindModule for x11-xcb and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``X11::x11-xcb``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``X11-xcb_FOUND`` + True, if all required components and the core library were found. +``X11-xcb_VERSION`` + Detected version of found x11-xcb libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``X11-xcb_LIBRARY`` + Path to the library component of x11-xcb. +``X11-xcb_INCLUDE_DIR`` + Directory containing ``Xlib-xcb.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_X11-xcb QUIET x11-xcb) +endif() + +find_path( + X11-xcb_INCLUDE_DIR + NAMES X11/Xlib-xcb.h + HINTS ${PC_X11-xcb_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "X11-xcb include directory") + +find_library( + X11-xcb_LIBRARY + NAMES X11-xcb + HINTS ${PC_x11-xcb-LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "X11-xcb location") + +if(PC_X11-xcb_VERSION VERSION_GREATER 0) + set(X11-xcb_VERSION ${PC_X11-xcb_VERSION}) +else() + if(NOT X11-xcb_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find X11-xcb version.") + endif() + set(X11-xcb_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + X11-xcb + REQUIRED_VARS X11-xcb_LIBRARY X11-xcb_INCLUDE_DIR + VERSION_VAR X11-xcb_VERSION REASON_FAILURE_MESSAGE "Ensure that X11-xcb is installed on the system.") +mark_as_advanced(X11-xcb_INCLUDE_DIR X11-xcb_LIBRARY) + +if(X11-xcb_FOUND) + if(NOT TARGET X11::x11-xcb) + if(IS_ABSOLUTE "${X11-xcb_LIBRARY}") + add_library(X11::x11-xcb UNKNOWN IMPORTED) + set_property(TARGET X11::x11-xcb PROPERTY IMPORTED_LOCATION "${X11-xcb_LIBRARY}") + else() + add_library(X11::x11-xcb INTERFACE IMPORTED) + set_property(TARGET X11::x11-xcb PROPERTY IMPORTED_LIBNAME "${X11-xcb_LIBRARY}") + endif() + + set_target_properties( + X11::x11-xcb + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_X11-xcb_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${X11-xcb_INCLUDE_DIR}" + VERSION ${X11-xcb_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + X11-xcb PROPERTIES + URL "https://www.X.org" + DESCRIPTION + "Provides functions needed by clients which take advantage of Xlib/XCB to mix calls to both Xlib and XCB over the same X connection." +) diff --git a/cmake/finders/FindXcb.cmake b/cmake/finders/FindXcb.cmake new file mode 100644 index 00000000000000..979471c026b1af --- /dev/null +++ b/cmake/finders/FindXcb.cmake @@ -0,0 +1,302 @@ +#[=======================================================================[.rst +FindXcb +------- + +FindModule for XCB and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Components +^^^^^^^^^^ + +.. versionadded:: 1.0 + +This module contains provides several components: + +``xcb-xcb`` +``xcb-composite`` +``xcb-damage`` +``xcb-dri2,`` +``xcb-ewmh`` +``xcb-glx`` +``xcb-icccm`` +``xcb-image`` +``xcb-keysyms +``xcb-randr`` +``xcb-render`` +``xcb-renderutil`` +``xcb-shape`` +``xcb-shm`` +``xcb-sync`` +``xcb-util +``xcb-xfixes`` +``xcb-xtest`` +``xcb-xv`` +``xcb-xinput`` +``xcb-xinerama`` + +Import targets exist for each component. + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` targets: + +``xcb::xcb`` + xcb component + +``xcb::xcb-composite`` + xcb-composite component + +``xcb::xcb-damage`` + xcb-damage component + +``xcb::xcb-dri2`` + xcb-dri2 component + +``xcb::xcb-ewmh`` + xcb-ewmh component + +``xcb::xcb-glx`` + xcb-glx component + +``xcb::xcb-icccm`` + xcb-icccm component + +``xcb::xcb-image`` + xcb-image component + +``xcb::xcb-keysyms`` + xcb-keysyms component + +``xcb::xcb-randr`` + xcb-randr component + +``xcb::xcb-render`` + xcb-render component + +``xcb::xcb-renderutil`` + xcb-renderutil component + +``xcb::xcb-shape`` + xcb-shape component + +``xcb::xcb-shm`` + xcb-shm component + +``xcb::xcb-sync`` + xcb-sync component + +``xcb::xcb-util`` + xcb-util component + +``xcb::xcb-xfixes`` + xcb-xfixes component + +``xcb::xcb-xtest`` + xcb-xtest component + +``xcb::xcb-xv`` + xcb-xv component + +``xcb::xcb-xinput`` + xcb-xinput component + +``xcb::xcb-xinerema`` + xcb-xinerema component + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Xcb__FOUND`` + True, if required component was found. +``Xcb__VERSION`` + Detected version of found XCB component library. +``Xcb__INCLUDE_DIRS`` + Include directories needed for XCB component. +``Xcb__LIBRARIES`` + Libraries needed to link to XCB component. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Xcb__LIBRARY`` + Path to the library component of XCB. +``Xcb__INCLUDE_DIR`` + Directory containing ``.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-lint: disable=R0915 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) + +list( + APPEND + _Xcb_DEFAULT_COMPONENTS + xcb + xcb-composite + xcb-damage + xcb-dri2, + xcb-ewmh + xcb-glx + xcb-icccm + xcb-image + xcb-keysyms + xcb-randr + xcb-render + xcb-renderutil + xcb-shape + xcb-shm + xcb-sync + xcb-util + xcb-xfixes + xcb-xtest + xcb-xv + xcb-xinput + xcb-xinerama) +list( + APPEND + _Xcb_HEADERS + xcb.h + composite.h + damage.h + dri2h.h + xcb_ewmh.h + glx.h + xcb_icccm.h + xcb_image.h + xcb_keysyms.h + randr.h + render.h + xcb_renderutil.h + shape.h + shm.h + sync.h + xcb_util.h + xfixes.h + xtest.h + xv.h + xinput.h + xinerama.h) + +if(NOT Xcb_FIND_COMPONENTS) + set(Xcb_FIND_COMPONENTS ${_Xcb_DEFAULT_COMPONENTS}) +endif() + +# Xcb_find_component: Find and create targets for specified xcb component +macro(Xcb_find_component component) + list(GET _Xcb_DEFAULT_COMPONENTS ${component} COMPONENT_NAME) + list(GET _Xcb_HEADERS ${component} COMPONENT_HEADER) + + if(NOT TARGET xcb::${COMPONENT_NAME}) + if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Xcb_${COMPONENT_NAME} QUIET ${COMPONENT_NAME}) + endif() + + find_path( + Xcb_${COMPONENT_NAME}_INCLUDE_DIR + NAMES "xcb/${COMPONENT_HEADER}" + HINTS ${PC_Xcb_${COMPONENT_NAME}_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "XCB component ${COMPONENT_NAME} include directory") + + find_library( + Xcb_${COMPONENT_NAME}_LIBRARY + NAMES "${COMPONENT_NAME}" + HINTS ${PC_Xcb_${COMPONENT_NAME}_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "XCB component ${COMPONENT_NAME} location") + + if(PC_Xcb_${COMPONENT_NAME}_VERSION VERSION_GREATER 0) + set(Xcb_${COMPONENT_NAME}_VERSION ${PC_Xcb_${COMPONENT_NAME}_VERSION}) + else() + if(NOT Xcb_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find ${COMPONENT_NAME} version.") + endif() + set(Xcb_${COMPONENT_NAME}_VERSION 0.0.0) + endif() + + if(Xcb_${COMPONENT_NAME}_LIBRARY AND Xcb_${COMPONENT_NAME}_INCLUDE_DIR) + set(Xcb_${COMPONENT_NAME}_FOUND TRUE) + set(Xcb_${COMPONENT_NAME}_LIBRARIES ${Xcb_${COMPONENT_NAME}_LIBRARY}) + set(Xcb_${COMPONENT_NAME}_INCLUDE_DIRS ${Xcb_${COMPONENT_NAME}_INCLUDE_DIR}) + set(Xcb_${COMPONENT_NAME}_DEFINITIONS ${PC_Xcb_${COMPONENT_NAME}_CFLAGS_OTHER}) + mark_as_advanced(Xcb_${COMPONENT_NAME}_LIBRARY Xcb_${COMPONENT_NAME}_INCLUDE_DIR) + + if(IS_ABSOLUTE "${Xcb_${COMPONENT_NAME}_LIBRARY}") + add_library(xcb::${COMPONENT_NAME} UNKNOWN IMPORTED) + set_property(TARGET xcb::${COMPONENT_NAME} PROPERTY IMPORTED_LOCATION "${Xcb_${COMPONENT_NAME}_LIBRARY}") + else() + add_library(xcb::${COMPONENT_NAME} INTERFACE IMPORTED) + set_property(TARGET xcb::${COMPONENT_NAME} PROPERTY IMPORTED_LIBNAME "${Xcb_${COMPONENT_NAME}_LIBRARY}") + endif() + + set_target_properties( + xcb::${COMPONENT_NAME} + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Xcb_${COMPONENT_NAME}_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Xcb_${COMPONENT_NAME}_INCLUDE_DIR}" + VERSION ${Xcb_${COMPONENT_NAME}_VERSION}) + list(APPEND Xcb_COMPONENTS xcb::${COMPONENT_NAME}) + list(APPEND Xcb_LIBRARIES ${Xcb_${COMPONENT_NAME}_LIBRARY}) + list(APPEND Xcb_INCLUDE_DIRS ${Xcb_${COMPONENT_NAME}_INCLUDE_DIR}) + if(NOT Xcb_VERSION) + set(Xcb_VERSION ${Xcb_${COMPONENT_NAME}_VERSION}) + endif() + endif() + else() + list(APPEND Xcb_COMPONENTS xcb::${COMPONENT_NAME}) + set(Xcb_${COMPONENT_NAME}_FOUND TRUE) + get_target_property(component_location xcb::${COMPONENT_NAME} IMPORTED_LOCATION) + if(NOT component_location) + get_target_property(component_location xcb::${COMPONENT_NAME} IMPORTED_LIBNAME) + endif() + get_target_property(component_include_dir xcb::${COMPONENT_NAME} INTERFACE_INCLUDE_DIRECTORIES) + list(APPEND Xcb_LIBRARIES ${component_location}) + list(APPEND Xcb_INCLUDE_DIRS ${component_include_dir}) + unset(component_location) + unset(component_include_dir) + endif() +endmacro() + +foreach(component IN LISTS Xcb_FIND_COMPONENTS) + list(FIND _Xcb_DEFAULT_COMPONENTS "${component}" valid_component) + + if(valid_component GREATER_EQUAL 0) + xcb_find_component(${valid_component}) + else() + message(FATAL_ERROR "Unknown XCB component required: ${component}.") + endif() +endforeach() + +list(REMOVE_DUPLICATES Xcb_INCLUDE_DIRS) + +find_package_handle_standard_args( + Xcb + REQUIRED_VARS Xcb_LIBRARIES Xcb_INCLUDE_DIRS + VERSION_VAR Xcb_VERSION + HANDLE_COMPONENTS REASON_FAILURE_MESSAGE "Ensure xcb is installed on the system.") + +unset(_Xcb_DEFAULT_COMPONENTS) +unset(_Xcb_HEADERS) + +include(FeatureSummary) +set_package_properties( + Xcb PROPERTIES + URL "https://xcb.freedesktop.org" + DESCRIPTION + "A replacement for Xlib featuring a small footprint, latency hiding, direct access to the protocol, improved threading support, and extensibility." +) diff --git a/cmake/finders/FindXkbcommon.cmake b/cmake/finders/FindXkbcommon.cmake new file mode 100644 index 00000000000000..1071c4ec8a89fe --- /dev/null +++ b/cmake/finders/FindXkbcommon.cmake @@ -0,0 +1,105 @@ +#[=======================================================================[.rst +FindXkbcommon +------------- + +FindModule for xkbcommon and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``xkbcommon::xkbcommon``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Xkbcommon_FOUND`` + True, if all required components and the core library were found. +``Xkbcommon_VERSION`` + Detected version of found xkbcommon libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Xkbcommon_LIBRARY`` + Path to the library component of xkbcommon. +``Xkbcommon_INCLUDE_DIR`` + Directory containing ``xkbcommon.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Xkbcommon QUIET xkbcommon) +endif() + +find_path( + Xkbcommon_INCLUDE_DIR + NAMES xkbcommon/xkbcommon.h + HINTS ${PC_Xkbcommon_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + PATH_SUFFIXES xkbcommon + DOC "xkbcommon include directory") + +find_library( + Xkbcommon_LIBRARY + NAMES xkbcommon libxkbcommon + HINTS ${PC_Xkbcommon_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "xkbcommon location") + +if(PC_Xkbcommon_VERSION VERSION_GREATER 0) + set(Xkbcommon_VERSION ${PC_Xkbcommon_VERSION}) +else() + if(NOT Xkbcommon_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find xkbcommon version.") + endif() + set(Xkbcommon_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Xkbcommon + REQUIRED_VARS Xkbcommon_LIBRARY Xkbcommon_INCLUDE_DIR + VERSION_VAR Xkbcommon_VERSION REASON_FAILURE_MESSAGE "Ensure that xkbcommon is installed on the system.") +mark_as_advanced(Xkbcommon_INCLUDE_DIR Xkbcommon_LIBRARY) + +if(Xkbcommon_FOUND) + if(NOT TARGET xkbcommon::xkbcommon) + if(IS_ABSOLUTE "${Xkbcommon_LIBRARY}") + add_library(xkbcommon::xkbcommon UNKNOWN IMPORTED) + set_property(TARGET xkbcommon::xkbcommon PROPERTY IMPORTED_LOCATION "${Xkbcommon_LIBRARY}") + else() + add_library(xkbcommon::xkbcommon INTERFACE IMPORTED) + set_property(TARGET xkbcommon::xkbcommon PROPERTY IMPORTED_LIBNAME "${Xkbcommon_LIBRARY}") + endif() + + set_target_properties( + xkbcommon::xkbcommon + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Xkbcommon_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Xkbcommon_INCLUDE_DIR}" + VERSION ${Xkbcommon_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Xkbcommon PROPERTIES + URL "https://www.xkbcommon.org" + DESCRIPTION + "A library for handling of keyboard descriptions, including loading them from disk, parsing them and handling their state." +) diff --git a/cmake/linux/compilerconfig.cmake b/cmake/linux/compilerconfig.cmake new file mode 100644 index 00000000000000..bc218df379499e --- /dev/null +++ b/cmake/linux/compilerconfig.cmake @@ -0,0 +1,90 @@ +# OBS CMake Linux compiler configuration module + +include_guard(GLOBAL) + +include(ccache) +include(compiler_common) + +option(ENABLE_COMPILER_TRACE "Enable Clang time-trace (requires Clang and Ninja)" OFF) +mark_as_advanced(ENABLE_COMPILER_TRACE) + +# gcc options for C +set(_obs_gcc_c_options + # cmake-format: sortable + $<$:-Wno-error=deprecated-declarations> + -fno-strict-aliasing + -fopenmp-simd + -Wdeprecated-declarations + -Wempty-body + -Wenum-conversion + -Werror=return-type + -Wextra + -Wformat + -Wformat-security + -Wno-conversion + -Wno-float-conversion + -Wno-implicit-fallthrough + -Wno-missing-braces + -Wno-missing-field-initializers + -Wno-shadow + -Wno-sign-conversion + -Wno-trigraphs + -Wno-unknown-pragmas + -Wno-unused-function + -Wno-unused-label + -Wparentheses + -Wuninitialized + -Wunreachable-code + -Wunused-parameter + -Wunused-value + -Wunused-variable + -Wvla) + +add_compile_options( + -fopenmp-simd + "$<$:${_obs_gcc_c_options}>" + "$<$:-Wint-conversion;-Wno-missing-prototypes;-Wno-strict-prototypes;-Wpointer-sign>" + "$<$:${_obs_gcc_c_options}>" + "$<$:-Winvalid-offsetof;-Wno-overloaded-virtual>" + "$<$:${_obs_clang_c_options}>" + "$<$:${_obs_clang_cxx_options}>") + +# Add support for color diagnostics and CMake switch for warnings as errors to CMake < 3.24 +if(CMAKE_VERSION VERSION_LESS 3.24.0) + add_compile_options($<$:-fcolor-diagnostics> + $<$:-fcolor-diagnostics>) + if(CMAKE_COMPILE_WARNING_AS_ERROR) + add_compile_options(-Werror) + endif() +else() + set(CMAKE_COLOR_DIAGNOSTICS ON) +endif() + +if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) + # * Disable false-positive warning in GCC 12.1.0 and later + # * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105562 + if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.1.0) + add_compile_options(-Wno-error=maybe-uninitialized) + endif() + + # * Add warning for infinite recursion (added in GCC 12) + # * Also disable warnings for stringop-overflow due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106297 + if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0.0) + add_compile_options(-Winfinite-recursion -Wno-stringop-overflow) + endif() + + if(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) + add_compile_options(-Wno-error=type-limits) + endif() +endif() + +# Enable compiler and build tracing (requires Ninja generator) +if(ENABLE_COMPILER_TRACE AND CMAKE_GENERATOR STREQUAL "Ninja") + add_compile_options($<$:-ftime-trace> $<$:-ftime-trace>) +else() + set(ENABLE_COMPILER_TRACE + OFF + CACHE STRING "Enable Clang time-trace (required Clang and Ninja)" FORCE) +endif() + +add_compile_definitions($<$:DEBUG> $<$:_DEBUG> SIMDE_ENABLE_OPENMP) diff --git a/cmake/linux/cpackconfig.cmake b/cmake/linux/cpackconfig.cmake new file mode 100644 index 00000000000000..6a45f8346c2702 --- /dev/null +++ b/cmake/linux/cpackconfig.cmake @@ -0,0 +1,69 @@ +# OBS CMake Linux CPack configuration module + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include_guard(GLOBAL) + +include(cpackconfig_common) + +# Add GPLv2 license file to CPack +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/UI/data/license/gplv2.txt") +set(CPACK_PACKAGE_EXECUTABLES "obs") + +if(ENABLE_RELEASE_BUILD) + set(CPACK_PACKAGE_VERSION "${OBS_VERSION_CANONICAL}") +else() + set(CPACK_PACKAGE_VERSION "${OBS_VERSION}") +endif() + +set(CPACK_SOURCE_PACKAGE_FILE_NAME "obs-studio-${CPACK_PACKAGE_VERSION}-sources") +set(CPACK_SOURCE_GENERATOR "TGZ") +set(CPACK_SOURCE_IGNORE_FILES "/.git" "/.*build.*" "/.ccache" "/.deps") +set(CPACK_ARCHIVE_THREADS 0) + +if(OS_LINUX) + set(CPACK_GENERATOR "DEB") + set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS TRUE) + set(CPACK_SET_DESTDIR TRUE) + set(CPACK_DEBIAN_DEBUGINFO_PACKAGE TRUE) + set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${OBS_COMPANY_NAME}") +elseif(OS_FREEBSD) + set(CPACK_GENERATOR "FREEBSD") + + set(CPACK_FREEBSD_PACKAGE_MAINTAINER "${OBS_COMPANY_NAME}") + set(CPACK_FREEBSD_PACKAGE_LICENSE "GPLv2") + + set(CPACK_FREEBSD_PACKAGE_DEPS + # cmake-format: sortable + "audio/alsa-lib" + "audio/fdk-aac" + "audio/jack" + "audio/pulseaudio" + "audio/sndio" + "devel/jansson" + "devel/libpci" + "devel/libsysinfo" + "devel/nlohmann-json" + "devel/qt6-base" + "devel/qt6-svg" + "devel/swig" + "devel/websocketpp" + "ftp/curl" + "graphics/mesa-libs" + "graphics/qr-code-generator" + "lang/luajit" + "lang/python39" + "misc/e2fsprogs-libuuid" + "multimedia/ffmpeg" + "multimedia/librist" + "multimedia/pipewire" + "multimedia/v4l_compat" + "multimedia/vlc" + "net/asio" + "www/libdatachannel" + "www/srt") +endif() + +include(CPack) diff --git a/cmake/linux/defaults.cmake b/cmake/linux/defaults.cmake new file mode 100644 index 00000000000000..a495f019816f19 --- /dev/null +++ b/cmake/linux/defaults.cmake @@ -0,0 +1,41 @@ +# OBS CMake Linux defaults module + +include_guard(GLOBAL) + +option(ENABLE_PULSEAUDIO "Enable PulseAudio support" ON) +option(ENABLE_WAYLAND "Enable building with support for Wayland" ON) + +option(ENABLE_RELOCATABLE "Enable relocatable build" OFF) + +# Set default installation directories +include(GNUInstallDirs) + +if(CMAKE_INSTALL_LIBDIR MATCHES "(CMAKE_SYSTEM_PROCESSOR)") + string(REPLACE "CMAKE_SYSTEM_PROCESSOR" "${CMAKE_SYSTEM_PROCESSOR}" CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}") +endif() + +if(ENABLE_RELOCATABLE) + set(OBS_EXECUTABLE_RPATH "$ORIGIN/;$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") + set(OBS_LIBRARY_RPATH "$ORIGIN/") + set(OBS_MODULE_RPATH "$ORIGIN/;$ORIGIN/..") +endif() + +set(OBS_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/rundir") +set(OBS_EXECUTABLE_DESTINATION "${CMAKE_INSTALL_BINDIR}") +set(OBS_INCLUDE_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/obs") +set(OBS_LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}") +set(OBS_PLUGIN_DESTINATION "${CMAKE_INSTALL_LIBDIR}/obs-plugins") +set(OBS_SCRIPT_PLUGIN_DESTINATION "${CMAKE_INSTALL_LIBDIR}/obs-scripting") +set(OBS_DATA_DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/obs") +set(OBS_CMAKE_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake") + +# Set additional paths used by OBS for self-discovery +set(OBS_PLUGIN_PATH "${CMAKE_INSTALL_LIBDIR}/obs-plugins") +set(OBS_SCRIPT_PLUGIN_PATH "${CMAKE_INSTALL_LIBDIR}/obs-scripting") +set(OBS_DATA_PATH "${OBS_DATA_DESTINATION}") +set(OBS_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") + +# Enable find_package targets to become globally available targets +set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE) + +include(cpackconfig) diff --git a/cmake/linux/helpers.cmake b/cmake/linux/helpers.cmake new file mode 100644 index 00000000000000..01c3402c7b5c2f --- /dev/null +++ b/cmake/linux/helpers.cmake @@ -0,0 +1,291 @@ +# OBS CMake Linux helper functions module + +# cmake-format: off +# cmake-lint: disable=C0301 +# cmake-format: on + +include_guard(GLOBAL) + +include(helpers_common) + +# set_target_properties_obs: Set target properties for use in obs-studio +function(set_target_properties_obs target) + set(options "") + set(oneValueArgs "") + set(multiValueArgs PROPERTIES) + cmake_parse_arguments(PARSE_ARGV 0 _STPO "${options}" "${oneValueArgs}" "${multiValueArgs}") + + message(DEBUG "Setting additional properties for target ${target}...") + + while(_STPO_PROPERTIES) + list(POP_FRONT _STPO_PROPERTIES key value) + set_property(TARGET ${target} PROPERTY ${key} "${value}") + endwhile() + + get_target_property(target_type ${target} TYPE) + + if(target_type STREQUAL EXECUTABLE) + install(TARGETS ${target} RUNTIME DESTINATION "${OBS_EXECUTABLE_DESTINATION}" COMPONENT Runtime) + + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$/${OBS_EXECUTABLE_DESTINATION}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" + "${OBS_OUTPUT_DIR}/$/${OBS_EXECUTABLE_DESTINATION}" + COMMENT "Copy ${target} to binary directory" + VERBATIM) + + if(target STREQUAL obs-studio) + get_property(obs_executables GLOBAL PROPERTY _OBS_EXECUTABLES) + get_property(obs_modules GLOBAL PROPERTY OBS_MODULES_ENABLED) + add_dependencies(${target} ${obs_executables} ${obs_modules}) + + target_add_resource(${target} "${CMAKE_CURRENT_SOURCE_DIR}/../AUTHORS" + "${OBS_DATA_DESTINATION}/obs-studio/authors") + elseif(target STREQUAL browser-helper) + set_property(GLOBAL APPEND PROPERTY _OBS_EXECUTABLES ${target}) + return() + else() + set_property(GLOBAL APPEND PROPERTY _OBS_EXECUTABLES ${target}) + endif() + + set_target_properties(${target} PROPERTIES BUILD_RPATH "${OBS_OUTPUT_DIR}/$/${OBS_LIBRARY_DESTINATION}" + INSTALL_RPATH "${OBS_EXECUTABLE_RPATH}") + elseif(target_type STREQUAL SHARED_LIBRARY) + set_target_properties( + ${target} + PROPERTIES VERSION ${OBS_VERSION_MAJOR} + SOVERSION ${OBS_VERSION_CANONICAL} + BUILD_RPATH "${OBS_OUTPUT_DIR}/$/${OBS_LIBRARY_DESTINATION}" + INSTALL_RPATH "${OBS_LIBRARY_RPATH}") + + install( + TARGETS ${target} + LIBRARY DESTINATION "${OBS_LIBRARY_DESTINATION}" COMPONENT Runtime + PUBLIC_HEADER + DESTINATION "${OBS_INCLUDE_DESTINATION}" + COMPONENT Development + EXCLUDE_FROM_ALL) + + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$/${OBS_LIBRARY_DESTINATION}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" + "${OBS_OUTPUT_DIR}/$/${OBS_LIBRARY_DESTINATION}/" + COMMENT "Copy ${target} to library directory (${OBS_LIBRARY_DESTINATION})" + VERBATIM) + + if(target STREQUAL libobs OR target STREQUAL obs-frontend-api) + install( + FILES "$/$$.so.0" + DESTINATION "${OBS_LIBRARY_DESTINATION}") + + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND + "${CMAKE_COMMAND}" -E create_symlink + "$$.so.${OBS_VERSION_MAJOR}" + "$$.so.0" + COMMAND + "${CMAKE_COMMAND}" -E copy_if_different + "$/$$.so.0" + "${OBS_OUTPUT_DIR}/$/${OBS_LIBRARY_DESTINATION}" + COMMENT "Create symlink for legacy ${target}") + endif() + + elseif(target_type STREQUAL MODULE_LIBRARY) + if(target STREQUAL obs-browser) + set_target_properties(${target} PROPERTIES VERSION 0 SOVERSION ${OBS_VERSION_CANONICAL}) + else() + set_target_properties( + ${target} + PROPERTIES VERSION 0 + SOVERSION ${OBS_VERSION_CANONICAL} + BUILD_RPATH "${OBS_OUTPUT_DIR}/$/${OBS_LIBRARY_DESTINATION}" + INSTALL_RPATH "${OBS_MODULE_RPATH}") + endif() + + if(${target} STREQUAL obspython OR ${target} STREQUAL obslua) + set(plugin_destination "${OBS_SCRIPT_PLUGIN_DESTINATION}") + set_property(TARGET ${target} PROPERTY INSTALL_RPATH "$ORIGIN/;$ORIGIN/..") + else() + set(plugin_destination "${OBS_PLUGIN_DESTINATION}") + endif() + + install( + TARGETS ${target} + LIBRARY DESTINATION "${plugin_destination}" + COMPONENT Runtime + NAMELINK_COMPONENT Development) + + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$/${plugin_destination}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" + "${OBS_OUTPUT_DIR}/$/${plugin_destination}" + COMMENT "Copy ${target} to plugin directory (${plugin_destination})" + VERBATIM) + + if(${target} STREQUAL obspython) + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$/${OBS_SCRIPT_PLUGIN_DESTINATION}/" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$/obspython.py" + "${OBS_OUTPUT_DIR}/$/${OBS_SCRIPT_PLUGIN_DESTINATION}/" + COMMENT "Add obspython import module") + + install( + FILES "$/obspython.py" + DESTINATION "${OBS_SCRIPT_PLUGIN_DESTINATION}" + COMPONENT Runtime) + elseif(${target} STREQUAL obs-browser) + message(DEBUG "Add Chromium Embedded Framework to project for obs-browser plugin...") + if(TARGET CEF::Library) + get_target_property(imported_location CEF::Library IMPORTED_LOCATION_RELEASE) + + if(imported_location) + cmake_path(GET imported_location PARENT_PATH cef_location) + cmake_path(GET cef_location PARENT_PATH cef_root_location) + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$/${OBS_PLUGIN_DESTINATION}/" + COMMAND + "${CMAKE_COMMAND}" -E copy_if_different "${imported_location}" "${cef_location}/chrome-sandbox" + "${cef_location}/libEGL.so" "${cef_location}/libGLESv2.so" "${cef_location}/libvk_swiftshader.so" + "${cef_location}/libvulkan.so.1" "${cef_location}/snapshot_blob.bin" + "${cef_location}/v8_context_snapshot.bin" "${cef_location}/vk_swiftshader_icd.json" + "${OBS_OUTPUT_DIR}/$/${OBS_PLUGIN_DESTINATION}/" + COMMAND + "${CMAKE_COMMAND}" -E copy_if_different "${cef_root_location}/Resources/chrome_100_percent.pak" + "${cef_root_location}/Resources/chrome_200_percent.pak" "${cef_root_location}/Resources/icudtl.dat" + "${cef_root_location}/Resources/resources.pak" "${OBS_OUTPUT_DIR}/$/${OBS_PLUGIN_DESTINATION}/" + COMMAND "${CMAKE_COMMAND}" -E copy_directory "${cef_root_location}/Resources/locales" + "${OBS_OUTPUT_DIR}/$/${OBS_PLUGIN_DESTINATION}/locales" + COMMENT "Add Chromium Embedded Framwork to library directory") + + install( + FILES "${imported_location}" + "${cef_location}/chrome-sandbox" + "${cef_location}/libEGL.so" + "${cef_location}/libGLESv2.so" + "${cef_location}/libvk_swiftshader.so" + "${cef_location}/libvulkan.so.1" + "${cef_location}/snapshot_blob.bin" + "${cef_location}/v8_context_snapshot.bin" + "${cef_location}/vk_swiftshader_icd.json" + "${cef_root_location}/Resources/chrome_100_percent.pak" + "${cef_root_location}/Resources/chrome_200_percent.pak" + "${cef_root_location}/Resources/icudtl.dat" + "${cef_root_location}/Resources/resources.pak" + DESTINATION "${OBS_PLUGIN_DESTINATION}" + COMPONENT Runtime) + + install( + DIRECTORY "${cef_root_location}/Resources/locales" + DESTINATION "${OBS_PLUGIN_DESTINATION}" + USE_SOURCE_PERMISSIONS + COMPONENT Runtime) + endif() + endif() + endif() + + set_property(GLOBAL APPEND PROPERTY OBS_MODULES_ENABLED ${target}) + endif() + + target_install_resources(${target}) +endfunction() + +# Helper function to add resources into bundle +function(target_install_resources target) + message(DEBUG "Installing resources for target ${target}...") + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/data") + file(GLOB_RECURSE data_files "${CMAKE_CURRENT_SOURCE_DIR}/data/*") + foreach(data_file IN LISTS data_files) + cmake_path(RELATIVE_PATH data_file BASE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/" OUTPUT_VARIABLE + relative_path) + cmake_path(GET relative_path PARENT_PATH relative_path) + target_sources(${target} PRIVATE "${data_file}") + source_group("Resources/${relative_path}" FILES "${data_file}") + endforeach() + + get_property(obs_module_list GLOBAL PROPERTY OBS_MODULES_ENABLED) + if(target IN_LIST obs_module_list) + set(target_destination "${OBS_DATA_DESTINATION}/obs-plugins/${target}") + elseif(target STREQUAL obs) + set(target_destination "${OBS_DATA_DESTINATION}/obs-studio") + else() + set(target_destination "${OBS_DATA_DESTINATION}/${target}") + endif() + + install( + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/" + DESTINATION "${target_destination}" + USE_SOURCE_PERMISSIONS + COMPONENT Runtime) + + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$/${target_destination}" + COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/data" + "${OBS_OUTPUT_DIR}/$/${target_destination}" + COMMENT "Copy ${target} resources to data directory (${target_destination})" + VERBATIM) + endif() +endfunction() + +# Helper function to add a specific resource to a bundle +function(target_add_resource target resource) + get_property(obs_module_list GLOBAL PROPERTY OBS_MODULES_ENABLED) + if(${ARGN}) + set(target_destination "${ARGN}") + elseif(${target} IN_LIST obs_module_list) + set(target_destination "${OBS_DATA_DESTINATION}/obs-plugins/${target}") + elseif(target STREQUAL obs) + set(target_destination "${OBS_DATA_DESTINATION}/obs-studio") + else() + set(target_destination "${OBS_DATA_DESTINATION}/${target}") + endif() + + message(DEBUG "Add resource ${resource} to target ${target} at destination ${target_destination}...") + + install( + FILES "${resource}" + DESTINATION "${target_destination}" + COMPONENT Runtime) + + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$/${target_destination}/" + COMMAND "${CMAKE_COMMAND}" -E copy "${resource}" "${OBS_OUTPUT_DIR}/$/${target_destination}/" + COMMENT "Copy ${target} resource ${resource} to library directory (${target_destination})" + VERBATIM) +endfunction() + +# target_export: Helper function to export target as CMake package +function(target_export target) + set(exclude_variant "") + _target_export(${target}) + + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux/${target}.pc.in") + message(DEBUG "Generating pkgconfig file ${target}.pc.in...") + + install(CODE "set(OBS_VERSION_CANONICAL ${OBS_VERSION_CANONICAL})" COMPONENT Development) + install(CODE "set(CMAKE_C_STANDARD ${CMAKE_C_STANDARD})" COMPONENT Development) + install( + CODE "configure_file(\"${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux/${target}.pc.in\" \"${CMAKE_CURRENT_BINARY_DIR}/${target}.pc\" @ONLY)" + COMPONENT Development) + + install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/${target}.pc" + DESTINATION "${OBS_LIBRARY_DESTINATION}/pkgconfig" + COMPONENT Development) + endif() +endfunction() diff --git a/cmake/linux/toolchain-aarch64-clang.cmake b/cmake/linux/toolchain-aarch64-clang.cmake new file mode 100644 index 00000000000000..3e25fcf778df54 --- /dev/null +++ b/cmake/linux/toolchain-aarch64-clang.cmake @@ -0,0 +1,11 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm64) + +set(CMAKE_C_COMPILER clang) +set(CMAKE_C_COMPILER_TARGET aarch64-linux-gnu) + +set(CMAKE_CXX_COMPILER clang++) +set(CMAKE_CXX_COMPILER_TARGET aarch64-linux-gnu) + +set(CMAKE_ASM_COMPILER clang) +set(CMAKE_ASM_COMPILER_TARGET aarch64-linux-gnu) diff --git a/cmake/linux/toolchain-aarch64-gcc.cmake b/cmake/linux/toolchain-aarch64-gcc.cmake new file mode 100644 index 00000000000000..2a2df085a12374 --- /dev/null +++ b/cmake/linux/toolchain-aarch64-gcc.cmake @@ -0,0 +1,18 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm64) + +if(CROSS STREQUAL "") + set(CROSS aarch64-linux-gnu-) +endif() + +if(NOT CMAKE_C_COMPILER) + set(CMAKE_C_COMPILER ${CROSS}gcc) +endif() + +if(NOT CMAKE_CXX_COMPILER) + set(CMAKE_CXX_COMPILER ${CROSS}g++) +endif() + +if(NOT CMAKE_ASM_COMPILER) + set(CMAKE_ASM_COMPILER ${CROSS}as) +endif() diff --git a/cmake/linux/toolchain-x86_64-gcc.cmake b/cmake/linux/toolchain-x86_64-gcc.cmake new file mode 100644 index 00000000000000..39e6c84714c8ec --- /dev/null +++ b/cmake/linux/toolchain-x86_64-gcc.cmake @@ -0,0 +1,18 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR x86_64) + +if(CROSS STREQUAL "") + set(CROSS x86_64-linux-gnu-) +endif() + +if(NOT CMAKE_C_COMPILER) + set(CMAKE_C_COMPILER ${CROSS}gcc) +endif() + +if(NOT CMAKE_CXX_COMPILER) + set(CMAKE_CXX_COMPILER ${CROSS}g++) +endif() + +if(NOT CMAKE_ASM_COMPILER) + set(CMAKE_ASM_COMPILER ${CROSS}as) +endif() diff --git a/deps/json11/CMakeLists.txt b/deps/json11/CMakeLists.txt index 050e339d021f82..4835313b0be712 100644 --- a/deps/json11/CMakeLists.txt +++ b/deps/json11/CMakeLists.txt @@ -10,7 +10,8 @@ target_sources( target_include_directories(json11 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") -if(CMAKE_CXX_COMPILER_ID MATCHES "(AppleClang|Clang)" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14) +if((CMAKE_CXX_COMPILER_ID STREQUAL AppleClang AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14) + OR (CMAKE_CXX_COMPILER_ID STREQUAL Clang AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15)) target_compile_options(json11 PUBLIC -Wno-unqualified-std-cast-call) endif() diff --git a/deps/obs-scripting/CMakeLists.txt b/deps/obs-scripting/CMakeLists.txt index c47445028fcd1c..07826e3ea60727 100644 --- a/deps/obs-scripting/CMakeLists.txt +++ b/deps/obs-scripting/CMakeLists.txt @@ -50,5 +50,9 @@ if(OS_WINDOWS) endif() # cmake-format: off -set_target_properties_obs(obs-scripting PROPERTIES FOLDER scripting PREFIX "") +set_target_properties_obs(obs-scripting PROPERTIES FOLDER scripting) + +if (OS_WINDOWS OR OS_MACOS) + set_property(TARGET obs-scripting PROPERTY PREFIX "") +endif() # cmake-format: on diff --git a/deps/obs-scripting/obs-scripting-python.c b/deps/obs-scripting/obs-scripting-python.c index 335eb3c86c304e..f7a37f2d89e51e 100644 --- a/deps/obs-scripting/obs-scripting-python.c +++ b/deps/obs-scripting/obs-scripting-python.c @@ -1750,6 +1750,13 @@ bool obs_scripting_load_python(const char *python_path) } dstr_free(&resource_path); #else + char *relative_script_path = + os_get_executable_path_ptr("../" SCRIPT_DIR); + if (relative_script_path) { + add_to_python_path(relative_script_path); + } + bfree(relative_script_path); + char *absolute_script_path = os_get_abs_path_ptr(SCRIPT_DIR); add_to_python_path(absolute_script_path); bfree(absolute_script_path); diff --git a/deps/obs-scripting/obspython/CMakeLists.txt b/deps/obs-scripting/obspython/CMakeLists.txt index 935c550bd5103a..9d17384cc386c9 100644 --- a/deps/obs-scripting/obspython/CMakeLists.txt +++ b/deps/obs-scripting/obspython/CMakeLists.txt @@ -43,7 +43,7 @@ target_compile_options( obspython PRIVATE $<$:/wd4100> $<$:/wd4197> - $<$:-Wno-unused-parameter> + $<$:-Wno-unused-parameter> $<$:-Wno-macro-redefined> $<$:-Wno-unreachable-code>) diff --git a/libobs-opengl/CMakeLists.txt b/libobs-opengl/CMakeLists.txt index 0bb838747d880a..bb85d959dcb957 100644 --- a/libobs-opengl/CMakeLists.txt +++ b/libobs-opengl/CMakeLists.txt @@ -14,9 +14,9 @@ if(OS_LINUX OR OS_OPENBSD) find_package(X11 REQUIRED) # cmake-format: off - find_package(xcb REQUIRED xcb) + find_package(Xcb REQUIRED xcb) # cmake-format: on - find_package(x11-xcb REQUIRED) + find_package(X11-xcb REQUIRED) if(ENABLE_WAYLAND) find_package(OpenGL REQUIRED EGL) diff --git a/libobs/CMakeLists.txt b/libobs/CMakeLists.txt index ddf7de1139695d..0cad40a2fc1b0e 100644 --- a/libobs/CMakeLists.txt +++ b/libobs/CMakeLists.txt @@ -329,7 +329,6 @@ set(public_headers obs-source.h obs.h obs.hpp - util/apple/cfstring-utils.h util/array-serializer.h util/base.h util/bitstream.h @@ -369,12 +368,17 @@ set(public_headers util/task.h util/text-lookup.h util/threading-posix.h - util/threading-windows.h util/threading.h util/uthash.h util/util.hpp util/util_uint128.h - util/util_uint64.h + util/util_uint64.h) + +if(OS_WINDOWS) + list( + APPEND + public_headers + util/threading-windows.h util/windows/ComPtr.hpp util/windows/CoTaskMemPtr.hpp util/windows/device-enum.h @@ -383,6 +387,9 @@ set(public_headers util/windows/win-version.h util/windows/window-helpers.h util/windows/WinHandle.hpp) +elseif(OS_MACOS) + list(APPEND public_headers util/apple/cfstring-utils.h) +endif() if(ENABLE_HEVC) list(APPEND public_headers obs-hevc.h) diff --git a/libobs/cmake/linux/libobs.pc.in b/libobs/cmake/linux/libobs.pc.in new file mode 100644 index 00000000000000..580c071eaf18b8 --- /dev/null +++ b/libobs/cmake/linux/libobs.pc.in @@ -0,0 +1,13 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: libobs +Description: OBS Studio core compositor library +Version: @OBS_VERSION_CANONICAL@ + +Requires: +Libs: -L${libdir} -lobs +Libs.private: -pthread -lm +Cflags: -I${includedir} -std=gnu@CMAKE_C_STANDARD@ -fPIC -fvisibility=hidden -fopenmp-simd -Werror diff --git a/libobs/cmake/os-freebsd.cmake b/libobs/cmake/os-freebsd.cmake index 42d4e40bc2aecd..ad30f387d5f42d 100644 --- a/libobs/cmake/os-freebsd.cmake +++ b/libobs/cmake/os-freebsd.cmake @@ -1,11 +1,25 @@ +find_package(LibUUID REQUIRED) find_package(X11 REQUIRED) -find_package(x11-xcb REQUIRED) +find_package(X11-xcb REQUIRED) # cmake-format: off -find_package(xcb REQUIRED xcb OPTIONAL_COMPONENTS xcb-xinput) +find_package(Xcb REQUIRED xcb OPTIONAL_COMPONENTS xcb-xinput) # cmake-format: on -find_package(gio) +find_package(Gio) find_package(Sysinfo REQUIRED) +set(CMAKE_M_LIBS "") +include(CheckCSourceCompiles) +set(LIBM_TEST_SOURCE "#include\nfloat f; int main(){sqrt(f);return 0;}") +check_c_source_compiles("${LIBM_TEST_SOURCE}" HAVE_MATH_IN_STD_LIB) + +set(CMAKE_REQUIRED_INCLUDES "/usr/local/include") +set(UUID_TEST_SOURCE "#include\nint main(){return 0;}") +check_c_source_compiles("${UUID_TEST_SOURCE}" HAVE_UUID_HEADER) + +if(NOT HAVE_UUID_HEADER) + message(FATAL_ERROR "Required system header not found.") +endif() + target_sources( libobs PRIVATE # cmake-format: sortable @@ -18,14 +32,19 @@ target_sources( util/threading-posix.c util/threading-posix.h) -target_compile_definitions(libobs PRIVATE $<$:ENABLE_DARRAY_TYPE_TEST> - $<$:ENABLE_DARRAY_TYPE_TEST>) +target_compile_definitions( + libobs PRIVATE OBS_INSTALL_PREFIX="${OBS_INSTALL_PREFIX}" $<$:ENABLE_DARRAY_TYPE_TEST> + $<$:ENABLE_DARRAY_TYPE_TEST>) -target_link_libraries(libobs PRIVATE X11::x11-xcb xcb::xcb Sysinfo::Sysinfo) - -if(TARGET xcb::xcb-xinput) - target_link_libraries(libobs PRIVATE xcb::xcb-xinput) -endif() +target_link_libraries( + libobs + PRIVATE X11::x11-xcb + xcb::xcb + LibUUID::LibUUID + Sysinfo::Sysinfo + ${CMAKE_DL_LIBS} + $<$>:m> + $<$:xcb::xcb-input>) if(ENABLE_PULSEAUDIO) find_package(PulseAudio REQUIRED) @@ -40,10 +59,10 @@ if(ENABLE_PULSEAUDIO) audio-monitoring/pulse/pulseaudio-wrapper.h) target_link_libraries(libobs PRIVATE PulseAudio::PulseAudio) - target_enable_feature(libobs "PulseAudio audio monitoring (Linux)") + target_enable_feature(libobs "PulseAudio audio monitoring (FreeBSD)") else() target_sources(libobs PRIVATE audio-monitoring/null/null-audio-monitoring.c) - target_disable_feature(libobs "PulseAudio audio monitoring (Linux)") + target_disable_feature(libobs "PulseAudio audio monitoring (FreeBSD)") endif() if(TARGET gio::gio) @@ -52,16 +71,14 @@ if(TARGET gio::gio) endif() if(ENABLE_WAYLAND) - # cmake-format: off - find_package(Wayland COMPONENTS Client REQUIRED) - # cmake-format: on - find_package(xkbcommon REQUIRED) + find_package(Wayland REQUIRED Client) + find_package(Xkbcommon REQUIRED) target_sources(libobs PRIVATE obs-nix-wayland.c) target_link_libraries(libobs PRIVATE Wayland::Client xkbcommon::xkbcommon) - target_enable_feature(libobs "Wayland compositor support (Linux)") + target_enable_feature(libobs "Wayland compositor support (FreeBSD)") else() - target_disable_feature(libobs "Wayland compositor support (Linux)") + target_disable_feature(libobs "Wayland compositor support (FreebSD)") endif() set_target_properties(libobs PROPERTIES OUTPUT_NAME obs) diff --git a/libobs/cmake/os-linux.cmake b/libobs/cmake/os-linux.cmake index ab3d4f54838e1c..bc6b2395a9644e 100644 --- a/libobs/cmake/os-linux.cmake +++ b/libobs/cmake/os-linux.cmake @@ -1,10 +1,10 @@ find_package(LibUUID REQUIRED) find_package(X11 REQUIRED) -find_package(x11-xcb REQUIRED) +find_package(X11-xcb REQUIRED) # cmake-format: off -find_package(xcb REQUIRED xcb OPTIONAL_COMPONENTS xcb-xinput) +find_package(Xcb REQUIRED xcb OPTIONAL_COMPONENTS xcb-xinput) # cmake-format: on -find_package(gio) +find_package(Gio) target_sources( libobs @@ -18,15 +18,34 @@ target_sources( util/threading-posix.c util/threading-posix.h) -target_compile_definitions(libobs PRIVATE USE_XDG $<$:ENABLE_DARRAY_TYPE_TEST> - $<$:ENABLE_DARRAY_TYPE_TEST>) +target_compile_definitions( + libobs + PRIVATE USE_XDG OBS_INSTALL_PREFIX="${OBS_INSTALL_PREFIX}" $<$:ENABLE_DARRAY_TYPE_TEST> + $<$:ENABLE_DARRAY_TYPE_TEST>) + +if(CMAKE_C_COMPILER_ID STREQUAL GNU) + # * Silence type-limits warning in line 292 of libobs/utils/utf8.c + if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.3.0) + target_compile_options(libobs PRIVATE -Wno-error=type-limits) + endif() +endif() -target_link_libraries(libobs PRIVATE X11::x11-xcb xcb::xcb LibUUID::LibUUID ${CMAKE_DL_LIBS}) +set(CMAKE_M_LIBS "") +include(CheckCSourceCompiles) +set(LIBM_TEST_SOURCE "#include\nfloat f; int main(){sqrt(f);return 0;}") +check_c_source_compiles("${LIBM_TEST_SOURCE}" HAVE_MATH_IN_STD_LIB) -if(TARGET xcb::xcb-xinput) - target_link_libraries(libobs PRIVATE xcb::xcb-xinput) +set(UUID_TEST_SOURCE "#include\nint main(){return 0;}") +check_c_source_compiles("${UUID_TEST_SOURCE}" HAVE_UUID_HEADER) + +if(NOT HAVE_UUID_HEADER) + message(FATAL_ERROR "Required system header not found.") endif() +target_link_libraries( + libobs PRIVATE X11::x11-xcb xcb::xcb LibUUID::LibUUID ${CMAKE_DL_LIBS} $<$>:m> + $<$:xcb::xcb-input>) + if(ENABLE_PULSEAUDIO) find_package(PulseAudio REQUIRED) @@ -52,10 +71,8 @@ if(TARGET gio::gio) endif() if(ENABLE_WAYLAND) - # cmake-format: off - find_package(Wayland COMPONENTS Client REQUIRED) - # cmake-format: on - find_package(xkbcommon REQUIRED) + find_package(Wayland REQUIRED Client) + find_package(Xkbcommon REQUIRED) target_sources(libobs PRIVATE obs-nix-wayland.c) target_link_libraries(libobs PRIVATE Wayland::Client xkbcommon::xkbcommon) diff --git a/libobs/obs-config.h b/libobs/obs-config.h index 519f409ac4035a..21f9c15d7807ed 100644 --- a/libobs/obs-config.h +++ b/libobs/obs-config.h @@ -62,4 +62,4 @@ #define OBS_BETA 0 #endif -#define OBS_INSTALL_DATA_PATH OBS_INSTALL_PREFIX OBS_DATA_PATH +#define OBS_INSTALL_DATA_PATH OBS_INSTALL_PREFIX "/" OBS_DATA_PATH diff --git a/libobs/obs-nix.c b/libobs/obs-nix.c index b006a5598006b5..275d25f1f05d8d 100644 --- a/libobs/obs-nix.c +++ b/libobs/obs-nix.c @@ -47,24 +47,19 @@ const char *get_module_extension(void) return ".so"; } -#ifdef __LP64__ -#define BIT_STRING "64bit" -#else -#define BIT_STRING "32bit" -#endif - #define FLATPAK_PLUGIN_PATH "/app/plugins" static const char *module_bin[] = { + "../../obs-plugins/64bit", OBS_INSTALL_PREFIX "/" OBS_PLUGIN_DESTINATION, - "../../obs-plugins/" BIT_STRING, FLATPAK_PLUGIN_PATH "/" OBS_PLUGIN_DESTINATION, }; static const char *module_data[] = { + OBS_DATA_PATH "/%module%", OBS_INSTALL_DATA_PATH "/obs-plugins/%module%", - OBS_DATA_PATH "/obs-plugins/%module%", - FLATPAK_PLUGIN_PATH "/share/obs/obs-plugins/%module%"}; + FLATPAK_PLUGIN_PATH "/share/obs/obs-plugins/%module%", +}; static const int module_patterns_size = sizeof(module_bin) / sizeof(module_bin[0]); @@ -73,8 +68,27 @@ static const struct obs_nix_hotkeys_vtable *hotkeys_vtable = NULL; void add_default_module_paths(void) { - for (int i = 0; i < module_patterns_size; i++) + char *module_bin_path = + os_get_executable_path_ptr("../" OBS_PLUGIN_PATH); + char *module_data_path = os_get_executable_path_ptr( + "../" OBS_DATA_PATH "/obs-plugins/%module%"); + + if (module_bin_path && module_data_path) { + char *abs_module_bin_path = + os_get_abs_path_ptr(module_bin_path); + if (strcmp(abs_module_bin_path, OBS_INSTALL_PREFIX + "/" OBS_PLUGIN_DESTINATION) != 0) { + obs_add_module_path(module_bin_path, module_data_path); + } + bfree(abs_module_bin_path); + } + + bfree(module_bin_path); + bfree(module_data_path); + + for (int i = 0; i < module_patterns_size; i++) { obs_add_module_path(module_bin[i], module_data[i]); + } } /* @@ -89,6 +103,18 @@ char *find_libobs_data_file(const char *file) if (check_path(file, OBS_DATA_PATH "/libobs/", &output)) return output.array; + char *relative_data_path = + os_get_executable_path_ptr("../" OBS_DATA_PATH "/libobs/"); + if (relative_data_path) { + bool found = check_path(file, relative_data_path, &output); + + bfree(relative_data_path); + + if (found) { + return output.array; + } + } + if (OBS_INSTALL_PREFIX[0] != 0) { if (check_path(file, OBS_INSTALL_DATA_PATH "/libobs/", &output)) return output.array; diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 90bea35be27345..8b653b05369263 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.22...3.25) option(ENABLE_PLUGINS "Enable building OBS plugins" ON) if(OBS_CMAKE_VERSION VERSION_GREATER_EQUAL 3.0.0) - if(NOT ENABLE_PLUGINS) set_property(GLOBAL APPEND PROPERTY OBS_FEATURES_DISABLED "Plugin Support") return() @@ -12,85 +11,69 @@ if(OBS_CMAKE_VERSION VERSION_GREATER_EQUAL 3.0.0) set_property(GLOBAL APPEND PROPERTY OBS_FEATURES_ENABLED "Plugin Support") macro(check_obs_browser) - if(NOT (OS_WINDOWS AND NOT CMAKE_GENERATOR_PLATFORM MATCHES "(Win32|x64)")) - if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/obs-browser/cmake/macos/Info.plist.in") - add_subdirectory(obs-browser) - elseif(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/obs-browser/CMakeLists.txt") + if((OS_WINDOWS AND CMAKE_GENERATOR_PLATFORM MATCHES "(Win32|x64)") + OR OS_MACOS + OR OS_LINUX) + if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/obs-browser/CMakeLists.txt") message(FATAL_ERROR "Required submodule 'obs-browser' not available.") + else() + add_subdirectory(obs-browser) endif() + else() + add_custom_target(obs-browser) + target_disable(obs-browser) endif() endmacro() macro(check_obs_websocket) - if(OS_WINDOWS - OR OS_MACOS - OR OS_LINUX) - if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/obs-websocket/cmake/macos/Info.plist.in") - add_subdirectory(obs-websocket) - elseif(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/obs-websocket/CMakeLists.txt") - message(FATAL_ERROR "Required submodule 'obs-websocket' not available.") - endif() + if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/obs-websocket/CMakeLists.txt") + message(FATAL_ERROR "Required submodule 'obs-websocket' not available.") + else() + add_subdirectory(obs-websocket) endif() endmacro() # Add plugins in alphabetical order to retain order in IDE projects - add_subdirectory(aja) - if(OS_WINDOWS OR OS_MACOS) - add_subdirectory(coreaudio-encoder) - endif() - if(OS_WINDOWS - OR OS_MACOS - OR OS_LINUX) - add_subdirectory(decklink) - endif() - add_subdirectory(image-source) - if(OS_LINUX) - add_subdirectory(linux-alsa) - add_subdirectory(linux-capture) - add_subdirectory(linux-jack) - add_subdirectory(linux-pipewire) - add_subdirectory(linux-pulseaudio) - add_subdirectory(linux-v4l2) - endif() - if(OS_MACOS) - add_subdirectory(mac-avcapture) - add_subdirectory(mac-capture) - add_subdirectory(mac-syphon) - add_subdirectory(mac-videotoolbox) - add_subdirectory(mac-virtualcam) - endif() + add_obs_plugin(aja PLATFORMS WINDOWS MACOS LINUX WITH_MESSAGE) + add_obs_plugin(coreaudio-encoder PLATFORMS WINDOWS MACOS) + add_obs_plugin(decklink PLATFORMS WINDOWS MACOS LINUX WITH_MESSAGE) + add_obs_plugin(image-source) + add_obs_plugin(linux-alsa PLATFORMS LINUX FREEBSD OPENBSD) + add_obs_plugin(linux-capture PLATFORMS LINUX FREEBSD OPENBSD) + add_obs_plugin(linux-jack PLATFORMS LINUX FREEBSD OPENBSD) + add_obs_plugin(linux-pipewire PLATFORMS LINUX FREEBSD OPENBSD) + add_obs_plugin(linux-pulseaudio PLATFORMS LINUX FREEBSD OPENBSD) + add_obs_plugin(linux-v4l2 PLATFORMS LINUX FREEBSD OPENBSD) + add_obs_plugin(mac-avcapture PLATFORMS MACOS) + add_obs_plugin(mac-capture PLATFORMS MACOS) + add_obs_plugin(mac-syphon PLATFORMS MACOS) + add_obs_plugin(mac-videotoolbox PLATFORMS MACOS) + add_obs_plugin(mac-virtualcam PLATFORMS MACOS) + check_obs_browser() - add_subdirectory(obs-ffmpeg) - add_subdirectory(obs-filters) - add_subdirectory(obs-outputs) - if(OS_WINDOWS) - add_subdirectory(obs-qsv11) - add_subdirectory(obs-text) - endif() - add_subdirectory(obs-transitions) - if(OS_WINDOWS - OR OS_MACOS - OR OS_LINUX) - add_subdirectory(obs-vst) - endif() - add_subdirectory(obs-webrtc) + + add_obs_plugin(obs-ffmpeg) + add_obs_plugin(obs-filters) + add_obs_plugin(obs-libfdk) + add_obs_plugin(obs-outputs) + add_obs_plugin(obs-qsv11 PLATFORMS WINDOWS LINUX) + add_obs_plugin(obs-text PLATFORMS WINDOWS) + add_obs_plugin(obs-transitions) + add_obs_plugin(obs-vst PLATFORMS WINDOWS MACOS LINUX WITH_MESSAGE) + add_obs_plugin(obs-webrtc) + check_obs_websocket() - add_subdirectory(obs-x264) - add_subdirectory(rtmp-services) - if(OS_LINUX) - add_subdirectory(sndio) - endif() - add_subdirectory(text-freetype2) - if(OS_WINDOWS - OR OS_MACOS - OR OS_LINUX) - add_subdirectory(vlc-video) - endif() - if(OS_WINDOWS) - add_subdirectory(win-capture) - add_subdirectory(win-dshow) - add_subdirectory(win-wasapi) - endif() + + add_obs_plugin(obs-x264) + add_obs_plugin(oss-audio PLATFORMS FREEBSD OPENBSD) + add_obs_plugin(rtmp-services) + add_obs_plugin(sndio PLATFORMS LINUX FREEBSD OPENBSD) + add_obs_plugin(text-freetype2) + add_obs_plugin(vlc-video WITH_MESSAGE) + add_obs_plugin(win-capture PLATFORMS WINDOWS) + add_obs_plugin(win-dshow PLATFORMS WINDOWS) + add_obs_plugin(win-wasapi PLATFORMS WINDOWS) + return() endif() diff --git a/plugins/aja/CMakeLists.txt b/plugins/aja/CMakeLists.txt index 1f427030c2100b..ffdfdf8e06b8f0 100644 --- a/plugins/aja/CMakeLists.txt +++ b/plugins/aja/CMakeLists.txt @@ -54,7 +54,9 @@ target_sources( audio-repack.hpp main.cpp) -target_compile_options(aja-support PUBLIC $<$:-Wno-deprecated-declarations>) +target_compile_options( + aja-support PUBLIC $<$:-Wno-deprecated-declarations> + $<$:-Wno-unused-variable>) target_link_libraries( aja diff --git a/plugins/linux-alsa/CMakeLists.txt b/plugins/linux-alsa/CMakeLists.txt index a3ea221fb6ca91..b50038286e07f5 100644 --- a/plugins/linux-alsa/CMakeLists.txt +++ b/plugins/linux-alsa/CMakeLists.txt @@ -1,8 +1,11 @@ -project(linux-alsa) +cmake_minimum_required(VERSION 3.22...3.25) + +legacy_check() option(ENABLE_ALSA "Build OBS with ALSA support" ON) + if(NOT ENABLE_ALSA) - obs_status(DISABLED "linux-alsa") + target_disable(linux-alsa) return() endif() @@ -11,10 +14,8 @@ find_package(ALSA REQUIRED) add_library(linux-alsa MODULE) add_library(OBS::alsa ALIAS linux-alsa) -target_sources(linux-alsa PRIVATE linux-alsa.c alsa-input.c) - +target_sources(linux-alsa PRIVATE # cmake-format: sortable + alsa-input.c linux-alsa.c) target_link_libraries(linux-alsa PRIVATE OBS::libobs ALSA::ALSA) -set_target_properties(linux-alsa PROPERTIES FOLDER "plugins") - -setup_plugin_target(linux-alsa) +set_target_properties_obs(linux-alsa PROPERTIES FOLDER plugins PREFIX "") diff --git a/plugins/linux-alsa/alsa-input.c b/plugins/linux-alsa/alsa-input.c index 8c969343dd88b0..ee866e5172a088 100644 --- a/plugins/linux-alsa/alsa-input.c +++ b/plugins/linux-alsa/alsa-input.c @@ -317,14 +317,20 @@ obs_properties_t *alsa_get_properties(void *unused) obs_property_list_add_string(devices, descr, name); next: - if (name != NULL) - free(name), name = NULL; + if (name != NULL) { + free(name); + name = NULL; + } - if (descr != NULL) - free(descr), descr = NULL; + if (descr != NULL) { + free(descr); + descr = NULL; + } - if (io != NULL) - free(io), io = NULL; + if (io != NULL) { + free(io); + io = NULL; + } ++hint; } @@ -412,11 +418,14 @@ void _alsa_close(struct alsa_data *data) if (data->handle) { snd_pcm_drop(data->handle); - snd_pcm_close(data->handle), data->handle = NULL; + snd_pcm_close(data->handle); + data->handle = NULL; } - if (data->buffer) - bfree(data->buffer), data->buffer = NULL; + if (data->buffer) { + bfree(data->buffer); + data->buffer = NULL; + } } bool _alsa_configure(struct alsa_data *data) diff --git a/plugins/linux-alsa/cmake/legacy.cmake b/plugins/linux-alsa/cmake/legacy.cmake new file mode 100644 index 00000000000000..a3ea221fb6ca91 --- /dev/null +++ b/plugins/linux-alsa/cmake/legacy.cmake @@ -0,0 +1,20 @@ +project(linux-alsa) + +option(ENABLE_ALSA "Build OBS with ALSA support" ON) +if(NOT ENABLE_ALSA) + obs_status(DISABLED "linux-alsa") + return() +endif() + +find_package(ALSA REQUIRED) + +add_library(linux-alsa MODULE) +add_library(OBS::alsa ALIAS linux-alsa) + +target_sources(linux-alsa PRIVATE linux-alsa.c alsa-input.c) + +target_link_libraries(linux-alsa PRIVATE OBS::libobs ALSA::ALSA) + +set_target_properties(linux-alsa PROPERTIES FOLDER "plugins") + +setup_plugin_target(linux-alsa) diff --git a/plugins/linux-capture/CMakeLists.txt b/plugins/linux-capture/CMakeLists.txt index feb8077e823b1d..2f4c039996fceb 100644 --- a/plugins/linux-capture/CMakeLists.txt +++ b/plugins/linux-capture/CMakeLists.txt @@ -1,37 +1,45 @@ -project(linux-capture) +cmake_minimum_required(VERSION 3.22...3.25) + +legacy_check() find_package(X11 REQUIRED) -find_package(XCB COMPONENTS XCB XFIXES RANDR SHM XINERAMA COMPOSITE) -if(NOT TARGET XCB::COMPOSITE) - obs_status(FATAL_ERROR "xcb composite library not found") -endif() + +# cmake-format: off +find_package(Xcb REQUIRED xcb + xcb-xfixes + xcb-randr + xcb-shm + xcb-xinerama + xcb-composite) +# cmake-format: on add_library(linux-capture MODULE) add_library(OBS::capture ALIAS linux-capture) target_sources( linux-capture - PRIVATE linux-capture.c + PRIVATE # cmake-format: sortable + linux-capture.c + xcomposite-input.c + xcomposite-input.h xcursor-xcb.c xcursor-xcb.h xhelpers.c xhelpers.h - xshm-input.c - xcomposite-input.c - xcomposite-input.h) + xshm-input.c) target_link_libraries( linux-capture PRIVATE OBS::libobs - OBS::obsglad + OBS::glad X11::X11 - XCB::XCB - XCB::XFIXES - XCB::RANDR - XCB::SHM - XCB::XINERAMA - XCB::COMPOSITE) - -set_target_properties(linux-capture PROPERTIES FOLDER "plugins") + xcb::xcb + xcb::xcb-xfixes + xcb::xcb-randr + xcb::xcb-shm + xcb::xcb-xinerama + xcb::xcb-composite) -setup_plugin_target(linux-capture) +# cmake-format: off +set_target_properties_obs(linux-capture PROPERTIES FOLDER "plugins") +# cmake-format: on diff --git a/plugins/linux-capture/cmake/legacy.cmake b/plugins/linux-capture/cmake/legacy.cmake new file mode 100644 index 00000000000000..feb8077e823b1d --- /dev/null +++ b/plugins/linux-capture/cmake/legacy.cmake @@ -0,0 +1,37 @@ +project(linux-capture) + +find_package(X11 REQUIRED) +find_package(XCB COMPONENTS XCB XFIXES RANDR SHM XINERAMA COMPOSITE) +if(NOT TARGET XCB::COMPOSITE) + obs_status(FATAL_ERROR "xcb composite library not found") +endif() + +add_library(linux-capture MODULE) +add_library(OBS::capture ALIAS linux-capture) + +target_sources( + linux-capture + PRIVATE linux-capture.c + xcursor-xcb.c + xcursor-xcb.h + xhelpers.c + xhelpers.h + xshm-input.c + xcomposite-input.c + xcomposite-input.h) + +target_link_libraries( + linux-capture + PRIVATE OBS::libobs + OBS::obsglad + X11::X11 + XCB::XCB + XCB::XFIXES + XCB::RANDR + XCB::SHM + XCB::XINERAMA + XCB::COMPOSITE) + +set_target_properties(linux-capture PROPERTIES FOLDER "plugins") + +setup_plugin_target(linux-capture) diff --git a/plugins/linux-capture/xcomposite-input.c b/plugins/linux-capture/xcomposite-input.c index 22589a38c9b1d5..3e9788b069b891 100644 --- a/plugins/linux-capture/xcomposite-input.c +++ b/plugins/linux-capture/xcomposite-input.c @@ -390,7 +390,6 @@ void xcomp_create_pixmap(xcb_connection_t *conn, struct xcompcap *s, if (depth != 32) { s->exclude_alpha = true; } - xcb_window_t root = geom->root; free(geom); uint32_t vert_borders = s->crop_top + s->crop_bot + 2 * s->border; diff --git a/plugins/linux-jack/CMakeLists.txt b/plugins/linux-jack/CMakeLists.txt index c78418d63ff0c3..59f0eb2670a33a 100644 --- a/plugins/linux-jack/CMakeLists.txt +++ b/plugins/linux-jack/CMakeLists.txt @@ -1,8 +1,10 @@ -project(linux-jack) +cmake_minimum_required(VERSION 3.22...3.25) + +legacy_check() option(ENABLE_JACK "Build OBS with JACK support" OFF) if(NOT ENABLE_JACK) - obs_status(DISABLED "linux-jack") + target_disable(linux-jack) return() endif() @@ -11,10 +13,11 @@ find_package(Jack REQUIRED) add_library(linux-jack MODULE) add_library(OBS::jack ALIAS linux-jack) -target_sources(linux-jack PRIVATE linux-jack.c jack-wrapper.c jack-input.c) +target_sources(linux-jack PRIVATE # cmake-format: sortable + jack-input.c jack-wrapper.c linux-jack.c) -target_link_libraries(linux-jack PRIVATE OBS::libobs Jack::Jack) +target_compile_options(linux-jack PRIVATE $<$:-Wno-error=sign-compare>) -set_target_properties(linux-jack PROPERTIES FOLDER "plugins" PROJECT_LABEL "JACK Audio") +target_link_libraries(linux-jack PRIVATE OBS::libobs Jack::Jack) -setup_plugin_target(linux-jack) +set_target_properties_obs(linux-jack PROPERTIES FOLDER plugins PREFIX "" PROJECT_LABEL "JACK Audio") diff --git a/plugins/linux-jack/cmake/legacy.cmake b/plugins/linux-jack/cmake/legacy.cmake new file mode 100644 index 00000000000000..c78418d63ff0c3 --- /dev/null +++ b/plugins/linux-jack/cmake/legacy.cmake @@ -0,0 +1,20 @@ +project(linux-jack) + +option(ENABLE_JACK "Build OBS with JACK support" OFF) +if(NOT ENABLE_JACK) + obs_status(DISABLED "linux-jack") + return() +endif() + +find_package(Jack REQUIRED) + +add_library(linux-jack MODULE) +add_library(OBS::jack ALIAS linux-jack) + +target_sources(linux-jack PRIVATE linux-jack.c jack-wrapper.c jack-input.c) + +target_link_libraries(linux-jack PRIVATE OBS::libobs Jack::Jack) + +set_target_properties(linux-jack PROPERTIES FOLDER "plugins" PROJECT_LABEL "JACK Audio") + +setup_plugin_target(linux-jack) diff --git a/plugins/linux-pipewire/CMakeLists.txt b/plugins/linux-pipewire/CMakeLists.txt index 9f4b601bb326a8..1186a3df01da3d 100644 --- a/plugins/linux-pipewire/CMakeLists.txt +++ b/plugins/linux-pipewire/CMakeLists.txt @@ -1,29 +1,34 @@ -project(linux-pipewire) +cmake_minimum_required(VERSION 3.22...3.25) + +legacy_check() option(ENABLE_PIPEWIRE "Enable PipeWire support" ON) if(NOT ENABLE_PIPEWIRE) - obs_status(DISABLED "linux-pipewire") + target_disable(linux-pipewire) return() endif() find_package(PipeWire 0.3.33 REQUIRED) -find_package(Gio QUIET) -find_package(Libdrm QUIET) # we require libdrm/drm_fourcc.h to build - -if(NOT TARGET PipeWire::PipeWire) - obs_status(FATAL_ERROR "PipeWire library not found! Please install PipeWire or set ENABLE_PIPEWIRE=OFF.") -elseif(NOT TARGET GIO::GIO) - obs_status(FATAL_ERROR "Gio library not found! Please install GLib2 (or Gio) or set ENABLE_PIPEWIRE=OFF.") -elseif(NOT TARGET Libdrm::Libdrm) - obs_status(FATAL_ERROR "libdrm headers not found! Please install libdrm or set ENABLE_PIPEWIRE=OFF.") -endif() +find_package(Gio REQUIRED) +find_package(Libdrm REQUIRED) +get_target_property(libdrm_include_directories Libdrm::Libdrm INTERFACE_INCLUDE_DIRECTORIES) add_library(linux-pipewire MODULE) add_library(OBS::pipewire ALIAS linux-pipewire) +if(PipeWire_VERSION VERSION_GREATER_EQUAL 0.3.60) + target_enable_feature(linux-pipewire "PipeWire 0.3.60+ camera support") + set(_HAS_PIPEWIRE_CAMERA TRUE) +else() + set(_HAS_PIPEWIRE_CAMERA FALSE) +endif() + target_sources( linux-pipewire - PRIVATE formats.c + PRIVATE # cmake-format: sortable + $<$:camera-portal.c> + $<$:camera-portal.h> + formats.c formats.h linux-pipewire.c pipewire.c @@ -33,14 +38,8 @@ target_sources( screencast-portal.c screencast-portal.h) -target_link_libraries(linux-pipewire PRIVATE OBS::libobs OBS::obsglad PipeWire::PipeWire GIO::GIO Libdrm::Libdrm) - -if(PIPEWIRE_VERSION VERSION_GREATER_EQUAL 0.3.60) - obs_status(STATUS "PipeWire 0.3.60+ found, enabling camera support") - - target_sources(linux-pipewire PRIVATE camera-portal.c camera-portal.h) -endif() +target_include_directories(linux-pipewire PRIVATE ${libdrm_include_directories}) -set_target_properties(linux-pipewire PROPERTIES FOLDER "plugins") +target_link_libraries(linux-pipewire PRIVATE OBS::libobs OBS::glad PipeWire::PipeWire gio::gio) -setup_plugin_target(linux-pipewire) +set_target_properties_obs(linux-pipewire PROPERTIES FOLDER plugins PREFIX "") diff --git a/plugins/linux-pipewire/cmake/legacy.cmake b/plugins/linux-pipewire/cmake/legacy.cmake new file mode 100644 index 00000000000000..9f4b601bb326a8 --- /dev/null +++ b/plugins/linux-pipewire/cmake/legacy.cmake @@ -0,0 +1,46 @@ +project(linux-pipewire) + +option(ENABLE_PIPEWIRE "Enable PipeWire support" ON) +if(NOT ENABLE_PIPEWIRE) + obs_status(DISABLED "linux-pipewire") + return() +endif() + +find_package(PipeWire 0.3.33 REQUIRED) +find_package(Gio QUIET) +find_package(Libdrm QUIET) # we require libdrm/drm_fourcc.h to build + +if(NOT TARGET PipeWire::PipeWire) + obs_status(FATAL_ERROR "PipeWire library not found! Please install PipeWire or set ENABLE_PIPEWIRE=OFF.") +elseif(NOT TARGET GIO::GIO) + obs_status(FATAL_ERROR "Gio library not found! Please install GLib2 (or Gio) or set ENABLE_PIPEWIRE=OFF.") +elseif(NOT TARGET Libdrm::Libdrm) + obs_status(FATAL_ERROR "libdrm headers not found! Please install libdrm or set ENABLE_PIPEWIRE=OFF.") +endif() + +add_library(linux-pipewire MODULE) +add_library(OBS::pipewire ALIAS linux-pipewire) + +target_sources( + linux-pipewire + PRIVATE formats.c + formats.h + linux-pipewire.c + pipewire.c + pipewire.h + portal.c + portal.h + screencast-portal.c + screencast-portal.h) + +target_link_libraries(linux-pipewire PRIVATE OBS::libobs OBS::obsglad PipeWire::PipeWire GIO::GIO Libdrm::Libdrm) + +if(PIPEWIRE_VERSION VERSION_GREATER_EQUAL 0.3.60) + obs_status(STATUS "PipeWire 0.3.60+ found, enabling camera support") + + target_sources(linux-pipewire PRIVATE camera-portal.c camera-portal.h) +endif() + +set_target_properties(linux-pipewire PROPERTIES FOLDER "plugins") + +setup_plugin_target(linux-pipewire) diff --git a/plugins/linux-pulseaudio/CMakeLists.txt b/plugins/linux-pulseaudio/CMakeLists.txt index 59d0d5d97c32aa..7fff7d7b9f020e 100644 --- a/plugins/linux-pulseaudio/CMakeLists.txt +++ b/plugins/linux-pulseaudio/CMakeLists.txt @@ -1,7 +1,9 @@ -project(linux-pulseaudio) +cmake_minimum_required(VERSION 3.22...3.25) + +legacy_check() if(NOT ENABLE_PULSEAUDIO) - obs_status(DISABLED "linux-pulseaudio") + target_disable(linux-pulseaudio) return() endif() @@ -10,12 +12,8 @@ find_package(PulseAudio REQUIRED) add_library(linux-pulseaudio MODULE) add_library(OBS::pulseaudio ALIAS linux-pulseaudio) -target_sources(linux-pulseaudio PRIVATE linux-pulseaudio.c pulse-wrapper.c pulse-input.c) - -target_include_directories(linux-pulseaudio PRIVATE ${PULSEAUDIO_INCLUDE_DIR}) - -target_link_libraries(linux-pulseaudio PRIVATE OBS::libobs ${PULSEAUDIO_LIBRARY}) - -set_target_properties(linux-pulseaudio PROPERTIES FOLDER "plugins") +target_sources(linux-pulseaudio PRIVATE # cmake-format: sortable + linux-pulseaudio.c pulse-input.c pulse-wrapper.c) +target_link_libraries(linux-pulseaudio PRIVATE OBS::libobs PulseAudio::PulseAudio) -setup_plugin_target(linux-pulseaudio) +set_target_properties_obs(linux-pulseaudio PROPERTIES FOLDER plugins PREFIX "") diff --git a/plugins/linux-pulseaudio/cmake/legacy.cmake b/plugins/linux-pulseaudio/cmake/legacy.cmake new file mode 100644 index 00000000000000..59d0d5d97c32aa --- /dev/null +++ b/plugins/linux-pulseaudio/cmake/legacy.cmake @@ -0,0 +1,21 @@ +project(linux-pulseaudio) + +if(NOT ENABLE_PULSEAUDIO) + obs_status(DISABLED "linux-pulseaudio") + return() +endif() + +find_package(PulseAudio REQUIRED) + +add_library(linux-pulseaudio MODULE) +add_library(OBS::pulseaudio ALIAS linux-pulseaudio) + +target_sources(linux-pulseaudio PRIVATE linux-pulseaudio.c pulse-wrapper.c pulse-input.c) + +target_include_directories(linux-pulseaudio PRIVATE ${PULSEAUDIO_INCLUDE_DIR}) + +target_link_libraries(linux-pulseaudio PRIVATE OBS::libobs ${PULSEAUDIO_LIBRARY}) + +set_target_properties(linux-pulseaudio PROPERTIES FOLDER "plugins") + +setup_plugin_target(linux-pulseaudio) diff --git a/plugins/linux-v4l2/CMakeLists.txt b/plugins/linux-v4l2/CMakeLists.txt index 90db5d46e0812b..d992a5557e5b82 100644 --- a/plugins/linux-v4l2/CMakeLists.txt +++ b/plugins/linux-v4l2/CMakeLists.txt @@ -1,31 +1,43 @@ -project(linux-v4l2) +cmake_minimum_required(VERSION 3.22...3.25) + +legacy_check() option(ENABLE_V4L2 "Build OBS with v4l2 support" ON) +option(ENABLE_UDEV "Build linux-v4l2 with UDEV support" ON) + if(NOT ENABLE_V4L2) - obs_status(DISABLED "linux-v4l2") + target_disable(linux-v4l2) return() endif() -option(ENABLE_UDEV "Build linux-v4l2 with UDEV support" ON) - find_package(Libv4l2 REQUIRED) find_package(FFmpeg REQUIRED COMPONENTS avcodec avutil avformat) +if(OS_FREEBSD OR OS_OPENBSD) + set(CMAKE_REQUIRED_INCLUDES "/usr/local/include") +endif() +include(CheckCSourceCompiles) +set(V4L_TEST_SOURCE "#include\nint main(){return 0;}") +check_c_source_compiles("${V4L_TEST_SOURCE}" HAVE_VIDEODEV2_HEADER) + +if(NOT HAVE_VIDEODEV2_HEADER) + message(FATAL_ERROR "Required system header not found.") +endif() + add_library(linux-v4l2 MODULE) add_library(OBS::v4l2 ALIAS linux-v4l2) -target_sources(linux-v4l2 PRIVATE linux-v4l2.c v4l2-controls.c v4l2-input.c v4l2-helpers.c v4l2-output.c v4l2-decoder.c) - -target_link_libraries(linux-v4l2 PRIVATE OBS::libobs LIB4L2::LIB4L2 FFmpeg::avcodec FFmpeg::avformat FFmpeg::avutil) +target_sources(linux-v4l2 PRIVATE # cmake-format: sortable + linux-v4l2.c v4l2-controls.c v4l2-decoder.c v4l2-helpers.c v4l2-input.c v4l2-output.c) -set_target_properties(linux-v4l2 PROPERTIES FOLDER "plugins") +target_link_libraries(linux-v4l2 PRIVATE OBS::libobs Libv4l2::Libv4l2 FFmpeg::avcodec FFmpeg::avformat FFmpeg::avutil) if(ENABLE_UDEV) - find_package(Udev REQUIRED) + find_package(Libudev REQUIRED) target_sources(linux-v4l2 PRIVATE v4l2-udev.c) - target_link_libraries(linux-v4l2 PRIVATE Udev::Udev) + target_link_libraries(linux-v4l2 PRIVATE Libudev::Libudev) target_compile_definitions(linux-v4l2 PRIVATE HAVE_UDEV) endif() -setup_plugin_target(linux-v4l2) +set_target_properties_obs(linux-v4l2 PROPERTIES FOLDER plugins PREFIX "") diff --git a/plugins/linux-v4l2/cmake/legacy.cmake b/plugins/linux-v4l2/cmake/legacy.cmake new file mode 100644 index 00000000000000..90db5d46e0812b --- /dev/null +++ b/plugins/linux-v4l2/cmake/legacy.cmake @@ -0,0 +1,31 @@ +project(linux-v4l2) + +option(ENABLE_V4L2 "Build OBS with v4l2 support" ON) +if(NOT ENABLE_V4L2) + obs_status(DISABLED "linux-v4l2") + return() +endif() + +option(ENABLE_UDEV "Build linux-v4l2 with UDEV support" ON) + +find_package(Libv4l2 REQUIRED) +find_package(FFmpeg REQUIRED COMPONENTS avcodec avutil avformat) + +add_library(linux-v4l2 MODULE) +add_library(OBS::v4l2 ALIAS linux-v4l2) + +target_sources(linux-v4l2 PRIVATE linux-v4l2.c v4l2-controls.c v4l2-input.c v4l2-helpers.c v4l2-output.c v4l2-decoder.c) + +target_link_libraries(linux-v4l2 PRIVATE OBS::libobs LIB4L2::LIB4L2 FFmpeg::avcodec FFmpeg::avformat FFmpeg::avutil) + +set_target_properties(linux-v4l2 PROPERTIES FOLDER "plugins") + +if(ENABLE_UDEV) + find_package(Udev REQUIRED) + target_sources(linux-v4l2 PRIVATE v4l2-udev.c) + + target_link_libraries(linux-v4l2 PRIVATE Udev::Udev) + target_compile_definitions(linux-v4l2 PRIVATE HAVE_UDEV) +endif() + +setup_plugin_target(linux-v4l2) diff --git a/plugins/obs-ffmpeg/CMakeLists.txt b/plugins/obs-ffmpeg/CMakeLists.txt index 77c5ad8e4950bb..0fa71e58689b4a 100644 --- a/plugins/obs-ffmpeg/CMakeLists.txt +++ b/plugins/obs-ffmpeg/CMakeLists.txt @@ -5,6 +5,10 @@ legacy_check() option(ENABLE_FFMPEG_LOGGING "Enables obs-ffmpeg logging" OFF) option(ENABLE_NEW_MPEGTS_OUTPUT "Use native SRT/RIST mpegts output" ON) +if(OS_LINUX) + option(ENABLE_NATIVE_NVENC "Use native NVENC implementation" ON) +endif() + include(cmake/dependencies.cmake) add_library(obs-ffmpeg MODULE) @@ -23,9 +27,6 @@ target_sources( $<$:obs-ffmpeg-vaapi.c> $<$:vaapi-utils.c> $<$:vaapi-utils.h> - $<$:obs-nvenc-helpers.c> - $<$:obs-nvenc.c> - $<$:obs-nvenc.h> $<$:texture-amf-opts.hpp> $<$:texture-amf.cpp> obs-ffmpeg-audio-encoders.c @@ -58,10 +59,9 @@ target_link_libraries( FFmpeg::avutil FFmpeg::swscale FFmpeg::swresample - $<$:OBS::obs-nvenc-version> + $ $<$:OBS::w32-pthreads> $<$:AMF::AMF> - $<$:FFnvcodec::FFnvcodec> $<$:ws2_32> $<$:Libva::va> $<$:Libva::drm> diff --git a/plugins/obs-ffmpeg/cmake/dependencies.cmake b/plugins/obs-ffmpeg/cmake/dependencies.cmake index e2ff651add6194..442c8ea18325d1 100644 --- a/plugins/obs-ffmpeg/cmake/dependencies.cmake +++ b/plugins/obs-ffmpeg/cmake/dependencies.cmake @@ -26,15 +26,7 @@ endif() if(OS_WINDOWS) find_package(AMF 1.4.29 REQUIRED) - find_package(FFnvcodec 12.0.0.0...<12.2.0.0 REQUIRED) - - add_library(obs-nvenc-version INTERFACE) - add_library(OBS::obs-nvenc-version ALIAS obs-nvenc-version) - target_sources(obs-nvenc-version INTERFACE obs-nvenc-ver.h) - target_include_directories(obs-nvenc-version INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}") - add_subdirectory(obs-amf-test) - add_subdirectory(obs-nvenc-test) elseif( OS_LINUX OR OS_FREEBSD @@ -43,6 +35,32 @@ elseif( find_package(Libpci REQUIRED) endif() +if(OS_WINDOWS OR (OS_LINUX AND ENABLE_NATIVE_NVENC)) + add_library(obs-nvenc-version INTERFACE) + add_library(OBS::obs-nvenc-version ALIAS obs-nvenc-version) + target_sources(obs-nvenc-version INTERFACE obs-nvenc-ver.h) + target_include_directories(obs-nvenc-version INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}") + + find_package(FFnvcodec 12.0.0.0...<12.2.0.0 REQUIRED) + + if(OS_LINUX AND NOT TARGET OBS::glad) + add_subdirectory("${CMAKE_SOURCE_DIR}/deps/glad" "${CMAKE_BINARY_DIR}/deps/glad") + endif() + + add_library(obs-nvenc-native INTERFACE) + add_library(OBS::obs-nvenc-native ALIAS obs-nvenc-native) + target_sources(obs-nvenc-native INTERFACE obs-nvenc-helpers.c obs-nvenc.c obs-nvenc.h) + target_compile_definitions(obs-nvenc-native INTERFACE $<$:NVCODEC_AVAILABLE>) + target_include_directories(obs-nvenc-native INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}") + + target_link_libraries(obs-nvenc-native INTERFACE FFnvcodec::FFnvcodec OBS::obs-nvenc-version + $<$:OBS::glad>) + + if(OS_WINDOWS) + add_subdirectory(obs-nvenc-test) + endif() +endif() + if(ENABLE_NEW_MPEGTS_OUTPUT) find_package(Librist QUIET) find_package(Libsrt QUIET) diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-vaapi.c b/plugins/obs-ffmpeg/obs-ffmpeg-vaapi.c index 127ef658a493be..fabde2aa99b393 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-vaapi.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-vaapi.c @@ -562,27 +562,35 @@ static bool vaapi_encode(void *data, struct encoder_frame *frame, size_t size; enc->first_packet = false; + + switch (enc->codec) { + case CODEC_HEVC: #ifdef ENABLE_HEVC - if (enc->codec == CODEC_HEVC) { obs_extract_hevc_headers( enc->packet->data, enc->packet->size, &new_packet, &size, &enc->header, &enc->header_size, &enc->sei, &enc->sei_size); - } else + break; +#else + warn("vaapi_encode: HEVC codec is not supported"); + goto fail; #endif - if (enc->codec == CODEC_H264) { + case CODEC_H264: obs_extract_avc_headers( enc->packet->data, enc->packet->size, &new_packet, &size, &enc->header, &enc->header_size, &enc->sei, &enc->sei_size); - } else if (enc->codec == CODEC_AV1) { + break; + + case CODEC_AV1: obs_extract_av1_headers(enc->packet->data, enc->packet->size, &new_packet, &size, &enc->header, &enc->header_size); + break; } da_copy_array(enc->buffer, new_packet, size); diff --git a/plugins/obs-ffmpeg/vaapi-utils.c b/plugins/obs-ffmpeg/vaapi-utils.c index 036949d0a02175..d636558b709d48 100644 --- a/plugins/obs-ffmpeg/vaapi-utils.c +++ b/plugins/obs-ffmpeg/vaapi-utils.c @@ -128,7 +128,6 @@ static uint32_t vaapi_display_ep_combo_rate_controls(VAProfile profile, VADisplay dpy, const char *device_path) { - bool ret = false; VAStatus va_status; VAConfigAttrib attrib[1]; attrib->type = VAConfigAttribRateControl; diff --git a/plugins/obs-filters/CMakeLists.txt b/plugins/obs-filters/CMakeLists.txt index 4dd653ae3ff43f..697b4985afee23 100644 --- a/plugins/obs-filters/CMakeLists.txt +++ b/plugins/obs-filters/CMakeLists.txt @@ -34,9 +34,10 @@ target_link_libraries(obs-filters PRIVATE OBS::libobs $<$:O include(cmake/speexdsp.cmake) include(cmake/rnnoise.cmake) -include(cmake/nvidia.cmake) if(OS_WINDOWS) + include(cmake/nvidia.cmake) + configure_file(cmake/windows/obs-module.rc.in obs-filters.rc) target_sources(obs-filters PRIVATE obs-filters.rc) endif() diff --git a/plugins/obs-filters/cmake/nvidia.cmake b/plugins/obs-filters/cmake/nvidia.cmake index 63b36f8f7017c9..22d1a003bb4b75 100644 --- a/plugins/obs-filters/cmake/nvidia.cmake +++ b/plugins/obs-filters/cmake/nvidia.cmake @@ -1,7 +1,5 @@ -if(OS_WINDOWS) - option(ENABLE_NVAFX "Enable building with NVIDIA Audio Effects SDK (requires redistributable to be installed)" ON) - option(ENABLE_NVVFX "Enable building with NVIDIA Video Effects SDK (requires redistributable to be installed)" ON) -endif() +option(ENABLE_NVAFX "Enable building with NVIDIA Audio Effects SDK (requires redistributable to be installed)" ON) +option(ENABLE_NVVFX "Enable building with NVIDIA Video Effects SDK (requires redistributable to be installed)" ON) if(ENABLE_NVAFX) target_enable_feature(obs-filters "NVIDIA Audio FX support" LIBNVAFX_ENABLED HAS_NOISEREDUCTION) diff --git a/plugins/obs-filters/cmake/rnnoise.cmake b/plugins/obs-filters/cmake/rnnoise.cmake index 3f72937984b9e5..a7ff86e4742821 100644 --- a/plugins/obs-filters/cmake/rnnoise.cmake +++ b/plugins/obs-filters/cmake/rnnoise.cmake @@ -1,47 +1,53 @@ option(ENABLE_RNNOISE "Enable building with RNNoise noise supression filter" ON) if(ENABLE_RNNOISE) - if(NOT OS_WINDOWS AND NOT OS_MACOS) - add_library(obs-rnnoise OBJECT) - - target_sources( - obs-rnnoise - PRIVATE # cmake-format: sortable - rnnoise/src/_kiss_fft_guts.h - rnnoise/src/arch.h - rnnoise/src/celt_lpc.c - rnnoise/src/celt_lpc.h - rnnoise/src/common.h - rnnoise/src/denoise.c - rnnoise/src/kiss_fft.c - rnnoise/src/kiss_fft.h - rnnoise/src/opus_types.h - rnnoise/src/pitch.c - rnnoise/src/pitch.h - rnnoise/src/rnn.c - rnnoise/src/rnn.h - rnnoise/src/rnn_data.c - rnnoise/src/rnn_data.h - rnnoise/src/rnn_reader.c - rnnoise/src/tansig_table.h - PUBLIC rnnoise/include/rnnoise.h) - - add_library(Librnnoise::Librnnoise ALIAS obs-rnnoise) - - target_include_directories(obs-rnnoise PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/rnnoise/include") - - target_compile_definitions(obs-rnnoise PUBLIC COMPILE_OPUS) - - target_compile_options(obs-rnnoise PRIVATE -Wno-newline-eof -Wno-error=null-dereference) - - set_target_properties(obs-rnnoise PROPERTIES FOLDER plugins/obs-filters/rnnoise POSITION_INDEPENDENT_CODE TRUE) - else() + if(OS_WINDOWS OR OS_MACOS) find_package(Librnnoise REQUIRED) - - target_sources(obs-filters PRIVATE noise-suppress-filter.c) + else() + find_package(Librnnoise) + + if(NOT TARGET Librnnoise::Librnnoise) + message(WARNING "No RNNoise library found. Using internal RNNoise version instead.") + add_library(obs-rnnoise OBJECT) + + target_sources( + obs-rnnoise + PRIVATE # cmake-format: sortable + rnnoise/src/_kiss_fft_guts.h + rnnoise/src/arch.h + rnnoise/src/celt_lpc.c + rnnoise/src/celt_lpc.h + rnnoise/src/common.h + rnnoise/src/denoise.c + rnnoise/src/kiss_fft.c + rnnoise/src/kiss_fft.h + rnnoise/src/opus_types.h + rnnoise/src/pitch.c + rnnoise/src/pitch.h + rnnoise/src/rnn.c + rnnoise/src/rnn.h + rnnoise/src/rnn_data.c + rnnoise/src/rnn_data.h + rnnoise/src/rnn_reader.c + rnnoise/src/tansig_table.h + PUBLIC rnnoise/include/rnnoise.h) + + add_library(Librnnoise::Librnnoise ALIAS obs-rnnoise) + + target_include_directories(obs-rnnoise PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/rnnoise/include") + + target_compile_definitions(obs-rnnoise PUBLIC COMPILE_OPUS) + + target_compile_options(obs-rnnoise PRIVATE -Wno-newline-eof -Wno-error=null-dereference) + + set_target_properties(obs-rnnoise PROPERTIES FOLDER plugins/obs-filters/rnnoise POSITION_INDEPENDENT_CODE TRUE) + endif() endif() + target_sources(obs-filters PRIVATE noise-suppress-filter.c) + target_link_libraries(obs-filters PRIVATE Librnnoise::Librnnoise) + target_enable_feature(obs-filters "RNNoise noise suppression" LIBRNNOISE_ENABLED HAS_NOISEREDUCTION) else() target_disable_feature(obs-filters "RNNoise noise suppression") diff --git a/plugins/obs-libfdk/CMakeLists.txt b/plugins/obs-libfdk/CMakeLists.txt index efdb6908f650c4..36a69257b88dc4 100644 --- a/plugins/obs-libfdk/CMakeLists.txt +++ b/plugins/obs-libfdk/CMakeLists.txt @@ -1,9 +1,10 @@ -project(obs-libfdk) +cmake_minimum_required(VERSION 3.22...3.25) -option(ENABLE_LIBFDK "Enable FDK AAC support" OFF) +legacy_check() +option(ENABLE_LIBFDK "Enable FDK AAC support" OFF) if(NOT ENABLE_LIBFDK) - obs_status(DISABLED "obs-libfdk") + target_disable(obs-libfdk) return() endif() @@ -14,8 +15,6 @@ add_library(OBS::libfdk ALIAS obs-libfdk) target_sources(obs-libfdk PRIVATE obs-libfdk.c) -target_link_libraries(obs-libfdk PRIVATE OBS::libobs LibFDK::LibFDK) - -set_target_properties(obs-libfdk PROPERTIES FOLDER "plugins" PREFIX "") +target_link_libraries(obs-libfdk PRIVATE OBS::libobs Libfdk::Libfdk) -setup_plugin_target(obs-libfdk) +set_target_properties_obs(obs-libfdk PROPERTIES FOLDER plugins PREFIX "") diff --git a/plugins/obs-libfdk/cmake/legacy.cmake b/plugins/obs-libfdk/cmake/legacy.cmake new file mode 100644 index 00000000000000..efdb6908f650c4 --- /dev/null +++ b/plugins/obs-libfdk/cmake/legacy.cmake @@ -0,0 +1,21 @@ +project(obs-libfdk) + +option(ENABLE_LIBFDK "Enable FDK AAC support" OFF) + +if(NOT ENABLE_LIBFDK) + obs_status(DISABLED "obs-libfdk") + return() +endif() + +find_package(Libfdk REQUIRED) + +add_library(obs-libfdk MODULE) +add_library(OBS::libfdk ALIAS obs-libfdk) + +target_sources(obs-libfdk PRIVATE obs-libfdk.c) + +target_link_libraries(obs-libfdk PRIVATE OBS::libobs LibFDK::LibFDK) + +set_target_properties(obs-libfdk PROPERTIES FOLDER "plugins" PREFIX "") + +setup_plugin_target(obs-libfdk) diff --git a/plugins/obs-outputs/cmake/ftl.cmake b/plugins/obs-outputs/cmake/ftl.cmake index deb945853744dc..cdbeb948b63a8e 100644 --- a/plugins/obs-outputs/cmake/ftl.cmake +++ b/plugins/obs-outputs/cmake/ftl.cmake @@ -55,11 +55,11 @@ target_include_directories( "$<$>:${CMAKE_CURRENT_SOURCE_DIR}/ftl-sdk/libftl/posix>") if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10) - target_compile_options(ftl-sdk PRIVATE -Wno-error=enum-conversion) + target_compile_options(ftl-sdk PRIVATE -Wno-error=enum-conversion -Wno-error=maybe-uninitialized) endif() target_sources(obs-outputs PRIVATE ftl-stream.c) target_link_libraries(obs-outputs PRIVATE ftl-sdk) target_enable_feature(obs-outputs "FTL protocol support") -set_target_properties(ftl-sdk PROPERTIES FOLDER plugins/obs-outputs) +set_target_properties(ftl-sdk PROPERTIES FOLDER plugins/obs-outputs POSITION_INDEPENDENT_CODE TRUE) diff --git a/plugins/obs-qsv11/common_utils_linux.cpp b/plugins/obs-qsv11/common_utils_linux.cpp index cdadafda20800b..4ddb3a127c1b28 100644 --- a/plugins/obs-qsv11/common_utils_linux.cpp +++ b/plugins/obs-qsv11/common_utils_linux.cpp @@ -252,7 +252,6 @@ static void vaapi_close(struct vaapi_device *device) static uint32_t vaapi_check_support(VADisplay display, VAProfile profile, VAEntrypoint entrypoint) { - bool ret = false; VAConfigAttrib attrib[1]; attrib->type = VAConfigAttribRateControl; diff --git a/plugins/obs-qsv11/obs-qsv11.c b/plugins/obs-qsv11/obs-qsv11.c index cf9d2b8fe5f8e3..87f3ab35125939 100644 --- a/plugins/obs-qsv11/obs-qsv11.c +++ b/plugins/obs-qsv11/obs-qsv11.c @@ -1253,8 +1253,6 @@ static void parse_packet_av1(struct obs_qsv *obsqsv, packet->priority = priority; - bool pFrame = pBS->FrameType & MFX_FRAMETYPE_P; - packet->dts = ts_mfx_to_obs(pBS->DecodeTimeStamp, voi); #if 0 @@ -1276,8 +1274,6 @@ static void parse_packet_hevc(struct obs_qsv *obsqsv, const struct video_output_info *voi, bool *received_packet) { - bool is_vcl_packet = false; - if (pBS == NULL || pBS->DataLength == 0) { *received_packet = false; return; diff --git a/plugins/oss-audio/CMakeLists.txt b/plugins/oss-audio/CMakeLists.txt index b538cf4db21342..05b315c3c4f58f 100644 --- a/plugins/oss-audio/CMakeLists.txt +++ b/plugins/oss-audio/CMakeLists.txt @@ -1,9 +1,11 @@ -project(oss-audio) +cmake_minimum_required(VERSION 3.22...3.25) + +legacy_check() option(ENABLE_OSS "Enable building with OSS audio support" ON) if(NOT ENABLE_OSS) - obs_status(DISABLED "oss-audio") + target_disable(oss-audio) return() endif() @@ -16,12 +18,4 @@ target_sources(oss-audio PRIVATE oss-audio.c oss-input.c) target_link_libraries(oss-audio PRIVATE OBS::libobs OSS::OSS) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/oss-platform.h.in oss-platform.h) - -target_include_directories(oss-audio PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - -target_sources(oss-audio PRIVATE oss-platform.h) - -set_target_properties(oss-audio PROPERTIES FOLDER "plugins") - -setup_plugin_target(oss-audio) +set_target_properties_obs(oss-audio PROPERTIES FOLDER plugins PREFIX "") diff --git a/plugins/oss-audio/cmake/legacy.cmake b/plugins/oss-audio/cmake/legacy.cmake new file mode 100644 index 00000000000000..b538cf4db21342 --- /dev/null +++ b/plugins/oss-audio/cmake/legacy.cmake @@ -0,0 +1,27 @@ +project(oss-audio) + +option(ENABLE_OSS "Enable building with OSS audio support" ON) + +if(NOT ENABLE_OSS) + obs_status(DISABLED "oss-audio") + return() +endif() + +find_package(OSS REQUIRED) + +add_library(oss-audio MODULE) +add_library(OBS::oss-audio ALIAS oss-audio) + +target_sources(oss-audio PRIVATE oss-audio.c oss-input.c) + +target_link_libraries(oss-audio PRIVATE OBS::libobs OSS::OSS) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/oss-platform.h.in oss-platform.h) + +target_include_directories(oss-audio PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + +target_sources(oss-audio PRIVATE oss-platform.h) + +set_target_properties(oss-audio PROPERTIES FOLDER "plugins") + +setup_plugin_target(oss-audio) diff --git a/plugins/oss-audio/oss-input.c b/plugins/oss-audio/oss-input.c index 368ca5acf6bd4b..04581529e6ecc9 100644 --- a/plugins/oss-audio/oss-input.c +++ b/plugins/oss-audio/oss-input.c @@ -26,7 +26,7 @@ along with this program. If not, see . #include #include #include -#include "oss-platform.h" +#include #define blog(level, msg, ...) blog(level, "oss-audio: " msg, ##__VA_ARGS__) diff --git a/plugins/sndio/CMakeLists.txt b/plugins/sndio/CMakeLists.txt index 850f685e34c3b5..c60c2a1c64f82c 100644 --- a/plugins/sndio/CMakeLists.txt +++ b/plugins/sndio/CMakeLists.txt @@ -1,8 +1,10 @@ -project(sndio) +cmake_minimum_required(VERSION 3.22...3.25) + +legacy_check() option(ENABLE_SNDIO "Build OBS with sndio support" OFF) if(NOT ENABLE_SNDIO) - obs_status(DISABLED "sndio") + target_disable(sndio) return() endif() @@ -13,8 +15,8 @@ add_library(OBS::sndio ALIAS sndio) target_sources(sndio PRIVATE sndio.c sndio-input.c) -target_link_libraries(sndio PRIVATE OBS::libobs Sndio::Sndio) +target_compile_options(sndio PRIVATE -Wno-error=vla) -set_target_properties(sndio PROPERTIES FOLDER "plugins") +target_link_libraries(sndio PRIVATE OBS::libobs Sndio::Sndio) -setup_plugin_target(sndio) +set_target_properties_obs(sndio PROPERTIES FOLDER plugins PREFIX "") diff --git a/plugins/sndio/cmake/legacy.cmake b/plugins/sndio/cmake/legacy.cmake new file mode 100644 index 00000000000000..850f685e34c3b5 --- /dev/null +++ b/plugins/sndio/cmake/legacy.cmake @@ -0,0 +1,20 @@ +project(sndio) + +option(ENABLE_SNDIO "Build OBS with sndio support" OFF) +if(NOT ENABLE_SNDIO) + obs_status(DISABLED "sndio") + return() +endif() + +find_package(Sndio REQUIRED) + +add_library(sndio MODULE) +add_library(OBS::sndio ALIAS sndio) + +target_sources(sndio PRIVATE sndio.c sndio-input.c) + +target_link_libraries(sndio PRIVATE OBS::libobs Sndio::Sndio) + +set_target_properties(sndio PROPERTIES FOLDER "plugins") + +setup_plugin_target(sndio) diff --git a/plugins/vlc-video/CMakeLists.txt b/plugins/vlc-video/CMakeLists.txt index 072e0bfd3c841b..b9ee1a564824ee 100644 --- a/plugins/vlc-video/CMakeLists.txt +++ b/plugins/vlc-video/CMakeLists.txt @@ -3,24 +3,22 @@ cmake_minimum_required(VERSION 3.22...3.25) legacy_check() macro(check_vlc_path) - if(OS_WINDOWS OR OS_MACOS) - if(NOT EXISTS "${VLC_PATH}/include/vlc/libvlc.h") - message(FATAL_ERROR "Unable to find libvlc.h. Check if VLC_PATH set correctly.") - endif() - - target_include_directories(vlc-video PRIVATE "${VLC_PATH}/include/vlc") - elseif( - OS_LINUX - OR OS_FREEBSD - OR OS_OPENBSD) - find_package(PkgConfig QUIET) - if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_Libvlc QUIET libvlc) - endif() - - if(PC_Libvlc_INCLUDEDIR) - target_include_directories(vlc-video PRIVATE "${PC_Libvlc_INCLUDEDIR}/vlc") - endif() + find_package(PkgConfig QUIET) + if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_Libvlc QUIET libvlc) + endif() + + find_path( + LibVLC_INCLUDE_DIR + NAMES vlc/libvlc.h + HINTS ${PC_Libvlc_INCLUDEDIR} ${VLC_PATH}/include + PATHS /usr/include /usr/local/include + DOC "LibVLC include directory") + + if(LibVLC_INCLUDE_DIR) + target_include_directories(vlc-video PRIVATE "${LibVLC_INCLUDE_DIR}") + else() + message(FATAL_ERROR "Required system header not found.") endif() endmacro() diff --git a/plugins/vlc-video/vlc-video-plugin.h b/plugins/vlc-video/vlc-video-plugin.h index 79d875e6b28139..b3ecce54fd7e5c 100644 --- a/plugins/vlc-video/vlc-video-plugin.h +++ b/plugins/vlc-video/vlc-video-plugin.h @@ -1,16 +1,16 @@ #include -#include +#include #ifdef _MSC_VER #include typedef SSIZE_T ssize_t; #endif -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include extern libvlc_instance_t *libvlc; extern uint64_t time_start; diff --git a/test/test-input/CMakeLists.txt b/test/test-input/CMakeLists.txt index c364c88433e1b1..5bcce1b009f39b 100644 --- a/test/test-input/CMakeLists.txt +++ b/test/test-input/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.24...3.25) +cmake_minimum_required(VERSION 3.22...3.25) legacy_check()