Sfoglia il codice sorgente

Reorganize project files

PatTheMav 3 anni fa
parent
commit
2764248a5d

+ 107 - 0
.clang-format

@@ -0,0 +1,107 @@
+# please use clang-format version 8 or later
+
+Standard: Cpp11
+AccessModifierOffset: -8
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlines: Left
+AlignOperands: true
+AlignTrailingComments: true
+#AllowAllArgumentsOnNextLine: false  # requires clang-format 9
+#AllowAllConstructorInitializersOnNextLine: false  # requires clang-format 9
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: Inline
+AllowShortIfStatementsOnASingleLine: false
+#AllowShortLambdasOnASingleLine: Inline  # requires clang-format 9
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+  AfterClass: false
+  AfterControlStatement: false
+  AfterEnum: false
+  AfterFunction: true
+  AfterNamespace: false
+  AfterObjCDeclaration: false
+  AfterStruct: false
+  AfterUnion: false
+  AfterExternBlock: false
+  BeforeCatch: false
+  BeforeElse: false
+  IndentBraces: false
+  SplitEmptyFunction: true
+  SplitEmptyRecord: true
+  SplitEmptyNamespace: true
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: BeforeColon
+BreakStringLiterals: false  # apparently unpredictable
+ColumnLimit: 80
+CompactNamespaces: false
+ConstructorInitializerAllOnOneLineOrOnePerLine: true
+ConstructorInitializerIndentWidth: 8
+ContinuationIndentWidth: 8
+Cpp11BracedListStyle: true
+DerivePointerAlignment: false
+DisableFormat: false
+FixNamespaceComments: false
+ForEachMacros: 
+  - 'json_object_foreach'
+  - 'json_object_foreach_safe'
+  - 'json_array_foreach'
+IncludeBlocks: Preserve
+IndentCaseLabels: false
+IndentPPDirectives: None
+IndentWidth: 8
+IndentWrappedFunctionNames: false
+KeepEmptyLinesAtTheStartOfBlocks: true
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+#ObjCBinPackProtocolList: Auto  # requires clang-format 7
+ObjCBlockIndentWidth: 8
+ObjCSpaceAfterProperty: true
+ObjCSpaceBeforeProtocolList: true
+
+PenaltyBreakAssignment: 10
+PenaltyBreakBeforeFirstCallParameter: 30
+PenaltyBreakComment: 10
+PenaltyBreakFirstLessLess: 0
+PenaltyBreakString: 10
+PenaltyExcessCharacter: 100
+PenaltyReturnTypeOnItsOwnLine: 60
+
+PointerAlignment: Right
+ReflowComments: false
+SortIncludes: false
+SortUsingDeclarations: false
+SpaceAfterCStyleCast: false
+#SpaceAfterLogicalNot: false  # requires clang-format 9
+SpaceAfterTemplateKeyword: false
+SpaceBeforeAssignmentOperators: true
+#SpaceBeforeCtorInitializerColon: true  # requires clang-format 7
+#SpaceBeforeInheritanceColon: true  # requires clang-format 7
+SpaceBeforeParens: ControlStatements
+#SpaceBeforeRangeBasedForLoopColon: true  # requires clang-format 7
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInCStyleCastParentheses: false
+SpacesInContainerLiterals: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+#StatementMacros:  # requires clang-format 8
+#  - 'Q_OBJECT'
+TabWidth: 8
+#TypenameMacros:  # requires clang-format 9
+#  - 'DARRAY'
+UseTab: ForContinuationAndIndentation
+---
+Language: ObjC

+ 14 - 0
.cmake-format.json

@@ -0,0 +1,14 @@
+{
+    "additional_commands": {
+      "find_qt": {
+        "flags": [],
+        "kwargs": {
+          "VERSION": "+",
+          "COMPONENTS": "+",
+          "COMPONENTS_WIN": "+",
+          "COMPONENTS_MACOS": "+",
+          "COMPONENTS_LINUX": "+"
+        }
+      }
+    }
+}

+ 6 - 0
.github/scripts/.Brewfile

@@ -0,0 +1,6 @@
+brew "ccache"
+brew "coreutils"
+brew "cmake"
+brew "git"
+brew "jq"
+brew "ninja"

+ 1 - 1
CI/utility/check-format.sh → .github/scripts/check-changes.sh

@@ -8,4 +8,4 @@ if [[ $dirty ]]; then
     echo "$dirty"
     echo "================================="
     exit 1
-fi
+fi

+ 51 - 0
.github/scripts/check-cmake.sh

