Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions cmake/dependencies/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,19 @@ include_directories(SYSTEM ${MINIUPNP_INCLUDE_DIRS})
include("${CMAKE_MODULE_PATH}/dependencies/ffmpeg.cmake")

# Opus
# Homebrew provides opus as a dynamic library only, so disable static linking for Homebrew builds
if(SUNSHINE_BUILD_HOMEBREW)
set(OPUS_USE_STATIC OFF CACHE BOOL "Static linking for libopus")
if(TARGET PkgConfig::SUNSHINE_BUNDLED_OPUS)
# Match the Opus version linked by the shared FFmpeg package.
set(Opus_LIBRARY PkgConfig::SUNSHINE_BUNDLED_OPUS) # cmake-lint: disable=C0103
set(Opus_INCLUDE_DIR "${FFMPEG_PREPARED_BINARIES}/include") # cmake-lint: disable=C0103
else()
set(OPUS_USE_STATIC ON CACHE BOOL "Static linking for libopus")
# Homebrew provides opus as a dynamic library only, so disable static linking for Homebrew builds
if(SUNSHINE_BUILD_HOMEBREW)
set(OPUS_USE_STATIC OFF CACHE BOOL "Static linking for libopus")
else()
set(OPUS_USE_STATIC ON CACHE BOOL "Static linking for libopus")
endif()
include("${CMAKE_MODULE_PATH}/dependencies/FindOpus.cmake")
endif()
include("${CMAKE_MODULE_PATH}/dependencies/FindOpus.cmake")

# platform specific dependencies
if(WIN32)
Expand Down
64 changes: 63 additions & 1 deletion cmake/dependencies/ffmpeg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if(NOT DEFINED FFMPEG_PREPARED_BINARIES)
endif()

# Set extraction directory and prepared binaries path
set(FFMPEG_EXTRACT_DIR "${FFMPEG_DOWNLOAD_DIR}")
set(FFMPEG_EXTRACT_DIR "${FFMPEG_VERSION_DIR}")
set(FFMPEG_PREPARED_BINARIES "${FFMPEG_EXTRACT_DIR}/ffmpeg")

# Set the archive filename based on architecture
Expand Down Expand Up @@ -176,4 +176,66 @@ else()
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_PLATFORM_LIBRARIES})
endif()

# Shared packages supply the full static dependency list, including decoders.
# Older packages retain the library list above.
set(_sunshine_ffmpeg_pc "${FFMPEG_PREPARED_BINARIES}/lib/pkgconfig/libavcodec.pc")
set(_sunshine_ffmpeg_relocatable -1)
if(EXISTS "${_sunshine_ffmpeg_pc}")
file(READ "${_sunshine_ffmpeg_pc}" _sunshine_ffmpeg_metadata LIMIT 512)
string(FIND "${_sunshine_ffmpeg_metadata}" "prefix=\${pcfiledir}/../.." _sunshine_ffmpeg_relocatable)
endif()
if(_sunshine_ffmpeg_relocatable GREATER_EQUAL 0)
# Refresh cached paths when the package or system library search policy changes.
get_cmake_property(_sunshine_cache_variables CACHE_VARIABLES)
foreach(variable IN LISTS _sunshine_cache_variables)
if(variable MATCHES "^(pkgcfg_lib_|__pkg_config_checked_)?SUNSHINE_BUNDLED_(FFMPEG|OPUS)")
unset(${variable} CACHE)
endif()
endforeach()
foreach(variable PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR)
if(DEFINED ENV{${variable}})
set(_sunshine_saved_${variable} "$ENV{${variable}}")
else()
unset(_sunshine_saved_${variable})
endif()
endforeach()
set(_sunshine_saved_pkg_config_argn "${PKG_CONFIG_ARGN}")
# The package supplies static codec archives; system libraries keep their normal linkage.
set(ENV{PKG_CONFIG_PATH} "${FFMPEG_PREPARED_BINARIES}/lib/pkgconfig")
set(ENV{PKG_CONFIG_LIBDIR} "$ENV{PKG_CONFIG_PATH}")
unset(ENV{PKG_CONFIG_SYSROOT_DIR})
set(PKG_CONFIG_ARGN --static)
if(WIN32)
set(_sunshine_saved_library_suffixes "${CMAKE_FIND_LIBRARY_SUFFIXES}")
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
endif()
find_package(PkgConfig REQUIRED)
pkg_check_modules(SUNSHINE_BUNDLED_FFMPEG REQUIRED IMPORTED_TARGET libcbs libavcodec libswscale libavutil)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# Explicit shared compiler runtimes bypass -static-libstdc++/-static-libgcc.
# Let the C++ driver apply Sunshine's runtime policy from targets/linux.cmake.
get_target_property(_sunshine_ffmpeg_link_libraries
PkgConfig::SUNSHINE_BUNDLED_FFMPEG INTERFACE_LINK_LIBRARIES)
list(FILTER _sunshine_ffmpeg_link_libraries EXCLUDE
REGEX "(^|/)(lib)?(stdc\\+\\+|gcc_s)(\\.[^/]*)?$")
set_property(TARGET PkgConfig::SUNSHINE_BUNDLED_FFMPEG PROPERTY
INTERFACE_LINK_LIBRARIES "${_sunshine_ffmpeg_link_libraries}")
endif()
if(EXISTS "${FFMPEG_PREPARED_BINARIES}/lib/libopus.a")
pkg_check_modules(SUNSHINE_BUNDLED_OPUS REQUIRED IMPORTED_TARGET opus)
endif()
foreach(variable PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR)
if(DEFINED _sunshine_saved_${variable})
set(ENV{${variable}} "${_sunshine_saved_${variable}}")
else()
unset(ENV{${variable}})
endif()
endforeach()
set(PKG_CONFIG_ARGN "${_sunshine_saved_pkg_config_argn}")
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES "${_sunshine_saved_library_suffixes}")
endif()
set(FFMPEG_LIBRARIES PkgConfig::SUNSHINE_BUNDLED_FFMPEG)
endif()

