diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fc0f5f..d1ca98a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,140 +1,109 @@ -# Copyright (C) 2017 - 2021 Michael Fabian 'Xaymar' Dirks -# Copyright (C) 2020 - 2021 Corsair GmbH -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -# CMake Setup cmake_minimum_required(VERSION 3.8...4.0) -################################################################################ -# Configure Type -################################################################################ - -# Detect if we are building by ourselves or as part of something else. -if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}") - set(GROUPED OFF) - set(PREFIX "") -else() - set(GROUPED ON) - set(PREFIX "StreamDeck_") -endif() -set(LOGPREFIX "StreamDeck:") - ################################################################################ # Versioning ################################################################################ set(VERSION_MAJOR 5) -set(VERSION_MINOR 0) -set(VERSION_PATCH 5) +set(VERSION_MINOR 3) +set(VERSION_PATCH 2) set(VERSION_TWEAK 0) set(VERSION_SUFFIX "") set(VERSION_COMMIT "00000000") # Check if we are in a git repository. if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git") - # Try and figure out where git is. - find_program(GIT git - PATHS - /bin - /sbin - /usr/bin - /usr/local/bin - ) - - if(GIT) - set(GIT_RESULT) - set(GIT_OUTPUT) - set(GIT_ERROR) - - execute_process( - COMMAND "${GIT}" describe --tags --long --match "[0-9]*.[0-9]*.[0-9]*" --abbrev=8 HEAD - WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} - RESULT_VARIABLE GIT_RESULT - OUTPUT_VARIABLE GIT_OUTPUT - ERROR_VARIABLE GIT_ERROR - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_STRIP_TRAILING_WHITESPACE - ERROR_QUIET - ) - - if(GIT_RESULT EQUAL 0) - string(REPLACE "-" "." GIT_OUTPUT "${GIT_OUTPUT}") - string(REPLACE "." ";" GIT_OUTPUT "${GIT_OUTPUT}") - - # Parse Version - list(GET GIT_OUTPUT 0 VERSION_MAJOR) - list(GET GIT_OUTPUT 1 VERSION_MINOR) - list(GET GIT_OUTPUT 2 VERSION_PATCH) - list(GET GIT_OUTPUT 3 VERSION_TWEAK) - list(GET GIT_OUTPUT 4 VERSION_COMMIT) - - # Patch needs additional parsing. - # This may be a [0-9]*[a-z]*[0-9]+ string. - string(REGEX MATCHALL "^([0-9]+)([a-z]+[0-9]+)?" T_MATCHES "${VERSION_PATCH}") - set(VERSION_PATCH "${CMAKE_MATCH_1}") - if(CMAKE_MATCH_2) - set(VERSION_SUFFIX "${CMAKE_MATCH_2}") - else() - set(VERSION_SUFFIX "") - endif() - else() - message(WARNING "${LOGPREFIX} Failed to detect version, using default instead.") - endif() - endif() + # Try and figure out where git is. + find_program(GIT git + PATHS + /bin + /sbin + /usr/bin + /usr/local/bin + ) + + if(GIT) + set(GIT_RESULT) + set(GIT_OUTPUT) + set(GIT_ERROR) + + execute_process( + COMMAND "${GIT}" describe --tags --long --match "[0-9]*.[0-9]*.[0-9]*" --abbrev=8 HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + RESULT_VARIABLE GIT_RESULT + OUTPUT_VARIABLE GIT_OUTPUT + ERROR_VARIABLE GIT_ERROR + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) + + if(GIT_RESULT EQUAL 0) + string(REPLACE "-" "." GIT_OUTPUT "${GIT_OUTPUT}") + string(REPLACE "." ";" GIT_OUTPUT "${GIT_OUTPUT}") + + # Parse Version + list(GET GIT_OUTPUT 0 VERSION_MAJOR) + list(GET GIT_OUTPUT 1 VERSION_MINOR) + list(GET GIT_OUTPUT 2 VERSION_PATCH) + list(GET GIT_OUTPUT 3 VERSION_TWEAK) + list(GET GIT_OUTPUT 4 VERSION_COMMIT) + + # Patch needs additional parsing. + # This may be a [0-9]*[a-z]*[0-9]+ string. + string(REGEX MATCHALL "^([0-9]+)([a-z]+[0-9]+)?" T_MATCHES "${VERSION_PATCH}") + set(VERSION_PATCH "${CMAKE_MATCH_1}") + if(CMAKE_MATCH_2) + set(VERSION_SUFFIX "${CMAKE_MATCH_2}") + else() + set(VERSION_SUFFIX "") + endif() + else() + message(WARNING "${LOGPREFIX} Failed to detect version, using default instead.") + endif() + endif() else() - message(STATUS "${LOGPREFIX} Not a git repository, automatic version detection disabled.") + message(STATUS "${LOGPREFIX} Not a git repository, automatic version detection disabled.") endif() # Allow manual overrides of the detected version. set(${PREFIX}VERSION "" CACHE STRING "Override StreamDeck version with this string. Format: Major.Minor.Patch[Suffix][-Tweak[-Commit8c]]") if(NOT (${PREFIX}VERSION STREQUAL "")) - string(REPLACE "-" "." T_VERSION "${${PREFIX}VERSION}") - string(REPLACE "." ";" T_VERSION "${${PREFIX}VERSION}") - - list(LENGTH T_VERSION T_VERSIONLEN) - list(GET T_VERSION 0 VERSION_MAJOR) - list(GET T_VERSION 1 VERSION_MINOR) - list(GET T_VERSION 2 VERSION_PATCH) - if (T_VERSIONLEN GREATER_EQUAL 3) - list(GET T_VERSION 3 VERSION_TWEAK) - else() - set(VERSION_BUILD 0) - endif() - if (T_VERSIONLEN GREATER_EQUAL 4) - list(GET T_VERSION 4 VERSION_COMMIT) - else() - set(VERSION_COMMIT "") - endif() - - # Patch needs additional parsing. - # This may be a [0-9]*[a-z]*[0-9]+ string. - string(REGEX MATCHALL "^([0-9]+)([a-z]+[0-9]+)?" T_MATCHES "${VERSION_PATCH}") - set(VERSION_PATCH "${CMAKE_MATCH_1}") - if(CMAKE_MATCH_2) - set(VERSION_SUFFIX "${CMAKE_MATCH_2}") - else() - set(VERSION_SUFFIX "") - endif() + string(REPLACE "-" "." T_VERSION "${${PREFIX}VERSION}") + string(REPLACE "." ";" T_VERSION "${${PREFIX}VERSION}") + + list(LENGTH T_VERSION T_VERSIONLEN) + list(GET T_VERSION 0 VERSION_MAJOR) + list(GET T_VERSION 1 VERSION_MINOR) + list(GET T_VERSION 2 VERSION_PATCH) + if (T_VERSIONLEN GREATER_EQUAL 3) + list(GET T_VERSION 3 VERSION_TWEAK) + else() + set(VERSION_BUILD 0) + endif() + if (T_VERSIONLEN GREATER_EQUAL 4) + list(GET T_VERSION 4 VERSION_COMMIT) + else() + set(VERSION_COMMIT "") + endif() + + # Patch needs additional parsing. + # This may be a [0-9]*[a-z]*[0-9]+ string. + string(REGEX MATCHALL "^([0-9]+)([a-z]+[0-9]+)?" T_MATCHES "${VERSION_PATCH}") + set(VERSION_PATCH "${CMAKE_MATCH_1}") + if(CMAKE_MATCH_2) + set(VERSION_SUFFIX "${CMAKE_MATCH_2}") + else() + set(VERSION_SUFFIX "") + endif() endif() # Generate Version String if(NOT (VERSION_COMMIT STREQUAL "")) - set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_TWEAK}${VERSION_SUFFIX}-${VERSION_COMMIT}") + set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_TWEAK}${VERSION_SUFFIX}") else() - set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_TWEAK}${VERSION_SUFFIX}") + set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_TWEAK}${VERSION_SUFFIX}") endif() # Log the detected version. @@ -143,11 +112,14 @@ message(STATUS "${LOGPREFIX} Version ${VERSION_STRING}") ################################################################################ # Project ################################################################################ + +set(PROJECT_SUFFIX "" CACHE STRING "Optional suffix for project name") + project( - StreamDeckPlugin - VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_TWEAK} - DESCRIPTION "Stream Deck integration for OBS Studio." - HOMEPAGE_URL "https://elgato.com/" + StreamDeckPlugin${PROJECT_SUFFIX} + VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_TWEAK} + DESCRIPTION "Stream Deck integration for OBS Studio." + HOMEPAGE_URL "https://elgato.com/" ) # Full Project Name @@ -156,1010 +128,20 @@ set(PROJECT_FULL_NAME "Stream Deck (for OBS Studio)") # Description set(PROJECT_DESCRIPTION "Integration for Stream Deck into OBS Studio.") -# Authors (TODO: Generate this from AUTHORS) -set(PROJECT_AUTHORS "Michael Fabian 'Xaymar' Dirks ") +# Authors +set(PROJECT_AUTHORS "Corsair Memory Inc. All Rights Reserved") -# Copyright Years (TODO: Update every year) -set(PROJECT_COPYRIGHT_YEARS "2021") +# Copyright Years +set(PROJECT_COPYRIGHT_YEARS "2022") # Versioning set(PROJECT_VERSION_STRING ${VERSION_STRING}) -################################################################################ -# Modules -################################################################################ - -# Search Paths -set(CMAKE_MODULE_PATH - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" - "${CMAKE_CURRENT_SOURCE_DIR}/cmake" -) - -# Include -include("Architecture") # Architecture Detection -include("util") # CacheClear, CacheSet -include("DownloadProject") # DownloadProject - -################################################################################ -# Platform Setup -################################################################################ - -# Operating System -if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - set(D_PLATFORM_OS "windows") - set(D_PLATFORM_WINDOWS 1) -elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(D_PLATFORM_OS "linux") - set(D_PLATFORM_LINUX 1) -elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set(D_PLATFORM_OS "macos") - set(D_PLATFORM_MAC 1) -else() - set(D_PLATFORM_OS "unknown") - set(D_PLATFORM_UNKNOWN 1) - message(WARNING "${LOGPREFIX} The operating system '${CMAKE_SYSTEM_NAME}' is unknown to to this script, continue at your own risk.") -endif() - -# Architecture -set(D_PLATFORM_INSTR ${ARCH_INST}) -if(ARCH_INST STREQUAL "x86") - set(D_PLATFORM_INSTR_X86 ON) - set(D_PLATFORM_ARCH_X86 ON) -elseif(ARCH_INST STREQUAL "ARM") - set(D_PLATFORM_INSTR_ARM ON) - set(D_PLATFORM_ARCH_ARM ON) -elseif(ARCH_INST STREQUAL "IA64") - set(D_PLATFORM_INSTR_ITANIUM ON) - set(D_PLATFORM_ARCH_ITANIUM ON) -endif() -set(D_PLATFORM_ARCH ${ARCH_INST}) - -# Bitness -set(D_PLATFORM_BITS ${ARCH_BITS}) -set(D_PLATFORM_BITS_PTR ${ARCH_BITS_POINTER}) - -################################################################################ -# C/C++ Compiler Adjustments -################################################################################ -if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) - message(STATUS "Applying custom flags for MSVC style build.") - - # MSVC/ClangCL - # - Dynamically link Microsoft C/C++ Redistributable. - # - Enable /W3 and disable useless warnings. - # - Enable C++ exceptions with SEH exceptions. - # - Enable multi-processor compiling. - - # Build with dynamic MSVC linkage. - add_compile_options( - $<$:/MD> - $<$:/MDd> - $<$:/MD> - $<$:/MD> - $<$:/MD> - ) - - # Enable most useful warnings. - set(DISABLED_WARNINGS - "/wd4061" "/wd4100" "/wd4180" "/wd4201" "/wd4464" "/wd4505" "/wd4514" - "/wd4571" "/wd4623" "/wd4625" "/wd4626" "/wd4668" "/wd4710" "/wd4774" - "/wd4820" "/wd5026" "/wd5027" "/wd5039" "/wd5045" "/wd26812" - ) - add_compile_options("/W3") - foreach(WARN ${DISABLED_WARNINGS}) - add_compile_options("${WARN}") - endforeach() - - # C++ Exceptions & SEH - add_compile_options("/EHa") - - # Multiprocessor compiling - add_compile_options("/MP") -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - message(STATUS "Applying custom flags for GNU style build.") - - # Clang/AppleClang/GNU - # - Don't export by default. (Temporarily disabled) - # - Enable all and extra warnings. - - add_compile_options("-Wall") - add_compile_options("-Wextra") - # add_compile_options("-fvisibility=hidden") -endif() - -################################################################################ -# Detect if we are building with OBS Studio (different from Grouped builds) -################################################################################ - -set(STANDALONE ON) -if(GROUPED AND (TARGET libobs)) - set(STANDALONE OFF) -endif() -if(STANDALONE) - message(STATUS "${LOGPREFIX} This is a standalone build.") - set(${PREFIX}OBS_NATIVE OFF) -else() - message(STATUS "${LOGPREFIX} This is a combined build.") - set(${PREFIX}OBS_NATIVE ON) -endif() - -################################################################################ -# Options -################################################################################ - -## Code Related -set(${PREFIX}ENABLE_CLANG ON CACHE BOOL "Enable Clang integration for supported compilers.") -set(${PREFIX}ENABLE_CODESIGN OFF CACHE BOOL "Enable Code Signing integration for supported environments.") -# Installation / Packaging -if(STANDALONE) - set(STRUCTURE_UNIFIED CACHE BOOL "Install for use in a Plugin Manager") - if(D_PLATFORM_LINUX) - set(STRUCTURE_PACKAGEMANAGER CACHE BOOL "Install for use in a Package Manager (system-wide installation)") - endif() +set(BUILD_OLD "" CACHE BOOL "Build with the old CMake file?") - set(PACKAGE_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "Where to place the packages?") - set(PACKAGE_NAME "${PROJECT_NAME}" CACHE STRING "What should the package be called?") - set(PACKAGE_SUFFIX "" CACHE STRING "Any suffix for the package name? (Defaults to the current version string)") -endif() - -################################################################################ -# Clang -################################################################################ - -if(${PREFIX}ENABLE_CLANG AND (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/clang/Clang.cmake")) - include("cmake/clang/Clang.cmake") - set(HAVE_CLANG ON) -endif() - -################################################################################ -# Codesign -################################################################################ - -if(${PREFIX}ENABLE_CODESIGN AND (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/codesign/CodeSign.cmake")) - include("cmake/codesign/CodeSign.cmake") - set(HAVE_CODESIGN ON) - - set(${PREFIX}CODESIGN_FILE "" CACHE FILEPATH "Path to Code-Signing certificate.") - if(WIN32) - set(${PREFIX}CODESIGN_NAME "" CACHE STRING "Name of Code-Signing certificate in Windows's certificate storage.") - endif() - set(${PREFIX}CODESIGN_PASS "" CACHE STRING "Password for Code-Signing certificate.") - set(${PREFIX}CODESIGN_TIMESTAMPS ON CACHE BOOL "Should the resulting binary be timestamped?") - - set(_CODESIGN_FILE "$ENV{${PREFIX}CODESIGN_FILE}") - if(${PREFIX}CODESIGN_FILE) - set(_CODESIGN_FILE "${${PREFIX}CODESIGN_FILE}") - endif() - set(_CODESIGN_NAME "$ENV{${PREFIX}CODESIGN_NAME}") - if(${PREFIX}CODESIGN_NAME) - set(_CODESIGN_NAME "${${PREFIX}CODESIGN_NAME}") - endif() - set(_CODESIGN_PASS "$ENV{${PREFIX}CODESIGN_PASS}") - if(${PREFIX}CODESIGN_PASS) - set(_CODESIGN_PASS "${${PREFIX}CODESIGN_PASS}") - endif() -endif() - - -################################################################################ -# Standalone Build: OBS Studio -################################################################################ - -if(NOT ${PREFIX}OBS_NATIVE) - # Options - set(${PREFIX}DOWNLOAD_OBS_URL "" CACHE STRING "(Optional) URL of prebuilt libOBS archive to download.") - set(${PREFIX}DOWNLOAD_OBS_HASH "" CACHE STRING "(Optional) The hash for the libOBS archive.") - mark_as_advanced( - ${PREFIX}DOWNLOAD_OBS_URL - ${PREFIX}DOWNLOAD_OBS_HASH - ) - - # Allow overriding what version we build against. - if(${PREFIX}DOWNLOAD_OBS_URL) - set(_DOWNLOAD_OBS_URL "${${PREFIX}DOWNLOAD_OBS_URL}") - set(_DOWNLOAD_OBS_HASH "${${PREFIX}DOWNLOAD_OBS_HASH}") - else() - set(_DOWNLOAD_OBS_VERSION "27.0.0-ci") - if (D_PLATFORM_WINDOWS) - if (D_PLATFORM_ARCH_X86) - set(_DOWNLOAD_OBS_URL "https://github.com/Xaymar/obs-studio/releases/download/${_DOWNLOAD_OBS_VERSION}/obs-studio-x64-0.0.0.0-windows-${D_PLATFORM_ARCH}-${D_PLATFORM_BITS}.7z") - if (D_PLATFORM_BITS EQUAL 64) - set(_DOWNLOAD_OBS_HASH "SHA256=EBF9853C8A553E16ECBCA22523F401E6CF1EB2E8DA93F1493FEF41D65BD06633") - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - elseif(D_PLATFORM_LINUX) - if (D_PLATFORM_ARCH_X86) - set(_DOWNLOAD_OBS_URL "https://github.com/Xaymar/obs-studio/releases/download/${_DOWNLOAD_OBS_VERSION}/obs-studio-x64-0.0.0.0-ubuntu-${D_PLATFORM_ARCH}-${D_PLATFORM_BITS}.7z") - if (D_PLATFORM_BITS EQUAL 64) - set(_DOWNLOAD_OBS_HASH "SHA256=0AF6C7262C37D80C24CB18523A851FD765C04E766D8EB0F4AC0F6E75D13A035F") - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - elseif(D_PLATFORM_MAC) - if (D_PLATFORM_ARCH_X86) - set(_DOWNLOAD_OBS_URL "https://github.com/Xaymar/obs-studio/releases/download/${_DOWNLOAD_OBS_VERSION}/obs-studio-x64-0.0.0.0-macos-${D_PLATFORM_ARCH}-${D_PLATFORM_BITS}.7z") - if (D_PLATFORM_BITS EQUAL 64) - set(_DOWNLOAD_OBS_HASH "SHA256=F15BC4CA8EB3F581A94372759CFE554E30D202B604B541445A5756B878E4E799") - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - endif() - - # Download libOBS - download_project( - PROJ libobs - URL "${_DOWNLOAD_OBS_URL}" - URL_HASH "${_DOWNLOAD_OBS_HASH}" - DOWNLOAD_NO_PROGRESS OFF - UPDATE_DISCONNECTED OFF - ) - - include("${libobs_SOURCE_DIR}/cmake/LibObs/LibObsConfig.cmake") -endif() - -if(${PREFIX}OBS_NATIVE) - if(TARGET obs-frontend-api) - set(HAVE_OBSFE ON) - endif() +if ( ${BUILD_OLD} ) + include("OldCMake.cmake") else() - if (EXISTS "${libobs_SOURCE_DIR}/cmake/obs-frontend-api/obs-frontend-apiConfig.cmake") - include("${libobs_SOURCE_DIR}/cmake/obs-frontend-api/obs-frontend-apiConfig.cmake") - set(HAVE_OBSFE ON) - endif() -endif() - -################################################################################ -# Standalone Build: OBS Studio Dependencies -################################################################################ - -if(STANDALONE AND NOT D_PLATFORM_LINUX) - # Options - set(${PREFIX}DOWNLOAD_OBSDEPS_URL "" CACHE STRING "(Optional) URL of prebuilt libOBS archive to download.") - set(${PREFIX}DOWNLOAD_OBSDEPS_HASH "" CACHE STRING "(Optional) The hash for the libOBS archive.") - mark_as_advanced( - ${PREFIX}DOWNLOAD_OBSDEPS_URL - ${PREFIX}DOWNLOAD_OBSDEPS_HASH - ) - - # Allow overriding what version we build against. - if(${PREFIX}DOWNLOAD_OBSDEPS_URL) - set(_DOWNLOAD_OBSDEPS_URL "${${PREFIX}DOWNLOAD_OBSDEPS_URL}") - set(_DOWNLOAD_OBSDEPS_HASH "${${PREFIX}DOWNLOAD_OBSDEPS_HASH}") - else() - if (D_PLATFORM_WINDOWS) - if (D_PLATFORM_ARCH_X86) - set(_DOWNLOAD_OBSDEPS_URL "https://github.com/Xaymar/obs-studio/releases/download/27.0.0/deps-windows-x86.7z") - if (D_PLATFORM_BITS EQUAL 64) - set(_DOWNLOAD_OBSDEPS_HASH "SHA256=B4AED165016F0B64A7E8B256CCC12EAF8AF087F61B0B239B9D3D00277485B5B5") - elseif (D_PLATFORM_BITS EQUAL 32) - set(_DOWNLOAD_OBSDEPS_HASH "SHA256=B4AED165016F0B64A7E8B256CCC12EAF8AF087F61B0B239B9D3D00277485B5B5") - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - elseif(D_PLATFORM_MAC) - if (D_PLATFORM_ARCH_X86) - if (D_PLATFORM_BITS EQUAL 64) - set(_DOWNLOAD_OBSDEPS_URL "https://github.com/Xaymar/obs-studio/releases/download/27.0.0/deps-macos-x86_64-2021-03-25.tar.gz") - set(_DOWNLOAD_OBSDEPS_HASH "SHA256=1C409374BCAB9D5CEEAFC121AA327E13AB222096718AF62F2648302DF62898D6") - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - elseif(D_PLATFORM_ARCH_ARM) - if (D_PLATFORM_BITS EQUAL 64) - set(_DOWNLOAD_OBSDEPS_URL "https://github.com/Xaymar/obs-studio/releases/download/27.0.0/deps-macos-arm64-2021-03-25.tar.gz") - set(_DOWNLOAD_OBSDEPS_HASH "SHA256=C0EC57D360AF190E372D6BB883134FA26B1A7E49840DD146B172B48D548B55BC") - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - endif() - - # Download libOBS - download_project( - PROJ obsdeps - URL "${_DOWNLOAD_OBSDEPS_URL}" - URL_HASH "${_DOWNLOAD_OBSDEPS_HASH}" - DOWNLOAD_NO_PROGRESS OFF - UPDATE_DISCONNECTED OFF - ) - - if (D_PLATFORM_WINDOWS) - set(_OBSDEPS_PATH "${obsdeps_SOURCE_DIR}/win${D_PLATFORM_BITS}") - elseif(D_PLATFORM_MAC) - set(_OBSDEPS_PATH "${obsdeps_SOURCE_DIR}/obsdeps") - endif() + include("OBSTemplate.cmake") endif() - -################################################################################ -# Standalone Build: Qt v5.x -################################################################################ - -if(STANDALONE AND NOT D_PLATFORM_LINUX) - set(${PREFIX}DOWNLOAD_QT OFF CACHE BOOL "Download Qt?") - - if(${PREFIX}DOWNLOAD_QT) - set(${PREFIX}DOWNLOAD_QT_URL "" CACHE STRING "") - set(${PREFIX}DOWNLOAD_QT_HASH "" CACHE STRING "") - mark_as_advanced( - ${PREFIX}DOWNLOAD_QT_URL - ${PREFIX}DOWNLOAD_QT_HASH - ) - - # Allow overriding what version we build against. - if(${PREFIX}DOWNLOAD_QT_URL) - set(_DOWNLOAD_QT_URL "${${PREFIX}DOWNLOAD_QT_URL}") - set(_DOWNLOAD_QT_HASH "${${PREFIX}DOWNLOAD_QT_HASH}") - else() - if (D_PLATFORM_WINDOWS) - if (D_PLATFORM_ARCH_X86) - if (D_PLATFORM_BITS EQUAL 64) - set(_DOWNLOAD_QT_URL "https://github.com/Xaymar/obs-studio/releases/download/27.0.0/qt-5.15.2-windows-x86-64.7z") - set(_DOWNLOAD_QT_HASH "SHA256=109B9C21EF165B0C46DFAA9AD23124F2070ED4D74207C4AFB308183CB8D43BDD") - elseif (D_PLATFORM_BITS EQUAL 32) - set(_DOWNLOAD_QT_URL "https://github.com/Xaymar/obs-studio/releases/download/27.0.0/qt-5.15.2-windows-x86-32.7z") - set(_DOWNLOAD_QT_HASH "SHA256=372E4FBF2A15DD4FDA955A07334D8B8AC6802990148C9CB4E766C90205F8F570") - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - elseif(D_PLATFORM_MAC) - if (D_PLATFORM_ARCH_X86) - if (D_PLATFORM_BITS EQUAL 64) - set(_DOWNLOAD_QT_URL "https://github.com/Xaymar/obs-studio/releases/download/27.0.0/qt-5.15.2-macos-x86_64-2021-03-25.tar.gz") - set(_DOWNLOAD_QT_HASH "SHA256=FFABB54624B931EA3FCC06BED244895F50CEFC95DE09D792D280C46D4F91D4C5") - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - elseif(D_PLATFORM_ARCH_ARM) - if (D_PLATFORM_BITS EQUAL 64) - set(_DOWNLOAD_QT_URL "https://github.com/Xaymar/obs-studio/releases/download/27.0.0/qt-5.15.2-macos-arm64-2021-03-25.tar.gz") - set(_DOWNLOAD_QT_HASH "SHA256=366BA8AC0FA0CAC440AFB9ED1C2EF5932E50091DC43BDE8B5C4B490082B6F19F") - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - else() - message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") - return() - endif() - endif() - - download_project( - PROJ qt - URL "${_DOWNLOAD_QT_URL}" - URL_HASH "${_DOWNLOAD_QT_HASH}" - DOWNLOAD_NO_PROGRESS OFF - UPDATE_DISCONNECTED OFF - ) - - set(Qt5_DIR "${qt_SOURCE_DIR}" CACHE STRING "Path to Qt5") - if (D_PLATFORM_WINDOWS) - if (D_PLATFORM_ARCH_X86) - if (D_PLATFORM_BITS EQUAL 64) - CacheSet(Qt5_DIR "${qt_SOURCE_DIR}/lib/cmake/Qt5") - elseif (D_PLATFORM_BITS EQUAL 32) - CacheSet(Qt5_DIR "${qt_SOURCE_DIR}/lib/cmake/Qt5") - endif() - endif() - elseif(D_PLATFORM_MAC) - CacheSet(Qt5_DIR "${qt_SOURCE_DIR}/lib/cmake/Qt5") - endif() - endif() -endif() - -if(NOT Qt5_DIR) - if(ENV{Qt5_DIR}) - set(Qt5_DIR "$ENV{Qt5_DIR}") - endif() -endif() -find_package(Qt5 - REQUIRED COMPONENTS Core Widgets - CONFIG - HINTS - "${Qt5_DIR}" - "${Qt5_DIR}/lib" - "${Qt5_DIR}/lib/cmake" - "${Qt5_DIR}/lib/cmake/Qt5" -) -set(HAVE_QT ${Qt5_FOUND}) - -################################################################################ -# Code -################################################################################ -set(PROJECT_DATA_LOCALE ) -set(PROJECT_DATA_EFFECTS ) -set(PROJECT_DATA_SHADERS ) -set(PROJECT_LIBRARIES ) -set(PROJECT_LIBRARIES_DELAYED ) -set(PROJECT_INCLUDE_DIRS ) -set(PROJECT_TEMPLATES ) -set(PROJECT_PRIVATE_GENERATED ) -set(PROJECT_PRIVATE_SOURCE ) -set(PROJECT_UI ) -set(PROJECT_UI_SOURCE ) -set(PROJECT_DEFINITIONS ) - -# Configure Files -configure_file( - "templates/config.hpp.in" - "generated/config.hpp" -) -LIST(APPEND PROJECT_TEMPLATES "templates/config.hpp.in") -LIST(APPEND PROJECT_PRIVATE_GENERATED "${PROJECT_BINARY_DIR}/generated/config.hpp") - -configure_file( - "templates/version.hpp.in" - "generated/version.hpp" -) -LIST(APPEND PROJECT_TEMPLATES "templates/version.hpp.in") -LIST(APPEND PROJECT_PRIVATE_GENERATED "${PROJECT_BINARY_DIR}/generated/version.hpp") - -configure_file( - "templates/module.cpp.in" - "generated/module.cpp" -) -LIST(APPEND PROJECT_TEMPLATES "templates/module.cpp.in") -LIST(APPEND PROJECT_PRIVATE_GENERATED "${PROJECT_BINARY_DIR}/generated/module.cpp") - -if(D_PLATFORM_WINDOWS) # Windows Support - set(PROJECT_PRODUCT_NAME "${PROJECT_FULL_NAME}") - set(PROJECT_COMPANY_NAME "${PROJECT_AUTHORS}") - set(PROJECT_COPYRIGHT "${PROJECT_AUTHORS} © ${PROJECT_COPYRIGHT_YEARS}") - set(PROJECT_LEGAL_TRADEMARKS_1 "") - set(PROJECT_LEGAL_TRADEMARKS_2 "") - - configure_file( - "templates/version.rc.in" - "generated/version.rc" - @ONLY - ) - LIST(APPEND PROJECT_TEMPLATES "templates/version.rc.in") - LIST(APPEND PROJECT_PRIVATE_GENERATED "${PROJECT_BINARY_DIR}/generated/version.rc") -endif() - -# Minimum Dependencies -list(APPEND PROJECT_LIBRARIES - libobs - obs-frontend-api -) - -# Qt5 -list(APPEND PROJECT_LIBRARIES - Qt5::Core - Qt5::Widgets -) - -# Project itself -list(APPEND PROJECT_PRIVATE_SOURCE - "source/module.hpp" - "source/module.cpp" - "source/json-rpc.hpp" - "source/json-rpc.cpp" - "source/server.hpp" - "source/server.cpp" - "source/handlers/handler-system.hpp" - "source/handlers/handler-system.cpp" - "source/handlers/handler-obs-frontend.hpp" - "source/handlers/handler-obs-frontend.cpp" - "source/handlers/handler-obs-source.hpp" - "source/handlers/handler-obs-source.cpp" - "source/handlers/handler-obs-scene.hpp" - "source/handlers/handler-obs-scene.cpp" -) -list(APPEND PROJECT_INCLUDE_DIRS - "${PROJECT_BINARY_DIR}/generated" - "${PROJECT_SOURCE_DIR}/source" - "third-party/nlohmann-json/single_include/" - "third-party/websocketpp/" - "third-party/asio/asio/include" -) -list(APPEND PROJECT_UI - "ui/popup.ui" - "ui/popup.qrc" -) -list(APPEND PROJECT_UI_SOURCE - "source/details-popup.cpp" - "source/details-popup.hpp" -) -list(APPEND PROJECT_DEFINITIONS - -DASIO_STANDALONE - -D_WEBSOCKETPP_CPP11_STL_ - -DVERSION_STR=\"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}\" -) - -# Windows -if(D_PLATFORM_WINDOWS) - list(APPEND PROJECT_PRIVATE_SOURCE - "source/windll.cpp" - ) - list(APPEND PROJECT_LIBRARIES - Delayimp.lib - ) - # Disable/Enable a ton of things. - list(APPEND PROJECT_DEFINITIONS - # Microsoft Visual C++ - _CRT_SECURE_NO_WARNINGS - _ENABLE_EXTENDED_ALIGNED_STORAGE - # windows.h - WIN32_LEAN_AND_MEAN - NOGPICAPMASKS - NOVIRTUALKEYCODES - #NOWINMESSAGES - NOWINSTYLES - NOSYSMETRICS - NOMENUS - NOICONS - NOKEYSTATES - NOSYSCOMMANDS - NORASTEROPS - NOSHOWWINDOW - NOATOM - NOCLIPBOARD - NOCOLOR - #NOCTLMGR - NODRAWTEXT - #NOGDI - NOKERNEL - #NOUSER - #NONLS - NOMB - NOMEMMGR - NOMETAFILE - NOMINMAX - #NOMSG - NOOPENFILE - NOSCROLL - NOSERVICE - NOSOUND - #NOTEXTMETRIC - NOWH - NOWINOFFSETS - NOCOMM - NOKANJI - #NOHELP - NOPROFILER - NODEFERWINDOWPOS - NOMCX - NOIME - NOMDI - NOINOUT - ) -endif() - -# GCC before 9.0, Clang before 9.0 -if((CMAKE_C_COMPILER_ID STREQUAL "GNU") - OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - OR (CMAKE_C_COMPILER_ID STREQUAL "Clang") - OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) - list(APPEND PROJECT_LIBRARIES - "stdc++fs" - ) - endif() -endif() - -################################################################################ -# Register Library -################################################################################ - -# Combine all variables that matter. -set(PROJECT_FILES - # Always exist - ${PROJECT_DATA} - ${PROJECT_PRIVATE_GENERATED} - ${PROJECT_PRIVATE_SOURCE} - ${PROJECT_TEMPLATES} - # UI-only (empty if not enabled) - ${PROJECT_UI} - ${PROJECT_UI_SOURCE} -) - -# Set source groups for IDE generators. -source_group(TREE "${PROJECT_SOURCE_DIR}/data" PREFIX "Data" FILES ${PROJECT_DATA}) -source_group(TREE "${PROJECT_SOURCE_DIR}/source" PREFIX "Source" FILES ${PROJECT_PRIVATE_SOURCE} ${PROJECT_UI_SOURCE}) -source_group(TREE "${PROJECT_BINARY_DIR}/generated" PREFIX "Source" FILES ${PROJECT_PRIVATE_GENERATED}) -source_group(TREE "${PROJECT_SOURCE_DIR}/templates" PREFIX "Templates" FILES ${PROJECT_TEMPLATES}) -source_group(TREE "${PROJECT_SOURCE_DIR}/ui" PREFIX "User Interface" FILES ${PROJECT_UI}) - -# Prevent unwanted files from being built as source. -set_source_files_properties(${PROJECT_DATA} ${PROJECT_TEMPLATES} ${PROJECT_UI} PROPERTIES - HEADER_FILE_ONLY ON -) - -# Prevent non-UI files from being Qt'd -if(HAVE_QT) - set_source_files_properties(${PROJECT_DATA} ${PROJECT_TEMPLATES} ${PROJECT_PRIVATE_GENERATED} ${PROJECT_PRIVATE_SOURCE} PROPERTIES - SKIP_AUTOGEN ON - SKIP_AUTOMOC ON - SKIP_AUTORCC ON - SKIP_AUTOUIC ON - ) -endif() - -# Register the library -add_library(${PROJECT_NAME} MODULE ${PROJECT_FILES}) # We are a module for libOBS. -target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_INCLUDE_DIRS}) -target_compile_definitions(${PROJECT_NAME} PRIVATE ${PROJECT_DEFINITIONS}) -target_link_libraries(${PROJECT_NAME} ${PROJECT_LIBRARIES}) - -# Set C++ Standard and Extensions -set_target_properties(${PROJECT_NAME} PROPERTIES - CXX_STANDARD 17 - CXX_STANDARD_REQUIRED ON - CXX_EXTENSIONS OFF -) - -# Remove prefix on other platforms. -set_target_properties(${PROJECT_NAME} PROPERTIES - PREFIX "" - IMPORT_PREFIX "" -) - -# Set file version (on anything but MacOS) -if(NOT D_PLATFORM_MAC) - set_target_properties(${PROJECT_NAME} PROPERTIES - VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK} - SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK} - ) -endif() - -# Delay-Loading on Microsoft Visual C++ -if(D_PLATFORM_WINDOWS) - foreach(DELAYLOAD ${PROJECT_LIBRARIES_DELAYED}) - get_target_property(_lf ${PROJECT_NAME} LINK_FLAGS) - if (NOT _lf) - set(_lf "") - endif() - set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "${_lf} /DELAYLOAD:${DELAYLOAD}") - add_link_options("/DELAYLOAD:${DELAYLOAD}") - endforeach() -endif() - -# Enable Qt if needed -if(HAVE_QT) - set_target_properties(${PROJECT_NAME} PROPERTIES - AUTOUIC ON - AUTOUIC_SEARCH_PATHS "${PROJECT_SOURCE_DIR};${PROJECT_SOURCE_DIR}/ui" - AUTOMOC ON - AUTORCC ON - AUTOGEN_BUILD_DIR "${PROJECT_BINARY_DIR}/generated" - ) -endif() - -# MacOS: Disable automatic Code Signing in Xcode -if(D_PLATFORM_MAC) - set_target_properties(${PROJECT_NAME} PROPERTIES - XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" - XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO" - ) -endif() - - -################################################################################ -# Extra Tools -################################################################################ - -# Clang -if(HAVE_CLANG) - generate_compile_commands_json( - TARGETS ${PROJECT_NAME} - ) - clang_tidy( - TARGETS ${PROJECT_NAME} - VERSION 9.0.0 - ) - clang_format( - TARGETS ${PROJECT_NAME} - DEPENDENCY - VERSION 9.0.0 - ) -endif() - -# Apple otool -if(D_PLATFORM_MAC) - # OBS - mac_get_linker_id(TARGET libobs OUTPUT T_OBS_LINK) - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND install_name_tool ARGS -change "${T_OBS_LINK}" "@executable_path/../Frameworks/libobs.0.dylib" $ - ) - message(STATUS "${LOGPREFIX} Added post-build step for adjusting libobs linking path.") - - # OBS Front-End API - if (TRUE) - mac_get_linker_id(TARGET obs-frontend-api OUTPUT T_OBSFE_LINK) - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND install_name_tool ARGS -change "${T_OBSFE_LINK}" "@executable_path/../Frameworks/libobs-frontend-api.dylib" $ - ) - message(STATUS "${LOGPREFIX} Added post-build step for adjusting libobs-frontend-api linking path.") - endif() - - # Qt5 - if (TRUE) - # Figure out the linker location for Qt5::Core - mac_get_linker_id(TARGET Qt5::Core OUTPUT T_QT5CORE_LINK) - - # Figure out the linker location for Qt5::Gui - mac_get_linker_id(TARGET Qt5::Gui OUTPUT T_QT5GUI_LINK) - - # Figure out the linker location for Qt5::Widsgets - mac_get_linker_id(TARGET Qt5::Widgets OUTPUT T_QT5WIDGETS_LINK) - - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - # - QtCore - COMMAND install_name_tool ARGS -change "${T_QT5CORE_LINK}" "@executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore" $ - # - QtGui - COMMAND install_name_tool ARGS -change "${T_QT5GUI_LINK}" "@executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui" $ - # - QtWidgets - COMMAND install_name_tool ARGS -change "${T_QT5WIDGETS_LINK}" "@executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets" $ - ) - message(STATUS "${LOGPREFIX} Added post-build step for adjusting Qt5::Core linking path (Found: ${Qt5_DIR} resolved to ${T_QT5CORE_LINK}).") - message(STATUS "${LOGPREFIX} Added post-build step for adjusting Qt5::Gui linking path (Found: ${Qt5_DIR} resolved to ${T_QT5GUI_LINK}).") - message(STATUS "${LOGPREFIX} Added post-build step for adjusting Qt5::Widgets linking path (Found: ${Qt5_DIR} resolved to ${T_QT5WIDGETS_LINK}).") - endif() -endif() - -# Code Sign -if(HAVE_CODESIGN) - set(_CODESIGN_TIMESTAMP "") - if(${PREFIX}CODESIGN_TIMESTAMPS) - set(_CODESIGN_TIMESTAMP "TIMESTAMPS") - endif() - codesign( - TARGETS ${PROJECT_NAME} - CERTIFICATE_FILE "${_CODESIGN_FILE}" - CERTIFICATE_NAME "${_CODESIGN_NAME}" - CERTIFICATE_PASS "${_CODESIGN_PASS}" - ${_CODESIGN_TIMESTAMP} - ) -endif() - -################################################################################ -# Installation -################################################################################ - -if(${PREFIX}OBS_NATIVE) - # Grouped builds don't offer standalone services. - install_obs_plugin_with_data(${PROJECT_NAME} data) -else() - if(STRUCTURE_UNIFIED) - install( - DIRECTORY "data/" - DESTINATION "data/" - FILE_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE - DIRECTORY_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE - ) - - if(D_PLATFORM_WINDOWS) - install( - TARGETS ${PROJECT_NAME} - RUNTIME DESTINATION "bin/windows-${D_PLATFORM_INSTR}-${D_PLATFORM_BITS}/" COMPONENT StreamDeck - LIBRARY DESTINATION "bin/windows-${D_PLATFORM_INSTR}-${D_PLATFORM_BITS}/" COMPONENT StreamDeck - PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE - ) - if(MSVC) - install( - FILES $ - DESTINATION "bin/windows-${D_PLATFORM_INSTR}-${D_PLATFORM_BITS}/" - COMPONENT StreamDeck - OPTIONAL - ) - endif() - elseif(D_PLATFORM_LINUX) - install( - TARGETS ${PROJECT_NAME} - RUNTIME DESTINATION "bin/linux-${D_PLATFORM_INSTR}-${D_PLATFORM_BITS}/" COMPONENT StreamDeck - LIBRARY DESTINATION "bin/linux-${D_PLATFORM_INSTR}-${D_PLATFORM_BITS}/" COMPONENT StreamDeck - PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE - ) - elseif(D_PLATFORM_MAC) - install( - TARGETS ${PROJECT_NAME} - RUNTIME DESTINATION "bin/mac-${D_PLATFORM_INSTR}-${D_PLATFORM_BITS}/" COMPONENT StreamDeck - LIBRARY DESTINATION "bin/mac-${D_PLATFORM_INSTR}-${D_PLATFORM_BITS}/" COMPONENT StreamDeck - PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE - ) - endif() - - install( - FILES LICENSE - DESTINATION "LICENSE" - COMPONENT StreamDeck - ) - install( - FILES icon.png - DESTINATION "icon.png" - COMPONENT StreamDeck - ) - elseif(D_PLATFORM_WINDOWS) - install( - TARGETS ${PROJECT_NAME} - RUNTIME DESTINATION "obs-plugins/${D_PLATFORM_BITS}bit/" COMPONENT StreamDeck - LIBRARY DESTINATION "obs-plugins/${D_PLATFORM_BITS}bit/" COMPONENT StreamDeck - ) - install( - DIRECTORY "data/" - DESTINATION "data/obs-plugins/${PROJECT_NAME}/" - ) - if(MSVC) - install( - FILES $ - DESTINATION "obs-plugins/${D_PLATFORM_BITS}bit/" - OPTIONAL - ) - endif() - elseif(D_PLATFORM_LINUX) - if(STRUCTURE_PACKAGEMANAGER) - install( - TARGETS ${PROJECT_NAME} - RUNTIME DESTINATION "lib/obs-plugins/" COMPONENT StreamDeck - LIBRARY DESTINATION "lib/obs-plugins/" COMPONENT StreamDeck - PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE - ) - install( - DIRECTORY "data/" - DESTINATION "share/obs/obs-plugins/${PROJECT_NAME}" - COMPONENT StreamDeck - FILE_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE - DIRECTORY_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE - ) - else() - install( - TARGETS ${PROJECT_NAME} - RUNTIME DESTINATION "plugins/${PROJECT_NAME}/bin/${D_PLATFORM_BITS}bit/" COMPONENT StreamDeck - LIBRARY DESTINATION "plugins/${PROJECT_NAME}/bin/${D_PLATFORM_BITS}bit/" COMPONENT StreamDeck - PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE - ) - install( - DIRECTORY "data/" - DESTINATION "plugins/${PROJECT_NAME}/data/" - COMPONENT StreamDeck - FILE_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE - DIRECTORY_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE - ) - endif() - elseif(D_PLATFORM_MAC) - install( - TARGETS ${PROJECT_NAME} - RUNTIME DESTINATION "${PROJECT_NAME}/bin/" COMPONENT StreamDeck - LIBRARY DESTINATION "${PROJECT_NAME}/bin/" COMPONENT StreamDeck - PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE - ) - install( - DIRECTORY "data/" - DESTINATION "${PROJECT_NAME}/data/" - COMPONENT StreamDeck - FILE_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE - DIRECTORY_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE - ) - endif() -endif() - -################################################################################ -# Packaging -################################################################################ - -if(NOT ${PREFIX}OBS_NATIVE) - # Packaging - if(NOT PACKAGE_SUFFIX) - set(_PACKAGE_SUFFIX_OVERRIDE "${VERSION_STRING}") - else() - set(_PACKAGE_SUFFIX_OVERRIDE "${PACKAGE_SUFFIX}") - endif() - set(_PACKAGE_FULL_NAME "${PACKAGE_PREFIX}/${PACKAGE_NAME}-${_PACKAGE_SUFFIX_OVERRIDE}") - - if(STRUCTURE_UNIFIED) - add_custom_target( - PACKAGE_ZIP - ${CMAKE_COMMAND} -E tar cfv "${_PACKAGE_FULL_NAME}.obs" --format=zip -- - "." - WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}" - ) - else() - add_custom_target( - PACKAGE_7Z - ${CMAKE_COMMAND} -E tar cfv "${_PACKAGE_FULL_NAME}.7z" --format=7zip -- - "." - WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}" - ) - add_custom_target( - PACKAGE_ZIP - ${CMAKE_COMMAND} -E tar cfv "${_PACKAGE_FULL_NAME}.zip" --format=zip -- - "." - WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}" - ) - - # Windows - if(D_PLATFORM_WINDOWS) - ## Installer (InnoSetup) - get_filename_component(ISS_FILES_DIR "${CMAKE_INSTALL_PREFIX}" ABSOLUTE) - file(TO_NATIVE_PATH "${ISS_FILES_DIR}" ISS_FILES_DIR) - - get_filename_component(ISS_PACKAGE_DIR "${PACKAGE_PREFIX}" ABSOLUTE) - file(TO_NATIVE_PATH "${ISS_PACKAGE_DIR}" ISS_PACKAGE_DIR) - - get_filename_component(ISS_SOURCE_DIR "${PROJECT_SOURCE_DIR}" ABSOLUTE) - file(TO_NATIVE_PATH "${ISS_SOURCE_DIR}" ISS_SOURCE_DIR) - - get_filename_component(ISS_MSVCHELPER_PATH "${msvc-redist-helper_BUILD_DIR}" ABSOLUTE) - file(TO_NATIVE_PATH "${ISS_MSVCHELPER_PATH}" ISS_MSVCHELPER_PATH) - - if(HAVE_CODESIGN) - codesign_command_win32( - SHA1 - RETURN_BIN ISS_CODESIGN_BIN_SHA1 - RETURN_ARGS ISS_CODESIGN_CMD_SHA1 - CERTIFICATE_FILE "${_CODESIGN_FILE}" - CERTIFICATE_NAME "${_CODESIGN_NAME}" - CERTIFICATE_PASS "${_CODESIGN_PASS}" - ${_CODESIGN_TIMESTAMP} - ) - codesign_command_win32( - SHA2 APPEND - RETURN_BIN ISS_CODESIGN_BIN_SHA2 - RETURN_ARGS ISS_CODESIGN_CMD_SHA2 - CERTIFICATE_FILE "${_CODESIGN_FILE}" - CERTIFICATE_NAME "${_CODESIGN_NAME}" - CERTIFICATE_PASS "${_CODESIGN_PASS}" - ${_CODESIGN_TIMESTAMP} - ) - list(JOIN ISS_CODESIGN_CMD_SHA1 " " ISS_CODESIGN_CMD_SHA1) - list(JOIN ISS_CODESIGN_CMD_SHA2 " " ISS_CODESIGN_CMD_SHA2) - - configure_file( - "templates/installer-signed.iss.in" - "installer.iss" - ) - else() - configure_file( - "templates/installer.iss.in" - "installer.iss" - ) - endif() - endif() - endif() -endif() - diff --git a/OBSTemplate.cmake b/OBSTemplate.cmake new file mode 100644 index 0000000..e51568e --- /dev/null +++ b/OBSTemplate.cmake @@ -0,0 +1,156 @@ +cmake_minimum_required(VERSION 3.16...3.21) + +################################################################################ +# OBS Plugin Template +################################################################################ + +# Change obs-plugintemplate to your plugin's name in a machine-readable format (e.g.: +# obs-myawesomeplugin) and set +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) +set(PLUGIN_AUTHOR "${PROJECT_AUTHORS}") + +# 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.elgato.ElgatoRemoteControlOBS") + +# Replace `me@contoso.com` with the maintainer email address you want to put in Linux packages +set(LINUX_MAINTAINER_EMAIL "") + +set(PROJECT_DEFINITIONS ) +list(APPEND PROJECT_DEFINITIONS + -DASIO_STANDALONE + -D_WEBSOCKETPP_CPP11_STL_ +) +list(APPEND PROJECT_DEFINITIONS + -DVERSION_STR=\"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}\" +) + +target_compile_definitions(${PROJECT_NAME} PRIVATE ${PROJECT_DEFINITIONS}) + +# 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 + "source/module.hpp" + "source/module.cpp" + "source/json-rpc.hpp" + "source/json-rpc.cpp" + "source/server.hpp" + "source/server.cpp" + "source/handlers/handler-system.hpp" + "source/handlers/handler-system.cpp" + "source/handlers/handler-obs-frontend.hpp" + "source/handlers/handler-obs-frontend.cpp" + "source/handlers/handler-obs-source.hpp" + "source/handlers/handler-obs-source.cpp" + "source/handlers/handler-obs-scene.hpp" + "source/handlers/handler-obs-scene.cpp" + "source/details-popup.cpp" + "source/details-popup.hpp" + "${PROJECT_BINARY_DIR}/generated/module.cpp" +) + +target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE + "${PROJECT_BINARY_DIR}/generated" + "${PROJECT_SOURCE_DIR}/source" + "third-party/nlohmann-json/single_include/" + "third-party/websocketpp/" + "third-party/asio/asio/include" +) + +# Import libobs as main plugin dependency +find_package(libobs REQUIRED) +include(cmake/ObsPluginHelpers.cmake) + +# Uncomment these lines if you want to use the OBS Frontend API in your plugin +find_package(obs-frontend-api REQUIRED) +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::obs-frontend-api) + +find_qt(COMPONENTS Widgets Core) +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Qt::Core Qt::Widgets) +set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES + AUTOMOC ON + AUTOUIC ON + AUTORCC ON + AUTOUIC_SEARCH_PATHS "${PROJECT_SOURCE_DIR};${PROJECT_SOURCE_DIR}/ui" +) + +set_target_properties(${PROJECT_NAME} PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF +) + +# Configure Files +configure_file( + "templates/config.hpp.in" + "generated/config.hpp" +) + +configure_file( + "templates/version.hpp.in" + "generated/version.hpp" +) +configure_file( + "templates/module.cpp.in" + "generated/module.cpp" +) + +if(D_PLATFORM_WINDOWS) # Windows Support + set(PROJECT_PRODUCT_NAME "${PROJECT_FULL_NAME}") + set(PROJECT_COMPANY_NAME "${PROJECT_AUTHORS}") + set(PROJECT_COPYRIGHT "${PROJECT_COPYRIGHT_YEARS}, ${PROJECT_AUTHORS}") + set(PROJECT_LEGAL_TRADEMARKS_1 "") + set(PROJECT_LEGAL_TRADEMARKS_2 "") + + configure_file( + "templates/version.rc.in" + "generated/version.rc" + @ONLY + ) +endif() + +# /!\ TAKE NOTE: No need to edit things past this point /!\ + +# --- Platform-independent build settings --- + +target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src) + +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs) + +# --- End of section --- + +# --- Windows-specific build settings and tasks --- +if(OS_WINDOWS) + configure_file(cmake/bundle/windows/installer-Windows.iss.in + ${CMAKE_BINARY_DIR}/installer-Windows.generated.iss) + + configure_file(cmake/bundle/windows/resource.rc.in ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.rc) + target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.rc) + + if(MSVC) + target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE /W4) + endif() + # --- End of section --- + + # -- macOS specific build settings and tasks -- +elseif(OS_MACOS) + configure_file(cmake/bundle/macos/installer-macos.pkgproj.in + ${CMAKE_BINARY_DIR}/installer-macos.generated.pkgproj) + + 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) + # --- End of section --- + + # --- Linux-specific build settings and tasks --- +else() + target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall) +endif() +# --- End of section --- + +setup_plugin_target(${CMAKE_PROJECT_NAME}) diff --git a/OldCMake.cmake b/OldCMake.cmake new file mode 100644 index 0000000..d652276 --- /dev/null +++ b/OldCMake.cmake @@ -0,0 +1,1068 @@ +# Copyright (C) 2017, Michael Fabian 'Xaymar' Dirks . All rights reserved. +# Copyright (C) 2022, Corsair Memory Inc. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +# CMake Setup +cmake_minimum_required(VERSION 3.8...4.0) + +################################################################################ +# Configure Type +################################################################################ + +# Detect if we are building by ourselves or as part of something else. +if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}") + set(GROUPED OFF) + set(PREFIX "") +else() + set(GROUPED ON) + set(PREFIX "StreamDeck_") +endif() +set(LOGPREFIX "StreamDeck:") + + + +################################################################################ +# Modules +################################################################################ + +# Search Paths +set(CMAKE_MODULE_PATH + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake" +) + +# Include +include("Architecture") # Architecture Detection +include("util") # CacheClear, CacheSet +include("DownloadProject") # DownloadProject + +################################################################################ +# Platform Setup +################################################################################ + +# Operating System +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(D_PLATFORM_OS "windows") + set(D_PLATFORM_WINDOWS 1) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(D_PLATFORM_OS "linux") + set(D_PLATFORM_LINUX 1) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(D_PLATFORM_OS "macos") + set(D_PLATFORM_MAC 1) +else() + set(D_PLATFORM_OS "unknown") + set(D_PLATFORM_UNKNOWN 1) + message(WARNING "${LOGPREFIX} The operating system '${CMAKE_SYSTEM_NAME}' is unknown to to this script, continue at your own risk.") +endif() + +# Architecture +set(D_PLATFORM_INSTR ${ARCH_INST}) +if(ARCH_INST STREQUAL "x86") + set(D_PLATFORM_INSTR_X86 ON) + set(D_PLATFORM_ARCH_X86 ON) +elseif(ARCH_INST STREQUAL "ARM") + set(D_PLATFORM_INSTR_ARM ON) + set(D_PLATFORM_ARCH_ARM ON) +elseif(ARCH_INST STREQUAL "IA64") + set(D_PLATFORM_INSTR_ITANIUM ON) + set(D_PLATFORM_ARCH_ITANIUM ON) +endif() +set(D_PLATFORM_ARCH ${ARCH_INST}) + +# Bitness +set(D_PLATFORM_BITS ${ARCH_BITS}) +set(D_PLATFORM_BITS_PTR ${ARCH_BITS_POINTER}) + +################################################################################ +# C/C++ Compiler Adjustments +################################################################################ +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) + message(STATUS "Applying custom flags for MSVC style build.") + + # MSVC/ClangCL + # - Dynamically link Microsoft C/C++ Redistributable. + # - Enable /W3 and disable useless warnings. + # - Enable C++ exceptions with SEH exceptions. + # - Enable multi-processor compiling. + + # Build with dynamic MSVC linkage. + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + $<$:/MD> + $<$:/MD> + ) + + # Enable most useful warnings. + set(DISABLED_WARNINGS + "/wd4061" "/wd4100" "/wd4180" "/wd4201" "/wd4464" "/wd4505" "/wd4514" + "/wd4571" "/wd4623" "/wd4625" "/wd4626" "/wd4668" "/wd4710" "/wd4774" + "/wd4820" "/wd5026" "/wd5027" "/wd5039" "/wd5045" "/wd26812" + ) + add_compile_options("/W3") + foreach(WARN ${DISABLED_WARNINGS}) + add_compile_options("${WARN}") + endforeach() + + # C++ Exceptions & SEH + add_compile_options("/EHa") + + # Multiprocessor compiling + add_compile_options("/MP") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + message(STATUS "Applying custom flags for GNU style build.") + + # Clang/AppleClang/GNU + # - Don't export by default. (Temporarily disabled) + # - Enable all and extra warnings. + + add_compile_options("-Wall") + add_compile_options("-Wextra") + # add_compile_options("-fvisibility=hidden") +endif() + +################################################################################ +# Detect if we are building with OBS Studio (different from Grouped builds) +################################################################################ + +set(STANDALONE ON) +if(GROUPED AND (TARGET libobs)) + set(STANDALONE OFF) +endif() +if(STANDALONE) + message(STATUS "${LOGPREFIX} This is a standalone build.") + set(${PREFIX}OBS_NATIVE OFF) +else() + message(STATUS "${LOGPREFIX} This is a combined build.") + set(${PREFIX}OBS_NATIVE ON) +endif() + +################################################################################ +# Options +################################################################################ + +## Code Related +set(${PREFIX}ENABLE_CLANG ON CACHE BOOL "Enable Clang integration for supported compilers.") +set(${PREFIX}ENABLE_CODESIGN OFF CACHE BOOL "Enable Code Signing integration for supported environments.") + +# Installation / Packaging +if(STANDALONE) + set(STRUCTURE_UNIFIED CACHE BOOL "Install for use in a Plugin Manager") + if(D_PLATFORM_LINUX) + set(STRUCTURE_PACKAGEMANAGER CACHE BOOL "Install for use in a Package Manager (system-wide installation)") + endif() + + set(PACKAGE_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "Where to place the packages?") + set(PACKAGE_NAME "${PROJECT_NAME}" CACHE STRING "What should the package be called?") + set(PACKAGE_SUFFIX "" CACHE STRING "Any suffix for the package name? (Defaults to the current version string)") +endif() + +################################################################################ +# Clang +################################################################################ + +if(${PREFIX}ENABLE_CLANG AND (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/clang/Clang.cmake")) + include("cmake/clang/Clang.cmake") + set(HAVE_CLANG ON) +endif() + +################################################################################ +# Codesign +################################################################################ + +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/submodules/maketools-for-windows/Signing/corsair_sign_regular.bat") + set(HAVE_CODESIGN ON) +endif() + + +################################################################################ +# Standalone Build: OBS Studio +################################################################################ + +if(NOT ${PREFIX}OBS_NATIVE) + # Options + set(${PREFIX}DOWNLOAD_OBS_URL "" CACHE STRING "(Optional) URL of prebuilt libOBS archive to download.") + set(${PREFIX}DOWNLOAD_OBS_HASH "" CACHE STRING "(Optional) The hash for the libOBS archive.") + mark_as_advanced( + ${PREFIX}DOWNLOAD_OBS_URL + ${PREFIX}DOWNLOAD_OBS_HASH + ) + + # Allow overriding what version we build against. + if(${PREFIX}DOWNLOAD_OBS_URL) + set(_DOWNLOAD_OBS_URL "${${PREFIX}DOWNLOAD_OBS_URL}") + set(_DOWNLOAD_OBS_HASH "${${PREFIX}DOWNLOAD_OBS_HASH}") + else() + set(_DOWNLOAD_OBS_VERSION "27.0.0-ci") + if (D_PLATFORM_WINDOWS) + if (D_PLATFORM_ARCH_X86) + set(_DOWNLOAD_OBS_URL "https://github.com/Xaymar/obs-studio/releases/download/${_DOWNLOAD_OBS_VERSION}/obs-studio-x64-0.0.0.0-windows-${D_PLATFORM_ARCH}-${D_PLATFORM_BITS}.7z") + if (D_PLATFORM_BITS EQUAL 64) + set(_DOWNLOAD_OBS_HASH "SHA256=EBF9853C8A553E16ECBCA22523F401E6CF1EB2E8DA93F1493FEF41D65BD06633") + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + elseif(D_PLATFORM_LINUX) + if (D_PLATFORM_ARCH_X86) + set(_DOWNLOAD_OBS_URL "https://github.com/Xaymar/obs-studio/releases/download/${_DOWNLOAD_OBS_VERSION}/obs-studio-x64-0.0.0.0-ubuntu-${D_PLATFORM_ARCH}-${D_PLATFORM_BITS}.7z") + if (D_PLATFORM_BITS EQUAL 64) + set(_DOWNLOAD_OBS_HASH "SHA256=0AF6C7262C37D80C24CB18523A851FD765C04E766D8EB0F4AC0F6E75D13A035F") + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + elseif(D_PLATFORM_MAC) + if (D_PLATFORM_ARCH_X86) + set(_DOWNLOAD_OBS_URL "https://github.com/Xaymar/obs-studio/releases/download/${_DOWNLOAD_OBS_VERSION}/obs-studio-x64-0.0.0.0-macos-${D_PLATFORM_ARCH}-${D_PLATFORM_BITS}.7z") + if (D_PLATFORM_BITS EQUAL 64) + set(_DOWNLOAD_OBS_HASH "SHA256=F15BC4CA8EB3F581A94372759CFE554E30D202B604B541445A5756B878E4E799") + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + elseif(D_PLATFORM_ARCH_ARM) + message(NOTICE "Building for ARM64") + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + endif() + + # Download libOBS + download_project( + PROJ libobs + URL "${_DOWNLOAD_OBS_URL}" + URL_HASH "${_DOWNLOAD_OBS_HASH}" + DOWNLOAD_NO_PROGRESS OFF + UPDATE_DISCONNECTED OFF + ) + + include("${libobs_SOURCE_DIR}/cmake/LibObs/LibObsConfig.cmake") +endif() + +if(${PREFIX}OBS_NATIVE) + if(TARGET obs-frontend-api) + set(HAVE_OBSFE ON) + endif() +else() + if (EXISTS "${libobs_SOURCE_DIR}/cmake/obs-frontend-api/obs-frontend-apiConfig.cmake") + include("${libobs_SOURCE_DIR}/cmake/obs-frontend-api/obs-frontend-apiConfig.cmake") + set(HAVE_OBSFE ON) + endif() +endif() + +################################################################################ +# Standalone Build: OBS Studio Dependencies +################################################################################ + +if(STANDALONE AND NOT D_PLATFORM_LINUX) + # Options + set(${PREFIX}DOWNLOAD_OBSDEPS_URL "" CACHE STRING "(Optional) URL of prebuilt libOBS archive to download.") + set(${PREFIX}DOWNLOAD_OBSDEPS_HASH "" CACHE STRING "(Optional) The hash for the libOBS archive.") + mark_as_advanced( + ${PREFIX}DOWNLOAD_OBSDEPS_URL + ${PREFIX}DOWNLOAD_OBSDEPS_HASH + ) + + # Allow overriding what version we build against. + if(${PREFIX}DOWNLOAD_OBSDEPS_URL) + set(_DOWNLOAD_OBSDEPS_URL "${${PREFIX}DOWNLOAD_OBSDEPS_URL}") + set(_DOWNLOAD_OBSDEPS_HASH "${${PREFIX}DOWNLOAD_OBSDEPS_HASH}") + else() + if (D_PLATFORM_WINDOWS) + if (D_PLATFORM_ARCH_X86) + set(_DOWNLOAD_OBSDEPS_URL "https://github.com/Xaymar/obs-studio/releases/download/27.0.0/deps-windows-x86.7z") + if (D_PLATFORM_BITS EQUAL 64) + set(_DOWNLOAD_OBSDEPS_HASH "SHA256=B4AED165016F0B64A7E8B256CCC12EAF8AF087F61B0B239B9D3D00277485B5B5") + elseif (D_PLATFORM_BITS EQUAL 32) + set(_DOWNLOAD_OBSDEPS_HASH "SHA256=B4AED165016F0B64A7E8B256CCC12EAF8AF087F61B0B239B9D3D00277485B5B5") + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + elseif(D_PLATFORM_MAC) + if (D_PLATFORM_ARCH_X86) + if (D_PLATFORM_BITS EQUAL 64) + set(_DOWNLOAD_OBSDEPS_URL "https://github.com/Xaymar/obs-studio/releases/download/27.0.0/deps-macos-x86_64-2021-03-25.tar.gz") + set(_DOWNLOAD_OBSDEPS_HASH "SHA256=1C409374BCAB9D5CEEAFC121AA327E13AB222096718AF62F2648302DF62898D6") + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + elseif(D_PLATFORM_ARCH_ARM) + if (D_PLATFORM_BITS EQUAL 64) + set(_DOWNLOAD_OBSDEPS_URL "https://github.com/Xaymar/obs-studio/releases/download/27.0.0/deps-macos-arm64-2021-03-25.tar.gz") + set(_DOWNLOAD_OBSDEPS_HASH "SHA256=C0EC57D360AF190E372D6BB883134FA26B1A7E49840DD146B172B48D548B55BC") + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + endif() + + # Download libOBS + download_project( + PROJ obsdeps + URL "${_DOWNLOAD_OBSDEPS_URL}" + URL_HASH "${_DOWNLOAD_OBSDEPS_HASH}" + DOWNLOAD_NO_PROGRESS OFF + UPDATE_DISCONNECTED OFF + ) + + if (D_PLATFORM_WINDOWS) + set(_OBSDEPS_PATH "${obsdeps_SOURCE_DIR}/win${D_PLATFORM_BITS}") + elseif(D_PLATFORM_MAC) + set(_OBSDEPS_PATH "${obsdeps_SOURCE_DIR}/obsdeps") + endif() +endif() + +################################################################################ +# Standalone Build: Qt v5.x +################################################################################ + +#set(QT_INSTALL "" CACHE PATH "Qt Installation Path") +#list(APPEND CMAKE_PREFIX_PATH "${QT_INSTALL}") + +if(STANDALONE AND NOT D_PLATFORM_LINUX) + set(${PREFIX}DOWNLOAD_QT OFF CACHE BOOL "Download Qt?") + set(${PREFIX}WITH_QT6 OFF CACHE BOOL "Use Qt6?") + + if(${PREFIX}DOWNLOAD_QT) + set(${PREFIX}DOWNLOAD_QT_URL "" CACHE STRING "") + set(${PREFIX}DOWNLOAD_QT_HASH "" CACHE STRING "") + mark_as_advanced( + ${PREFIX}DOWNLOAD_QT_URL + ${PREFIX}DOWNLOAD_QT_HASH + ) + + # Allow overriding what version we build against. + if(${PREFIX}DOWNLOAD_QT_URL) + set(_DOWNLOAD_QT_URL "${${PREFIX}DOWNLOAD_QT_URL}") + set(_DOWNLOAD_QT_HASH "${${PREFIX}DOWNLOAD_QT_HASH}") + else() + if (D_PLATFORM_WINDOWS) + if (D_PLATFORM_ARCH_X86) + if (D_PLATFORM_BITS EQUAL 64) + set(_DOWNLOAD_QT_URL "https://github.com/Xaymar/obs-studio/releases/download/27.0.0/qt-5.15.2-windows-x86-64.7z") + set(_DOWNLOAD_QT_HASH "SHA256=109B9C21EF165B0C46DFAA9AD23124F2070ED4D74207C4AFB308183CB8D43BDD") + elseif (D_PLATFORM_BITS EQUAL 32) + set(_DOWNLOAD_QT_URL "https://github.com/Xaymar/obs-studio/releases/download/27.0.0/qt-5.15.2-windows-x86-32.7z") + set(_DOWNLOAD_QT_HASH "SHA256=372E4FBF2A15DD4FDA955A07334D8B8AC6802990148C9CB4E766C90205F8F570") + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + elseif(D_PLATFORM_MAC) + if (D_PLATFORM_ARCH_X86) + if (D_PLATFORM_BITS EQUAL 64) + set(_DOWNLOAD_QT_URL "https://github.com/Xaymar/obs-studio/releases/download/27.0.0/qt-5.15.2-macos-x86_64-2021-03-25.tar.gz") + set(_DOWNLOAD_QT_HASH "SHA256=FFABB54624B931EA3FCC06BED244895F50CEFC95DE09D792D280C46D4F91D4C5") + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + elseif(D_PLATFORM_ARCH_ARM) + if (D_PLATFORM_BITS EQUAL 64) + set(_DOWNLOAD_QT_URL "https://github.com/Xaymar/obs-studio/releases/download/27.0.0/qt-5.15.2-macos-arm64-2021-03-25.tar.gz") + set(_DOWNLOAD_QT_HASH "SHA256=366BA8AC0FA0CAC440AFB9ED1C2EF5932E50091DC43BDE8B5C4B490082B6F19F") + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + else() + message(FATAL_ERROR "${LOGPREFIX} Platform '${D_PLATFORM_OS}' with architecture '${D_PLATFORM_ARCH}' and bitness '${D_PLATFORM_BITS}' is not supported.") + return() + endif() + endif() + + download_project( + PROJ qt + URL "${_DOWNLOAD_QT_URL}" + URL_HASH "${_DOWNLOAD_QT_HASH}" + DOWNLOAD_NO_PROGRESS OFF + UPDATE_DISCONNECTED OFF + ) + + + if(${PREFIX}WITH_QT6) + set(Qt6_DIR "${qt_SOURCE_DIR}" CACHE STRING "Path to Qt6") + list(APPEND CMAKE_PREFIX_PATH "${qt_SOURCE_DIR}") + else() + set(Qt5_DIR "${qt_SOURCE_DIR}" CACHE STRING "Path to Qt5") + if (D_PLATFORM_WINDOWS) + if (D_PLATFORM_ARCH_X86) + if (D_PLATFORM_BITS EQUAL 64) + CacheSet(Qt5_DIR "${qt_SOURCE_DIR}/lib/cmake/Qt5") + elseif (D_PLATFORM_BITS EQUAL 32) + CacheSet(Qt5_DIR "${qt_SOURCE_DIR}/lib/cmake/Qt5") + endif() + endif() + elseif(D_PLATFORM_MAC) + CacheSet(Qt5_DIR "${qt_SOURCE_DIR}/lib/cmake/Qt5") + endif() + endif() + + endif() +endif() + + +set(${PREFIX}BUILD_LOADER OFF CACHE BOOL "Build Loader library instead") + +if(NOT ${PREFIX}BUILD_LOADER) + if(${PREFIX}WITH_QT6) + unset(QT_FEATURE_separate_debug_info) + unset(QT_FEATURE_dbus) + unset(QT_FEATURE_getentropy) + unset(QT_FEATURE_printsupport) + unset(QT_FEATURE_sql) + find_package(Qt6 + REQUIRED COMPONENTS Core Widgets + CONFIG + HINTS + "${Qt6_DIR}" + "${Qt6_DIR}/lib" + "${Qt6_DIR}/lib/cmake" + "${Qt6_DIR}/lib/cmake/Qt6" + ) + set(HAVE_QT ${Qt6_FOUND}) + else() + if(NOT Qt5_DIR) + if(ENV{Qt5_DIR}) + set(Qt5_DIR "$ENV{Qt5_DIR}") + endif() + endif() + + find_package(Qt5 + REQUIRED COMPONENTS Core Widgets + CONFIG + HINTS + "${Qt5_DIR}" + "${Qt5_DIR}/lib" + "${Qt5_DIR}/lib/cmake" + "${Qt5_DIR}/lib/cmake/Qt5" + ) + set(HAVE_QT ${Qt5_FOUND}) + endif() +endif() + + + +################################################################################ +# Code +################################################################################ +set(PROJECT_DATA_LOCALE ) +set(PROJECT_DATA_EFFECTS ) +set(PROJECT_DATA_SHADERS ) +set(PROJECT_LIBRARIES ) +set(PROJECT_LIBRARIES_DELAYED ) +set(PROJECT_INCLUDE_DIRS ) +set(PROJECT_TEMPLATES ) +set(PROJECT_PRIVATE_GENERATED ) +set(PROJECT_PRIVATE_SOURCE ) +set(PROJECT_UI ) +set(PROJECT_UI_SOURCE ) +set(PROJECT_DEFINITIONS ) + +# Configure Files +configure_file( + "templates/config.hpp.in" + "generated/config.hpp" +) +LIST(APPEND PROJECT_TEMPLATES "templates/config.hpp.in") +LIST(APPEND PROJECT_PRIVATE_GENERATED "${PROJECT_BINARY_DIR}/generated/config.hpp") + +configure_file( + "templates/version.hpp.in" + "generated/version.hpp" +) +LIST(APPEND PROJECT_TEMPLATES "templates/version.hpp.in") +LIST(APPEND PROJECT_PRIVATE_GENERATED "${PROJECT_BINARY_DIR}/generated/version.hpp") + + +if(NOT ${PREFIX}BUILD_LOADER) + configure_file( + "templates/module.cpp.in" + "generated/module.cpp" + ) + + LIST(APPEND PROJECT_TEMPLATES "templates/module.cpp.in") + LIST(APPEND PROJECT_PRIVATE_GENERATED "${PROJECT_BINARY_DIR}/generated/module.cpp") +endif() + +if(D_PLATFORM_WINDOWS) # Windows Support + set(PROJECT_PRODUCT_NAME "${PROJECT_FULL_NAME}") + set(PROJECT_COMPANY_NAME "${PROJECT_AUTHORS}") + set(PROJECT_COPYRIGHT "${PROJECT_COPYRIGHT_YEARS}, ${PROJECT_AUTHORS}") + set(PROJECT_LEGAL_TRADEMARKS_1 "") + set(PROJECT_LEGAL_TRADEMARKS_2 "") + + configure_file( + "templates/version.rc.in" + "generated/version.rc" + @ONLY + ) + LIST(APPEND PROJECT_TEMPLATES "templates/version.rc.in") + LIST(APPEND PROJECT_PRIVATE_GENERATED "${PROJECT_BINARY_DIR}/generated/version.rc") +endif() + + +# Minimum Dependencies +list(APPEND PROJECT_LIBRARIES + libobs +) +if(NOT ${PREFIX}BUILD_LOADER) + # Minimum Dependencies + list(APPEND PROJECT_LIBRARIES + obs-frontend-api + ) +endif() + + +if(NOT ${PREFIX}BUILD_LOADER) + # Qt + if(${PREFIX}WITH_QT6) + list(APPEND PROJECT_LIBRARIES + Qt6::Core + Qt6::Widgets + ) + else() + list(APPEND PROJECT_LIBRARIES + Qt5::Core + Qt5::Widgets + ) + endif() + + # Project itself + list(APPEND PROJECT_PRIVATE_SOURCE + "source/module.hpp" + "source/module.cpp" + "source/json-rpc.hpp" + "source/json-rpc.cpp" + "source/server.hpp" + "source/server.cpp" + "source/handlers/handler-system.hpp" + "source/handlers/handler-system.cpp" + "source/handlers/handler-obs-frontend.hpp" + "source/handlers/handler-obs-frontend.cpp" + "source/handlers/handler-obs-source.hpp" + "source/handlers/handler-obs-source.cpp" + "source/handlers/handler-obs-scene.hpp" + "source/handlers/handler-obs-scene.cpp" + ) + list(APPEND PROJECT_INCLUDE_DIRS + "${PROJECT_BINARY_DIR}/generated" + "${PROJECT_SOURCE_DIR}/source" + "third-party/nlohmann-json/single_include/" + "third-party/websocketpp/" + "third-party/asio/asio/include" + ) + list(APPEND PROJECT_UI + "ui/popup.ui" + "ui/popup.qrc" + ) + list(APPEND PROJECT_UI_SOURCE + "source/details-popup.cpp" + "source/details-popup.hpp" + ) + list(APPEND PROJECT_DEFINITIONS + -DASIO_STANDALONE + -D_WEBSOCKETPP_CPP11_STL_ + ) +else() + list(APPEND PROJECT_PRIVATE_SOURCE + "source/loader/module.cpp" + ) + list(APPEND PROJECT_DEFINITIONS + -DIS_LOADER + ) +endif() + +list(APPEND PROJECT_DEFINITIONS + -DVERSION_STR=\"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}\" +) + +# Windows +if(D_PLATFORM_WINDOWS) + list(APPEND PROJECT_PRIVATE_SOURCE + "source/windll.cpp" + ) + list(APPEND PROJECT_LIBRARIES + Delayimp.lib + ) + # Disable/Enable a ton of things. + list(APPEND PROJECT_DEFINITIONS + # Microsoft Visual C++ + _CRT_SECURE_NO_WARNINGS + _ENABLE_EXTENDED_ALIGNED_STORAGE + # windows.h + WIN32_LEAN_AND_MEAN + NOGPICAPMASKS + NOVIRTUALKEYCODES + #NOWINMESSAGES + NOWINSTYLES + NOSYSMETRICS + NOMENUS + NOICONS + NOKEYSTATES + NOSYSCOMMANDS + NORASTEROPS + NOSHOWWINDOW + NOATOM + NOCLIPBOARD + NOCOLOR + #NOCTLMGR + NODRAWTEXT + #NOGDI + NOKERNEL + #NOUSER + #NONLS + NOMB + NOMEMMGR + NOMETAFILE + NOMINMAX + #NOMSG + NOOPENFILE + NOSCROLL + NOSERVICE + NOSOUND + #NOTEXTMETRIC + NOWH + NOWINOFFSETS + NOCOMM + NOKANJI + #NOHELP + NOPROFILER + NODEFERWINDOWPOS + NOMCX + NOIME + NOMDI + NOINOUT + ) +endif() + + +# GCC before 9.0, Clang before 9.0 +if((CMAKE_C_COMPILER_ID STREQUAL "GNU") + OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + OR (CMAKE_C_COMPILER_ID STREQUAL "Clang") + OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) + list(APPEND PROJECT_LIBRARIES + "stdc++fs" + ) + endif() +endif() + +################################################################################ +# Register Library +################################################################################ + +# Combine all variables that matter. +set(PROJECT_FILES + # Always exist + ${PROJECT_DATA} + ${PROJECT_PRIVATE_GENERATED} + ${PROJECT_PRIVATE_SOURCE} + ${PROJECT_TEMPLATES} + # UI-only (empty if not enabled) + ${PROJECT_UI} + ${PROJECT_UI_SOURCE} +) + +# Set source groups for IDE generators. +source_group(TREE "${PROJECT_SOURCE_DIR}/data" PREFIX "Data" FILES ${PROJECT_DATA}) +source_group(TREE "${PROJECT_SOURCE_DIR}/source" PREFIX "Source" FILES ${PROJECT_PRIVATE_SOURCE} ${PROJECT_UI_SOURCE}) +source_group(TREE "${PROJECT_BINARY_DIR}/generated" PREFIX "Source" FILES ${PROJECT_PRIVATE_GENERATED}) +source_group(TREE "${PROJECT_SOURCE_DIR}/templates" PREFIX "Templates" FILES ${PROJECT_TEMPLATES}) +source_group(TREE "${PROJECT_SOURCE_DIR}/ui" PREFIX "User Interface" FILES ${PROJECT_UI}) + +# Prevent unwanted files from being built as source. +set_source_files_properties(${PROJECT_DATA} ${PROJECT_TEMPLATES} ${PROJECT_UI} PROPERTIES + HEADER_FILE_ONLY ON +) + +# Prevent non-UI files from being Qt'd +if(HAVE_QT) + set_source_files_properties(${PROJECT_DATA} ${PROJECT_TEMPLATES} ${PROJECT_PRIVATE_GENERATED} ${PROJECT_PRIVATE_SOURCE} PROPERTIES + SKIP_AUTOGEN ON + SKIP_AUTOMOC ON + SKIP_AUTORCC ON + SKIP_AUTOUIC ON + ) +endif() + +# Register the library +add_library(${PROJECT_NAME} MODULE ${PROJECT_FILES}) # We are a module for libOBS. +target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_INCLUDE_DIRS}) +target_compile_definitions(${PROJECT_NAME} PRIVATE ${PROJECT_DEFINITIONS}) +target_link_libraries(${PROJECT_NAME} ${PROJECT_LIBRARIES}) + +# Set C++ Standard and Extensions +set_target_properties(${PROJECT_NAME} PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF +) + +# Remove prefix on other platforms. +set_target_properties(${PROJECT_NAME} PROPERTIES + PREFIX "" + IMPORT_PREFIX "" +) + +# Set file version (on anything but MacOS) +if(NOT D_PLATFORM_MAC) + set_target_properties(${PROJECT_NAME} PROPERTIES + VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK} + SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK} + ) +endif() + +# Delay-Loading on Microsoft Visual C++ +if(D_PLATFORM_WINDOWS) + foreach(DELAYLOAD ${PROJECT_LIBRARIES_DELAYED}) + get_target_property(_lf ${PROJECT_NAME} LINK_FLAGS) + if (NOT _lf) + set(_lf "") + endif() + set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "${_lf} /DELAYLOAD:${DELAYLOAD}") + add_link_options("/DELAYLOAD:${DELAYLOAD}") + endforeach() +endif() + +# Enable Qt if needed +if(HAVE_QT) + set_target_properties(${PROJECT_NAME} PROPERTIES + AUTOUIC ON + AUTOUIC_SEARCH_PATHS "${PROJECT_SOURCE_DIR};${PROJECT_SOURCE_DIR}/ui" + AUTOMOC ON + AUTORCC ON + AUTOGEN_BUILD_DIR "${PROJECT_BINARY_DIR}/generated" + ) +endif() + +# MacOS: Disable automatic Code Signing in Xcode +if(D_PLATFORM_MAC) + set_target_properties(${PROJECT_NAME} PROPERTIES + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" + XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO" + ) +endif() + + +################################################################################ +# Extra Tools +################################################################################ + +# Clang +if(HAVE_CLANG) + generate_compile_commands_json( + TARGETS ${PROJECT_NAME} + ) + clang_tidy( + TARGETS ${PROJECT_NAME} + VERSION 9.0.0 + ) + clang_format( + TARGETS ${PROJECT_NAME} + DEPENDENCY + VERSION 9.0.0 + ) +endif() + +# Apple otool +if(D_PLATFORM_MAC) + # OBS + mac_get_linker_id(TARGET libobs OUTPUT T_OBS_LINK) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND install_name_tool ARGS -change "${T_OBS_LINK}" "@executable_path/../Frameworks/libobs.0.dylib" $ + ) + message(STATUS "${LOGPREFIX} Added post-build step for adjusting libobs linking path.") + + # OBS Front-End API + if (TRUE) + mac_get_linker_id(TARGET obs-frontend-api OUTPUT T_OBSFE_LINK) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND install_name_tool ARGS -change "${T_OBSFE_LINK}" "@executable_path/../Frameworks/libobs-frontend-api.dylib" $ + ) + message(STATUS "${LOGPREFIX} Added post-build step for adjusting libobs-frontend-api linking path.") + endif() + + if (NOT ${PREFIX}BUILD_LOADER) + if(${PREFIX}WITH_QT6) + # Figure out the linker location for Qt6::Core + mac_get_linker_id(TARGET Qt6::Core OUTPUT T_QT6CORE_LINK) + + # Figure out the linker location for Qt6::Gui + mac_get_linker_id(TARGET Qt6::Gui OUTPUT T_QT6GUI_LINK) + + # Figure out the linker location for Qt6::Widsgets + mac_get_linker_id(TARGET Qt6::Widgets OUTPUT T_QT6WIDGETS_LINK) + + + message(STATUS "${LOGPREFIX} Added post-build step for adjusting Qt6::Core linking path (Found: ${Qt6_DIR} resolved to ${T_QT6CORE_LINK}).") + message(STATUS "${LOGPREFIX} Added post-build step for adjusting Qt6::Gui linking path (Found: ${Qt6_DIR} resolved to ${T_QT6GUI_LINK}).") + message(STATUS "${LOGPREFIX} Added post-build step for adjusting Qt6::Widgets linking path (Found: ${Qt6_DIR} resolved to ${T_QT6WIDGETS_LINK}).") + else() + # Qt5 + # Figure out the linker location for Qt5::Core + mac_get_linker_id(TARGET Qt5::Core OUTPUT T_QT5CORE_LINK) + + # Figure out the linker location for Qt5::Gui + mac_get_linker_id(TARGET Qt5::Gui OUTPUT T_QT5GUI_LINK) + + # Figure out the linker location for Qt5::Widsgets + mac_get_linker_id(TARGET Qt5::Widgets OUTPUT T_QT5WIDGETS_LINK) + + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + # - QtCore + COMMAND install_name_tool ARGS -change "${T_QT5CORE_LINK}" "@executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore" $ + # - QtGui + COMMAND install_name_tool ARGS -change "${T_QT5GUI_LINK}" "@executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui" $ + # - QtWidgets + COMMAND install_name_tool ARGS -change "${T_QT5WIDGETS_LINK}" "@executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets" $ + ) + message(STATUS "${LOGPREFIX} Added post-build step for adjusting Qt5::Core linking path (Found: ${Qt5_DIR} resolved to ${T_QT5CORE_LINK}).") + message(STATUS "${LOGPREFIX} Added post-build step for adjusting Qt5::Gui linking path (Found: ${Qt5_DIR} resolved to ${T_QT5GUI_LINK}).") + message(STATUS "${LOGPREFIX} Added post-build step for adjusting Qt5::Widgets linking path (Found: ${Qt5_DIR} resolved to ${T_QT5WIDGETS_LINK}).") + endif() + endif() +endif() + + +################################################################################ +# Installation +################################################################################ + +if(${PREFIX}OBS_NATIVE) + # Grouped builds don't offer standalone services. + install_obs_plugin_with_data(${PROJECT_NAME} data) +else() + if(STRUCTURE_UNIFIED) + install( + DIRECTORY "data/" + DESTINATION "data/" + FILE_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE + DIRECTORY_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE + ) + + if(D_PLATFORM_WINDOWS) + install( + TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION "bin/windows-${D_PLATFORM_INSTR}-${D_PLATFORM_BITS}/" COMPONENT StreamDeck + LIBRARY DESTINATION "bin/windows-${D_PLATFORM_INSTR}-${D_PLATFORM_BITS}/" COMPONENT StreamDeck + PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE + ) + if(MSVC) + install( + FILES $ + DESTINATION "bin/windows-${D_PLATFORM_INSTR}-${D_PLATFORM_BITS}/" + COMPONENT StreamDeck + OPTIONAL + ) + endif() + elseif(D_PLATFORM_LINUX) + install( + TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION "bin/linux-${D_PLATFORM_INSTR}-${D_PLATFORM_BITS}/" COMPONENT StreamDeck + LIBRARY DESTINATION "bin/linux-${D_PLATFORM_INSTR}-${D_PLATFORM_BITS}/" COMPONENT StreamDeck + PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE + ) + elseif(D_PLATFORM_MAC) + install( + TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION "bin/mac-${D_PLATFORM_INSTR}-${D_PLATFORM_BITS}/" COMPONENT StreamDeck + LIBRARY DESTINATION "bin/mac-${D_PLATFORM_INSTR}-${D_PLATFORM_BITS}/" COMPONENT StreamDeck + PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE + ) + endif() + + install( + FILES LICENSE + DESTINATION "LICENSE" + COMPONENT StreamDeck + ) + install( + FILES icon.png + DESTINATION "icon.png" + COMPONENT StreamDeck + ) + elseif(D_PLATFORM_WINDOWS) + install( + TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION "obs-plugins/${D_PLATFORM_BITS}bit/" COMPONENT StreamDeck + LIBRARY DESTINATION "obs-plugins/${D_PLATFORM_BITS}bit/" COMPONENT StreamDeck + ) + install( + DIRECTORY "data/" + DESTINATION "data/obs-plugins/${PROJECT_NAME}/" + ) + if(MSVC) + install( + FILES $ + DESTINATION "obs-plugins/${D_PLATFORM_BITS}bit/" + OPTIONAL + ) + endif() + elseif(D_PLATFORM_LINUX) + if(STRUCTURE_PACKAGEMANAGER) + install( + TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION "lib/obs-plugins/" COMPONENT StreamDeck + LIBRARY DESTINATION "lib/obs-plugins/" COMPONENT StreamDeck + PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE + ) + install( + DIRECTORY "data/" + DESTINATION "share/obs/obs-plugins/${PROJECT_NAME}" + COMPONENT StreamDeck + FILE_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE + DIRECTORY_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE + ) + else() + install( + TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION "plugins/${PROJECT_NAME}/bin/${D_PLATFORM_BITS}bit/" COMPONENT StreamDeck + LIBRARY DESTINATION "plugins/${PROJECT_NAME}/bin/${D_PLATFORM_BITS}bit/" COMPONENT StreamDeck + PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE + ) + install( + DIRECTORY "data/" + DESTINATION "plugins/${PROJECT_NAME}/data/" + COMPONENT StreamDeck + FILE_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE + DIRECTORY_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE + ) + endif() + elseif(D_PLATFORM_MAC) + install( + TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION "${PROJECT_NAME}/bin/" COMPONENT StreamDeck + LIBRARY DESTINATION "${PROJECT_NAME}/bin/" COMPONENT StreamDeck + PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE + ) + install( + DIRECTORY "data/" + DESTINATION "${PROJECT_NAME}/data/" + COMPONENT StreamDeck + FILE_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE + DIRECTORY_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE + ) + endif() +endif() + +################################################################################ +# Packaging +################################################################################ + +if(NOT ${PREFIX}OBS_NATIVE) + # Packaging + if(NOT PACKAGE_SUFFIX) + set(_PACKAGE_SUFFIX_OVERRIDE "${VERSION_STRING}") + else() + set(_PACKAGE_SUFFIX_OVERRIDE "${PACKAGE_SUFFIX}") + endif() + set(_PACKAGE_FULL_NAME "${PACKAGE_PREFIX}/${PACKAGE_NAME}-${_PACKAGE_SUFFIX_OVERRIDE}") + + if(STRUCTURE_UNIFIED) + add_custom_target( + PACKAGE_ZIP + ${CMAKE_COMMAND} -E tar cfv "${_PACKAGE_FULL_NAME}.obs" --format=zip -- + "." + WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}" + ) + else() + add_custom_target( + PACKAGE_7Z + ${CMAKE_COMMAND} -E tar cfv "${_PACKAGE_FULL_NAME}.7z" --format=7zip -- + "." + WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}" + ) + add_custom_target( + PACKAGE_ZIP + ${CMAKE_COMMAND} -E tar cfv "${_PACKAGE_FULL_NAME}.zip" --format=zip -- + "." + WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}" + ) + + # Windows + if(D_PLATFORM_WINDOWS) + ## Installer (InnoSetup) + get_filename_component(ISS_FILES_DIR "${CMAKE_INSTALL_PREFIX}" ABSOLUTE) + file(TO_NATIVE_PATH "${ISS_FILES_DIR}" ISS_FILES_DIR) + + get_filename_component(ISS_PACKAGE_DIR "${PACKAGE_PREFIX}" ABSOLUTE) + file(TO_NATIVE_PATH "${ISS_PACKAGE_DIR}" ISS_PACKAGE_DIR) + + get_filename_component(ISS_SOURCE_DIR "${PROJECT_SOURCE_DIR}" ABSOLUTE) + file(TO_NATIVE_PATH "${ISS_SOURCE_DIR}" ISS_SOURCE_DIR) + + get_filename_component(ISS_MSVCHELPER_PATH "${msvc-redist-helper_BUILD_DIR}" ABSOLUTE) + file(TO_NATIVE_PATH "${ISS_MSVCHELPER_PATH}" ISS_MSVCHELPER_PATH) + + if(HAVE_CODESIGN) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND call ${PROJECT_SOURCE_DIR}/submodules/maketools-for-windows/Signing/corsair_sign_regular.bat $(TargetDir)$(TargetFileName) + ) + configure_file( + "templates/installer-signed.iss.in" + "installer.iss" + ) + else() + configure_file( + "templates/installer.iss.in" + "installer.iss" + ) + endif() + endif() + endif() +endif() + + diff --git a/buildspec.json b/buildspec.json new file mode 100644 index 0000000..b8fbbe6 --- /dev/null +++ b/buildspec.json @@ -0,0 +1,83 @@ +{ + "dependencies": { + "obs-studio": { + "version": "28.0.0-beta1", + "repository": "https://github.com/obsproject/obs-studio.git", + "branch": "master", + "hash": "43a49dca47344a5170159ef99b86b97f90d4e4ad" + }, + "prebuilt": { + "version": "2022-08-02", + "baseUrl": "https://github.com/obsproject/obs-deps/releases/download", + "label": "Pre-built obs-deps", + "hashes": { + "macos-x86_64": "7637e52305e6fc53014b5aabd583f1a4490b1d97450420e977cae9a336a29525", + "macos-arm64": "755e0fa69b17a3ae444e1befa9d91d77e3cafe628fbd1c6333686091826595cd", + "macos-universal": "de057e73e6fe0825664c258ca2dd6798c41ae580bf4d896e1647676a4941934a", + "windows-x64": "2192d8ce780c4281b807cd457994963669e5202659ecd92f19b54c3e7d0c1915", + "windows-x86": "9f8582ab5891b000869d6484ea591add9fbac9f1c91b56c7b85fdfd56a261c1b" + } + }, + "qt5": { + "version": "2022-08-02", + "baseUrl": "https://github.com/obsproject/obs-deps/releases/download", + "label": "Pre-built Qt5", + "hashes": { + "macos-x86_64": "3d0381a52b0e4d49967936c4357f79ac711f43564329304a6db5c90edadd2697", + "macos-arm64": "f4b32548c0530f121956bf0a9a70c36ecbbfca81073d39c396a1759baf2a05c3", + "macos-universal": "9a6cf3b9a6c9efee6ba10df649202e8075e99f3c54ae88dc9a36dbc9d7471c1e", + "windows-x64": "6488a33a474f750d5a4a268a5e20c78bb40799d99136a1b7ce3365a843cb2fd7", + "windows-x86": "a916e09b0a874036801deab2c8a7ec14fdf5d268aa5511eac5bf40727e0c4e33" + }, + "pdb-hashes": { + "windows-x64": "e0e5070143fcad9311a68ce5685d8ba8f34f581ed6942b7a92d360f94ca1ba11", + "windows-x86": "36642d1052aa461964f46c17610477b0d9b9defbe2d745ccaacb85f805c1bec2" + } + }, + "qt6": { + "version": "2022-08-02", + "baseUrl": "https://github.com/obsproject/obs-deps/releases/download", + "label": "Pre-built Qt6", + "hashes": { + "macos-x86_64": "a83f72a11023b03b6cb2dc365f0a66ad9df31163bbb4fe2df32d601856a9fad3", + "macos-arm64": "2f30af90c049670a5660656adbb440668aa1b0567f75a5f29e1def9108928403", + "macos-universal": "252e6684f43ab9c6f262c73af739e2296ce391b998da2c4ee04c254aaa07db18", + "windows-x64": "e5509b54196a3f935250cc4b9c54160c8e588fd0f92bc078a2a64f9d9e2e4e93", + "windows-x86": "24fc03bef153a0e027c1479e42eb08097a4ea1d70a4710825be0783d0626cb0d" + }, + "pdb-hashes": { + "windows-x64": "60e5b1d2bc4d7c431bc05f14e3b1e85e088788c372fa85f58717cd6c49555a46", + "windows-x86": "f34d1a89fc85d92913bd6c7f75ec5c28471d74db708c98161100bc8b75f8fc63" + } + } + }, + "platformConfig": { + "macos-x86_64": { + "qtVersion": 6, + "deploymentTarget": "10.15" + }, + "macos-arm64": { + "qtVersion": 6, + "deploymentTarget": "11.0" + }, + "macos-universal": { + "qtVersion": 6, + "deploymentTarget": "10.15" + }, + "windows-x64": { + "qtVersion": 6, + "visualStudio": "Visual Studio 17 2022", + "platformSDK": "10.0.20348.0" + }, + "windows-x86": { + "qtVersion": 6, + "visualStudio": "Visual Studio 17 2022", + "platformSDK": "10.0.20348.0" + }, + "linux-x86_64": { + "qtVersion": 6 + } + }, + "name": "obs-plugintemplate", + "version": "1.0.0" +} diff --git a/ci/linux_multiarch.sh b/ci/linux_multiarch.sh deleted file mode 100755 index 3de4856..0000000 --- a/ci/linux_multiarch.sh +++ /dev/null @@ -1,33 +0,0 @@ -# !/bin/bash - -# Bootstrap -_root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -pushd "${root}"> /dev/null - -_arch=$1 -_build="../build/linux_${_arch}" -_distrib="${root}/../build/distrib" - -# Make Distrib Directory -if [ ! -d "${_distrib}" ]; then - mkdir "${_distrib}" -fi - -# Configure -cmake -H.. -B"${_build}" \ - -G"Ninja" \ - -DCMAKE_INSTALL_PREFIX="${_build}_install" \ - -DCMAKE_INSTALL_PREFIX=../build/install \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DENABLE_CLANG=OFF -if [[ $? -ne 0 ]]; then - exit 1 -fi - -# Compile -cmake --build "${_build}" --config RelWithDebInfo --target install -if [[ $? -ne 0 ]]; then - exit 1 -fi - -popd > /dev/null diff --git a/ci/linux_x86-64.sh b/ci/linux_x86-64.sh deleted file mode 100755 index e45024e..0000000 --- a/ci/linux_x86-64.sh +++ /dev/null @@ -1,12 +0,0 @@ -# !/bin/bash - -# Bootstrap -_root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -pushd "${root}"> /dev/null - -./linux_multiarch.sh x86-64 -if [[ $? -ne 0 ]]; then - exit 1 -fi - -popd > /dev/null diff --git a/ci/macos_arm64.sh b/ci/macos_arm64.sh deleted file mode 100755 index 8eb1672..0000000 --- a/ci/macos_arm64.sh +++ /dev/null @@ -1,9 +0,0 @@ -# !/bin/bash - -# Bootstrap -_root=$0:A -pushd "${root}"> /dev/null - -./macos_multiarch.sh arm64 - -popd > /dev/null diff --git a/ci/macos_multiarch.sh b/ci/macos_multiarch.sh index 0037847..378a657 100755 --- a/ci/macos_multiarch.sh +++ b/ci/macos_multiarch.sh @@ -16,18 +16,67 @@ if [ ! -d "${_distrib}" ]; then mkdir "${_distrib}" fi -# Configure +echo "Qt6/OBS 28" + +../obs-scripts/scripts/build-macos.zsh --target macos-universal + +echo "Qt5" + +# A hack to get around dylib issues +pushd /tmp +curl -L "https://github.com/Xaymar/obs-studio/releases/download/27.0.0/qt-5.15.2-macos-x86_64-2021-03-25.tar.gz" -o /tmp/obsdeps.tar.gz +tar -xzf obsdeps.tar.gz +popd + +# Configure Qt5 cmake -H.. -B"${_build}" \ -DCMAKE_OSX_ARCHITECTURES="$1" \ -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" \ -DCMAKE_INSTALL_PREFIX=../build/install \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DENABLE_CLANG=OFF + -DWITH_QT6=OFF \ + -DBUILD_OLD=YES \ + -DDOWNLOAD_QT=ON \ + -DDOWNLOAD_QT_URL="https://github.com/Xaymar/obs-studio/releases/download/27.0.0/qt-5.15.2-macos-x86_64-2021-03-25.tar.gz" \ + -DDOWNLOAD_QT_HASH="SHA256=FFABB54624B931EA3FCC06BED244895F50CEFC95DE09D792D280C46D4F91D4C5" \ + -DDOWNLOAD_OBS_URL="https://github.com/Xaymar/obs-studio/releases/download/27.0.0-ci/obs-studio-x64-0.0.0.0-macos-x86-64.7z" \ + -DDOWNLOAD_OBS_HASH="SHA256=F15BC4CA8EB3F581A94372759CFE554E30D202B604B541445A5756B878E4E799" \ + -DDOWNLOAD_OBSDEPS_URL="https://github.com/Xaymar/obs-studio/releases/download/27.0.0/deps-macos-x86_64-2021-03-25.tar.gz" \ + -DDOWNLOAD_OBSDEPS_HASH="SHA256=1C409374BCAB9D5CEEAFC121AA327E13AB222096718AF62F2648302DF62898D6" \ + -DENABLE_CLANG=OFF \ + -DBUILD_LOADER=no \ + -DPROJECT_SUFFIX=Qt5 +if [[ $? -ne 0 ]]; then + exit 1 +fi + + +# Compile Qt5 +cmake --build "${_build}" --config RelWithDebInfo --target install +if [[ $? -ne 0 ]]; then + exit 1 +fi + + +echo "Loader" + +# Configure Loader +cmake -H.. -B"${_build}" \ + -DCMAKE_OSX_ARCHITECTURES="x86_64" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" \ + -DCMAKE_INSTALL_PREFIX=../build/install \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DWITH_QT6=OFF \ + -DDOWNLOAD_QT=OFF \ + -DBUILD_OLD=YES \ + -DENABLE_CLANG=OFF \ + -DBUILD_LOADER=yes \ + -DPROJECT_SUFFIX= if [[ $? -ne 0 ]]; then exit 1 fi -# Compile +# Compile Loader cmake --build "${_build}" --config RelWithDebInfo --target install if [[ $? -ne 0 ]]; then exit 1 diff --git a/ci/windows_multiarch.bat b/ci/windows_multiarch.bat index 0aed30c..c8f032e 100644 --- a/ci/windows_multiarch.bat +++ b/ci/windows_multiarch.bat @@ -1,33 +1,90 @@ @ECHO OFF +echo hi + REM Bootstrap SET "ROOT=%~dp0" PUSHD "%ROOT%" > NUL SET "ARCH=%1" -SET "BUILD=../build/windows_%ARCH%" -SET "DISTRIB=%ROOT%/../build/distrib" +SET "BUILD=%ROOT%..\build\windows_%ARCH%" +SET "DISTRIB=%ROOT%..\build\distrib" :: Make Distrib Directory if NOT EXIST "%DISTRIB%" ( mkdir "%DISTRIB%" ) -:: Configure +:: Configure Qt6 +cmake -H.. -B"%BUILD%" ^ + -G"Visual Studio 16 2019" -A"%2" ^ + -DCMAKE_INSTALL_PREFIX="%BUILD%_install" ^ + -DCMAKE_PREFIX_PATH="C:\Qt\6.2.2\msvc2019_64" ^ + -DDOWNLOAD_QT=OFF ^ + -DENABLE_CLANG=OFF ^ + -DWITH_QT6=ON ^ + -DBUILD_OLD=YES ^ + -DBUILD_LOADER=no ^ + -DPROJECT_SUFFIX=Qt6 +if %ERRORLEVEL% NEQ 0 ( + PAUSE +) + +:: Compile Qt6 +cmake --build "%BUILD%" --config RelWithDebInfo --target INSTALL +if %ERRORLEVEL% NEQ 0 ( + PAUSE +) + +:: Configure Qt5 cmake -H.. -B"%BUILD%" ^ -G"Visual Studio 16 2019" -A"%2" ^ -DCMAKE_INSTALL_PREFIX="%BUILD%_install" ^ - -DCMAKE_BUILD_TYPE=RelWithDebInfo ^ -DDOWNLOAD_QT=ON ^ - -DENABLE_CLANG=OFF + -DWITH_QT6=OFF ^ + -DBUILD_OLD=YES ^ + -DENABLE_CLANG=OFF ^ + -DBUILD_LOADER=no ^ + -DPROJECT_SUFFIX=Qt5 +if %ERRORLEVEL% NEQ 0 ( + PAUSE +) + +:: Compile Qt5 +cmake --build "%BUILD%" --config RelWithDebInfo --target INSTALL +if %ERRORLEVEL% NEQ 0 ( + PAUSE +) + +:: Configure Loader +cmake -H.. -B"%BUILD%" ^ + -G"Visual Studio 16 2019" -A"%2" ^ + -DCMAKE_INSTALL_PREFIX="%BUILD%_install" ^ + -DCMAKE_PREFIX_PATH="C:\Qt\6.2.2\msvc2019_64" ^ + -DDOWNLOAD_QT=OFF ^ + -DWITH_QT6=OFF ^ + -DBUILD_OLD=YES ^ + -DBUILD_LOADER=yes ^ + -DPROJECT_SUFFIX= if %ERRORLEVEL% NEQ 0 ( PAUSE ) -:: Compile +:: Compile Loader cmake --build "%BUILD%" --config RelWithDebInfo --target INSTALL if %ERRORLEVEL% NEQ 0 ( PAUSE ) POPD > NUL + +:: Build Installer +PUSHD "%ROOT%../installer/Windows" > NUL + +set "OBSPluginLocation=%BUILD%/RelWithDebInfo" +set BUILD_SETUP_CONFIGURATION=Setup +echo BUILD=%BUILD% +echo OBSPluginLocation=%OBSPluginLocation% +call Setup_Bamboo.bat + +POPD > NUL diff --git a/ci/windows_x86-32.bat b/ci/windows_x86-32.bat deleted file mode 100644 index dddf3e1..0000000 --- a/ci/windows_x86-32.bat +++ /dev/null @@ -1,9 +0,0 @@ -@ECHO OFF - -REM Bootstrap -SET "ROOT=%~dp0" -PUSHD "%ROOT%" > NUL - -windows_multiarch x86-32 Win32 - -POPD > NUL diff --git a/cmake/ObsPluginHelpers.cmake b/cmake/ObsPluginHelpers.cmake new file mode 100644 index 0000000..a0bb212 --- /dev/null +++ b/cmake/ObsPluginHelpers.cmake @@ -0,0 +1,698 @@ +if(POLICY CMP0087) + cmake_policy(SET CMP0087 NEW) +endif() + +set(OBS_STANDALONE_PLUGIN_DIR ${CMAKE_SOURCE_DIR}/release) + +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 behavior +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() + +# Set macOS and Windows specific if default value is used +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() + +# Set default build type to RelWithDebInfo and specify allowed alternative values +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() + +# Set default Qt version to AUTO, preferring an available Qt6 with a fallback to Qt5 +if(NOT QT_VERSION) + set(QT_VERSION + AUTO + CACHE STRING "OBS Qt version [AUTO, 6, 5]" FORCE) + set_property(CACHE QT_VERSION PROPERTY STRINGS AUTO 6 5) +endif() + +# Macro to find best possible Qt version for use with the project: +# +# * Use QT_VERSION value as a hint for desired Qt version +# * If "AUTO" was specified, prefer Qt6 over Qt5 +# * Creates versionless targets of desired component if none had been created by Qt itself (Qt +# versions < 5.15) +# +macro(find_qt) + set(multiValueArgs COMPONENTS COMPONENTS_WIN COMPONENTS_MAC COMPONENTS_LINUX) + cmake_parse_arguments(FIND_QT "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # Do not use versionless targets in the first step to avoid Qt::Core being clobbered by later + # opportunistic find_package runs + set(QT_NO_CREATE_VERSIONLESS_TARGETS ON) + + # Loop until _QT_VERSION is set or FATAL_ERROR aborts script execution early + while(NOT _QT_VERSION) + if(QT_VERSION STREQUAL AUTO AND NOT _QT_TEST_VERSION) + set(_QT_TEST_VERSION 6) + elseif(NOT QT_VERSION STREQUAL AUTO) + set(_QT_TEST_VERSION ${QT_VERSION}) + endif() + + find_package( + Qt${_QT_TEST_VERSION} + COMPONENTS Core + QUIET) + + if(TARGET Qt${_QT_TEST_VERSION}::Core) + set(_QT_VERSION + ${_QT_TEST_VERSION} + CACHE INTERNAL "") + message(STATUS "Qt version found: ${_QT_VERSION}") + unset(_QT_TEST_VERSION) + break() + elseif(QT_VERSION STREQUAL AUTO) + if(_QT_TEST_VERSION EQUAL 6) + message(WARNING "Qt6 was not found, falling back to Qt5") + set(_QT_TEST_VERSION 5) + continue() + endif() + endif() + message(FATAL_ERROR "Neither Qt6 nor Qt5 found.") + endwhile() + + # Enable versionless targets for the remaining Qt components + set(QT_NO_CREATE_VERSIONLESS_TARGETS OFF) + + set(_QT_COMPONENTS ${FIND_QT_COMPONENTS}) + if(OS_WINDOWS) + list(APPEND _QT_COMPONENTS ${FIND_QT_COMPONENTS_WIN}) + elseif(OS_MACOS) + list(APPEND _QT_COMPONENTS ${FIND_QT_COMPONENTS_MAC}) + else() + list(APPEND _QT_COMPONENTS ${FIND_QT_COMPONENTS_LINUX}) + endif() + + find_package( + Qt${_QT_VERSION} + COMPONENTS ${_QT_COMPONENTS} + REQUIRED) + + list(APPEND _QT_COMPONENTS Core) + + if("Gui" IN_LIST FIND_QT_COMPONENTS_LINUX) + list(APPEND _QT_COMPONENTS "GuiPrivate") + endif() + + # Check for versionless targets of each requested component and create if necessary + foreach(_COMPONENT IN LISTS _QT_COMPONENTS) + if(NOT TARGET Qt::${_COMPONENT} AND TARGET Qt${_QT_VERSION}::${_COMPONENT}) + add_library(Qt::${_COMPONENT} INTERFACE IMPORTED) + set_target_properties(Qt::${_COMPONENT} PROPERTIES INTERFACE_LINK_LIBRARIES + Qt${_QT_VERSION}::${_COMPONENT}) + endif() + endforeach() +endmacro() + +# Set relative path variables for file configurations +file(RELATIVE_PATH RELATIVE_INSTALL_PATH ${CMAKE_SOURCE_DIR} ${CMAKE_INSTALL_PREFIX}) +file(RELATIVE_PATH RELATIVE_BUILD_PATH ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) + +if(OS_POSIX) + # Set default GCC/clang compile options: + # + # * Treat warnings as errors + # * Enable extra warnings, https://clang.llvm.org/docs/DiagnosticsReference.html#wextra + # * Warning about usage of variable length array, + # https://clang.llvm.org/docs/DiagnosticsReference.html#wvla + # * Warning about bad format specifiers, + # https://clang.llvm.org/docs/DiagnosticsReference.html#wformat + # * Warning about non-strings used as format strings, + # https://clang.llvm.org/docs/DiagnosticsReference.html#wformat-security + # * Warning about non-exhaustive switch blocks, + # https://clang.llvm.org/docs/DiagnosticsReference.html#wswitch + # * Warning about unused parameters, + # https://clang.llvm.org/docs/DiagnosticsReference.html#wunused-parameter + # * DISABLE warning about unused functions, + # https://clang.llvm.org/docs/DiagnosticsReference.html#wunused-function + # * DISABLE warning about missing field initializers, + # https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-field-initializers + # * DISABLE strict aliasing optimisations + # * C ONLY - treat implicit function declarations (use before declare) as errors, + # https://clang.llvm.org/docs/DiagnosticsReference.html#wimplicit-function-declaration + # * C ONLY - DISABLE warning about missing braces around subobject initalizers, + # https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-braces + # * C ONLY, Clang ONLY - Warning about implicit conversion of NULL to another type, + # https://clang.llvm.org/docs/DiagnosticsReference.html#wnull-conversion + # * C & C++, Clang ONLY - Disable warning about integer conversion losing precision, + # https://clang.llvm.org/docs/DiagnosticsReference.html#wshorten-64-to-32 + # * C++, GCC ONLY - Warning about implicit conversion of NULL to another type + # * Enable color diagnostics on Clang (CMAKE_COLOR_DIAGNOSTICS available in CMake 3.24) + target_compile_options( + ${CMAKE_PROJECT_NAME} + PRIVATE + -Wextra + -Wvla + -Wformat + -Wformat-security + -Wswitch + -Wunused-parameter + -Wno-unused-function + -Wno-missing-field-initializers + -fno-strict-aliasing + "$<$:-Werror-implicit-function-declaration;-Wno-missing-braces>" + "$<$:-Wnull-conversion;-Wno-error=shorten-64-to-32;-fcolor-diagnostics>" + "$<$:-Wnull-conversion;-Wno-error=shorten-64-to-32;-fcolor-diagnostics>" + "$<$:-Wconversion-null>" + "$<$:-DDEBUG=1;-D_DEBUG=1>") + + # GCC 12.1.0 has a regression bug which trigger maybe-uninitialized warnings where there is not. + # (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105562) + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "12.1.0") + target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wno-error=maybe-uninitialized) + endif() + + if(NOT CCACHE_SET) + # Try to find and enable ccache + 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} + CACHE INTERNAL "") + set(CMAKE_C_COMPILER_LAUNCHER + ${CCACHE_PROGRAM} + CACHE INTERNAL "") + set(CMAKE_OBJC_COMPILER_LAUNCHER + ${CCACHE_PROGRAM} + CACHE INTERNAL "") + set(CMAKE_OBJCXX_COMPILER_LAUNCHER + ${CCACHE_PROGRAM} + CACHE INTERNAL "") + set(CMAKE_CUDA_COMPILER_LAUNCHER + ${CCACHE_PROGRAM} + CACHE INTERNAL "") # CMake 3.9+ + set(CCACHE_SET + ON + CACHE INTERNAL "") + endif() + endif() +endif() + +# Set required C++ standard to C++17 +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +# Get lowercase host architecture for easier comparison +if(MSVC_CXX_ARCHITECTURE_ID) + string(TOLOWER ${MSVC_CXX_ARCHITECTURE_ID} _HOST_ARCH) +else() + string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} _HOST_ARCH) +endif() + +if(_HOST_ARCH MATCHES "i[3-6]86|x86|x64|x86_64|amd64" AND NOT CMAKE_OSX_ARCHITECTURES STREQUAL + "arm64") + # Enable MMX, SSE and SSE2 on compatible host systems (assuming no cross-compile) + set(ARCH_SIMD_FLAGS -mmmx -msse -msse2) +elseif(_HOST_ARCH MATCHES "arm64|arm64e|aarch64") + # Enable available built-in SIMD support in Clang and GCC + if(CMAKE_C_COMPILER_ID MATCHES "^(Apple)?Clang|GNU" OR CMAKE_CXX_COMPILER_ID MATCHES + "^(Apple)?Clang|GNU") + include(CheckCCompilerFlag) + include(CheckCXXCompilerFlag) + + check_c_compiler_flag("-fopenmp-simd" C_COMPILER_SUPPORTS_OPENMP_SIMD) + check_cxx_compiler_flag("-fopenmp-simd" CXX_COMPILER_SUPPORTS_OPENMP_SIMD) + target_compile_options( + ${CMAKE_PROJECT_NAME} + PRIVATE + -DSIMDE_ENABLE_OPENMP + "$<$,$>:-fopenmp-simd>" + "$<$,$>:-fopenmp-simd>") + endif() +endif() + +# macOS specific settings +if(OS_MACOS) + # Set macOS-specific C++ standard library + target_compile_options( + ${CMAKE_PROJECT_NAME} + PRIVATE "$<$:-fcolor-diagnostics>" -stdlib=libc++) + + # Set build architecture to host architecture by default + if(NOT CMAKE_OSX_ARCHITECTURES) + set(CMAKE_OSX_ARCHITECTURES + ${CMAKE_HOST_SYSTEM_PROCESSOR} + CACHE STRING "Build architecture for macOS" FORCE) + endif() + set_property(CACHE CMAKE_OSX_ARCHITECTURES PROPERTY STRINGS arm64 x86_64 "arm64;x86_64") + + # Set deployment target to 11.0 for Apple Silicon or 10.15 for Intel and Universal builds + if(NOT CMAKE_OSX_DEPLOYMENT_TARGET) + set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET[arch=arm64] "11.0") + set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET[arch=x86_64] "10.15") + + if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64") + set(_MACOS_DEPLOYMENT_TARGET "11.0") + else() + set(_MACOS_DEPLOYMENT_TARGET "10.15") + endif() + + set(CMAKE_OSX_DEPLOYMENT_TARGET + ${_MACOS_DEPLOYMENT_TARGET} + CACHE STRING + "Minimum macOS version to target for deployment (at runtime); newer APIs weak linked" + FORCE) + unset(_MACOS_DEPLOYMENT_TARGET) + endif() + + set_property(CACHE CMAKE_OSX_DEPLOYMENT_TARGET PROPERTY STRINGS 13.0 12.0 11.0 10.15) + + # Override macOS install directory + if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX + ${CMAKE_BINARY_DIR}/install + CACHE STRING "Directory to install OBS to after building" FORCE) + endif() + + # Set up codesigning for Xcode builds with team IDs or standalone builds with developer identity + if(NOT OBS_BUNDLE_CODESIGN_TEAM) + if(NOT OBS_BUNDLE_CODESIGN_IDENTITY) + set(OBS_BUNDLE_CODESIGN_IDENTITY + "-" + CACHE STRING "OBS code signing identity for macOS" FORCE) + endif() + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ${OBS_BUNDLE_CODESIGN_IDENTITY}) + else() + # Team ID specified, warn if Xcode generator is not used and fall back to ad-hoc signing + if(NOT XCODE) + message( + WARNING + "Code signing with a team identifier is only supported with the Xcode generator. Using ad-hoc code signature instead." + ) + if(NOT OBS_BUNDLE_CODESIGN_IDENTITY) + set(OBS_BUNDLE_CODESIGN_IDENTITY + "-" + CACHE STRING "OBS code signing identity for macOS" FORCE) + endif() + else() + unset(OBS_BUNDLE_CODESIGN_IDENTITY) + set_property(CACHE OBS_BUNDLE_CODESIGN_TEAM PROPERTY HELPSTRING + "OBS code signing team for macOS") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE Automatic) + set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${OBS_BUNDLE_CODESIGN_TEAM}) + endif() + endif() + + # Set path to entitlements property list for codesigning. Entitlements should match the host + # binary, in this case OBS.app. + set(OBS_CODESIGN_ENTITLEMENTS + ${CMAKE_SOURCE_DIR}/cmake/bundle/macos/entitlements.plist + CACHE INTERNAL "Path to codesign entitlements plist") + # Enable linker codesigning by default. Building OBS or plugins on host systems older than macOS + # 10.15 is not supported + set(OBS_CODESIGN_LINKER + ON + CACHE BOOL "Enable linker codesigning on macOS (macOS 11+ required)") + + # 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 + if(OBS_CODESIGN_LINKER) + set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "-o linker-signed") + 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) + + # Helper function for plugin targets (macOS version) + function(setup_plugin_target target) + # Sanity check for required bundle information + # + # * Bundle identifier + # * Bundle version + # * Short version string + 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 variables for automatic property list generation + set(MACOSX_PLUGIN_BUNDLE_NAME + "${target}" + PARENT_SCOPE) + set(MACOSX_PLUGIN_BUNDLE_VERSION + "${MACOSX_PLUGIN_BUNDLE_VERSION}" + PARENT_SCOPE) + set(MACOSX_PLUGIN_SHORT_VERSION_STRING + "${MACOSX_PLUGIN_SHORT_VERSION_STRING}" + PARENT_SCOPE) + set(MACOSX_PLUGIN_EXECUTABLE_NAME + "${target}" + PARENT_SCOPE) + set(MACOSX_PLUGIN_BUNDLE_TYPE + "BNDL" + PARENT_SCOPE) + + # Set installation target to install prefix root (default for bundles) + install( + TARGETS ${target} + LIBRARY DESTINATION "." + COMPONENT obs_plugins + NAMELINK_COMPONENT ${target}_Development) + + if(TARGET Qt::Core) + # Framework version has changed between Qt5 (uses wrong numerical version) and Qt6 (uses + # correct alphabetical version) + if(${_QT_VERSION} EQUAL 5) + set(_QT_FW_VERSION "${QT_VERSION}") + else() + set(_QT_FW_VERSION "A") + endif() + + # Set up install-time command to fix Qt library references to point into OBS.app bundle + set(_COMMAND + "${CMAKE_INSTALL_NAME_TOOL} \\ + -change ${CMAKE_PREFIX_PATH}/lib/QtWidgets.framework/Versions/${QT_VERSION}/QtWidgets @rpath/QtWidgets.framework/Versions/${_QT_FW_VERSION}/QtWidgets \\ + -change ${CMAKE_PREFIX_PATH}/lib/QtCore.framework/Versions/${QT_VERSION}/QtCore @rpath/QtCore.framework/Versions/${_QT_FW_VERSION}/QtCore \\ + -change ${CMAKE_PREFIX_PATH}/lib/QtGui.framework/Versions/${QT_VERSION}/QtGui @rpath/QtGui.framework/Versions/${_QT_FW_VERSION}/QtGui \\ + \\\"\${CMAKE_INSTALL_PREFIX}/${target}.plugin/Contents/MacOS/${target}\\\"") + install(CODE "execute_process(COMMAND /bin/sh -c \"${_COMMAND}\")" COMPONENT obs_plugins) + unset(_QT_FW_VERSION) + endif() + + # Set macOS bundle properties + set_target_properties( + ${target} + PROPERTIES PREFIX "" + 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_ENTITLEMENTS + "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/bundle/macOS/entitlements.plist") + + # If not building with Xcode, manually code-sign the plugin + 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() + + install_bundle_resources(${target}) + endfunction() + + # Helper function to add resources from "data" directory as bundle resources + 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() + # Check for target architecture (64bit vs 32bit) + 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) + + # Unix specific settings + if(OS_POSIX) + # Paths to binaries and plugins differ between portable and non-portable builds on Linux + option(LINUX_PORTABLE "Build portable version (Linux)" ON) + 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() + + # Setup Linux-specific CPack values for "deb" package generation + 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_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-linux-x86_64") + + 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() + # Windows specific settings + 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") + + if(MSVC) + # Set default Visual Studio CL.exe compile options. + # + # * Enable building with multiple processes, + # https://docs.microsoft.com/en-us/cpp/build/reference/mp-build-with-multiple-processes?view=msvc-170 + # * Enable lint-like warnings, + # https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level?view=msvc-170 + # * Enable treating all warnings as errors, + # https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level?view=msvc-170 + # * RelWithDebInfo ONLY - Enable expanding of all functions not explicitly marked for no + # inlining, + # https://docs.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170 + # * Enable UNICODE support, + # https://docs.microsoft.com/en-us/windows/win32/learnwin32/working-with-strings#unicode-and-ansi-functions + # * DISABLE warnings about using POSIX function names, + # https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=msvc-170#posix-function-names + # * DISABLE warnings about unsafe CRT library functions, + # https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=msvc-170#unsafe-crt-library-functions + # * DISABLE warnings about nonstandard nameless structs/unions, + # https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4201?view=msvc-170 + target_compile_options( + ${CMAKE_PROJECT_NAME} + PRIVATE /MP + /W3 + /WX + /wd4201 + "$<$:/Ob2>" + "$<$:/DDEBUG=1;/D_DEBUG=1>" + /DUNICODE + /D_UNICODE + /D_CRT_SECURE_NO_WARNINGS + /D_CRT_NONSTDC_NO_WARNINGS) + + # Set default Visual Studio linker options. + # + # * Enable removal of functions and data that are never used, + # https://docs.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=msvc-170 + # * Enable treating all warnings as errors, + # https://docs.microsoft.com/en-us/cpp/build/reference/wx-treat-linker-warnings-as-errors?view=msvc-170 + # * x64 ONLY - DISABLE creation of table of safe exception handlers, + # https://docs.microsoft.com/en-us/cpp/build/reference/safeseh-image-has-safe-exception-handlers?view=msvc-170 + # * Debug ONLY - DISABLE incremental linking, + # https://docs.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 + # * RelWithDebInfo ONLY - Disable incremental linking, but enable COMDAT folding, + # https://docs.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=msvc-170 + target_link_options( + ${CMAKE_PROJECT_NAME} + PRIVATE + "LINKER:/OPT:REF" + "LINKER:/WX" + "$<$>:LINKER\:/SAFESEH\:NO>" + "$<$:LINKER\:/INCREMENTAL\:NO>" + "$<$:LINKER\:/INCREMENTAL\:NO;/OPT\:ICF>") + endif() + endif() + + # Helper function for plugin targets (Windows and Linux version) + function(setup_plugin_target target) + # Set prefix to empty string to avoid automatic naming of generated library, i.e. + # "lib" + set_target_properties(${target} PROPERTIES PREFIX "") + + # Set install directories + install( + TARGETS ${target} + RUNTIME DESTINATION "${OBS_PLUGIN_DESTINATION}" COMPONENT ${target}_Runtime + LIBRARY DESTINATION "${OBS_PLUGIN_DESTINATION}" + COMPONENT ${target}_Runtime + NAMELINK_COMPONENT ${target}_Development) + + # Set rundir install directory + install( + FILES $ + DESTINATION $/${OBS_PLUGIN_DESTINATION} + COMPONENT obs_rundir + EXCLUDE_FROM_ALL) + + if(OS_WINDOWS) + # Set install directory for optional PDB symbol files + install( + FILES $ + CONFIGURATIONS "RelWithDebInfo" "Debug" + DESTINATION ${OBS_PLUGIN_DESTINATION} + COMPONENT ${target}_Runtime + OPTIONAL) + + # Set rundir install directory for optional PDB symbol files + install( + FILES $ + CONFIGURATIONS "RelWithDebInfo" "Debug" + DESTINATION $/${OBS_PLUGIN_DESTINATION} + COMPONENT obs_rundir + OPTIONAL EXCLUDE_FROM_ALL) + endif() + + # Add resources from data directory + setup_target_resources(${target} obs-plugins/${target}) + + # Set up plugin for testing in available OBS build on Windows + if(OS_WINDOWS AND DEFINED OBS_BUILD_DIR) + setup_target_for_testing(${target} obs-plugins/${target}) + endif() + + # Custom command to install generated plugin into rundir + 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=$ -P + ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake + COMMENT "Installing to plugin rundir" + VERBATIM) + endfunction() + + # Helper function to add resources from "data" directory + 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 $/${OBS_DATA_DESTINATION}/${destination} + USE_SOURCE_PERMISSIONS + COMPONENT obs_rundir + EXCLUDE_FROM_ALL) + endif() + endfunction() + + if(OS_WINDOWS) + # Additional Windows-only helper function to copy plugin to existing OBS development directory: + # + # Copies plugin with associated PDB symbol files as well as contents of data directory into the + # OBS rundir as specified by "OBS_BUILD_DIR". + function(setup_target_for_testing target destination) + install( + FILES $ + DESTINATION $/${OBS_PLUGIN_DESTINATION} + COMPONENT obs_testing + EXCLUDE_FROM_ALL) + + install( + FILES $ + CONFIGURATIONS "RelWithDebInfo" "Debug" + DESTINATION $/${OBS_PLUGIN_DESTINATION} + COMPONENT obs_testing + OPTIONAL EXCLUDE_FROM_ALL) + + install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/ + DESTINATION $/${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=$ -P + ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake + COMMENT "Installing to OBS test directory" + VERBATIM) + endfunction() + endif() +endif() diff --git a/cmake/bundle/macos/Plugin-Info.plist.in b/cmake/bundle/macos/Plugin-Info.plist.in new file mode 100644 index 0000000..1b0f234 --- /dev/null +++ b/cmake/bundle/macos/Plugin-Info.plist.in @@ -0,0 +1,26 @@ + + + + + CFBundleName + ${MACOSX_PLUGIN_BUNDLE_NAME} + CFBundleIdentifier + ${MACOSX_PLUGIN_GUI_IDENTIFIER} + CFBundleVersion + ${MACOSX_PLUGIN_BUNDLE_VERSION} + CFBundleShortVersionString + ${MACOSX_PLUGIN_SHORT_VERSION_STRING} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleExecutable + ${MACOSX_PLUGIN_EXECUTABLE_NAME} + CFBundlePackageType + ${MACOSX_PLUGIN_BUNDLE_TYPE} + CFBundleSupportedPlatforms + + MacOSX + + LSMinimumSystemVersion + 10.13 + + diff --git a/cmake/bundle/macos/entitlements.plist b/cmake/bundle/macos/entitlements.plist new file mode 100644 index 0000000..516d0d5 --- /dev/null +++ b/cmake/bundle/macos/entitlements.plist @@ -0,0 +1,17 @@ + + + + + com.apple.security.cs.allow-unsigned-executable-memory + + com.apple.security.device.camera + + com.apple.security.device.audio-input + + com.apple.security.cs.disable-library-validation + + + com.apple.security.cs.allow-dyld-environment-variables + + + diff --git a/installer/mac/OBS.pkgproj b/cmake/bundle/macos/installer-macos.pkgproj.in old mode 100755 new mode 100644 similarity index 76% rename from installer/mac/OBS.pkgproj rename to cmake/bundle/macos/installer-macos.pkgproj.in index d046d93..2a1f643 --- a/installer/mac/OBS.pkgproj +++ b/cmake/bundle/macos/installer-macos.pkgproj.in @@ -46,68 +46,30 @@ CHILDREN + BUNDLE_CAN_DOWNGRADE + + BUNDLE_POSTINSTALL_PATH + + PATH_TYPE + 0 + + BUNDLE_PREINSTALL_PATH + + PATH_TYPE + 0 + CHILDREN - - - CHILDREN - - - CHILDREN - - GID - 80 - PATH - ../../StreamDeckPlugin.so - PATH_TYPE - 1 - PERMISSIONS - 493 - TYPE - 3 - UID - 0 - - - GID - 80 - PATH - bin - PATH_TYPE - 2 - PERMISSIONS - 493 - TYPE - 2 - UID - 0 - - - CHILDREN - - GID - 80 - PATH - data - PATH_TYPE - 2 - PERMISSIONS - 493 - TYPE - 2 - UID - 0 - - + GID 80 PATH - StreamDeckPlugin + ../@RELATIVE_INSTALL_PATH@/@CMAKE_PROJECT_NAME@.plugin PATH_TYPE - 2 + 1 PERMISSIONS 493 TYPE - 2 + 3 UID 0 @@ -119,7 +81,7 @@ PATH_TYPE 2 PERMISSIONS - 493 + 509 TYPE 2 UID @@ -133,7 +95,7 @@ PATH_TYPE 2 PERMISSIONS - 493 + 509 TYPE 2 UID @@ -525,7 +487,7 @@ SHOW_INVISIBLE SPLIT_FORKS - + TREAT_MISSING_FILES_AS_WARNING VERSION @@ -535,17 +497,13 @@ POSTINSTALL_PATH - PATH - post-installation.sh PATH_TYPE - 3 + 0 PREINSTALL_PATH - PATH - pre-installation.sh PATH_TYPE - 3 + 0 RESOURCES @@ -553,19 +511,19 @@ PACKAGE_SETTINGS AUTHENTICATION - 1 + 0 CONCLUSION_ACTION 0 FOLLOW_SYMBOLIC_LINKS IDENTIFIER - com.elgato.ElgatoRemoteControlOBS + @MACOS_BUNDLEID@ LOCATION 0 NAME - Elgato Remote Control for OBS + @CMAKE_PROJECT_NAME@ OVERWRITE_PERMISSIONS - + PAYLOAD_SIZE -1 REFERENCE_PATH @@ -575,12 +533,12 @@ USE_HFS+_COMPRESSION VERSION - 1.0 + @CMAKE_PROJECT_VERSION@ TYPE 0 UUID - 3268B2F9-7EAD-441B-9993-3EE78F5F3FCC + 0B7A74BC-65CF-4FF1-AC34-5C743E8A48F5 PROJECT @@ -589,79 +547,21 @@ NOTES - PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBIVE1M - IDQuMDEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvVFIvaHRtbDQv - c3RyaWN0LmR0ZCI+CjxodG1sPgo8aGVhZD4KPG1ldGEgaHR0cC1l - cXVpdj0iQ29udGVudC1UeXBlIiBjb250ZW50PSJ0ZXh0L2h0bWw7 - IGNoYXJzZXQ9VVRGLTgiPgo8bWV0YSBodHRwLWVxdWl2PSJDb250 - ZW50LVN0eWxlLVR5cGUiIGNvbnRlbnQ9InRleHQvY3NzIj4KPHRp - dGxlPjwvdGl0bGU+CjxtZXRhIG5hbWU9IkdlbmVyYXRvciIgY29u - dGVudD0iQ29jb2EgSFRNTCBXcml0ZXIiPgo8bWV0YSBuYW1lPSJD - b2NvYVZlcnNpb24iIGNvbnRlbnQ9IjE1MDQuODIiPgo8c3R5bGUg - dHlwZT0idGV4dC9jc3MiPgo8L3N0eWxlPgo8L2hlYWQ+Cjxib2R5 - Pgo8L2JvZHk+CjwvaHRtbD4K PROJECT_PRESENTATION BACKGROUND - ALIGNMENT - 0 APPAREANCES DARK_AQUA - - ALIGNMENT - 0 - BACKGROUND_PATH - - PATH - backgroundDark.png - PATH_TYPE - 3 - - CUSTOM - - LAYOUT_DIRECTION - 0 - SCALING - 1 - + LIGHT_AQUA - - ALIGNMENT - 0 - BACKGROUND_PATH - - PATH - backgroundLight.png - PATH_TYPE - 3 - - CUSTOM - - LAYOUT_DIRECTION - 0 - SCALING - 1 - - - BACKGROUND_PATH - - PATH - backgroundLight.png - PATH_TYPE - 3 + - CUSTOM - - LAYOUT_DIRECTION - 0 - SCALING - 1 SHARED_SETTINGS_FOR_ALL_APPAREANCES - + INSTALLATION TYPE @@ -679,18 +579,18 @@ OPTIONS HIDDEN - + STATE - 0 + 1 PACKAGE_UUID - 3268B2F9-7EAD-441B-9993-3EE78F5F3FCC + 0B7A74BC-65CF-4FF1-AC34-5C743E8A48F5 TITLE TYPE 0 UUID - DB00584B-2B4D-4B13-8D09-9AD318CA1E70 + 52B6084A-F58D-45C3-BE37-76AD45F16072 REMOVED @@ -698,7 +598,7 @@ MODE - 1 + 0 INSTALLATION_STEPS @@ -784,165 +684,57 @@ TITLE LOCALIZATIONS - - - LANGUAGE - English - VALUE - Elgato Remote Control for OBS - - + PROJECT_REQUIREMENTS LIST - - BEHAVIOR - 3 - DICTIONARY - - IC_REQUIREMENT_SCRIPT_ARGUMENTS - - IC_REQUIREMENT_SCRIPT_COMPARATOR - 0 - IC_REQUIREMENT_SCRIPT_EMBED - - IC_REQUIREMENT_SCRIPT_PATH - - PATH - chkOSVer.sh - PATH_TYPE - 3 - - IC_REQUIREMENT_SCRIPT_VALUE - 0 - - IC_REQUIREMENT_CHECK_TYPE - 0 - IDENTIFIER - fr.whitebox.Packages.requirement.scripts - MESSAGE - - - LANGUAGE - English - SECONDARY_VALUE - - VALUE - This application requires macOS Sierra 10.12 or later. - - - NAME - check os - STATE - - BEHAVIOR 3 DICTIONARY IC_REQUIREMENT_OS_DISK_TYPE - 0 + 1 IC_REQUIREMENT_OS_DISTRIBUTION_TYPE 0 IC_REQUIREMENT_OS_MINIMUM_VERSION - 101101 + 101300 IC_REQUIREMENT_CHECK_TYPE - 1 + 0 IDENTIFIER fr.whitebox.Packages.requirement.os MESSAGE - - - LANGUAGE - English - VALUE - small then minimzed request of OS. - - + NAME Operating System STATE - + RESOURCES - - - CHILDREN - - GID - 0 - PATH - backgroundDark.png - PATH_TYPE - 3 - PERMISSIONS - 420 - TYPE - 3 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - backgroundLight.png - PATH_TYPE - 3 - PERMISSIONS - 420 - TYPE - 3 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - ../../StreamDeckPlugin.so - PATH_TYPE - 1 - PERMISSIONS - 493 - TYPE - 3 - UID - 0 - - + ROOT_VOLUME_ONLY - + PROJECT_SETTINGS ADVANCED_OPTIONS - installer-script.options.platforms.client:arch - - - - installer-script:minSpecVersion - + installer-script.domains:enable_currentUserHome + 1 BUILD_FORMAT 0 BUILD_PATH PATH - ../../ + ../@RELATIVE_BUILD_PATH@ PATH_TYPE - 3 + 1 EXCLUDED_FILES @@ -1113,7 +905,7 @@ NAME - Elgato Remote Control for OBS + @CMAKE_PROJECT_NAME@ PAYLOAD_ONLY TREAT_MISSING_PRESENTATION_DOCUMENTS_AS_WARNING diff --git a/cmake/bundle/windows/installer-Windows.iss.in b/cmake/bundle/windows/installer-Windows.iss.in new file mode 100644 index 0000000..4cc709b --- /dev/null +++ b/cmake/bundle/windows/installer-Windows.iss.in @@ -0,0 +1,64 @@ +#define MyAppName "@CMAKE_PROJECT_NAME@" +#define MyAppVersion "@CMAKE_PROJECT_VERSION@" +#define MyAppPublisher "@PLUGIN_AUTHOR@" +#define MyAppURL "http://www.mywebsite.com" + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. +; Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{CD703FE5-1F2C-4837-BD3D-DD840D83C3E3} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={code:GetDirName} +DefaultGroupName={#MyAppName} +OutputBaseFilename={#MyAppName}-{#MyAppVersion}-Windows-Installer +Compression=lzma +SolidCompression=yes +DirExistsWarning=no + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Files] +Source: "..\release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "..\LICENSE"; Flags: dontcopy +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}" +Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" + +[Code] +procedure InitializeWizard(); +var + GPLText: AnsiString; + Page: TOutputMsgMemoWizardPage; +begin + ExtractTemporaryFile('LICENSE'); + LoadStringFromFile(ExpandConstant('{tmp}\LICENSE'), GPLText); + Page := CreateOutputMsgMemoPage(wpWelcome, + 'License Information', 'Please review the license terms before installing {#MyAppName}', + 'Press Page Down to see the rest of the agreement. Once you are aware of your rights, click Next to continue.', + String(GPLText) + ); +end; + +// credit where it's due : +// following function come from https://github.com/Xaymar/obs-studio_amf-encoder-plugin/blob/master/%23Resources/Installer.in.iss#L45 +function GetDirName(Value: string): string; +var + InstallPath: string; +begin + // initialize default path, which will be returned when the following registry + // key queries fail due to missing keys or for some different reason + Result := '{autopf}\obs-studio'; + // query the first registry value; if this succeeds, return the obtained value + if RegQueryStringValue(HKLM32, 'SOFTWARE\OBS Studio', '', InstallPath) then + Result := InstallPath +end; + diff --git a/cmake/bundle/windows/resource.rc.in b/cmake/bundle/windows/resource.rc.in new file mode 100644 index 0000000..fc4a5b4 --- /dev/null +++ b/cmake/bundle/windows/resource.rc.in @@ -0,0 +1,32 @@ +1 VERSIONINFO + FILEVERSION ${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},0 + PRODUCTVERSION ${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},0 + FILEFLAGSMASK 0x0L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x0L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "${PLUGIN_AUTHOR}" + VALUE "FileDescription", "${PROJECT_NAME}" + VALUE "FileVersion", "${PROJECT_VERSION}" + VALUE "InternalName", "${PROJECT_NAME}" + VALUE "LegalCopyright", "(C) ${PLUGIN_AUTHOR}" + VALUE "OriginalFilename", "${PROJECT_NAME}" + VALUE "ProductName", "${PROJECT_NAME}" + VALUE "ProductVersion", "${PROJECT_VERSION}" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/installer/mac/backgroundDark.png b/installer/mac/backgroundDark.png deleted file mode 100644 index 28cd910..0000000 Binary files a/installer/mac/backgroundDark.png and /dev/null differ diff --git a/installer/mac/backgroundLight.png b/installer/mac/backgroundLight.png deleted file mode 100644 index 99fea1f..0000000 Binary files a/installer/mac/backgroundLight.png and /dev/null differ diff --git a/installer/mac/chkOSVer.sh b/installer/mac/chkOSVer.sh deleted file mode 100755 index d25e50c..0000000 --- a/installer/mac/chkOSVer.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -# http://stackoverflow.com/questions/4023830/how-compare-two-strings-in-dot-separated-version-format-in-bash -vercomp () -{ - if [[ $1 == $2 ]] - then - return 0 - fi - local IFS=. - local i ver1=($1) ver2=($2) - # fill empty fields in ver1 with zeros - for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) - do - ver1[i]=0 - done - for ((i=0; i<${#ver1[@]}; i++)) - do - if [[ -z ${ver2[i]} ]] - then - # fill empty fields in ver2 with zeros - ver2[i]=0 - fi - if ((10#${ver1[i]} > 10#${ver2[i]})) - then - return 1 - fi - if ((10#${ver1[i]} < 10#${ver2[i]})) - then - return 2 - fi - done - return 0 -} - -#------------------------------------------------------------------- -osVer="$(sw_vers -productVersion)" -minVer="10.12.0" - -echo "current OS version: ${osVer}" -echo "minimum OS Version: $minVer" - - -vercomp ${osVer} $minVer - -case $? in - 0) - op='=' - echo "result: os version equal minimum OS Version" - exit 0 - ;; - 1) - op='>' - echo "result: os version bigger than minimum OS Version" - exit 0 - ;; - 2) - op='<' - echo "result: os version smaller than minimum OS Version" - exit -1 - ;; -esac - -exit -1 diff --git a/installer/mac/post-installation.sh b/installer/mac/post-installation.sh deleted file mode 100755 index a9bf588..0000000 --- a/installer/mac/post-installation.sh +++ /dev/null @@ -1 +0,0 @@ -#!/bin/bash diff --git a/installer/mac/pre-installation.sh b/installer/mac/pre-installation.sh deleted file mode 100755 index a9bf588..0000000 --- a/installer/mac/pre-installation.sh +++ /dev/null @@ -1 +0,0 @@ -#!/bin/bash diff --git a/obs-scripts/actions/build-plugin/action.yml b/obs-scripts/actions/build-plugin/action.yml new file mode 100644 index 0000000..1e91d15 --- /dev/null +++ b/obs-scripts/actions/build-plugin/action.yml @@ -0,0 +1,77 @@ +name: 'Setup and build plugin' +description: 'Builds the plugin for specified architecture and build config.' +inputs: + target: + description: 'Build target for dependencies' + required: true + config: + description: 'Build configuration' + required: false + default: 'Release' + codesign: + description: 'Enable codesigning (macOS only)' + required: false + default: 'false' + codesignIdent: + description: 'Developer ID for application codesigning (macOS only)' + required: false + default: '-' + visualStudio: + description: 'Visual Studio version (Windows only)' + required: false + default: 'Visual Studio 16 2019' + workingDirectory: + description: 'Working directory for packaging' + required: false + default: ${{ github.workspace }} +runs: + using: 'composite' + steps: + - name: Run macOS Build + if: ${{ runner.os == 'macOS' }} + shell: zsh {0} + env: + CODESIGN_IDENT: ${{ inputs.codesignIdent }} + run: | + build_args=( + -c ${{ inputs.config }} + -t macos-${{ inputs.target }} + ) + + if [[ '${{ inputs.codesign }}' == 'true' ]] build_args+=(-s) + if (( ${+CI} && ${+RUNNER_DEBUG} )) build_args+=(--debug) + + ${{ inputs.workingDirectory }}/.github/scripts/build-macos.zsh ${build_args} + + - name: Run Linux Build + if: ${{ runner.os == 'Linux' }} + shell: bash + run: | + build_args=( + -c ${{ inputs.config }} + -t linux-${{ inputs.target }} + ) + + if [[ -n "${CI}" && -n "${RUNNER_DEBUG}" ]]; then + build_args+=(--debug) + fi + + ${{ inputs.workingDirectory }}/.github/scripts/build-linux.sh "${build_args[@]}" + + - name: Run Windows Build + if: ${{ runner.os == 'Windows' }} + shell: pwsh + run: | + $BuildArgs = @{ + Target = '${{ inputs.target }}' + Configuration = '${{ inputs.config }}' + CMakeGenerator = '${{ inputs.visualStudio }}' + } + + if ( ( Test-Path env:CI ) -and ( Test-Path env:RUNNER_DEBUG ) ) { + $BuildArgs += @{ + Debug = $true + } + } + + ${{ inputs.workingDirectory }}/.github/scripts/Build-Windows.ps1 @BuildArgs diff --git a/obs-scripts/actions/package-plugin/action.yml b/obs-scripts/actions/package-plugin/action.yml new file mode 100644 index 0000000..094803e --- /dev/null +++ b/obs-scripts/actions/package-plugin/action.yml @@ -0,0 +1,99 @@ +name: 'Package plugin' +description: 'Packages the plugin for specified architecture and build config.' +inputs: + target: + description: 'Build target for dependencies' + required: true + config: + description: 'Build configuration' + required: false + default: 'Release' + codesign: + description: 'Enable codesigning (macOS only)' + required: false + default: 'false' + notarize: + description: 'Enable notarization (macOS only)' + required: false + default: 'false' + codesignIdent: + description: 'Developer ID for application codesigning (macOS only)' + required: false + default: '-' + installerIdent: + description: 'Developer ID for installer package codesigning (macOS only)' + required: false + default: '' + codesignUser: + description: 'Apple ID username for notarization (macOS only)' + required: false + default: '' + codesignPass: + description: 'Apple ID password for notarization (macOS only)' + required: false + default: '' + createInstaller: + description: 'Create InnoSetup installer (Windows only)' + required: false + default: 'false' + workingDirectory: + description: 'Working directory for packaging' + required: false + default: ${{ github.workspace }} +runs: + using: 'composite' + steps: + - name: Run macOS packaging + if: ${{ runner.os == 'macOS' }} + shell: zsh {0} + env: + CODESIGN_IDENT: ${{ inputs.codesignIdent }} + CODESIGN_IDENT_INSTALLER: ${{ inputs.installerIdent }} + CODESIGN_IDENT_USER: ${{ inputs.codesignUser }} + CODESIGN_IDENT_PASS: ${{ inputs.codesignPass }} + run: | + package_args=( + -c ${{ inputs.config }} + -t macos-${{ inputs.target }} + ) + + if [[ '${{ inputs.codesign }}' == 'true' ]] package_args+=(-s) + if [[ '${{ inputs.notarize }}' == 'true' ]] package_args+=(-n) + if (( ${+CI} && ${+RUNNER_DEBUG} )) build_args+=(--debug) + + ${{ inputs.workingDirectory }}/.github/scripts/package-macos.zsh ${package_args} + + - name: Run Linux packaging + if: ${{ runner.os == 'Linux' }} + shell: bash + run: | + package_args=( + -c ${{ inputs.config }} + -t linux-${{ inputs.target }} + ) + if [[ -n "${CI}" && -n "${RUNNER_DEBUG}" ]]; then + build_args+=(--debug) + fi + + ${{ inputs.workingDirectory }}/.github/scripts/package-linux.sh "${package_args[@]}" + + - name: Run Windows packaging + if: ${{ runner.os == 'Windows' }} + shell: pwsh + run: | + $PackageArgs = @{ + Target = '${{ inputs.target }}' + Configuration = '${{ inputs.config }}' + } + + if ( '${{ inputs.createInstaller }}' -eq 'true' ) { + $PackageArgs += @{BuildInstaller = $true} + } + + if ( ( Test-Path env:CI ) -and ( Test-Path env:RUNNER_DEBUG ) ) { + $BuildArgs += @{ + Debug = $true + } + } + + ${{ inputs.workingDirectory }}/.github/scripts/Package-Windows.ps1 @PackageArgs diff --git a/obs-scripts/scripts/.Aptfile b/obs-scripts/scripts/.Aptfile new file mode 100644 index 0000000..59196f0 --- /dev/null +++ b/obs-scripts/scripts/.Aptfile @@ -0,0 +1,9 @@ +package 'cmake' +package 'ccache' +package 'curl' +package 'git' +package 'jq' +package 'ninja-build', bin: 'ninja' +package 'pkg-config' +package 'clang' +package 'clang-format-13' diff --git a/obs-scripts/scripts/.Brewfile b/obs-scripts/scripts/.Brewfile new file mode 100644 index 0000000..6990ecf --- /dev/null +++ b/obs-scripts/scripts/.Brewfile @@ -0,0 +1,6 @@ +brew "ccache" +brew "coreutils" +brew "cmake" +brew "git" +brew "jq" +brew "ninja" diff --git a/obs-scripts/scripts/.Brewfile.lock.json b/obs-scripts/scripts/.Brewfile.lock.json new file mode 100644 index 0000000..fcf36ee --- /dev/null +++ b/obs-scripts/scripts/.Brewfile.lock.json @@ -0,0 +1,267 @@ +{ + "entries": { + "brew": { + "ccache": { + "version": "4.6.3", + "bottle": { + "rebuild": 0, + "root_url": "https://ghcr.io/v2/homebrew/core", + "files": { + "arm64_monterey": { + "cellar": ":any", + "url": "https://ghcr.io/v2/homebrew/core/ccache/blobs/sha256:d00f6995fde17848af8c0b5e10d35e8dbdbf2e0b7075737f59bc8942789b2934", + "sha256": "d00f6995fde17848af8c0b5e10d35e8dbdbf2e0b7075737f59bc8942789b2934" + }, + "arm64_big_sur": { + "cellar": ":any", + "url": "https://ghcr.io/v2/homebrew/core/ccache/blobs/sha256:d60513b435068f2de5874cca5162f130dc9ad8d9d9c5a30e3bd02062c0167480", + "sha256": "d60513b435068f2de5874cca5162f130dc9ad8d9d9c5a30e3bd02062c0167480" + }, + "monterey": { + "cellar": ":any", + "url": "https://ghcr.io/v2/homebrew/core/ccache/blobs/sha256:1160742c08e43d94c6247f50147f977fb88255c1626af71c68e855c967c367c4", + "sha256": "1160742c08e43d94c6247f50147f977fb88255c1626af71c68e855c967c367c4" + }, + "big_sur": { + "cellar": ":any", + "url": "https://ghcr.io/v2/homebrew/core/ccache/blobs/sha256:7deed925e3c8dc75e6f63504c4c9f4c23a4115984016837df24d5a29c92699b3", + "sha256": "7deed925e3c8dc75e6f63504c4c9f4c23a4115984016837df24d5a29c92699b3" + }, + "catalina": { + "cellar": ":any", + "url": "https://ghcr.io/v2/homebrew/core/ccache/blobs/sha256:592e5069f3c4bec8bd331196cf2267cdca487a87534107310c2d496d4b002021", + "sha256": "592e5069f3c4bec8bd331196cf2267cdca487a87534107310c2d496d4b002021" + }, + "x86_64_linux": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/ccache/blobs/sha256:e61a66d7252c1e75190e1df75c45de70d786c8137083440cd47db2ef6ebd97bd", + "sha256": "e61a66d7252c1e75190e1df75c45de70d786c8137083440cd47db2ef6ebd97bd" + } + } + } + }, + "coreutils": { + "version": "9.1", + "bottle": { + "rebuild": 0, + "root_url": "https://ghcr.io/v2/homebrew/core", + "files": { + "arm64_monterey": { + "cellar": "/opt/homebrew/Cellar", + "url": "https://ghcr.io/v2/homebrew/core/coreutils/blobs/sha256:6a9a4988eda436fb5bdb5969044579c2e618e21eee8c8bbe32614ad29fe56bd7", + "sha256": "6a9a4988eda436fb5bdb5969044579c2e618e21eee8c8bbe32614ad29fe56bd7" + }, + "arm64_big_sur": { + "cellar": "/opt/homebrew/Cellar", + "url": "https://ghcr.io/v2/homebrew/core/coreutils/blobs/sha256:85ef910aa223d48c0e73fc187aba54b86930c86f906e3d079ed0b114762bb24e", + "sha256": "85ef910aa223d48c0e73fc187aba54b86930c86f906e3d079ed0b114762bb24e" + }, + "monterey": { + "cellar": "/usr/local/Cellar", + "url": "https://ghcr.io/v2/homebrew/core/coreutils/blobs/sha256:7c9f988b4f9207415a5c96efd32376bc8cf2b280a7a36fbebb0b8fc334a14056", + "sha256": "7c9f988b4f9207415a5c96efd32376bc8cf2b280a7a36fbebb0b8fc334a14056" + }, + "big_sur": { + "cellar": "/usr/local/Cellar", + "url": "https://ghcr.io/v2/homebrew/core/coreutils/blobs/sha256:e446ef889d70bc377d67fa2d7f6a1fbc9faaee444a9e9086a1f5bd484069e5c0", + "sha256": "e446ef889d70bc377d67fa2d7f6a1fbc9faaee444a9e9086a1f5bd484069e5c0" + }, + "catalina": { + "cellar": "/usr/local/Cellar", + "url": "https://ghcr.io/v2/homebrew/core/coreutils/blobs/sha256:0d2117fa63dfcbb678c4e499f9ca0413c2c5bfa0a1bbdefde620434f2ead93a0", + "sha256": "0d2117fa63dfcbb678c4e499f9ca0413c2c5bfa0a1bbdefde620434f2ead93a0" + }, + "x86_64_linux": { + "cellar": "/home/linuxbrew/.linuxbrew/Cellar", + "url": "https://ghcr.io/v2/homebrew/core/coreutils/blobs/sha256:3c2fbec99344b50d620695d16197eb112cb8bee6d3f9e47cb682484755b91f38", + "sha256": "3c2fbec99344b50d620695d16197eb112cb8bee6d3f9e47cb682484755b91f38" + } + } + } + }, + "cmake": { + "version": "3.24.1", + "bottle": { + "rebuild": 0, + "root_url": "https://ghcr.io/v2/homebrew/core", + "files": { + "arm64_monterey": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:c9127632ab72ddb79e659fb87f194bc604342948bd332499326860e02a7cfa4e", + "sha256": "c9127632ab72ddb79e659fb87f194bc604342948bd332499326860e02a7cfa4e" + }, + "arm64_big_sur": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:324b9abb0023ce29c80119d2b0d1361ae69bc573e2dcdbcd2f5bfcffe715a6e3", + "sha256": "324b9abb0023ce29c80119d2b0d1361ae69bc573e2dcdbcd2f5bfcffe715a6e3" + }, + "monterey": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:d40d888e7ce0d4fa898bac4c8afb964c9a4fa3d7d9a4877fc7223a2ee3160e96", + "sha256": "d40d888e7ce0d4fa898bac4c8afb964c9a4fa3d7d9a4877fc7223a2ee3160e96" + }, + "big_sur": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:e95e1f4a6c430affa61a458ee2ea3fdce1a76a6f4a5c358382187f28ec20535f", + "sha256": "e95e1f4a6c430affa61a458ee2ea3fdce1a76a6f4a5c358382187f28ec20535f" + }, + "catalina": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:ae58875a2d89c985e92348cbc2f848433b31f2dad2a94973bce7f135c777e0c0", + "sha256": "ae58875a2d89c985e92348cbc2f848433b31f2dad2a94973bce7f135c777e0c0" + }, + "x86_64_linux": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:e58aeb64631bf97d05c12d8efe72b45d6ec9662e891b7abfa0e25b2c7af1ac7f", + "sha256": "e58aeb64631bf97d05c12d8efe72b45d6ec9662e891b7abfa0e25b2c7af1ac7f" + } + } + } + }, + "git": { + "version": "2.37.2", + "bottle": { + "rebuild": 0, + "root_url": "https://ghcr.io/v2/homebrew/core", + "files": { + "arm64_monterey": { + "cellar": "/opt/homebrew/Cellar", + "url": "https://ghcr.io/v2/homebrew/core/git/blobs/sha256:626f952d77c17bec5ce3e8de405e9ff23dd79695b65fcabce0b8843a9e493a29", + "sha256": "626f952d77c17bec5ce3e8de405e9ff23dd79695b65fcabce0b8843a9e493a29" + }, + "arm64_big_sur": { + "cellar": "/opt/homebrew/Cellar", + "url": "https://ghcr.io/v2/homebrew/core/git/blobs/sha256:701fcd4d036735dda4d5bf1963adb809fddadb9e59cf833aee09bb0a4d15bd56", + "sha256": "701fcd4d036735dda4d5bf1963adb809fddadb9e59cf833aee09bb0a4d15bd56" + }, + "monterey": { + "cellar": "/usr/local/Cellar", + "url": "https://ghcr.io/v2/homebrew/core/git/blobs/sha256:ce3061dcf134a71ba7dea703eab44a2481bb820daa297d48f9e3660f58168347", + "sha256": "ce3061dcf134a71ba7dea703eab44a2481bb820daa297d48f9e3660f58168347" + }, + "big_sur": { + "cellar": "/usr/local/Cellar", + "url": "https://ghcr.io/v2/homebrew/core/git/blobs/sha256:35f1fa27307ecd221d2646f1652660a5fbc1446c9854d7e0550a930e767fb8bf", + "sha256": "35f1fa27307ecd221d2646f1652660a5fbc1446c9854d7e0550a930e767fb8bf" + }, + "catalina": { + "cellar": "/usr/local/Cellar", + "url": "https://ghcr.io/v2/homebrew/core/git/blobs/sha256:b298a21602fe2b188fa2c9d929e61165568ab37de995088ebaa30abacaf05082", + "sha256": "b298a21602fe2b188fa2c9d929e61165568ab37de995088ebaa30abacaf05082" + }, + "x86_64_linux": { + "cellar": "/home/linuxbrew/.linuxbrew/Cellar", + "url": "https://ghcr.io/v2/homebrew/core/git/blobs/sha256:a1ea06b515e5f47d0efa5f97b3e54e9ea8672adba61f8f2125d57e246d7276d9", + "sha256": "a1ea06b515e5f47d0efa5f97b3e54e9ea8672adba61f8f2125d57e246d7276d9" + } + } + } + }, + "jq": { + "version": "1.6", + "bottle": { + "rebuild": 1, + "root_url": "https://ghcr.io/v2/homebrew/core", + "files": { + "arm64_monterey": { + "cellar": ":any", + "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:f70e1ae8df182b242ca004492cc0a664e2a8195e2e46f30546fe78e265d5eb87", + "sha256": "f70e1ae8df182b242ca004492cc0a664e2a8195e2e46f30546fe78e265d5eb87" + }, + "arm64_big_sur": { + "cellar": ":any", + "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:674b3ae41c399f1e8e44c271b0e6909babff9fcd2e04a2127d25e2407ea4dd33", + "sha256": "674b3ae41c399f1e8e44c271b0e6909babff9fcd2e04a2127d25e2407ea4dd33" + }, + "monterey": { + "cellar": ":any", + "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:7fee6ea327062b37d34ef5346a84810a1752cc7146fff1223fab76c9b45686e0", + "sha256": "7fee6ea327062b37d34ef5346a84810a1752cc7146fff1223fab76c9b45686e0" + }, + "big_sur": { + "cellar": ":any", + "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:bf0f8577632af7b878b6425476f5b1ab9c3bf66d65affb0c455048a173a0b6bf", + "sha256": "bf0f8577632af7b878b6425476f5b1ab9c3bf66d65affb0c455048a173a0b6bf" + }, + "catalina": { + "cellar": ":any", + "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:820a3c85fcbb63088b160c7edf125d7e55fc2c5c1d51569304499c9cc4b89ce8", + "sha256": "820a3c85fcbb63088b160c7edf125d7e55fc2c5c1d51569304499c9cc4b89ce8" + }, + "mojave": { + "cellar": ":any", + "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:71f0e76c5b22e5088426c971d5e795fe67abee7af6c2c4ae0cf4c0eb98ed21ff", + "sha256": "71f0e76c5b22e5088426c971d5e795fe67abee7af6c2c4ae0cf4c0eb98ed21ff" + }, + "high_sierra": { + "cellar": ":any", + "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:dffcffa4ea13e8f0f2b45c5121e529077e135ae9a47254c32182231662ee9b72", + "sha256": "dffcffa4ea13e8f0f2b45c5121e529077e135ae9a47254c32182231662ee9b72" + }, + "sierra": { + "cellar": ":any", + "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:bb4d19dc026c2d72c53eed78eaa0ab982e9fcad2cd2acc6d13e7a12ff658e877", + "sha256": "bb4d19dc026c2d72c53eed78eaa0ab982e9fcad2cd2acc6d13e7a12ff658e877" + }, + "x86_64_linux": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:2beea2c2c372ccf1081e9a5233fc3020470803254284aeecc071249d76b62338", + "sha256": "2beea2c2c372ccf1081e9a5233fc3020470803254284aeecc071249d76b62338" + } + } + } + }, + "ninja": { + "version": "1.11.0", + "bottle": { + "rebuild": 0, + "root_url": "https://ghcr.io/v2/homebrew/core", + "files": { + "arm64_monterey": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/ninja/blobs/sha256:46cdad783a36c60dcce23b8a1857e54dd0e3935f30ec4586596bad81c1b1c347", + "sha256": "46cdad783a36c60dcce23b8a1857e54dd0e3935f30ec4586596bad81c1b1c347" + }, + "arm64_big_sur": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/ninja/blobs/sha256:1b87214797b286ee46413e9099f686bba663ea838cb688f2a59e4fc48b9c2a7e", + "sha256": "1b87214797b286ee46413e9099f686bba663ea838cb688f2a59e4fc48b9c2a7e" + }, + "monterey": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/ninja/blobs/sha256:61f5f9c72b75a42e1f44a47932e476a1602594a8fe8e27a3dd73d89f4c356e8f", + "sha256": "61f5f9c72b75a42e1f44a47932e476a1602594a8fe8e27a3dd73d89f4c356e8f" + }, + "big_sur": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/ninja/blobs/sha256:99b7e8cf83eb6eda1e6c787eb970a67df2725a67e5c476c85172ed6c5701f32a", + "sha256": "99b7e8cf83eb6eda1e6c787eb970a67df2725a67e5c476c85172ed6c5701f32a" + }, + "catalina": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/ninja/blobs/sha256:cdd5ba34ff65ec225548bd872dd775bc29fb4ae3994a2a4629d367dfb02eff2a", + "sha256": "cdd5ba34ff65ec225548bd872dd775bc29fb4ae3994a2a4629d367dfb02eff2a" + }, + "x86_64_linux": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/ninja/blobs/sha256:745d1eb8dea681f16692b2dcdcb9e464547bb5d9c84e78b177898405421bc82b", + "sha256": "745d1eb8dea681f16692b2dcdcb9e464547bb5d9c84e78b177898405421bc82b" + } + } + } + } + } + }, + "system": { + "macos": { + "monterey": { + "HOMEBREW_VERSION": "3.5.10", + "HOMEBREW_PREFIX": "/opt/homebrew", + "Homebrew/homebrew-core": "12a796617c3233fcbf2daa2aba483eec1304eb86", + "CLT": "13.4.0.0.1.1651278267", + "Xcode": "13.4", + "macOS": "12.1" + } + } + } +} diff --git a/obs-scripts/scripts/.Wingetfile b/obs-scripts/scripts/.Wingetfile new file mode 100644 index 0000000..4e7c46e --- /dev/null +++ b/obs-scripts/scripts/.Wingetfile @@ -0,0 +1,3 @@ +package '7zip.7zip', path: '7-zip', bin: '7z' +package 'cmake', path: 'Cmake\bin', bin: 'cmake' +package 'innosetup', path: 'Inno Setup 6', bin: 'iscc' diff --git a/obs-scripts/scripts/.build.zsh b/obs-scripts/scripts/.build.zsh new file mode 100644 index 0000000..b5898ba --- /dev/null +++ b/obs-scripts/scripts/.build.zsh @@ -0,0 +1,246 @@ +#!/usr/bin/env zsh + +builtin emulate -L zsh +setopt EXTENDED_GLOB +setopt PUSHD_SILENT +setopt ERR_EXIT +setopt ERR_RETURN +setopt NO_UNSET +setopt PIPE_FAIL +setopt NO_AUTO_PUSHD +setopt NO_PUSHD_IGNORE_DUPS +setopt FUNCTION_ARGZERO + +## Enable for script debugging +# setopt WARN_CREATE_GLOBAL +# setopt WARN_NESTED_VAR +# setopt XTRACE + +autoload -Uz is-at-least && if ! is-at-least 5.2; then + print -u2 -PR "%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.2%b is the minimum supported version. Upgrade Zsh to fix this issue." + exit 1 +fi + +_trap_error() { + print -u2 -PR '%F{1} ✖︎ script execution error%f' + print -PR -e " + Callstack: + ${(j:\n :)funcfiletrace} + " + exit 2 +} + +build() { + if (( ! ${+SCRIPT_HOME} )) typeset -g SCRIPT_HOME=${ZSH_ARGZERO:A:h} + local host_os=${${(s:-:)ZSH_ARGZERO:t:r}[2]} + local target="${host_os}-${CPUTYPE}" + local project_root=${SCRIPT_HOME:A:h:h} + local buildspec_file="${project_root}/buildspec.json" + + trap '_trap_error' ZERR + + fpath=("${SCRIPT_HOME}/utils.zsh" ${fpath}) + autoload -Uz log_info log_error log_output set_loglevel check_${host_os} setup_${host_os} setup_obs setup_ccache + + if [[ ! -r ${buildspec_file} ]] { + log_error \ + 'No buildspec.json found. Please create a build specification for your project.' \ + 'A buildspec.json.template file is provided in the repository to get you started.' + return 2 + } + + typeset -g -a skips=() + local -i _verbosity=1 + local -r _version='1.0.0' + local -r -a _valid_targets=( + macos-x86_64 + macos-arm64 + macos-universal + linux-x86_64 + ) + local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel) + if [[ ${host_os} == 'macos' ]] { + local -r -a _valid_generators=(Xcode Ninja 'Unix Makefiles') + local generator="${${CI:+Ninja}:-Xcode}" + } else { + local -r -a _valid_generators=(Ninja 'Unix Makefiles') + local generator='Ninja' + } + local -r _usage=" +Usage: %B${functrace[1]%:*}%b