@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+
+set -o errexit
+set -o pipefail
+
+if [ ${#} -eq 1 -a "${1}" = "VERBOSE" ]; then
+    VERBOSITY="-l debug"
+else
+    VERBOSITY=""
+fi
+
+if [ "${CI}" ]; then
+    MODE="--check"
+else
+    MODE="-i"
+fi
+
+# Runs the formatter in parallel on the code base.
+# Return codes:
+#  - 1 there are files to be formatted
+#  - 0 everything looks fine
+
+# Get CPU count
+OS=$(uname)
+NPROC=1
+if [[ ${OS} = "Linux" ]] ; then
+    NPROC=$(nproc)
+elif [[ ${OS} = "Darwin" ]] ; then
+    NPROC=$(sysctl -n hw.physicalcpu)
+fi
+
+# Discover clang-format
+if ! type cmake-format 2> /dev/null ; then
+    echo "Required cmake-format not found"
+    exit 1
+fi
+
+find . -type d \( \
+    -path ./\*build -o \
+    -path ./deps/jansson -o \
+    -path ./plugins/decklink/\*/decklink-sdk -o \
+    -path ./plugins/enc-amf -o \
+    -path ./plugins/mac-syphon/syphon-framework -o \
+    -path ./plugins/obs-outputs/ftl-sdk -o \
+    -path ./plugins/obs-vst -o \
+    -path ./plugins/obs-browser -o \
+    -path ./plugins/win-dshow/libdshowcapture \
+\) -prune -false -type f -o \
+    -name 'CMakeLists.txt' -or \
+    -name '*.cmake' \
+ | xargs -L10 -P ${NPROC} cmake-format ${MODE} ${VERBOSITY}

+ 1 - 1
CI/utility/formatcode.sh → .github/scripts/check-format.sh

@@ -42,7 +42,7 @@ else
 fi
 
 find . -type d \( \
-    -path ./\*build -o \
+    -path ./\*build\* -o \
     -path ./cmake -o \
     -path ./deps -o \
     -path ./plugins/decklink/\*/decklink-sdk -o \

+ 0 - 2
CI/include/Brewfile

@@ -1,2 +0,0 @@
-brew "cmake"
-brew "ninja"

+ 0 - 1
CI/include/Xcnotary

@@ -1 +0,0 @@
-brew "akeru-inc/tap/xcnotary"

+ 52 - 86
CMakeLists.txt

@@ -1,124 +1,90 @@
 cmake_minimum_required(VERSION 3.16)
 
 # Change obs-plugintemplate to your plugin's name in a machine-readable format
-# (e.g.: obs-myawesomeplugin) and set 
-project(obs-plugintemplate VERSION 1.0.0)
+# (e.g.: obs-myawesomeplugin) and set
+project(obs-plugintemplate VERSION 1.0.5)
 add_library(${CMAKE_PROJECT_NAME} MODULE)
 
 # Replace `Your Name Here` with the name (yours or your organization's) you want
-# to see as the author of the plugin (in the plugin's metadata itself and in the installers)
+# to see as the author of the plugin (in the plugin's metadata itself and in the
+# installers)
 set(PLUGIN_AUTHOR "Your Name Here")
 
-# Replace `com.example.obs-plugin-template` with a unique Bundle ID for macOS releases
-# (used both in the installer and when submitting the installer for notarization)
-set(MACOS_BUNDLEID "com.example.obs-plugintemplate")
+# Replace `com.example.obs-plugin-template` with a unique Bundle ID for macOS
+# releases (used both in the installer and when submitting the installer for
+# notarization)
+set(MACOS_BUNDLEID "com.example.${CMAKE_PROJECT_NAME}")
 
-# Replace `me@contoso.com` with the maintainer email address you want to put in Linux packages
+# Replace `me@contoso.com` with the maintainer email address you want to put in
+# Linux packages
 set(LINUX_MAINTAINER_EMAIL "me@mymailhost.com")
 
-# Add your custom source files here - header files are optional and only required for visibility
-# e.g. in Xcode or Visual Studio
-target_sources(${CMAKE_PROJECT_NAME}
-	PRIVATE
-		src/plugin-main.c)
+# Add your custom source files here - header files are optional and only
+# required for visibility e.g. in Xcode or Visual Studio
+target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/plugin-main.c)
 
 # /!\ TAKE NOTE: No need to edit things past this point /!\
 
 find_package(libobs REQUIRED)
 find_package(obs-frontend-api REQUIRED)
-include(external/ObsPluginHelpers.cmake)
-find_package(Qt5Core REQUIRED)
-find_package(Qt5Widgets REQUIRED)
+include(cmake/ObsPluginHelpers.cmake)
 
+configure_file(src/plugin-macros.h.in
+               ${CMAKE_SOURCE_DIR}/src/plugin-macros.generated.h)
 
-configure_file(
-	src/plugin-macros.h.in
-	${CMAKE_SOURCE_DIR}/src/plugin-macros.generated.h)
-
-target_sources(${CMAKE_PROJECT_NAME}
-	PRIVATE
-		src/plugin-macros.generated.h)
+target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/plugin-macros.generated.h)
 
 # --- Platform-independent build settings ---
 
 target_include_directories(${CMAKE_PROJECT_NAME}
-	PRIVATE ${CMAKE_SOURCE_DIR}/src)
+                           PRIVATE ${CMAKE_SOURCE_DIR}/src)
 
-target_link_libraries(${CMAKE_PROJECT_NAME}
-	PRIVATE
-		OBS::libobs
-		OBS::obs-frontend-api
-		Qt5::Core
-		Qt5::Widgets)
+target_link_libraries(
+  ${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs OBS::obs-frontend-api Qt5::Core
+                                Qt5::Widgets)
 
-set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
-	AUTOMOC ON
-	AUTOUIC ON
-	AUTORCC ON)
+set_target_properties(
+  ${CMAKE_PROJECT_NAME}
+  PROPERTIES AUTOMOC ON
+             AUTOUIC ON
+             AUTORCC ON)
 
-target_compile_features(${CMAKE_PROJECT_NAME}
-	PRIVATE
-		cxx_std_17)
+target_compile_features(${CMAKE_PROJECT_NAME} PRIVATE cxx_std_17)
 
 # --- End of section ---
 
 # --- Windows-specific build settings and tasks ---
 if(OS_WINDOWS)
-	configure_file(
-		installer/installer-Windows.iss.in
-		${CMAKE_SOURCE_DIR}/installer/installer-Windows.generated.iss)
-
-	configure_file(
-		CI/include/build_environment.ps1.in
-		${CMAKE_SOURCE_DIR}/CI/include/build_environment.ps1)
-
-	if(MSVC)
-		target_compile_options(${CMAKE_PROJECT_NAME}
-			PRIVATE
-				/MP
-				/d2FH4-)
-	endif()
-# --- End of section ---
+  configure_file(cmake/bundle/windows/installer-Windows.iss.in
+                 ${CMAKE_BINARY_DIR}/installer-Windows.generated.iss)
 
-# -- macOS specific build settings and tasks --
+  if(MSVC)
+    target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE /MP /d2FH4-)
+  endif()
+  # --- End of section ---
+
+  # -- macOS specific build settings and tasks --
 elseif(OS_MACOS)
-	configure_file(
-		bundle/installer-macOS.pkgproj.in
-		${CMAKE_SOURCE_DIR}/bundle/installer-macOS.generated.pkgproj)
-
-	configure_file(
-		CI/include/build_environment.sh.in
-		${CMAKE_SOURCE_DIR}/CI/include/build_environment.sh
-	)
-
-	set(MACOSX_PLUGIN_GUI_IDENTIFIER "${MACOS_BUNDLEID}")
-	set(MACOSX_PLUGIN_BUNDLE_VERSION "${CMAKE_PROJECT_VERSION}")
-	set(MACOSX_PLUGIN_SHORT_VERSION_STRING "1")
-
-	target_compile_options(${CMAKE_PROJECT_NAME}
-		PRIVATE
-			-Wall
-			-Wextra
-			-Werror-implicit-function-declaration
-			-stdlib=libc++
-			-fvisibility=default)
-
-	set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
-# --- End of section ---
+  configure_file(cmake/bundle/macos/installer-macOS.pkgproj.in
+                 ${CMAKE_BINARY_DIR}/installer-macOS.generated.pkgproj)
 
-# --- Linux-specific build settings and tasks ---
-else()
-	configure_file(
-		CI/include/build_environment.sh.in
-		${CMAKE_SOURCE_DIR}/CI/include/build_environment.sh
-	)
+  set(MACOSX_PLUGIN_GUI_IDENTIFIER "${MACOS_BUNDLEID}")
+  set(MACOSX_PLUGIN_BUNDLE_VERSION "${CMAKE_PROJECT_VERSION}")
+  set(MACOSX_PLUGIN_SHORT_VERSION_STRING "1")
+
+  target_compile_options(
+    ${CMAKE_PROJECT_NAME}
+    PRIVATE -Wall -Wextra -Werror-implicit-function-declaration -stdlib=libc++
+            -fvisibility=default)
 
-	target_compile_options(${CMAKE_PROJECT_NAME}
-		PRIVATE
-			-Wall
-			-Wextra)
+  set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
+  # --- End of section ---
+
+  # --- Linux-specific build settings and tasks ---
+else()
+  target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall -Wextra)
 