set(FFMPEG_INCLUDE_DIRS "${FFMPEG_PREPARED_BINARIES}/include")
8 changes: 4 additions & 4 deletions packaging/linux/flatpak/modules/ffmpeg.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"sources": [
{
"type": "file",
"url": "https://github.com/LizardByte/build-deps/releases/download/v2026.910.121303/Linux-x86_64-ffmpeg.tar.gz",
"sha256": "496d2bbb674d01e6033e31b9dfc15cbc9dc1494e882a4505f6ab1e03f75b385c",
"url": "https://github.com/LizardByte/build-deps/releases/download/v2026.1004.34232/Linux-x86_64-ffmpeg.tar.gz",
"sha256": "909b74cae27ad0d0d10dfd61f5cd04228617a565462057876172611f16f8f85a",
"dest-filename": "ffmpeg.tar.gz",
"only-arches": [
"x86_64"
Expand All @@ -23,8 +23,8 @@
},
{
"type": "file",
"url": "https://github.com/LizardByte/build-deps/releases/download/v2026.910.121303/Linux-aarch64-ffmpeg.tar.gz",
"sha256": "21f99409e1aba09191f9df28688fb7f9d44f98e65378a651324c632c19823aa0",
"url": "https://github.com/LizardByte/build-deps/releases/download/v2026.1004.34232/Linux-aarch64-ffmpeg.tar.gz",
"sha256": "9a8c489ff2eca949f6138d12e7a57469727ddeb48cbe5842d6225dab4a68a2a8",
"dest-filename": "ffmpeg.tar.gz",
"only-arches": [
"aarch64"
Expand Down
2 changes: 1 addition & 1 deletion packaging/sunshine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def base_cmake_args
-DCMAKE_INSTALL_PREFIX=#{prefix}
-DGLAD_SKIP_PIP_INSTALL=ON
-DHOMEBREW_ALLOW_FETCHCONTENT=ON
-DOPENSSL_ROOT_DIR=#{formula_opt_prefix("openssl")}
-DOPENSSL_ROOT_DIR=#{formula_opt_prefix("openssl@3")}
-DSUNSHINE_ASSETS_DIR=sunshine/assets
-DSUNSHINE_BUILD_HOMEBREW=ON
-DSUNSHINE_PUBLISHER_NAME='LizardByte'
Expand Down
Loading