2026-09-06 21:22:14 -07:00
|
|
|
cmake_minimum_required(VERSION 3.19)
|
2026-09-06 20:46:08 -07:00
|
|
|
|
|
|
|
|
project(obs-streamer-tools-plugin
|
2026-09-06 21:22:14 -07:00
|
|
|
VERSION 0.1.0
|
|
|
|
|
DESCRIPTION "OBS Studio source plugin for streamer-tools camera feeds"
|
2026-09-06 20:46:08 -07:00
|
|
|
LANGUAGES C CXX
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
|
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
2026-09-06 21:22:14 -07:00
|
|
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
|
|
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
|
|
|
|
endif()
|
|
|
|
|
|
2026-09-06 20:46:08 -07:00
|
|
|
enable_testing()
|
|
|
|
|
|
2026-09-06 21:22:14 -07:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
2026-09-06 22:02:17 -07:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/common")
|
|
|
|
|
|
|
|
|
|
# --- OBS SDK ---------------------------------------------------------------
|
|
|
|
|
# Linux gets libobs from the distribution (Ubuntu's libobs-dev ships real
|
|
|
|
|
# libobsConfig.cmake), and that path is left exactly as it was.
|
|
|
|
|
#
|
|
|
|
|
# macOS and Windows have no such package, so they use obs-plugintemplate's
|
|
|
|
|
# buildspec bootstrap, trimmed: it downloads the pinned obs-deps bundle and
|
|
|
|
|
# the pinned obs-studio source, then builds and installs just `libobs`. See
|
|
|
|
|
# buildspec.json for why the OBS pin is deliberately low, and
|
|
|
|
|
# cmake/common/buildspec_common.cmake for every change from upstream.
|
|
|
|
|
#
|
|
|
|
|
# STPLUGIN_BOOTSTRAP_OBS=OFF falls back to plain find_package(libobs), for a
|
|
|
|
|
# developer who already has an OBS SDK on their prefix path and does not want
|
|
|
|
|
# a from-source libobs build.
|
|
|
|
|
option(STPLUGIN_BOOTSTRAP_OBS "Download and build libobs from source (macOS/Windows)" ON)
|
|
|
|
|
|
2026-09-06 22:22:03 -07:00
|
|
|
# Fallbacks for imported targets that were exported under a different
|
|
|
|
|
# configuration name than the one being built, lifted from
|
|
|
|
|
# obs-plugintemplate's cmake/common/bootstrap.cmake. Without these, an
|
|
|
|
|
# imported libobs exported as (say) RelWithDebInfo fails a Release build with
|
|
|
|
|
# "IMPORTED_LOCATION or IMPORTED_IMPLIB not set for imported target
|
|
|
|
|
# OBS::libobs configuration Release".
|
|
|
|
|
set(CMAKE_MAP_IMPORTED_CONFIG_RELEASE Release RelWithDebInfo MinSizeRel None "")
|
|
|
|
|
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO RelWithDebInfo Release MinSizeRel None "")
|
|
|
|
|
set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL MinSizeRel Release RelWithDebInfo None "")
|
|
|
|
|
set(CMAKE_MAP_IMPORTED_CONFIG_DEBUG Debug RelWithDebInfo Release MinSizeRel None "")
|
|
|
|
|
|
2026-09-06 22:02:17 -07:00
|
|
|
include(osconfig)
|
|
|
|
|
if(STPLUGIN_BOOTSTRAP_OBS AND (OS_MACOS OR OS_WINDOWS))
|
|
|
|
|
if(OS_MACOS)
|
|
|
|
|
# client-sdk-cpp ships single-arch dylibs, so this plugin is built for
|
|
|
|
|
# one architecture even though the libobs it links is universal.
|
|
|
|
|
if(NOT CMAKE_OSX_ARCHITECTURES)
|
|
|
|
|
set(CMAKE_OSX_ARCHITECTURES "${CMAKE_HOST_SYSTEM_PROCESSOR}" CACHE STRING "" FORCE)
|
|
|
|
|
endif()
|
|
|
|
|
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
|
|
|
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "13.0" CACHE STRING "" FORCE)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
include(buildspec)
|
|
|
|
|
endif()
|
2026-09-06 21:22:14 -07:00
|
|
|
|
|
|
|
|
# --- LiveKit C++ client SDK -------------------------------------------------
|
|
|
|
|
# Pinned, prebuilt release of livekit/client-sdk-cpp, downloaded and unpacked
|
|
|
|
|
# by cmake/LiveKitSDK.cmake, then consumed through its own CMake package
|
|
|
|
|
# config as the LiveKit::livekit imported target. See the design doc's
|
|
|
|
|
# "Resolved (2026-09-07)" section: an exact pin, never "latest".
|
|
|
|
|
set(STPLUGIN_LIVEKIT_SDK_VERSION "1.10.1" CACHE STRING
|
|
|
|
|
"Pinned livekit/client-sdk-cpp release version")
|
|
|
|
|
set(STPLUGIN_LIVEKIT_SDK_TRIPLE "" CACHE STRING
|
|
|
|
|
"Override the client-sdk-cpp release triple (e.g. ubuntu-24.04-x64); empty = autodetect")
|
|
|
|
|
set(STPLUGIN_LIVEKIT_SDK_DIR "${CMAKE_BINARY_DIR}/_deps/livekit-sdk" CACHE PATH
|
|
|
|
|
"Directory the client-sdk-cpp release archive is extracted into (point at a persistent path to cache it across CI builds)")
|
|
|
|
|
|
|
|
|
|
include(LiveKitSDK)
|
|
|
|
|
if(STPLUGIN_LIVEKIT_SDK_TRIPLE)
|
|
|
|
|
livekit_sdk_setup(
|
|
|
|
|
VERSION "${STPLUGIN_LIVEKIT_SDK_VERSION}"
|
|
|
|
|
SDK_DIR "${STPLUGIN_LIVEKIT_SDK_DIR}"
|
|
|
|
|
TRIPLE "${STPLUGIN_LIVEKIT_SDK_TRIPLE}"
|
|
|
|
|
)
|
|
|
|
|
else()
|
|
|
|
|
livekit_sdk_setup(
|
|
|
|
|
VERSION "${STPLUGIN_LIVEKIT_SDK_VERSION}"
|
|
|
|
|
SDK_DIR "${STPLUGIN_LIVEKIT_SDK_DIR}"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
find_package(LiveKit CONFIG REQUIRED)
|
2026-09-06 20:46:08 -07:00
|
|
|
|
|
|
|
|
add_subdirectory(core)
|
|
|
|
|
|
|
|
|
|
find_package(libobs QUIET)
|
2026-09-06 22:25:59 -07:00
|
|
|
|
|
|
|
|
# The imported OBS::libobs target can come back without a location. OBS 30.0.2
|
|
|
|
|
# installs libobsTargets.cmake but not the per-configuration
|
|
|
|
|
# libobsTargets-<config>.cmake alongside it when libobs is built on its own,
|
|
|
|
|
# and CMake then fails at generate time with:
|
|
|
|
|
#
|
|
|
|
|
# IMPORTED_LOCATION or IMPORTED_IMPLIB not set for imported target
|
|
|
|
|
# "OBS::libobs" configuration "Release".
|
|
|
|
|
#
|
|
|
|
|
# Repair it here rather than fighting OBS's export machinery: the library the
|
|
|
|
|
# bootstrap just built is in a known place, and pointing the imported target
|
|
|
|
|
# at it is exactly what the missing file would have done. Distribution
|
|
|
|
|
# packages (Ubuntu's libobs-dev) export a complete target and never take this
|
|
|
|
|
# path.
|
|
|
|
|
if(libobs_FOUND AND TARGET OBS::libobs)
|
|
|
|
|
get_target_property(_stplugin_obs_location OBS::libobs IMPORTED_LOCATION)
|
|
|
|
|
get_target_property(_stplugin_obs_location_release OBS::libobs IMPORTED_LOCATION_RELEASE)
|
|
|
|
|
get_target_property(_stplugin_obs_implib OBS::libobs IMPORTED_IMPLIB)
|
|
|
|
|
get_target_property(_stplugin_obs_implib_release OBS::libobs IMPORTED_IMPLIB_RELEASE)
|
|
|
|
|
if(NOT _stplugin_obs_location
|
|
|
|
|
AND NOT _stplugin_obs_location_release
|
|
|
|
|
AND NOT _stplugin_obs_implib
|
|
|
|
|
AND NOT _stplugin_obs_implib_release)
|
|
|
|
|
set(_stplugin_deps "${CMAKE_CURRENT_SOURCE_DIR}/.deps")
|
|
|
|
|
if(APPLE)
|
|
|
|
|
set(_stplugin_obs_binary "${_stplugin_deps}/Frameworks/libobs.framework/Versions/A/libobs")
|
|
|
|
|
if(NOT EXISTS "${_stplugin_obs_binary}")
|
|
|
|
|
set(_stplugin_obs_binary "${_stplugin_deps}/Frameworks/libobs.framework/libobs")
|
|
|
|
|
endif()
|
|
|
|
|
if(EXISTS "${_stplugin_obs_binary}")
|
|
|
|
|
set_target_properties(
|
|
|
|
|
OBS::libobs
|
|
|
|
|
PROPERTIES
|
|
|
|
|
IMPORTED_LOCATION "${_stplugin_obs_binary}"
|
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${_stplugin_deps}/Frameworks/libobs.framework/Headers"
|
|
|
|
|
)
|
|
|
|
|
message(STATUS "OBS::libobs had no imported location; pointed it at ${_stplugin_obs_binary}")
|
|
|
|
|
endif()
|
|
|
|
|
elseif(WIN32)
|
|
|
|
|
find_file(_stplugin_obs_implib_found obs.lib PATHS "${_stplugin_deps}/lib" NO_DEFAULT_PATH)
|
|
|
|
|
find_file(_stplugin_obs_dll_found obs.dll PATHS "${_stplugin_deps}/bin" NO_DEFAULT_PATH)
|
|
|
|
|
if(_stplugin_obs_implib_found)
|
|
|
|
|
set_target_properties(OBS::libobs PROPERTIES IMPORTED_IMPLIB "${_stplugin_obs_implib_found}")
|
|
|
|
|
if(_stplugin_obs_dll_found)
|
|
|
|
|
set_target_properties(OBS::libobs PROPERTIES IMPORTED_LOCATION "${_stplugin_obs_dll_found}")
|
|
|
|
|
endif()
|
|
|
|
|
message(STATUS "OBS::libobs had no imported location; pointed it at ${_stplugin_obs_implib_found}")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2026-09-06 20:46:08 -07:00
|
|
|
if(libobs_FOUND)
|
|
|
|
|
message(STATUS "libobs found (${libobs_DIR}) -- building OBS adapter module")
|
|
|
|
|
add_subdirectory(obs-adapter)
|
|
|
|
|
else()
|
|
|
|
|
message(WARNING "libobs NOT found -- skipping OBS adapter module; core library still builds/tests")
|
|
|
|
|
endif()
|