-	set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
+  set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
 endif()
 # --- End of section ---
 

+ 11 - 15
README.md

@@ -6,40 +6,36 @@ This plugin is meant to make it easy to quickstart development of new OBS plugin
 
 - The CMake project file
 - Boilerplate plugin source code
-- A continuous-integration configuration for automated builds (a.k.a Build Bot)
+- GitHub Actions workflows and repository actions
+- Build scripts for Windows, macOS, and Linux
 
 ## Configuring
 
-Open `CMakeLists.txt` and edit the following lines at the beginning:
+Open `buildspec.json` and change the name and version of the plugin accordingly. This is also where the obs-studio version as well as the pre-built dependencies for Windows and macOS are defined. Use a release version (with associated checksums) from a recent [obs-deps release](https://github.com/obsproject/obs-deps/releases).
+
+Next, open `CMakeLists.txt` and edit the following lines at the beginning:
 
 ```cmake
-# Change `obs-plugintemplate` to your plugin's name in a machine-readable format
-# (e.g.: obs-myawesomeplugin) and set the value next to `VERSION` as your plugin's current version
 project(obs-plugintemplate VERSION 1.0.0)
 
-# Replace `Your Name Here` with the name (yours or your organization's) you want
-# to see as the author of the plugin (in the plugin's metadata itself and in the installers)
 set(PLUGIN_AUTHOR "Your Name Here")
 
-# Replace `com.example.obs-plugin-template` with a unique Bundle ID for macOS releases
-# (used both in the installer and when submitting the installer for notarization)
-set(MACOS_BUNDLEID "com.example.obs-plugintemplate")
-
-# Replace `me@contoso.com` with the maintainer email address you want to put in Linux packages
 set(LINUX_MAINTAINER_EMAIL "me@contoso.com")
 ```
 
-## CI / Build Bot
+The build scripts (contained in the `.github/scripts` directory) will update the `project` line automatically based on values from the `buildspec.json` file. If the scripts are not used, these changes need to be done manually.
+
+## GitHub Actions & CI
 
-The contained build scripts are used by the local main build script as well as by CI - every sub-script can be run individually as well - by default a workflow for Github Actions is provided, allowing your plugin to use CI right from your Github repository.
+The scripts contained in `github/scripts` can be used to build and package the plugin and take care of setting up obs-studio as well as its own dependencies. A default workflow for GitHub Actions is also provided and will use these scripts.
 
 ### Retrieving build artifacts
 
-Each build produces installers and packages that you can use for testing and releases. These artifacts can be found on the action result page via the "Actions" tab in your Github repository.
+Each build produces installers and packages that you can use for testing and releases. These artifacts can be found on the action result page via the "Actions" tab in your GitHub repository.
 
 #### Building a Release
 
-Simply create and push a tag and Github Actions will run the pipeline in Release Mode. This mode uses the tag as its version number instead of the git ref in normal mode.
+Simply create and push a tag and GitHub Actions will run the pipeline in Release Mode. This mode uses the tag as its version number instead of the git ref in normal mode.
 
 ### Signing and Notarizing on macOS
 

+ 56 - 0
buildspec.json

@@ -0,0 +1,56 @@
+{
+    "dependencies": {
+        "obs-studio": {
+            "version": "27.2.3",
+            "repository": "https://github.com/obsproject/obs-studio.git",
+            "branch": "master",
+            "hash": "13f2d7925ff49938e3b286a3b9a65d50c1491ec1"
+        },
+        "obs-deps": {
+            "macos-x86_64": {
+                "version": "2022-02-13",
+                "hash": "1a8715d66e664b857942deaded0dc46c4f6cd22e88f01ed1188f3bd3fcf632c4"
+            },
+            "macos-arm64": {
+                "version": "2022-02-13",
+                "hash": "2cfcaf05765400c696908f242aea87b6e1848e1a48cd3edc2eb7f8cb249c9d48"
+            },
+            "macos-universal": {
+                "version": "2022-02-13",
+                "hash": "77471b1d345a768e8efec3f6ad9dc79f3c7cd34840b66f721b80025d29713f5d"
+            },
+            "windows-x64": {
+                "version": "2022-03-16",
+                "hash": "ed73757d1faee1b8c4a9aeca539e1149704e430085608990771402e60074eec7"
+            },
+            "windows-x86": {
+                "version": "2022-03-16",
+                "hash": "4751f68488cf6d5dcc79fbf6735762154847ca509d669539b241bf4e5cbf7751"
+            }
+        },
+        "obs-deps-qt": {
+            "macos-x86_64": {
+                "version": "2022-02-13",
+                "hash": "35a58fee8dfd70d3d2dcc0ae0b77132c04a451c6f041a02dc41b207b375fc74b"
+            },
+            "macos-arm64": {
+                "version": "2022-02-13",
+                "hash": "e99146b9c7775c245a2d22f2ef24fc111fccd71bad0f03b64db707124ffb8707"
+            },
+            "macos-universal": {
+                "version": "2022-02-13",
+                "hash": "13fbcc45fd9d08b30e702d481fe4d58b23f93aa06848cede4ebe0956c79a5e8a"
+            },
+            "windows-x64": {
+                "version": "2022-03-16",
+                "hash": "4a5faed9bad327be079e08ed6715a287db8936d20e51b9cdfc7eb52d0a57c629"
+            },
+            "windows-x86": {
+                "version": "2022-03-16",
+                "hash": "6664bc60523a8c7c08690f6b800d8d57d830605b9c25d2ce41132c422b0c6e29"
+            }
+        }
+    },
+    "name": "obs-plugintemplate",
+    "version": "1.0.0"
+}

+ 444 - 0
cmake/ObsPluginHelpers.cmake

@@ -0,0 +1,444 @@
+if(POLICY CMP0087)
+  cmake_policy(SET CMP0087 NEW)
+endif()
+
+set(OBS_STANDALONE_PLUGIN_DIR ${CMAKE_SOURCE_DIR}/release)
+set(INCLUDED_LIBOBS_CMAKE_MODULES ON)
+
+include(GNUInstallDirs)
+if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
+  set(OS_MACOS ON)
+  set(OS_POSIX ON)
+elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD|OpenBSD")
+  set(OS_POSIX ON)
+  string(TOUPPER "${CMAKE_SYSTEM_NAME}" _SYSTEM_NAME_U)
+  set(OS_${_SYSTEM_NAME_U} ON)
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+  set(OS_WINDOWS ON)
+  set(OS_POSIX OFF)
+endif()
+
+# Old-Style plugin detected, find "modern" libobs variant instead and set global
+# include directories to fix "bad" plugin behaviour
+if(DEFINED LIBOBS_INCLUDE_DIR AND NOT TARGET OBS::libobs)
+  message(
+    DEPRECATION
+      "You are using an outdated method of adding 'libobs' to your project. Refer to the updated wiki on how to build and export 'libobs' and use it in your plugin projects."
+  )
+  find_package(libobs REQUIRED)
+  if(TARGET OBS::libobs)
+    set_target_properties(OBS::libobs PROPERTIES IMPORTED_GLOBAL TRUE)
+    message(STATUS "OBS: Using modern libobs target")
+
+    add_library(libobs ALIAS OBS::libobs)
+    if(OS_WINDOWS)
+      add_library(w32-pthreads ALIAS OBS::w32-pthreads)
+    endif()
+  endif()
+endif()
+
+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND (OS_WINDOWS OR OS_MACOS))
+  set(CMAKE_INSTALL_PREFIX
+      ${OBS_STANDALONE_PLUGIN_DIR}
+      CACHE STRING "Directory to install OBS plugin after building" FORCE)
+endif()
+
+if(NOT CMAKE_BUILD_TYPE)
+  set(CMAKE_BUILD_TYPE
+      "RelWithDebInfo"
+      CACHE STRING
+            "OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]" FORCE)
+  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Release RelWithDebInfo
+                                               Debug MinSizeRel)
+endif()
+
+if(NOT QT_VERSION)
+  set(QT_VERSION
+      "5"
+      CACHE STRING "OBS Qt version [5, 6]" FORCE)
+  set_property(CACHE QT_VERSION PROPERTY STRINGS 5 6)
+endif()
+
+macro(find_qt)
+  set(oneValueArgs VERSION)
+  set(multiValueArgs COMPONENTS COMPONENTS_WIN COMPONENTS_MAC COMPONENTS_LINUX)
+  cmake_parse_arguments(FIND_QT "" "${oneValueArgs}" "${multiValueArgs}"
+                        ${ARGN})
+
+  if(OS_WINDOWS)
+    find_package(
+      Qt${FIND_QT_VERSION}
+      COMPONENTS ${FIND_QT_COMPONENTS} ${FIND_QT_COMPONENTS_WIN}
+      REQUIRED)
+  elseif(OS_MACOS)
+    find_package(
+      Qt${FIND_QT_VERSION}
+      COMPONENTS ${FIND_QT_COMPONENTS} ${FIND_QT_COMPONENTS_MAC}
+      REQUIRED)
+  else()
+    find_package(
+      Qt${FIND_QT_VERSION}
+      COMPONENTS ${FIND_QT_COMPONENTS} ${FIND_QT_COMPONENTS_LINUX}
+      REQUIRED)
+  endif()
+
+  foreach(_COMPONENT IN LISTS FIND_QT_COMPONENTS FIND_QT_COMPONENTS_WIN
+                              FIND_QT_COMPONENTS_MAC FIND_QT_COMPONENTS_LINUX)
+    if(NOT TARGET Qt::${_COMPONENT} AND TARGET
+                                        Qt${FIND_QT_VERSION}::${_COMPONENT})
+
+      add_library(Qt::${_COMPONENT} INTERFACE IMPORTED)
+      set_target_properties(
+        Qt::${_COMPONENT} PROPERTIES INTERFACE_LINK_LIBRARIES
+                                     "Qt${FIND_QT_VERSION}::${_COMPONENT}")
+    endif()
+  endforeach()
+endmacro()
+
+find_qt(VERSION ${QT_VERSION} COMPONENTS Widgets Core)
+
+file(RELATIVE_PATH RELATIVE_INSTALL_PATH ${CMAKE_SOURCE_DIR}
+     ${CMAKE_INSTALL_PREFIX})
+file(RELATIVE_PATH RELATIVE_BUILD_PATH ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
+
+# Set up OS-specific environment and helper functions
+if(OS_MACOS)
+  find_program(CCACHE_PROGRAM "ccache")
+  set(CCACHE_SUPPORT
+      ON
+      CACHE BOOL "Enable ccache support")
+  mark_as_advanced(CCACHE_PROGRAM)
+  if(CCACHE_PROGRAM AND CCACHE_SUPPORT)
+    set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
+    set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
+    set(CMAKE_OBJC_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
+    set(CMAKE_OBJCXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
+    set(CMAKE_CUDA_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) # CMake 3.9+
+  endif()
+
+  set(CMAKE_OSX_ARCHITECTURES
+      "x86_64"
+      CACHE STRING
+            "OBS build architecture for macOS - x86_64 required at least")
+  set_property(CACHE CMAKE_OSX_ARCHITECTURES PROPERTY STRINGS x86_64 arm64
+                                                      "x86_64;arm64")
+
+  set(CMAKE_OSX_DEPLOYMENT_TARGET
+      "10.13"
+      CACHE STRING "OBS deployment target for macOS - 10.15+ required")
+  set_property(CACHE CMAKE_OSX_DEPLOYMENT_TARGET PROPERTY STRINGS 10.15 11 12)
+
+  set(OBS_BUNDLE_CODESIGN_IDENTITY
+      "-"
+      CACHE STRING "OBS code signing identity for macOS")
+  set(OBS_CODESIGN_ENTITLEMENTS
+      ${CMAKE_SOURCE_DIR}/cmake/bundle/macos/entitlements.plist
+      CACHE INTERNAL "Path to codesign entitlements plist")
+  set(OBS_CODESIGN_LINKER
+      ON
+      CACHE BOOL "Enable linker code-signing on macOS (macOS 11+ required)")
+
+  # Xcode configuration
+  if(XCODE)
+    # Tell Xcode to pretend the linker signed binaries so that editing with
+    # install_name_tool preserves ad-hoc signatures. This option is supported by
+    # codesign on macOS 11 or higher. See CMake Issue 21854:
+    # https://gitlab.kitware.com/cmake/cmake/-/issues/21854
+
+    set(CMAKE_XCODE_GENERATE_SCHEME ON)
+    if(OBS_CODESIGN_LINKER)
+      set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "-o linker-signed")
+    endif()
+  endif()
+
+  # Set default options for bundling on macOS
+  set(CMAKE_MACOSX_RPATH ON)
+  set(CMAKE_SKIP_BUILD_RPATH OFF)
+  set(CMAKE_BUILD_WITH_INSTALL_RPATH OFF)
+  set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks/")
+  set(CMAKE_INSTALL_RPATH_USE_LINK_PATH OFF)
+
+  function(setup_plugin_target target)
+    if(NOT DEFINED MACOSX_PLUGIN_GUI_IDENTIFIER)
+      message(
+        FATAL_ERROR
+          "No 'MACOSX_PLUGIN_GUI_IDENTIFIER' set, but is required to build plugin bundles on macOS - example: 'com.yourname.pluginname'"
+      )
+    endif()
+
+    if(NOT DEFINED MACOSX_PLUGIN_BUNDLE_VERSION)
+      message(
+        FATAL_ERROR
+          "No 'MACOSX_PLUGIN_BUNDLE_VERSION' set, but is required to build plugin bundles on macOS - example: '25'"
+      )
+    endif()
+
+    if(NOT DEFINED MACOSX_PLUGIN_SHORT_VERSION_STRING)
+      message(
+        FATAL_ERROR
+          "No 'MACOSX_PLUGIN_SHORT_VERSION_STRING' set, but is required to build plugin bundles on macOS - example: '1.0.2'"
+      )
+    endif()
+
+    set(MACOSX_PLUGIN_BUNDLE_NAME
+        "${target}"
+        PARENT_SCOPE)
+    set(MACOSX_PLUGIN_BUNDLE_VERSION
+        "${MACOSX_BUNDLE_BUNDLE_VERSION}"
+        PARENT_SCOPE)
+    set(MACOSX_PLUGIN_SHORT_VERSION_STRING
+        "${MACOSX_BUNDLE_SHORT_VERSION_STRING}"
+        PARENT_SCOPE)
+    set(MACOSX_PLUGIN_EXECUTABLE_NAME
+        "${target}"
+        PARENT_SCOPE)
+    set(MACOSX_PLUGIN_BUNDLE_TYPE
+        "BNDL"
+        PARENT_SCOPE)
+
+    install(
+      TARGETS ${target}
+      LIBRARY DESTINATION "."
+              COMPONENT obs_plugins
+              NAMELINK_COMPONENT ${target}_Development)
+
+    set(_COMMAND
+        "${CMAKE_INSTALL_NAME_TOOL} \\
+      -change ${CMAKE_PREFIX_PATH}/lib/QtWidgets.framework/Versions/${QT_VERSION}/QtWidgets @rpath/QtWidgets.framework/Versions/${QT_VERSION}/QtWidgets \\
+      -change ${CMAKE_PREFIX_PATH}/lib/QtCore.framework/Versions/${QT_VERSION}/QtCore @rpath/QtCore.framework/Versions/${QT_VERSION}/QtCore \\
+      -change ${CMAKE_PREFIX_PATH}/lib/QtGui.framework/Versions/${QT_VERSION}/QtGui @rpath/QtGui.framework/Versions/${QT_VERSION}/QtGui \\
+      \\\"\${CMAKE_INSTALL_PREFIX}/${target}.plugin/Contents/MacOS/${target}\\\""
+    )
+    install(CODE "execute_process(COMMAND /bin/sh -c \"${_COMMAND}\")"
+            COMPONENT obs_plugins)
+
+    if(NOT XCODE)
+      set(_COMMAND
+          "/usr/bin/codesign --force \\
+          --sign \\\"${OBS_BUNDLE_CODESIGN_IDENTITY}\\\" \\
+          --options runtime \\
+          --entitlements \\\"${CMAKE_CURRENT_FUNCTION_LIST_DIR}/bundle/macOS/entitlements.plist\\\" \\
+          \\\"${CMAKE_INSTALL_PREFIX}/${target}.plugin\\\"")
+      install(CODE "execute_process(COMMAND /bin/sh -c \"${_COMMAND}\")"
+              COMPONENT obs_plugins)
+    endif()
+
+    set_target_properties(
+      ${target}
+      PROPERTIES
+        BUNDLE ON
+        BUNDLE_EXTENSION "plugin"
+        OUTPUT_NAME ${target}
+        MACOSX_BUNDLE_INFO_PLIST
+        "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/bundle/macOS/Plugin-Info.plist.in"
+        XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER
+        "${MACOSX_PLUGIN_GUI_IDENTIFIER}"
+        XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "${OBS_BUNDLE_CODESIGN_IDENTITY}"
+        XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS
+        "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/bundle/macOS/entitlements.plist")
+
+    add_custom_command(
+      TARGET ${target}
+      POST_BUILD
+      COMMAND
+        /bin/sh -c
+        "codesign --force --sign \"-\" $<$<BOOL:${OBS_CODESIGN_LINKER}>:--options linker-signed >\"$<TARGET_BUNDLE_DIR:${target}>\""
+      COMMENT "Codesigning ${target}"
+      VERBATIM)
+
+    install_bundle_resources(${target})
+  endfunction()
+
+  function(install_bundle_resources 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)
+        file(RELATIVE_PATH _RELATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/data/
+             ${_DATA_FILE})
+        get_filename_component(_RELATIVE_PATH ${_RELATIVE_PATH} PATH)
+        target_sources(${target} PRIVATE ${_DATA_FILE})
+        set_source_files_properties(
+          ${_DATA_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION
+                                   Resources/${_RELATIVE_PATH})
+        string(REPLACE "\\" "\\\\" _GROUP_NAME ${_RELATIVE_PATH})
+        source_group("Resources\\${_GROUP_NAME}" FILES ${_DATA_FILE})
+      endforeach()
+    endif()
+  endfunction()
+else()
+  if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+    set(_ARCH_SUFFIX 64)
+  else()
+    set(_ARCH_SUFFIX 32)
+  endif()
+  set(OBS_OUTPUT_DIR ${CMAKE_BINARY_DIR}/rundir)
+
+  if(OS_POSIX)
+    find_program(CCACHE_PROGRAM "ccache")
+    set(CCACHE_SUPPORT
+        ON
+        CACHE BOOL "Enable ccache support")
+    mark_as_advanced(CCACHE_PROGRAM)
+    if(CCACHE_PROGRAM AND CCACHE_SUPPORT)
+      set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
+      set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
+      set(CMAKE_OBJC_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
+      set(CMAKE_OBJCXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
+      set(CMAKE_CUDA_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) # CMake 3.9+
+    endif()
+
+    option(LINUX_PORTABLE "Build portable version (Linux)" OFF)
+    if(NOT LINUX_PORTABLE)
+      set(OBS_LIBRARY_DESTINATION ${CMAKE_INSTALL_LIBDIR})
+      set(OBS_PLUGIN_DESTINATION ${OBS_LIBRARY_DESTINATION}/obs-plugins)
+      set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
+      set(OBS_DATA_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/obs)
+    else()
+      set(OBS_LIBRARY_DESTINATION bin/${_ARCH_SUFFIX}bit)
+      set(OBS_PLUGIN_DESTINATION obs-plugins/${_ARCH_SUFFIX}bit)
+      set(CMAKE_INSTALL_RPATH
+          "$ORIGIN/" "${CMAKE_INSTALL_PREFIX}/${OBS_LIBRARY_DESTINATION}")
+      set(OBS_DATA_DESTINATION "data")
+    endif()
+
+    if(OS_LINUX)
+      set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
+      set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${LINUX_MAINTAINER_EMAIL}")
+      set(CPACK_PACKAGE_VERSION "${CMAKE_PROJECT_VERSION}")
+
+      set(CPACK_GENERATOR "DEB")
+      set(CPACK_DEBIAN_PACKAGE_DEPENDS
+          "obs-studio (>= 27.0.0), libqt5core5a (>= 5.9.0~beta), libqt5gui5 (>= 5.3.0), libqt5widgets5 (>= 5.7.0)"
+      )
+
+      set(CPACK_OUTPUT_FILE_PREFIX ${CMAKE_SOURCE_DIR}/release)
+
+      if(NOT LINUX_PORTABLE)
+        set(CPACK_SET_DESTDIR ON)
+      endif()
+      include(CPack)
+    endif()
+  else()
+    set(OBS_LIBRARY_DESTINATION "bin/${_ARCH_SUFFIX}bit")
+    set(OBS_LIBRARY32_DESTINATION "bin/32bit")
+    set(OBS_LIBRARY64_DESTINATION "bin/64bit")
+    set(OBS_PLUGIN_DESTINATION "obs-plugins/${_ARCH_SUFFIX}bit")
+    set(OBS_PLUGIN32_DESTINATION "obs-plugins/32bit")
+    set(OBS_PLUGIN64_DESTINATION "obs-plugins/64bit")
+
+    set(OBS_DATA_DESTINATION "data")
+  endif()
+
+  function(setup_plugin_target target)
+    set_target_properties(${target} PROPERTIES PREFIX "")
+
+    install(
+      TARGETS ${target}
+      RUNTIME DESTINATION "${OBS_PLUGIN_DESTINATION}"
+              COMPONENT ${target}_Runtime
+      LIBRARY DESTINATION "${OBS_PLUGIN_DESTINATION}"
+              COMPONENT ${target}_Runtime
+              NAMELINK_COMPONENT ${target}_Development)
+
+    install(
+      FILES $<TARGET_FILE:${target}>
+      DESTINATION $<CONFIG>/${OBS_PLUGIN_DESTINATION}
+      COMPONENT obs_rundir
+      EXCLUDE_FROM_ALL)
+
+    if(OS_WINDOWS)
+      install(
+        FILES $<TARGET_PDB_FILE:${target}>
+        CONFIGURATIONS "RelWithDebInfo" "Debug"
+        DESTINATION ${OBS_PLUGIN_DESTINATION}
+        COMPONENT ${target}_Runtime
+        OPTIONAL)
+
+      install(
+        FILES $<TARGET_PDB_FILE:${target}>
+        CONFIGURATIONS "RelWithDebInfo" "Debug"
+        DESTINATION $<CONFIG>/${OBS_PLUGIN_DESTINATION}
+        COMPONENT obs_rundir
+        OPTIONAL EXCLUDE_FROM_ALL)
+    endif()
+
+    if(MSVC)
+      target_link_options(
+        ${target}
+        PRIVATE
+        "LINKER:/OPT:REF"
+        "$<$<NOT:$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>>:LINKER\:/SAFESEH\:NO>"
+        "$<$<CONFIG:DEBUG>:LINKER\:/INCREMENTAL:NO>"
+        "$<$<CONFIG:RELWITHDEBINFO>:LINKER\:/INCREMENTAL:NO>")
+    endif()
+
+    setup_target_resources(${target} obs-plugins/${target})
+
+    if(OS_WINDOWS AND DEFINED OBS_BUILD_DIR)
+      setup_target_for_testing(${target} obs-plugins/${target})
+    endif()
+
+    add_custom_command(
+      TARGET ${target}
+      POST_BUILD
+      COMMAND
+        "${CMAKE_COMMAND}" -DCMAKE_INSTALL_PREFIX=${OBS_OUTPUT_DIR}
+        -DCMAKE_INSTALL_COMPONENT=obs_rundir
+        -DCMAKE_INSTALL_CONFIG_NAME=$<CONFIG> -P
+        ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake
+      COMMENT "Installing to plugin rundir"
+      VERBATIM)
+  endfunction()
+
+  function(setup_target_resources target destination)
+    if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/data)
+      install(
+        DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/
+        DESTINATION ${OBS_DATA_DESTINATION}/${destination}
+        USE_SOURCE_PERMISSIONS
+        COMPONENT obs_plugins)
+
+      install(
+        DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data
+        DESTINATION $<CONFIG>/${OBS_DATA_DESTINATION}/${destination}
+        USE_SOURCE_PERMISSIONS
+        COMPONENT obs_rundir
+        EXCLUDE_FROM_ALL)
+    endif()
+  endfunction()
+
+  if(OS_WINDOWS)
+    function(setup_target_for_testing target destination)
+      install(
+        FILES $<TARGET_FILE:${target}>
+        DESTINATION $<CONFIG>/${OBS_PLUGIN_DESTINATION}
+        COMPONENT obs_testing
+        EXCLUDE_FROM_ALL)
+
+      install(
+        FILES $<TARGET_PDB_FILE:${target}>
+        CONFIGURATIONS "RelWithDebInfo" "Debug"
+        DESTINATION $<CONFIG>/${OBS_PLUGIN_DESTINATION}
+        COMPONENT obs_testing
+        OPTIONAL EXCLUDE_FROM_ALL)
+
+      install(
+        DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/
+        DESTINATION $<CONFIG>/${OBS_DATA_DESTINATION}/${destination}
+        USE_SOURCE_PERMISSIONS
+        COMPONENT obs_testing
+        EXCLUDE_FROM_ALL)
+
+      add_custom_command(
+        TARGET ${target}
+        POST_BUILD
+        COMMAND
+          "${CMAKE_COMMAND}" -DCMAKE_INSTALL_PREFIX=${OBS_BUILD_DIR}/rundir
+          -DCMAKE_INSTALL_COMPONENT=obs_testing
+          -DCMAKE_INSTALL_CONFIG_NAME=$<CONFIG> -P
+          ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake
+        COMMENT "Installing to OBS test directory"
+        VERBATIM)
+    endfunction()
+  endif()
+endif()

+ 0 - 0
bundle/macOS/Plugin-Info.plist.in → cmake/bundle/macos/Plugin-Info.plist.in


+ 0 - 0
bundle/macOS/entitlements.plist → cmake/bundle/macos/entitlements.plist


+ 0 - 0
bundle/installer-macOS.pkgproj.in → cmake/bundle/macos/installer-macOS.pkgproj.in


+ 0 - 0
installer/installer-Windows.iss.in → cmake/bundle/windows/installer-Windows.iss.in


+ 0 - 274
external/ObsPluginHelpers.cmake

@@ -1,274 +0,0 @@
-if(POLICY CMP0087)
-	cmake_policy(SET CMP0087 NEW)
-endif()
-
-set(OBS_STANDALONE_PLUGIN_DIR "${CMAKE_SOURCE_DIR}/release")
-set(INCLUDED_LIBOBS_CMAKE_MODULES ON)
-
-include(GNUInstallDirs)
-if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
-	set(OS_MACOS ON)
-	set(OS_POSIX ON)
-elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux|FreeBSD|OpenBSD")
-	set(OS_POSIX ON)
-	string(TOUPPER "${CMAKE_SYSTEM_NAME}" _SYSTEM_NAME_U)
-	set(OS_${_SYSTEM_NAME_U} ON)
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
-	set(OS_WINDOWS ON)
-	set(OS_POSIX OFF)
-endif()
-
-# Old-Style plugin detected, find "modern" libobs variant instead and set
-# global include directories to fix "bad" plugin behaviour
-if(DEFINED LIBOBS_INCLUDE_DIR AND NOT TARGET OBS::libobs)
-	message(DEPRECATION "You are using an outdated method of adding 'libobs' to your project. Refer to the updated wiki on how to build and export 'libobs' and use it in your plugin projects.")
-	find_package(libobs REQUIRED)
-	if(TARGET OBS::libobs)
-		set_target_properties(OBS::libobs PROPERTIES IMPORTED_GLOBAL TRUE)
-		message(STATUS "OBS: Using modern libobs target")
-
-		add_library(libobs ALIAS OBS::libobs)
-		if(OS_WINDOWS)
-			add_library(w32-pthreads ALIAS OBS::w32-pthreads)
-		endif()
-	endif()
-endif()
-
-if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND (OS_WINDOWS OR OS_MACOS))
-	set(CMAKE_INSTALL_PREFIX "${OBS_STANDALONE_PLUGIN_DIR}" CACHE STRING "Directory to install OBS plugin after building" FORCE)
-endif()
-
-if(NOT CMAKE_BUILD_TYPE)
-	set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
-		"OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]" FORCE)
-	set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Release RelWithDebInfo Debug MinSizeRel)
-endif()
-
-file(RELATIVE_PATH RELATIVE_INSTALL_PATH "${CMAKE_SOURCE_DIR}" "${CMAKE_INSTALL_PREFIX}")
-file(RELATIVE_PATH RELATIVE_BUILD_PATH "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}")
-
-# Set-up OS-specific environment and helper functions
-if(OS_MACOS)
-	if(NOT CMAKE_OSX_ARCHITECTURES)
-		set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "OBS plugin build architecture for macOS - x86_64 required at least" FORCE)
-	endif()
-
-	if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
-		set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "OBS plugin deployment target for macOS - 10.13+ required" FORCE)
-	endif()
-
-	if(NOT DEFINED OBS_CODESIGN_LINKER)
-		set(OBS_CODESIGN_LINKER ON CACHE BOOL "Enable linker code-signing on macOS (v11+ required" FORCE)
-	endif()
-
-	if(NOT DEFINED OBS_BUNDLE_CODESIGN_IDENTITY)
-		set(OBS_BUNDLE_CODESIGN_IDENTITY "-" CACHE STRING "Codesign identity for macOS" FORCE)
-	endif()
-
-	# Xcode configuration
-	if(XCODE)
-		# Tell Xcode to pretend the linker signed binaries so that
-		# editing with install_name_tool preserves ad-hoc signatures.
-		# See CMake Issue 21854.
-		# This option is supported by codesign on macOS 11 or higher.
-		set(CMAKE_XCODE_GENERATE_SCHEME ON)
-		if(OBS_CODESIGN_LINKER)
-			set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "-o linker-signed")
-		endif()
-	endif()
-
-	# Set default options for bundling on macOS
-	set(CMAKE_MACOSX_RPATH ON)
-	set(CMAKE_SKIP_BUILD_RPATH OFF)
-	set(CMAKE_BUILD_WITH_INSTALL_RPATH OFF)
-	set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks/")
-	set(CMAKE_INSTALL_RPATH_USE_LINK_PATH OFF)
-
-	function(setup_plugin_target target)
-		if(NOT DEFINED MACOSX_PLUGIN_GUI_IDENTIFIER)
-			message(FATAL_ERROR "No 'MACOSX_PLUGIN_GUI_IDENTIFIER' set, but is required to build plugin bundles on macOS - example: 'com.yourname.pluginname'")
-		endif()
-
-		if(NOT DEFINED MACOSX_PLUGIN_BUNDLE_VERSION)
-			message(FATAL_ERROR "No 'MACOSX_PLUGIN_BUNDLE_VERSION' set, but is required to build plugin bundles on macOS - example: '25'")
-		endif()
-
-		if(NOT DEFINED MACOSX_PLUGIN_SHORT_VERSION_STRING)
-			message(FATAL_ERROR "No 'MACOSX_PLUGIN_SHORT_VERSION_STRING' set, but is required to build plugin bundles on macOS - example: '1.0.2'")
-		endif()
-
-		set(MACOSX_PLUGIN_BUNDLE_NAME "${target}" PARENT_SCOPE)
-		set(MACOSX_PLUGIN_BUNDLE_VERSION "${MACOSX_BUNDLE_BUNDLE_VERSION}" PARENT_SCOPE)
-		set(MACOSX_PLUGIN_SHORT_VERSION_STRING "${MACOSX_BUNDLE_SHORT_VERSION_STRING}" PARENT_SCOPE)
-		set(MACOSX_PLUGIN_EXECUTABLE_NAME "${target}" PARENT_SCOPE)
-		set(MACOSX_PLUGIN_BUNDLE_TYPE "BNDL" PARENT_SCOPE)
-
-		install(TARGETS ${target}
-			LIBRARY DESTINATION "."
-				COMPONENT obs_plugins
-				NAMELINK_COMPONENT ${target}_Development)
-
-		install(CODE
-			"execute_process(COMMAND /bin/sh -c \"install_name_tool \\
-			-change ${CMAKE_PREFIX_PATH}/lib/QtWidgets.framework/Versions/5/QtWidgets @rpath/QtWidgets.framework/Versions/5/QtWidgets \\
-			-change ${CMAKE_PREFIX_PATH}/lib/QtCore.framework/Versions/5/QtCore @rpath/QtCore.framework/Versions/5/QtCore \\
-			-change ${CMAKE_PREFIX_PATH}/lib/QtGui.framework/Versions/5/QtGui @rpath/QtGui.framework/Versions/5/QtGui \\
-			${CMAKE_INSTALL_PREFIX}/${target}.plugin/Contents/MacOS/${target}\")")
-
-		if(NOT XCODE)
-			install(CODE
-				"execute_process(COMMAND /bin/sh -c \"/usr/bin/codesign --force --sign \\\"${OBS_BUNDLE_CODESIGN_IDENTITY}\\\" --options runtime --entitlements ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../bundle/macOS/entitlements.plist ${CMAKE_INSTALL_PREFIX}/${target}.plugin\")")
-		endif()
-
-		set_target_properties(${target} PROPERTIES
-			BUNDLE ON
-			BUNDLE_EXTENSION "plugin"
-			OUTPUT_NAME ${target}
-			MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../bundle/macOS/Plugin-Info.plist.in"
-			XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${MACOSX_PLUGIN_GUI_IDENTIFIER}"
-			XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "${OBS_BUNDLE_CODESIGN_IDENTITY}"
-			XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../bundle/macOS/entitlements.plist")
-
-		add_custom_command(TARGET ${target} POST_BUILD
-			COMMAND /bin/sh -c "codesign --force --sign \"-\" $<$<BOOL:${OBS_CODESIGN_LINKER}>:--options linker-signed >\"$<TARGET_BUNDLE_DIR:${target}>\""
-			COMMENT "Codesigning ${target}"
-			VERBATIM)
-
-		install_bundle_resources(${target})
-	endfunction()
-
-	function(install_bundle_resources 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)
-				file(RELATIVE_PATH _RELATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/data/ ${_DATA_FILE})
-				get_filename_component(_RELATIVE_PATH "${_RELATIVE_PATH}" PATH)
-				target_sources(${target}
-					PRIVATE ${_DATA_FILE})
-				set_source_files_properties(${_DATA_FILE} PROPERTIES
-					MACOSX_PACKAGE_LOCATION "Resources/${_RELATIVE_PATH}")
-				string(REPLACE "\\" "\\\\" _GROUP_NAME "${_RELATIVE_PATH}")
-				source_group("Resources\\${_GROUP_NAME}" FILES ${_DATA_FILE})
-			endforeach()
-		endif()
-	endfunction()
-else()
-	if(CMAKE_SIZEOF_VOID_P EQUAL 8)
-		set(_ARCH_SUFFIX 64)
-	else()
-		set(_ARCH_SUFFIX 32)
-	endif()
-	set(OBS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/rundir")
-
-	if(OS_POSIX)
-		IF(NOT LINUX_PORTABLE)
-			set(OBS_LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}")
-			set(OBS_PLUGIN_DESTINATION "${OBS_LIBRARY_DESTINATION}/obs-plugins")
-			set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
-			set(OBS_DATA_DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/obs")
-		else()
-			set(OBS_LIBRARY_DESTINATION "bin/${_ARCH_SUFFIX}bit")
-			set(OBS_PLUGIN_DESTINATION "obs-plugins/${_ARCH_SUFFIX}bit")
-			set(CMAKE_INSTALL_RPATH "$ORIGIN/" "${CMAKE_INSTALL_PREFIX}/${OBS_LIBRARY_DESTINATION}")
-			set(OBS_DATA_DESTINATION "data")
-		endif()
-
-		if(OS_LINUX)
-			set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
-			set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${LINUX_MAINTAINER_EMAIL}")
-			set(CPACK_PACKAGE_VERSION "${CMAKE_PROJECT_VERSION}")
-
-			set(CPACK_GENERATOR "DEB")
-			set(CPACK_DEBIAN_PACKAGE_DEPENDS
-				"obs-studio (>= 27.0.0), libqt5core5a (>= 5.9.0~beta), \
-				libqt5gui5 (>= 5.3.0), libqt5widgets5 (>= 5.7.0)")
-
-			if(NOT LINUX_PORTABLE)
-				set(CPACK_SET_DESTDIR ON)
-			endif()
-			include(CPack)
-		endif()
-	else()
-		set(OBS_LIBRARY_DESTINATION "bin/${_ARCH_SUFFIX}bit")
-		set(OBS_LIBRARY32_DESTINATION "bin/32bit")
-		set(OBS_LIBRARY64_DESTINATION "bin/64bit")
-		set(OBS_PLUGIN_DESTINATION "obs-plugins/${_ARCH_SUFFIX}bit")
-		set(OBS_PLUGIN32_DESTINATION "obs-plugins/32bit")
-		set(OBS_PLUGIN64_DESTINATION "obs-plugins/64bit")
-
-		set(OBS_DATA_DESTINATION "data")
-	endif()
-
-	function(setup_plugin_target target)
-		set_target_properties(${target} PROPERTIES
-			PREFIX "")
-
-		install(TARGETS ${target}
-			RUNTIME DESTINATION "${OBS_PLUGIN_DESTINATION}"
-				COMPONENT ${target}_Runtime
-			LIBRARY DESTINATION "${OBS_PLUGIN_DESTINATION}"
-				COMPONENT ${target}_Runtime
-				NAMELINK_COMPONENT ${target}_Development)
-
-		add_custom_command(TARGET ${target} POST_BUILD
-			COMMAND "${CMAKE_COMMAND}" -E copy
-				"$<TARGET_FILE:${target}>"
-				"${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/$<TARGET_FILE_NAME:${target}>"
-			VERBATIM)
-
-		if(OS_WINDOWS)
-			add_custom_command(TARGET ${target} POST_BUILD
-				COMMAND "${CMAKE_COMMAND}" -E "$<IF:$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>,copy,true>"
-					"$<TARGET_PDB_FILE:${target}>"
-					"${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/"
-				VERBATIM)
-		endif()
-
-		if(MSVC)
-			target_link_options(${target}
-				PRIVATE
-					"LINKER:/OPT:REF"
-					"$<$<NOT:$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>>:LINKER\:/SAFESEH\:NO>"
-					"$<$<CONFIG:DEBUG>:LINKER\:/INCREMENTAL:NO>"
-					"$<$<CONFIG:RELWITHDEBINFO>:LINKER\:/INCREMENTAL:NO>")
-		endif()
-
-		setup_target_resources("${target}" "obs-plugins/${target}")
-
-		if(OS_WINDOWS AND DEFINED OBS_BUILD_DIR)
-			setup_target_for_testing(${target})
-		endif()
-	endfunction()
-
-	function(setup_target_resources target destination)
-		if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/data")
-			install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/"
-				DESTINATION "${OBS_DATA_DESTINATION}/${destination}"
-				USE_SOURCE_PERMISSIONS)
-
-			add_custom_command(TARGET ${target} POST_BUILD
-				COMMAND "${CMAKE_COMMAND}" -E copy_directory
-					"${CMAKE_CURRENT_SOURCE_DIR}/data"
-					"${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_DATA_DESTINATION}/${destination}"
-				VERBATIM)
-		endif()
-	endfunction()
-
-	if(OS_WINDOWS)
-		function(setup_target_for_testing target)
-			add_custom_command(TARGET ${target} POST_BUILD
-				COMMAND "${CMAKE_COMMAND}" -E copy
-					"$<TARGET_FILE:${target}>"
-					"${OBS_BUILD_DIR}/rundir/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/$<TARGET_FILE_NAME:${target}>"
-				COMMAND "${CMAKE_COMMAND}" -E "$<IF:$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>,copy,true>"
-					"$<TARGET_PDB_FILE:${target}>"
-					"${OBS_BUILD_DIR}/rundir/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/$<TARGET_FILE_NAME:${target}>"
-				COMMAND "${CMAKE_COMMAND}" -E make_directory
-					"${OBS_BUILD_DIR}/rundir/$<CONFIG>/${OBS_DATA_DESTINATION}/obs-plugins/${target}"
-				COMMAND "${CMAKE_COMMAND}" -E copy_directory
-					"${CMAKE_CURRENT_SOURCE_DIR}/data"
-					"${OBS_BUILD_DIR}/rundir/$<CONFIG>/${OBS_DATA_DESTINATION}/obs-plugins/${target}"
-				VERBATIM)
-		endfunction()
-	endif()
-endif()