Second macOS failure, after the Xcode-generator one: OBS's own cmake/macos/compilerconfig.cmake reads the macOS SDK version by regex-matching "MacOSX<major>.<minor>.sdk" out of CMAKE_OSX_SYSROOT, and hard-fails when that does not match -- string sub-command REGEX, mode MATCH needs at least 5 arguments Your macOS SDK version () is too low. The macOS 13.1 SDK (Xcode 14.2) is required to build OBS. -- with an empty version in the message, which is the tell. With upstream's Xcode generator CMAKE_OSX_SYSROOT stays the literal string "macosx" and Xcode resolves it late, so that regex never runs against a real path. With Ninja, which this project now uses because the CI runner has no Xcode, CMake resolves it eagerly to `xcrun --show-sdk-path` -- and on a Command-Line-Tools-only install that is the UNVERSIONED symlink /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk. So swapping the generator moved the failure rather than removing it. _resolve_versioned_macos_sdk now hands the sub-build a path whose filename carries the version: a versioned sibling if the toolchain ships one (the common layout), otherwise a symlink to the same SDK created under .deps/sdk and named MacOSX<major>.<minor>.sdk. Either way clang gets the same SDK; only the spelling of the path changes, which is all OBS's check looks at. Also: the source's worker thread now backs off when the source is unconfigured, instead of re-evaluating once a second forever, and resets the backoff whenever the settings change -- a settings change is an operator action and should retry immediately. Filling the settings in bumps the generation counter and wakes the worker straight away, so the longer backoff costs no responsiveness. Linux re-verified: ctest 6/6. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RL8abRmgFXkVASHkkqiJbE
331 lines
13 KiB
CMake
331 lines
13 KiB
CMake
# Adapted from obsproject/obs-plugintemplate (cmake/common/buildspec_common.cmake,
|
|
# master as of 2026-09-06). Deliberate changes from upstream, all recorded here
|
|
# so a future re-sync knows what to keep:
|
|
#
|
|
# 1. _setup_obs_studio builds and installs the `libobs` target, not
|
|
# `obs-frontend-api`. This plugin's properties UI is plain
|
|
# obs_properties_* and it never touches the frontend API, so building it
|
|
# would only drag Qt back in -- which is the whole point of dropping qt6
|
|
# from dependencies_list.
|
|
# 2. It passes -DENABLE_UI:BOOL=OFF and -DENABLE_SCRIPTING:BOOL=OFF as well
|
|
# as upstream's -DENABLE_FRONTEND:BOOL=OFF. The pinned OBS (30.0.2)
|
|
# predates the ENABLE_FRONTEND option and gates its Qt-dependent UI on
|
|
# ENABLE_UI instead; without this the sub-build configures the whole
|
|
# OBS UI and demands Qt.
|
|
# 3. Only the Release configuration is built and installed. Upstream builds
|
|
# Debug as well; nothing here consumes a debug libobs, and it doubles the
|
|
# slowest step in CI.
|
|
# 4. macOS uses the Ninja generator and a single architecture, not upstream's
|
|
# Xcode generator and forced universal build. See the comment at that
|
|
# branch: a runner with only the Command Line Tools has no xcodebuild.
|
|
# 5. Generator flags are built as CMake lists so each becomes its own argv
|
|
# entry, rather than upstream's space-separated strings passed unquoted.
|
|
#
|
|
|
|
include_guard(GLOBAL)
|
|
|
|
# _check_deps_version: Checks for obs-deps VERSION file in prefix paths
|
|
function(_check_deps_version version)
|
|
set(found FALSE)
|
|
|
|
foreach(path IN LISTS CMAKE_PREFIX_PATH)
|
|
if(EXISTS "${path}/share/obs-deps/VERSION")
|
|
if(dependency STREQUAL qt6 AND NOT EXISTS "${path}/lib/cmake/Qt6/Qt6Config.cmake")
|
|
set(found FALSE)
|
|
continue()
|
|
endif()
|
|
|
|
file(READ "${path}/share/obs-deps/VERSION" _check_version)
|
|
string(REPLACE "\n" "" _check_version "${_check_version}")
|
|
string(REPLACE "-" "." _check_version "${_check_version}")
|
|
string(REPLACE "-" "." version "${version}")
|
|
|
|
if(_check_version VERSION_EQUAL version)
|
|
set(found TRUE)
|
|
break()
|
|
elseif(_check_version VERSION_LESS version)
|
|
message(
|
|
AUTHOR_WARNING
|
|
"Older ${label} version detected in ${path}: \n"
|
|
"Found ${_check_version}, require ${version}"
|
|
)
|
|
list(REMOVE_ITEM CMAKE_PREFIX_PATH "${path}")
|
|
list(APPEND CMAKE_PREFIX_PATH "${path}")
|
|
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH})
|
|
continue()
|
|
else()
|
|
message(
|
|
AUTHOR_WARNING
|
|
"Newer ${label} version detected in ${path}: \n"
|
|
"Found ${_check_version}, require ${version}"
|
|
)
|
|
set(found TRUE)
|
|
break()
|
|
endif()
|
|
endif()
|
|
endforeach()
|
|
|
|
return(PROPAGATE found CMAKE_PREFIX_PATH)
|
|
endfunction()
|
|
|
|
# _resolve_versioned_macos_sdk: return an SDK path whose *filename* carries the
|
|
# version number, e.g. .../MacOSX15.5.sdk.
|
|
#
|
|
# Not upstream. OBS's own cmake/macos/compilerconfig.cmake reads the SDK
|
|
# version by regex-matching "MacOSX<major>.<minor>.sdk" out of
|
|
# CMAKE_OSX_SYSROOT, and hard-fails if that does not match:
|
|
#
|
|
# string sub-command REGEX, mode MATCH needs at least 5 arguments
|
|
# Your macOS SDK version () is too low.
|
|
#
|
|
# With upstream's Xcode generator CMAKE_OSX_SYSROOT stays the literal string
|
|
# "macosx" and Xcode resolves it late, so the regex never runs against a real
|
|
# path. With Ninja -- which this project uses because CI has no Xcode -- CMake
|
|
# resolves it eagerly to whatever `xcrun --show-sdk-path` returns, and on a
|
|
# Command-Line-Tools-only install that is the UNVERSIONED symlink
|
|
# /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk. Hence this: prefer a
|
|
# versioned sibling if the toolchain ships one, and otherwise synthesise a
|
|
# correctly-named symlink to the same SDK.
|
|
function(_resolve_versioned_macos_sdk out_path)
|
|
set(${out_path} "" PARENT_SCOPE)
|
|
|
|
execute_process(
|
|
COMMAND xcrun --show-sdk-path
|
|
OUTPUT_VARIABLE _sdk
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
RESULT_VARIABLE _rc
|
|
ERROR_QUIET
|
|
)
|
|
if(NOT _rc EQUAL 0 OR NOT _sdk)
|
|
return()
|
|
endif()
|
|
|
|
# Already versioned: nothing to do.
|
|
get_filename_component(_sdk_name "${_sdk}" NAME)
|
|
if(_sdk_name MATCHES "^MacOSX[0-9]+\\.[0-9]+\\.sdk$")
|
|
set(${out_path} "${_sdk}" PARENT_SCOPE)
|
|
return()
|
|
endif()
|
|
|
|
execute_process(
|
|
COMMAND xcrun --show-sdk-version
|
|
OUTPUT_VARIABLE _sdk_version
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
RESULT_VARIABLE _rc
|
|
ERROR_QUIET
|
|
)
|
|
if(NOT _rc EQUAL 0 OR NOT _sdk_version MATCHES "^([0-9]+)\\.([0-9]+)")
|
|
return()
|
|
endif()
|
|
set(_short "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
|
|
|
|
# A versioned sibling next to the symlink is the common layout.
|
|
get_filename_component(_sdk_dir "${_sdk}" DIRECTORY)
|
|
if(EXISTS "${_sdk_dir}/MacOSX${_short}.sdk")
|
|
set(${out_path} "${_sdk_dir}/MacOSX${_short}.sdk" PARENT_SCOPE)
|
|
return()
|
|
endif()
|
|
|
|
# Otherwise make one, inside our own dependency directory.
|
|
set(_link_dir "${dependencies_dir}/sdk")
|
|
file(MAKE_DIRECTORY "${_link_dir}")
|
|
set(_link "${_link_dir}/MacOSX${_short}.sdk")
|
|
if(NOT EXISTS "${_link}")
|
|
file(CREATE_LINK "${_sdk}" "${_link}" SYMBOLIC)
|
|
endif()
|
|
if(EXISTS "${_link}")
|
|
message(STATUS "Using synthesised versioned macOS SDK path: ${_link}")
|
|
set(${out_path} "${_link}" PARENT_SCOPE)
|
|
endif()
|
|
endfunction()
|
|
|
|
# _setup_obs_studio: Create obs-studio build project, then build libobs and obs-frontend-api
|
|
function(_setup_obs_studio)
|
|
if(NOT libobs_DIR)
|
|
set(_is_fresh --fresh)
|
|
endif()
|
|
|
|
# Every generator-specific flag is built as a proper CMake list, so each
|
|
# element becomes its own argv entry. Upstream packs several flags into one
|
|
# space-separated string and passes it unquoted, which execute_process hands
|
|
# to cmake as a single argument -- it happens not to matter there because
|
|
# those flags are optional, but -DCMAKE_BUILD_TYPE is not.
|
|
set(_cmake_arch "")
|
|
set(_cmake_extra "")
|
|
|
|
if(OS_WINDOWS)
|
|
set(_cmake_generator "${CMAKE_GENERATOR}")
|
|
if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION)
|
|
list(APPEND _cmake_arch -A "${arch},version=${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
|
|
else()
|
|
list(APPEND _cmake_arch -A "${arch}")
|
|
endif()
|
|
list(APPEND _cmake_extra "-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}")
|
|
elseif(OS_MACOS)
|
|
# Ninja, not upstream's Xcode generator. A runner with only the Command
|
|
# Line Tools installed has no xcodebuild, and the Xcode generator then
|
|
# fails the OBS sub-configure outright with "No CMAKE_C_COMPILER could be
|
|
# found" -- observed on the `home-mac` CI runner. Ninja is single-config,
|
|
# hence the explicit CMAKE_BUILD_TYPE below.
|
|
set(_cmake_generator "Ninja")
|
|
# Single-architecture, not upstream's forced universal build: this plugin
|
|
# is built for one architecture anyway (client-sdk-cpp ships single-arch
|
|
# dylibs), so building libobs universal would double the slowest step in
|
|
# CI for a slice nothing links against.
|
|
if(CMAKE_OSX_ARCHITECTURES)
|
|
list(APPEND _cmake_arch "-DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES}")
|
|
endif()
|
|
list(APPEND _cmake_extra "-DCMAKE_BUILD_TYPE=Release")
|
|
if(CMAKE_OSX_DEPLOYMENT_TARGET)
|
|
list(APPEND _cmake_extra "-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
|
endif()
|
|
_resolve_versioned_macos_sdk(_sdk_path)
|
|
if(_sdk_path)
|
|
list(APPEND _cmake_extra "-DCMAKE_OSX_SYSROOT=${_sdk_path}")
|
|
endif()
|
|
endif()
|
|
|
|
message(STATUS "Configure ${label} (${arch})")
|
|
execute_process(
|
|
COMMAND
|
|
"${CMAKE_COMMAND}" -S "${dependencies_dir}/${_obs_destination}" -B
|
|
"${dependencies_dir}/${_obs_destination}/build_${arch}" -G ${_cmake_generator} ${_cmake_arch}
|
|
-DOBS_CMAKE_VERSION:STRING=3.0.0 -DENABLE_PLUGINS:BOOL=OFF -DENABLE_FRONTEND:BOOL=OFF
|
|
-DENABLE_UI:BOOL=OFF -DENABLE_SCRIPTING:BOOL=OFF -DENABLE_BROWSER:BOOL=OFF
|
|
-DOBS_VERSION_OVERRIDE:STRING=${_obs_version} "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ${_is_fresh}
|
|
${_cmake_extra}
|
|
RESULT_VARIABLE _process_result
|
|
COMMAND_ERROR_IS_FATAL ANY
|
|
)
|
|
message(STATUS "Configure ${label} (${arch}) - done")
|
|
|
|
message(STATUS "Build ${label} (Release - ${arch})")
|
|
execute_process(
|
|
COMMAND "${CMAKE_COMMAND}" --build build_${arch} --target libobs --config Release --parallel
|
|
WORKING_DIRECTORY "${dependencies_dir}/${_obs_destination}"
|
|
RESULT_VARIABLE _process_result
|
|
COMMAND_ERROR_IS_FATAL ANY
|
|
)
|
|
message(STATUS "Build ${label} (Release - ${arch}) - done")
|
|
|
|
message(STATUS "Install ${label} (${arch})")
|
|
execute_process(
|
|
COMMAND
|
|
"${CMAKE_COMMAND}" --install build_${arch} --component Development --config Release --prefix "${dependencies_dir}"
|
|
WORKING_DIRECTORY "${dependencies_dir}/${_obs_destination}"
|
|
RESULT_VARIABLE _process_result
|
|
COMMAND_ERROR_IS_FATAL ANY
|
|
)
|
|
message(STATUS "Install ${label} (${arch}) - done")
|
|
endfunction()
|
|
|
|
# _check_dependencies: Fetch and extract pre-built OBS build dependencies
|
|
function(_check_dependencies)
|
|
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec)
|
|
|
|
string(JSON dependency_data GET ${buildspec} dependencies)
|
|
|
|
foreach(dependency IN LISTS dependencies_list)
|
|
string(JSON data GET ${dependency_data} ${dependency})
|
|
string(JSON version GET ${data} version)
|
|
string(JSON hash GET ${data} hashes ${platform})
|
|
string(JSON url GET ${data} baseUrl)
|
|
string(JSON label GET ${data} label)
|
|
string(JSON revision ERROR_VARIABLE error GET ${data} revision ${platform})
|
|
|
|
message(STATUS "Setting up ${label} (${arch})")
|
|
|
|
set(file "${${dependency}_filename}")
|
|
set(destination "${${dependency}_destination}")
|
|
string(REPLACE "VERSION" "${version}" file "${file}")
|
|
string(REPLACE "VERSION" "${version}" destination "${destination}")
|
|
string(REPLACE "ARCH" "${arch}" file "${file}")
|
|
string(REPLACE "ARCH" "${arch}" destination "${destination}")
|
|
if(revision)
|
|
string(REPLACE "_REVISION" "_v${revision}" file "${file}")
|
|
string(REPLACE "-REVISION" "-v${revision}" file "${file}")
|
|
else()
|
|
string(REPLACE "_REVISION" "" file "${file}")
|
|
string(REPLACE "-REVISION" "" file "${file}")
|
|
endif()
|
|
|
|
if(EXISTS "${dependencies_dir}/.dependency_${dependency}_${arch}.sha256")
|
|
file(
|
|
READ
|
|
"${dependencies_dir}/.dependency_${dependency}_${arch}.sha256"
|
|
OBS_DEPENDENCY_${dependency}_${arch}_HASH
|
|
)
|
|
endif()
|
|
|
|
set(skip FALSE)
|
|
if(dependency STREQUAL prebuilt OR dependency STREQUAL qt6)
|
|
if(OBS_DEPENDENCY_${dependency}_${arch}_HASH STREQUAL ${hash})
|
|
_check_deps_version(${version})
|
|
|
|
if(found)
|
|
set(skip TRUE)
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
if(skip)
|
|
message(STATUS "Setting up ${label} (${arch}) - skipped")
|
|
continue()
|
|
endif()
|
|
|
|
if(dependency STREQUAL obs-studio)
|
|
set(url ${url}/${file})
|
|
else()
|
|
set(url ${url}/${version}/${file})
|
|
endif()
|
|
|
|
if(NOT EXISTS "${dependencies_dir}/${file}")
|
|
message(STATUS "Downloading ${url}")
|
|
file(DOWNLOAD "${url}" "${dependencies_dir}/${file}" STATUS download_status EXPECTED_HASH SHA256=${hash})
|
|
|
|
list(GET download_status 0 error_code)
|
|
list(GET download_status 1 error_message)
|
|
if(error_code GREATER 0)
|
|
message(STATUS "Downloading ${url} - Failure")
|
|
message(FATAL_ERROR "Unable to download ${url}, failed with error: ${error_message}")
|
|
file(REMOVE "${dependencies_dir}/${file}")
|
|
else()
|
|
message(STATUS "Downloading ${url} - done")
|
|
endif()
|
|
endif()
|
|
|
|
if(NOT OBS_DEPENDENCY_${dependency}_${arch}_HASH STREQUAL ${hash})
|
|
file(REMOVE_RECURSE "${dependencies_dir}/${destination}")
|
|
endif()
|
|
|
|
if(NOT EXISTS "${dependencies_dir}/${destination}")
|
|
file(MAKE_DIRECTORY "${dependencies_dir}/${destination}")
|
|
if(dependency STREQUAL obs-studio)
|
|
file(ARCHIVE_EXTRACT INPUT "${dependencies_dir}/${file}" DESTINATION "${dependencies_dir}")
|
|
else()
|
|
file(ARCHIVE_EXTRACT INPUT "${dependencies_dir}/${file}" DESTINATION "${dependencies_dir}/${destination}")
|
|
endif()
|
|
endif()
|
|
|
|
file(WRITE "${dependencies_dir}/.dependency_${dependency}_${arch}.sha256" "${hash}")
|
|
|
|
if(dependency STREQUAL prebuilt)
|
|
list(APPEND CMAKE_PREFIX_PATH "${dependencies_dir}/${destination}")
|
|
elseif(dependency STREQUAL qt6)
|
|
list(APPEND CMAKE_PREFIX_PATH "${dependencies_dir}/${destination}")
|
|
elseif(dependency STREQUAL obs-studio)
|
|
set(_obs_version ${version})
|
|
set(_obs_destination "${destination}")
|
|
list(APPEND CMAKE_PREFIX_PATH "${dependencies_dir}")
|
|
endif()
|
|
|
|
message(STATUS "Setting up ${label} (${arch}) - done")
|
|
endforeach()
|
|
|
|
list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH)
|
|
|
|
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE PATH "CMake prefix search path" FORCE)
|
|
|
|
_setup_obs_studio()
|
|
endfunction()
|