cmake: Improve bootstrapping and versioning code

Should fix the "'u': undeclared identifier" problem when code is generated from a shallow clone. Also fixes the issue where the clang submodule is required instead of optional.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2023-05-03 18:09:05 +02:00 committed by Xaymar
parent e32bd8cdae
commit eea4cadca2
2 changed files with 252 additions and 240 deletions

View file

@ -8,21 +8,9 @@
# AUTOGENERATED COPYRIGHT HEADER END # AUTOGENERATED COPYRIGHT HEADER END
# CMake Setup # CMake Setup
cmake_minimum_required(VERSION 3.13...4.0) cmake_minimum_required(VERSION 3.26...4.0)
list(APPEND CMAKE_MESSAGE_INDENT "[StreamFX] ")
if(${CMAKE_VERSION} VERSION_LESS 3.19) project(StreamFX)
set(LOGPREFIX "[StreamFX] ")
else()
list(APPEND CMAKE_MESSAGE_INDENT "[StreamFX] ")
set(LOGPREFIX "")
endif()
# MacOSX: Require at least MacOSX 10.15 for C++17 support.
if(APPLE)
if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.15)
CacheSet(CMAKE_OSX_DEPLOYMENT_TARGET "10.15")
endif()
endif()
################################################################################ ################################################################################
# Modules # Modules
@ -36,15 +24,34 @@ set(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
) )
# Include # Include required Modules
include("util") # CacheClear, CacheSet # - Stock
include("version") # version() include("CheckIPOSupported")
include("CheckIPOSupported") # check_ipo_supported # - Custom
include("util")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/version/version.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/version/version.cmake")
else()
message(FATAL_ERROR "Please ensure you've cloned recursively and try again. Thank you!")
endif()
# Include optional Modules
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/clang/Clang.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/clang/Clang.cmake")
endif()
################################################################################ ################################################################################
# Detect if we are building with OBS Studio (different from Grouped builds) # Bootstrapping
################################################################################ ################################################################################
# MacOSX: Require at least MacOSX 10.15 for C++17 support.
if(APPLE)
if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.15)
CacheSet(CMAKE_OSX_DEPLOYMENT_TARGET "10.15")
endif()
endif()
# Check if this is standalone or bundled.
set(STANDALONE ON) set(STANDALONE ON)
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}") if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}")
set(GROUPED OFF) set(GROUPED OFF)
@ -57,169 +64,6 @@ else()
endif() endif()
endif() endif()
if(STANDALONE)
message(STATUS "${LOGPREFIX}This is a standalone build, please make sure you've followed the instructions.")
else()
message(STATUS "${LOGPREFIX}This is a combined build.")
endif()
################################################################################
# Versioning
################################################################################
# For automatic versioning, which version is the "root" of the current changes?
set(_VERSION_GIT_BASE "0.11.0")
# What is our version goal?
set(_VERSION "0.12.0")
version(PARSE _VERSION "${_VERSION}")
# If possible, automatically generate versions from git.
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git")
find_program(GIT
NAMES
git
git.exe
)
if(EXISTS "${GIT}")
# Calculate the Tweak version component from the given base version.
execute_process(
COMMAND "${GIT}" describe --tags --long --match "${_VERSION_GIT_BASE}" --abbrev=8 HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
RESULT_VARIABLE GIT_RESULT
OUTPUT_VARIABLE _VERSION_GIT
ERROR_VARIABLE GIT_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if(GIT_RESULT EQUAL 0)
# Some minor string editing so the output conforms to SemVer 2.0.0.
string(REPLACE "-" ";" _VERSION_GIT "${_VERSION_GIT}")
# Parse as SemVer 2.0.0
list(GET _VERSION_GIT 1 _VERSION_GIT_TWEAK)
list(GET _VERSION_GIT 2 _VERSION_GIT_BUILD)
# Update our global version.
version(MODIFY _VERSION "${_VERSION}" COMPRESS
TWEAK "${_VERSION_GIT_TWEAK}"
BUILD "${_VERSION_GIT_BUILD}"
PRERELEASE "a"
REQUIRE PATCH TWEAK
)
version(PARSE _VERSION "${_VERSION}" REQUIRE PATCH TWEAK)
else()
message(WARNING "${LOGPREFIX}Unable to detect Tweak and Build component with 'git'.")
endif()
# Is there a tag on the current commit?
execute_process(
COMMAND "${GIT}" tag "--sort=-v:refname" "--points-at" HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
RESULT_VARIABLE GIT_RESULT
OUTPUT_VARIABLE _VERSION_TAG
ERROR_VARIABLE GIT_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if((GIT_RESULT EQUAL 0) AND (NOT "${_VERSION_TAG}" STREQUAL ""))
# Some minor string editing so the output conforms to SemVer 2.0.0.
string(REGEX REPLACE "[\r\n]+.*" "" _VERSION_TAG "${_VERSION_TAG}")
# Parse as SemVer 2.0.0
version(PARSE _VERSION_TAG "${_VERSION_TAG}" REQUIRE PATCH TWEAK)
if(_VERSION_TAG_PRERELEASE)
string(SUBSTRING "${_VERSION_TAG_PRERELEASE}" 1 -1 _VERSION_TAG_TWEAK)
string(SUBSTRING "${_VERSION_TAG_PRERELEASE}" 0 1 _VERSION_TAG_PRERELEASE)
if(NOT _VERSION_TAG_TWEAK STREQUAL _VERSION_GIT_TWEAK)
message(WARNING "${LOGPREFIX}'git' tag mismatches detected version: '${_VERSION_TAG_TWEAK}' != '${_VERSION_GIT_TWEAK}'.")
endif()
endif()
# Update our global version.
version(GENERATE _VERSION COMPRESS
MAJOR "${_VERSION_TAG_MAJOR}"
MINOR "${_VERSION_TAG_MINOR}"
PATCH "${_VERSION_TAG_PATCH}"
TWEAK "${_VERSION_TAG_TWEAK}"
PRERELEASE "${_VERSION_TAG_PRERELEASE}"
BUILD "${_VERSION_BUILD}"
REQUIRE PATCH TWEAK
)
version(PARSE _VERSION "${_VERSION}" REQUIRE PATCH TWEAK)
endif()
else()
message(STATUS "${LOGPREFIX}'git' not found, automatic version detection disabled.")
endif()
else()
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 detected or pre-configured version with this string. Accepts strings in CMake and SemVer 2.0.0 format.")
if(NOT ("${${PREFIX}VERSION}" STREQUAL ""))
version(PARSE _VERSION_CFG "${${PREFIX}VERSION}" REQUIRE PATCH TWEAK)
if("${_VERSION_CFG_BUILD}" STREQUAL "")
set(_VERSION_CFG_BUILD "${_VERSION_BUILD}")
endif()
version(GENERATE _VERSION COMPRESS
MAJOR "${_VERSION_CFG_MAJOR}"
MINOR "${_VERSION_CFG_MINOR}"
PATCH "${_VERSION_CFG_PATCH}"
TWEAK "${_VERSION_CFG_TWEAK}"
PRERELEASE "${_VERSION_CFG_PRERELEASE}"
BUILD "${_VERSION_CFG_BUILD}"
REQUIRE PATCH TWEAK
)
endif()
set(_VERSION_THIN "${_VERSION_MAJOR}.${_VERSION_MINOR}.${_VERSION_PATCH}")
if(NOT (_VERSION_PRERELEASE STREQUAL ""))
set(_VERSION_THIN "${_VERSION_THIN}${_VERSION_PRERELEASE}${_VERSION_TWEAK}")
endif()
if(NOT (VERSION_COMMIT STREQUAL ""))
set(_VERSION_THIN "${_VERSION_THIN}-${_VERSION_BUILD}")
endif()
# Parse & Log the detected version.
message(STATUS "${LOGPREFIX}Version ${_VERSION}")
################################################################################
# Project
################################################################################
# Metadata
version(GENERATE PROJECT_VERSION
MAJOR "${_VERSION_MAJOR}"
MINOR "${_VERSION_MINOR}"
PATCH "${_VERSION_PATCH}"
TWEAK "${_VERSION_TWEAK}"
REQUIRE PATCH TWEAK
)
project(
StreamFX
VERSION ${PROJECT_VERSION}
DESCRIPTION "Additional sources, filters, transitions and encoders for OBS Studio."
HOMEPAGE_URL "https://streamfx.xaymar.com/"
)
set(PROJECT_IDENTIFER "com.xaymar.${PROJECT_NAME}.obs")
set(PROJECT_TITLE "StreamFX (for OBS Studio)")
set(PROJECT_AUTHORS "Michael Fabian 'Xaymar' Dirks <info@xaymar.com>")
set(PROJECT_COPYRIGHT "2017 - 2022, Michael Fabian Dirks. All Rights Reserved")
set(PROJECT_TRADEMARKS "")
list(APPEND PROJECT_TRADEMARKS
"AMD is a trademark of Advanced Micro Devices Inc."
"NVIDIA is a trademark of Nvidia Corporation"
)
################################################################################
# Platform Setup
################################################################################
# Operating System # Operating System
if(CMAKE_SYSTEM_NAME STREQUAL "Windows") if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(D_PLATFORM_OS "windows") set(D_PLATFORM_OS "windows")
@ -233,7 +77,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
else() else()
set(D_PLATFORM_OS "unknown") set(D_PLATFORM_OS "unknown")
set(D_PLATFORM_UNKNOWN 1) 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.") message(WARNING "The operating system '${CMAKE_SYSTEM_NAME}' is unknown to to this script, continue at your own risk.")
endif() endif()
# Architecture # Architecture
@ -284,24 +128,165 @@ if(FOUND GREATER -1)
set(D_PLATFORM_ARCH_ITANIUM ON) set(D_PLATFORM_ARCH_ITANIUM ON)
endif() endif()
# Interprocedural Optimization
check_ipo_supported(RESULT D_HAS_IPO) check_ipo_supported(RESULT D_HAS_IPO)
set(D_PLATFORM_INSTR ${ARCH_INST}) set(D_PLATFORM_INSTR ${ARCH_INST})
set(D_PLATFORM_ARCH ${ARCH_INST}) set(D_PLATFORM_ARCH ${ARCH_INST})
message(STATUS "${LOGPREFIX}Target is ${D_PLATFORM_BITS}bit ${ARCH_INST} with a pointer size of ${D_PLATFORM_BITS_PTR}bit.") message(STATUS "Target is ${D_PLATFORM_BITS}bit ${ARCH_INST} with a pointer size of ${D_PLATFORM_BITS_PTR}bit.")
################################################################################
# Versioning
################################################################################
version(GENERATE _VERSION COMPRESSED MAJOR 0 MINOR 0 PATCH 0 TWEAK 0 REQUIRE "PATCH;")
version(PARSE _VERSION "${_VERSION}" REQUIRE "PATCH;TWEAK")
# If possible, automatically generate versions from git.
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git")
find_program(GIT
NAMES
git
git.exe
)
if(EXISTS "${GIT}")
# Determine the version by exist tag match.
execute_process(COMMAND "${GIT}" tag "--sort=-v:refname" "--points-at" 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) AND (NOT "${GIT_OUTPUT}" STREQUAL ""))
# Some minor string editing so the output conforms to SemVer 2.0.0.
string(REGEX REPLACE "[\r\n]+.*" "" GIT_OUTPUT "${GIT_OUTPUT}")
# Parse as SemVer 2.0.0
version(PARSE GIT_OUTPUT "${GIT_OUTPUT}" REQUIRE "PATCH;TWEAK")
if(GIT_OUTPUT_PRERELEASE)
string(SUBSTRING "${GIT_OUTPUT_PRERELEASE}" 1 -1 GIT_OUTPUT_TWEAK)
string(SUBSTRING "${GIT_OUTPUT_PRERELEASE}" 0 1 GIT_OUTPUT_PRERELEASE)
if(NOT GIT_OUTPUT_TWEAK STREQUAL GIT_OUTPUT_TWEAK)
message(WARNING "'git' tag mismatches detected version: '${GIT_OUTPUT_TWEAK}' != '${GIT_OUTPUT_TWEAK}'.")
endif()
endif()
# Update our global version.
version(GENERATE _VERSION COMPRESS
MAJOR "${GIT_OUTPUT_MAJOR}"
MINOR "${GIT_OUTPUT_MINOR}"
PATCH "${GIT_OUTPUT_PATCH}"
TWEAK "${GIT_OUTPUT_TWEAK}"
PRERELEASE "${GIT_OUTPUT_PRERELEASE}"
BUILD "${_VERSION_BUILD}"
REQUIRE "PATCH;TWEAK"
)
else()
# Try and calculate the exist version using git.
execute_process(COMMAND "${GIT}" describe --tags --long --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) AND (NOT "${GIT_OUTPUT}" STREQUAL ""))
# Result will be MAJOR.MINOR.PATCH-TWEAK-gHASH
string(REPLACE "-" ";" GIT_OUTPUT "${GIT_OUTPUT}")
string(REPLACE "." ";" GIT_OUTPUT "${GIT_OUTPUT}")
# Split into components
list(GET GIT_OUTPUT 0 GIT_OUTPUT_MAJOR)
list(GET GIT_OUTPUT 1 GIT_OUTPUT_MINOR)
list(GET GIT_OUTPUT 2 GIT_OUTPUT_PATCH)
list(GET GIT_OUTPUT 3 GIT_OUTPUT_TWEAK)
list(GET GIT_OUTPUT 4 GIT_OUTPUT_BUILD)
# Special case: Tag contains prerelease
if(GIT_OUTPUT_PATCH MATCHES "([0-9]+)([a-zA-Z]+)([0-9]*)")
# Patch requires special parsing.
set(GIT_OUTPUT_PATCH "${CMAKE_MATCH_1}")
MATH(EXPR GIT_OUTPUT_TWEAK "${GIT_OUTPUT_TWEAK} + ${CMAKE_MATCH_3}")
# Modify the global version
version(MODIFY _VERSION "${_VERSION}" COMPRESS
MAJOR "${GIT_OUTPUT_MAJOR}"
MINOR "${GIT_OUTPUT_MINOR}"
PATCH "${GIT_OUTPUT_PATCH}"
TWEAK "${GIT_OUTPUT_TWEAK}"
BUILD "${GIT_OUTPUT_BUILD}"
PRERELEASE "a"
REQUIRE "PATCH;TWEAK"
)
else()
# Modify the global version
version(MODIFY _VERSION "${_VERSION}" COMPRESS
MAJOR "${GIT_OUTPUT_MAJOR}"
MINOR "${GIT_OUTPUT_MINOR}"
PATCH "${GIT_OUTPUT_PATCH}"
TWEAK "${GIT_OUTPUT_TWEAK}"
BUILD "${GIT_OUTPUT_BUILD}"
PRERELEASE "a"
REQUIRE "PATCH;TWEAK"
)
endif()
else()
execute_process(COMMAND "${GIT}" rev-list --count 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)
message(STATUS "GIT=${GIT_RESULT},${GIT_OUTPUT},${GIT_ERROR}")
if((GIT_RESULT EQUAL 0) AND (NOT "${GIT_OUTPUT}" STREQUAL ""))
version(MODIFY _VERSION "${_VERSION}" COMPRESS
TWEAK "${GIT_OUTPUT}"
PRERELEASE "a"
REQUIRE "PATCH;TWEAK"
)
execute_process(COMMAND "${GIT}" log -1 "--pretty=format:g%h" --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) AND (NOT "${GIT_OUTPUT}" STREQUAL ""))
version(MODIFY _VERSION "${_VERSION}" COMPRESS
BUILD "${GIT_OUTPUT}"
PRERELEASE "a"
REQUIRE "PATCH;TWEAK"
)
else()
message(WARNING "Failed to detect full version with 'git'.")
endif()
else()
message(WARNING "Failed to automatically detect version with 'git'.")
endif()
endif()
endif()
else()
message(WARNING "'git' not found, automatic version detection disabled.")
endif()
else()
message(STATUS "Not a git repository, automatic version detection disabled.")
endif()
version(PARSE _VERSION "${_VERSION}" REQUIRE "PATCH;TWEAK")
# Allow manual overrides of the detected version.
if(NOT ("${${PREFIX}VERSION}" STREQUAL ""))
version(PARSE _VERSION_CFG "${${PREFIX}VERSION}" REQUIRE "PATCH;TWEAK")
if("${_VERSION_CFG_BUILD}" STREQUAL "")
set(_VERSION_CFG_BUILD "${_VERSION_BUILD}")
endif()
version(GENERATE _VERSION COMPRESS
MAJOR "${_VERSION_CFG_MAJOR}"
MINOR "${_VERSION_CFG_MINOR}"
PATCH "${_VERSION_CFG_PATCH}"
TWEAK "${_VERSION_CFG_TWEAK}"
PRERELEASE "${_VERSION_CFG_PRERELEASE}"
BUILD "${_VERSION_CFG_BUILD}"
)
endif()
set(_VERSION_THIN "${_VERSION_MAJOR}.${_VERSION_MINOR}.${_VERSION_PATCH}")
if(NOT (_VERSION_PRERELEASE STREQUAL ""))
set(_VERSION_THIN "${_VERSION_THIN}${_VERSION_PRERELEASE}${_VERSION_TWEAK}")
endif()
if(NOT (VERSION_COMMIT STREQUAL ""))
set(_VERSION_THIN "${_VERSION_THIN}-${_VERSION_BUILD}")
endif()
# Parse & Log the detected version.
message(STATUS "Version ${_VERSION_THIN}")
################################################################################ ################################################################################
# Options # Options
################################################################################ ################################################################################
# Dependencies # Version override
if(STANDALONE) set(${PREFIX}VERSION "" CACHE STRING "Specify an override for the automatically detected version. Accepts a mixture of SemVer 2.0 and CMake Version.")
set(libobs_DIR "" CACHE PATH "Path to libobs and obs-frontend-api")
set(Qt_DIR "" CACHE PATH "Path to Qt6 or Qt5")
set(CURL_DIR "" CACHE PATH "Path to CURL")
set(FFmpeg_DIR "" CACHE PATH "Path to FFmpeg")
endif()
set(AOM_DIR "" CACHE PATH "Path to AOM library")
# Features # Features
## Encoders ## Encoders
@ -341,7 +326,9 @@ set(${PREFIX}ENABLE_FRONTEND ON CACHE BOOL "Enable Frontend code.")
set(${PREFIX}ENABLE_UPDATER ON CACHE BOOL "Enable automatic update checks.") set(${PREFIX}ENABLE_UPDATER ON CACHE BOOL "Enable automatic update checks.")
## Code Related ## Code Related
set(${PREFIX}ENABLE_CLANG OFF CACHE BOOL "Enable Clang integration for supported compilers.") if(COMMAND clang_format)
set(${PREFIX}ENABLE_CLANG OFF CACHE BOOL "Enable Clang integration for supported compilers.")
endif()
set(${PREFIX}ENABLE_PROFILING OFF CACHE BOOL "Enable CPU and GPU performance tracking, which has a non-zero overhead at all times. Do not enable this for release builds.") set(${PREFIX}ENABLE_PROFILING OFF CACHE BOOL "Enable CPU and GPU performance tracking, which has a non-zero overhead at all times. Do not enable this for release builds.")
## Compile/Link Related ## Compile/Link Related
@ -372,19 +359,44 @@ if(STANDALONE)
set(PACKAGE_SUFFIX "" CACHE STRING "Any suffix for the package name? (Defaults to the current version string)") set(PACKAGE_SUFFIX "" CACHE STRING "Any suffix for the package name? (Defaults to the current version string)")
endif() endif()
################################################################################ # Dependencies
# Clang if(STANDALONE)
################################################################################ set(libobs_DIR "" CACHE PATH "Path to libobs and obs-frontend-api")
set(Qt_DIR "" CACHE PATH "Path to Qt6 or Qt5")
if(${PREFIX}ENABLE_CLANG AND (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/clang/Clang.cmake")) set(CURL_DIR "" CACHE PATH "Path to CURL")
include("cmake/clang/Clang.cmake") set(FFmpeg_DIR "" CACHE PATH "Path to FFmpeg")
set(HAVE_CLANG ON)
endif() endif()
set(AOM_DIR "" CACHE PATH "Path to AOM library")
################################################################################ ################################################################################
# Project
################################################################################
# Metadata
version(GENERATE PROJECT_VERSION
MAJOR "${_VERSION_MAJOR}"
MINOR "${_VERSION_MINOR}"
PATCH "${_VERSION_PATCH}"
TWEAK "${_VERSION_TWEAK}"
REQUIRE PATCH TWEAK
)
project(
StreamFX
VERSION ${PROJECT_VERSION}
DESCRIPTION "Additional sources, filters, transitions and encoders for OBS Studio."
HOMEPAGE_URL "https://streamfx.xaymar.com/"
)
set(PROJECT_IDENTIFER "com.xaymar.${PROJECT_NAME}.obs")
set(PROJECT_TITLE "StreamFX (for OBS Studio)")
set(PROJECT_AUTHORS "Michael Fabian 'Xaymar' Dirks <info@xaymar.com>")
set(PROJECT_COPYRIGHT "2017 - 2022, Michael Fabian Dirks. All Rights Reserved")
set(PROJECT_TRADEMARKS "")
list(APPEND PROJECT_TRADEMARKS
"AMD is a trademark of Advanced Micro Devices Inc."
"NVIDIA is a trademark of Nvidia Corporation"
)
# Component search paths # Component search paths
################################################################################
list(APPEND CMAKE_PREFIX_PATH list(APPEND CMAKE_PREFIX_PATH
"${${PREFIX}AOM_PATH}" "${${PREFIX}AOM_PATH}"
"${${PREFIX}OBSDEPS_PATH}" "${${PREFIX}OBSDEPS_PATH}"
@ -446,20 +458,20 @@ function(feature_encoder_ffmpeg RESOLVE)
is_feature_enabled(ENCODER_FFMPEG T_CHECK) is_feature_enabled(ENCODER_FFMPEG T_CHECK)
if(RESOLVE AND T_CHECK) if(RESOLVE AND T_CHECK)
if(NOT HAVE_FFMPEG) if(NOT HAVE_FFMPEG)
message(WARNING "${LOGPREFIX}FFmpeg Encoder requires FFmpeg. Disabling...") message(WARNING "FFmpeg Encoder requires FFmpeg. Disabling...")
set_feature_disabled(ENCODER_FFMPEG ON) set_feature_disabled(ENCODER_FFMPEG ON)
else() else()
# AMF # AMF
is_feature_enabled(ENCODER_FFMPEG_AMF T_CHECK) is_feature_enabled(ENCODER_FFMPEG_AMF T_CHECK)
if(T_CHECK AND D_PLATFORM_MAC) if(T_CHECK AND D_PLATFORM_MAC)
message(WARNING "${LOGPREFIX}FFmpeg Encoder 'AMF' requires Windows or Linux. Disabling...") message(WARNING "FFmpeg Encoder 'AMF' requires Windows or Linux. Disabling...")
set_feature_disabled(ENCODER_FFMPEG_AMF ON) set_feature_disabled(ENCODER_FFMPEG_AMF ON)
endif() endif()
# NVENC # NVENC
is_feature_enabled(ENCODER_FFMPEG_NVENC T_CHECK) is_feature_enabled(ENCODER_FFMPEG_NVENC T_CHECK)
if(T_CHECK AND D_PLATFORM_MAC) if(T_CHECK AND D_PLATFORM_MAC)
message(WARNING "${LOGPREFIX}FFmpeg Encoder 'NVENC' requires Windows or Linux. Disabling...") message(WARNING "FFmpeg Encoder 'NVENC' requires Windows or Linux. Disabling...")
set_feature_disabled(ENCODER_FFMPEG_NVENC ON) set_feature_disabled(ENCODER_FFMPEG_NVENC ON)
endif() endif()
@ -478,7 +490,7 @@ function(feature_encoder_aom_av1 RESOLVE)
is_feature_enabled(ENCODER_AOM_AV1 T_CHECK) is_feature_enabled(ENCODER_AOM_AV1 T_CHECK)
if(RESOLVE AND T_CHECK) if(RESOLVE AND T_CHECK)
if(NOT HAVE_AOM) if(NOT HAVE_AOM)
message(WARNING "${LOGPREFIX}AOM AV1 encoder missing AOM library. Disabling...") message(WARNING "AOM AV1 encoder missing AOM library. Disabling...")
set_feature_disabled(ENCODER_AOM_AV1 ON) set_feature_disabled(ENCODER_AOM_AV1 ON)
endif() endif()
elseif(T_CHECK) elseif(T_CHECK)
@ -491,14 +503,14 @@ function(feature_filter_autoframing RESOLVE)
if(RESOLVE AND T_CHECK) if(RESOLVE AND T_CHECK)
# Verify that the requirements for the providers are available # Verify that the requirements for the providers are available
if(NOT HAVE_NVIDIA_AR_SDK) if(NOT HAVE_NVIDIA_AR_SDK)
message(WARNING "${LOGPREFIX}'NVIDIA Augmented Reality SDK' is missing. Disabling NVIDIA provider...") message(WARNING "'NVIDIA Augmented Reality SDK' is missing. Disabling NVIDIA provider...")
set_feature_disabled(FILTER_AUTOFRAMING_NVIDIA ON) set_feature_disabled(FILTER_AUTOFRAMING_NVIDIA ON)
endif() endif()
# Verify that we have at least one provider for Auto-Framing. # Verify that we have at least one provider for Auto-Framing.
is_feature_enabled(FILTER_AUTOFRAMING_NVIDIA T_CHECK_NVIDIA) is_feature_enabled(FILTER_AUTOFRAMING_NVIDIA T_CHECK_NVIDIA)
if(NOT T_CHECK_NVIDIA) if(NOT T_CHECK_NVIDIA)
message(WARNING "${LOGPREFIX}Auto-Framing has no available providers. Disabling...") message(WARNING "Auto-Framing has no available providers. Disabling...")
set_feature_disabled(FILTER_AUTOFRAMING ON) set_feature_disabled(FILTER_AUTOFRAMING ON)
endif() endif()
elseif(T_CHECK) elseif(T_CHECK)
@ -520,14 +532,14 @@ function(feature_filter_denoising RESOLVE)
if(RESOLVE AND T_CHECK) if(RESOLVE AND T_CHECK)
# Verify that the requirements for the providers are available # Verify that the requirements for the providers are available
if(NOT HAVE_NVIDIA_VFX_SDK) if(NOT HAVE_NVIDIA_VFX_SDK)
message(WARNING "${LOGPREFIX}'NVIDIA Video Effects SDK' is missing. Disabling NVIDIA provider...") message(WARNING "'NVIDIA Video Effects SDK' is missing. Disabling NVIDIA provider...")
set_feature_disabled(FILTER_DENOISING_NVIDIA ON) set_feature_disabled(FILTER_DENOISING_NVIDIA ON)
endif() endif()
# Verify that we have at least one provider for Video Denoising. # Verify that we have at least one provider for Video Denoising.
is_feature_enabled(FILTER_DENOISING_NVIDIA T_CHECK_NVIDIA) is_feature_enabled(FILTER_DENOISING_NVIDIA T_CHECK_NVIDIA)
if(NOT T_CHECK_NVIDIA) if(NOT T_CHECK_NVIDIA)
message(WARNING "${LOGPREFIX}Denoising has no available providers. Disabling...") message(WARNING "Denoising has no available providers. Disabling...")
set_feature_disabled(FILTER_DENOISING ON) set_feature_disabled(FILTER_DENOISING ON)
endif() endif()
elseif(T_CHECK) elseif(T_CHECK)
@ -560,14 +572,14 @@ function(feature_filter_upscaling RESOLVE)
if(RESOLVE AND T_CHECK) if(RESOLVE AND T_CHECK)
# Verify that the requirements for the providers are available # Verify that the requirements for the providers are available
if(NOT HAVE_NVIDIA_VFX_SDK) if(NOT HAVE_NVIDIA_VFX_SDK)
message(WARNING "${LOGPREFIX}'NVIDIA Video Effects SDK' is missing. Disabling NVIDIA provider(s)...") message(WARNING "'NVIDIA Video Effects SDK' is missing. Disabling NVIDIA provider(s)...")
set_feature_disabled(FILTER_UPSCALING_NVIDIA ON) set_feature_disabled(FILTER_UPSCALING_NVIDIA ON)
endif() endif()
# Verify that we have at least one provider for Video Super-Resolution. # Verify that we have at least one provider for Video Super-Resolution.
is_feature_enabled(FILTER_UPSCALING_NVIDIA T_CHECK_NVIDIA) is_feature_enabled(FILTER_UPSCALING_NVIDIA T_CHECK_NVIDIA)
if(NOT T_CHECK_NVIDIA) if(NOT T_CHECK_NVIDIA)
message(WARNING "${LOGPREFIX}Upscaling has no available providers. Disabling...") message(WARNING "Upscaling has no available providers. Disabling...")
set_feature_disabled(FILTER_UPSCALING ON) set_feature_disabled(FILTER_UPSCALING ON)
endif() endif()
elseif(T_CHECK) elseif(T_CHECK)
@ -580,14 +592,14 @@ function(feature_filter_virtual_greenscreen RESOLVE)
if(RESOLVE AND T_CHECK) if(RESOLVE AND T_CHECK)
# Verify that the requirements for the providers are available # Verify that the requirements for the providers are available
if(NOT HAVE_NVIDIA_VFX_SDK) if(NOT HAVE_NVIDIA_VFX_SDK)
message(WARNING "${LOGPREFIX}'NVIDIA Video Effects SDK' is missing. Disabling NVIDIA provider(s)...") message(WARNING "'NVIDIA Video Effects SDK' is missing. Disabling NVIDIA provider(s)...")
set_feature_disabled(FILTER_VIRTUAL_GREENSCREEN_NVIDIA ON) set_feature_disabled(FILTER_VIRTUAL_GREENSCREEN_NVIDIA ON)
endif() endif()
# Verify that we have at least one provider for Video Super-Resolution. # Verify that we have at least one provider for Video Super-Resolution.
is_feature_enabled(FILTER_VIRTUAL_GREENSCREEN_NVIDIA T_CHECK_NVIDIA) is_feature_enabled(FILTER_VIRTUAL_GREENSCREEN_NVIDIA T_CHECK_NVIDIA)
if(NOT T_CHECK_NVIDIA) if(NOT T_CHECK_NVIDIA)
message(WARNING "${LOGPREFIX}Virtual Greenscreen has no available providers. Disabling...") message(WARNING "Virtual Greenscreen has no available providers. Disabling...")
set_feature_disabled(FILTER_VIRTUAL_GREENSCREEN ON) set_feature_disabled(FILTER_VIRTUAL_GREENSCREEN ON)
endif() endif()
elseif(T_CHECK) elseif(T_CHECK)
@ -611,13 +623,13 @@ function(feature_frontend RESOLVE)
is_feature_enabled(FRONTEND T_CHECK) is_feature_enabled(FRONTEND T_CHECK)
if(RESOLVE AND T_CHECK) if(RESOLVE AND T_CHECK)
if(NOT (Qt6_FOUND OR Qt5_FOUND)) if(NOT (Qt6_FOUND OR Qt5_FOUND))
message(WARNING "${LOGPREFIX}Front-End requires Qt. Disabling...") message(WARNING "Front-End requires Qt. Disabling...")
set_feature_disabled(FRONTEND ON) set_feature_disabled(FRONTEND ON)
elseif(NOT obs-frontend-api_FOUND) elseif(NOT obs-frontend-api_FOUND)
message(WARNING "${LOGPREFIX}Front-End requires OBS FrontEnd API. Disabling...") message(WARNING "Front-End requires OBS FrontEnd API. Disabling...")
set_feature_disabled(FRONTEND ON) set_feature_disabled(FRONTEND ON)
elseif(NOT HAVE_JSON) elseif(NOT HAVE_JSON)
message(WARNING "${LOGPREFIX}Front-End requires nlohmann::json. Disabling...") message(WARNING "Front-End requires nlohmann::json. Disabling...")
set_feature_disabled(FRONTEND ON) set_feature_disabled(FRONTEND ON)
endif() endif()
elseif(T_CHECK) elseif(T_CHECK)
@ -631,10 +643,10 @@ function(feature_updater RESOLVE)
is_feature_enabled(UPDATER T_CHECK) is_feature_enabled(UPDATER T_CHECK)
if(RESOLVE AND T_CHECK) if(RESOLVE AND T_CHECK)
if(NOT CURL_FOUND) if(NOT CURL_FOUND)
message(WARNING "${LOGPREFIX}Updater requires CURL. Disabling...") message(WARNING "Updater requires CURL. Disabling...")
set_feature_disabled(UPDATER ON) set_feature_disabled(UPDATER ON)
elseif(NOT HAVE_JSON) elseif(NOT HAVE_JSON)
message(WARNING "${LOGPREFIX}Updater requires nlohmann::json. Disabling...") message(WARNING "Updater requires nlohmann::json. Disabling...")
set_feature_disabled(UPDATER ON) set_feature_disabled(UPDATER ON)
endif() endif()
elseif(T_CHECK) elseif(T_CHECK)
@ -729,7 +741,7 @@ endif()
set(HAVE_JSON OFF) set(HAVE_JSON OFF)
if(REQUIRE_JSON) if(REQUIRE_JSON)
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/third-party/nlohmann-json/single_include") if(NOT EXISTS "${PROJECT_SOURCE_DIR}/third-party/nlohmann-json/single_include")
message(FATAL_ERROR "${LOGPREFIX}Please make sure to update git submodules to their latest supported version.") message(FATAL_ERROR "Please make sure to update git submodules to their latest supported version.")
return() return()
else() else()
set(JSON_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/third-party/nlohmann-json/single_include") set(JSON_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/third-party/nlohmann-json/single_include")
@ -795,9 +807,9 @@ if(REQUIRE_QT)
) )
endif() endif()
if(Qt6_FOUND) if(Qt6_FOUND)
message(STATUS "${LOGPREFIX}Using Qt6.") message(STATUS "Using Qt6.")
elseif(Qt5_FOUND) elseif(Qt5_FOUND)
message(STATUS "${LOGPREFIX}Using Qt5.") message(STATUS "Using Qt5.")
endif() endif()
endif() endif()
@ -1703,7 +1715,7 @@ endif()
# C/C++ Compiler Adjustments # C/C++ Compiler Adjustments
if(D_PLATFORM_WINDOWS AND ((CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))) if(D_PLATFORM_WINDOWS AND ((CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")))
# MSVC/ClangCL # MSVC/ClangCL
message(STATUS "${LOGPREFIX}Applying custom flags for MSVC style build.") message(STATUS "Applying custom flags for MSVC style build.")
# - Dynamically link Microsoft C/C++ Redistributable. # - Dynamically link Microsoft C/C++ Redistributable.
target_compile_options(${PROJECT_NAME} PRIVATE target_compile_options(${PROJECT_NAME} PRIVATE
@ -1761,19 +1773,19 @@ if(D_PLATFORM_WINDOWS AND ((CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") OR (CMAKE_CXX
if(D_PLATFORM_ARCH_X86) if(D_PLATFORM_ARCH_X86)
if(${PREFIX}TARGET_X86_64_V4) if(${PREFIX}TARGET_X86_64_V4)
target_compile_options(${PROJECT_NAME} PRIVATE "/arch:AVX512") target_compile_options(${PROJECT_NAME} PRIVATE "/arch:AVX512")
message(STATUS "${LOGPREFIX}Targeting x86-64-v4.") message(STATUS "Targeting x86-64-v4.")
elseif(${PREFIX}TARGET_X86_64_V3) elseif(${PREFIX}TARGET_X86_64_V3)
target_compile_options(${PROJECT_NAME} PRIVATE "/arch:AVX2") target_compile_options(${PROJECT_NAME} PRIVATE "/arch:AVX2")
message(STATUS "${LOGPREFIX}Targeting x86-64-v3.") message(STATUS "Targeting x86-64-v3.")
elseif(${PREFIX}TARGET_X86_64_V2_EX) elseif(${PREFIX}TARGET_X86_64_V2_EX)
target_compile_options(${PROJECT_NAME} PRIVATE "/arch:AVX") target_compile_options(${PROJECT_NAME} PRIVATE "/arch:AVX")
message(STATUS "${LOGPREFIX}Targeting extended x86-64-v2.") message(STATUS "Targeting extended x86-64-v2.")
elseif(${PREFIX}TARGET_X86_64_V2) elseif(${PREFIX}TARGET_X86_64_V2)
target_compile_options(${PROJECT_NAME} PRIVATE "/d2archSSE42") target_compile_options(${PROJECT_NAME} PRIVATE "/d2archSSE42")
message(STATUS "${LOGPREFIX}Targeting x86-64-v2.") message(STATUS "Targeting x86-64-v2.")
elseif(${PREFIX}TARGET_X86_64) elseif(${PREFIX}TARGET_X86_64)
#target_compile_options(${PROJECT_NAME} PRIVATE "/arch:SSE2") #target_compile_options(${PROJECT_NAME} PRIVATE "/arch:SSE2")
message(STATUS "${LOGPREFIX}Targeting x86-64.") message(STATUS "Targeting x86-64.")
endif() endif()
endif() endif()
@ -1815,7 +1827,7 @@ if(D_PLATFORM_WINDOWS AND ((CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") OR (CMAKE_CXX
endforeach() endforeach()
elseif(D_PLATFORM_LINUX AND ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))) elseif(D_PLATFORM_LINUX AND ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")))
# GCC/Clang # GCC/Clang
message(STATUS "${LOGPREFIX}Applying custom flags for GCC/Clang style build.") message(STATUS "Applying custom flags for GCC/Clang style build.")
# - Enable all warnings. # - Enable all warnings.
target_compile_options(${PROJECT_NAME} PRIVATE "-Wall") target_compile_options(${PROJECT_NAME} PRIVATE "-Wall")
@ -1854,18 +1866,18 @@ elseif(D_PLATFORM_LINUX AND ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_
target_compile_options(${PROJECT_NAME} PRIVATE target_compile_options(${PROJECT_NAME} PRIVATE
"-march=native" "-march=native"
) )
message(WARNING "${LOGPREFIX}Targeting native architecture. Binaries will not be distributable to other systems!") message(WARNING "Targeting native architecture. Binaries will not be distributable to other systems!")
elseif(D_PLATFORM_ARCH_X86) elseif(D_PLATFORM_ARCH_X86)
if(${PREFIX}TARGET_X86_64_V4) if(${PREFIX}TARGET_X86_64_V4)
target_compile_options(${PROJECT_NAME} PRIVATE target_compile_options(${PROJECT_NAME} PRIVATE
"-march=x86-64-v4" "-march=x86-64-v4"
) )
message(STATUS "${LOGPREFIX}Targeting x86-64-v4.") message(STATUS "Targeting x86-64-v4.")
elseif(${PREFIX}TARGET_X86_64_V3) elseif(${PREFIX}TARGET_X86_64_V3)
target_compile_options(${PROJECT_NAME} PRIVATE target_compile_options(${PROJECT_NAME} PRIVATE
"-march=x86-64-v3" "-march=x86-64-v3"
) )
message(STATUS "${LOGPREFIX}Targeting x86-64-v3.") message(STATUS "Targeting x86-64-v3.")
elseif(${PREFIX}TARGET_X86_64_V2_EX) elseif(${PREFIX}TARGET_X86_64_V2_EX)
target_compile_options(${PROJECT_NAME} PRIVATE target_compile_options(${PROJECT_NAME} PRIVATE
"-march=x86-64-v2" "-march=x86-64-v2"
@ -1878,17 +1890,17 @@ elseif(D_PLATFORM_LINUX AND ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_
"-mpclmul" "-mpclmul"
"-mpopcnt" "-mpopcnt"
) )
message(STATUS "${LOGPREFIX}Targeting extended x86-64-v2.") message(STATUS "Targeting extended x86-64-v2.")
elseif(${PREFIX}TARGET_X86_64_V2) elseif(${PREFIX}TARGET_X86_64_V2)
target_compile_options(${PROJECT_NAME} PRIVATE target_compile_options(${PROJECT_NAME} PRIVATE
"-march=x86-64-v2" "-march=x86-64-v2"
) )
message(STATUS "${LOGPREFIX}Targeting x86-64-v2.") message(STATUS "Targeting x86-64-v2.")
elseif(${PREFIX}TARGET_X86_64) elseif(${PREFIX}TARGET_X86_64)
target_compile_options(${PROJECT_NAME} PRIVATE target_compile_options(${PROJECT_NAME} PRIVATE
"-march=x86-64" "-march=x86-64"
) )
message(STATUS "${LOGPREFIX}Targeting x86-64.") message(STATUS "Targeting x86-64.")
endif() endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${PROJECT_NAME} PRIVATE target_compile_options(${PROJECT_NAME} PRIVATE
@ -1922,7 +1934,7 @@ elseif(D_PLATFORM_LINUX AND ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_
# add_compile_options("-fvisibility=hidden") # add_compile_options("-fvisibility=hidden")
elseif(D_PLATFORM_MAC AND (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")) elseif(D_PLATFORM_MAC AND (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
# AppleClang # AppleClang
message(STATUS "${LOGPREFIX}Applying custom flags for AppleClang style build.") message(STATUS "Applying custom flags for AppleClang style build.")
# - Enable most useful warnings. # - Enable most useful warnings.
target_compile_options(${PROJECT_NAME} PRIVATE "-Wall") target_compile_options(${PROJECT_NAME} PRIVATE "-Wall")
@ -1933,7 +1945,7 @@ elseif(D_PLATFORM_MAC AND (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
target_compile_options(${PROJECT_NAME} PRIVATE target_compile_options(${PROJECT_NAME} PRIVATE
"-march=native" "-march=native"
) )
message(WARNING "${LOGPREFIX}Targeting native architecture. Binaries will not be distributable to other systems!") message(WARNING "Targeting native architecture. Binaries will not be distributable to other systems!")
endif() endif()
# - Use fast unordered math if possible. # - Use fast unordered math if possible.
@ -2038,7 +2050,7 @@ endif()
# Clang # Clang
is_feature_enabled(CLANG T_CHECK) is_feature_enabled(CLANG T_CHECK)
if(T_CHECK AND HAVE_CLANG) if(T_CHECK)
generate_compile_commands_json( generate_compile_commands_json(
TARGETS ${PROJECT_NAME} TARGETS ${PROJECT_NAME}
) )

@ -1 +1 @@
Subproject commit 16bfa9568c3d72e07d94c214a0da53956c7a33eb Subproject commit 3bef96bafab04161991c2cd98a1ed51f6362d670