Sunshine/cmake/dependencies/common.cmake
2024-06-12 15:58:25 -04:00

85 lines
3.2 KiB
CMake

# load common dependencies
# this file will also load platform specific dependencies
# submodules
# moonlight common library
set(ENET_NO_INSTALL ON CACHE BOOL "Don't install any libraries build for enet")
add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/enet")
# web server
add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/Simple-Web-Server")
# common dependencies
find_package(OpenSSL REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(Threads REQUIRED)
pkg_check_modules(CURL REQUIRED libcurl)
# miniupnp
pkg_check_modules(MINIUPNP miniupnpc REQUIRED)
include_directories(SYSTEM ${MINIUPNP_INCLUDE_DIRS})
# ffmpeg pre-compiled binaries
if(NOT DEFINED FFMPEG_PREPARED_BINARIES)
if(WIN32)
set(FFMPEG_PLATFORM_LIBRARIES mfplat ole32 strmiids mfuuid vpl)
elseif(UNIX AND NOT APPLE)
set(FFMPEG_PLATFORM_LIBRARIES numa va va-drm va-x11 vdpau X11)
# TODO: remove mfx, it's not used and deprecated
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT SUNSHINE_BUILD_HOMEBREW)
list(APPEND FFMPEG_PLATFORM_LIBRARIES mfx)
set(CPACK_DEB_PLATFORM_PACKAGE_DEPENDS "libmfx1,")
set(CPACK_RPM_PLATFORM_PACKAGE_REQUIRES "intel-mediasdk >= 22.3.0,")
endif()
endif()
set(FFMPEG_PREPARED_BINARIES
"${CMAKE_SOURCE_DIR}/third-party/build-deps/ffmpeg/${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
# check if the directory exists
if(NOT EXISTS "${FFMPEG_PREPARED_BINARIES}")
message(FATAL_ERROR
"FFmpeg pre-compiled binaries not found at ${FFMPEG_PREPARED_BINARIES}. \
Please consider contributing to the LizardByte/build-deps repository. \
Optionally, you can use the FFMPEG_PREPARED_BINARIES option to specify the path to the \
system-installed FFmpeg libraries")
endif()
if(EXISTS "${FFMPEG_PREPARED_BINARIES}/lib/libhdr10plus.a")
set(HDR10_PLUS_LIBRARY
"${FFMPEG_PREPARED_BINARIES}/lib/libhdr10plus.a")
endif()
set(FFMPEG_LIBRARIES
"${FFMPEG_PREPARED_BINARIES}/lib/libavcodec.a"
"${FFMPEG_PREPARED_BINARIES}/lib/libavutil.a"
"${FFMPEG_PREPARED_BINARIES}/lib/libcbs.a"
"${FFMPEG_PREPARED_BINARIES}/lib/libSvtAv1Enc.a"
"${FFMPEG_PREPARED_BINARIES}/lib/libswscale.a"
"${FFMPEG_PREPARED_BINARIES}/lib/libx264.a"
"${FFMPEG_PREPARED_BINARIES}/lib/libx265.a"
${HDR10_PLUS_LIBRARY}
${FFMPEG_PLATFORM_LIBRARIES})
else()
set(FFMPEG_LIBRARIES
"${FFMPEG_PREPARED_BINARIES}/lib/libavcodec.a"
"${FFMPEG_PREPARED_BINARIES}/lib/libavutil.a"
"${FFMPEG_PREPARED_BINARIES}/lib/libcbs.a"
"${FFMPEG_PREPARED_BINARIES}/lib/libswscale.a"
${FFMPEG_PLATFORM_LIBRARIES})
endif()
set(FFMPEG_INCLUDE_DIRS
"${FFMPEG_PREPARED_BINARIES}/include")
# platform specific dependencies
if(WIN32)
include("${CMAKE_MODULE_PATH}/dependencies/windows.cmake")
elseif(UNIX)
include("${CMAKE_MODULE_PATH}/dependencies/unix.cmake")
if(APPLE)
include("${CMAKE_MODULE_PATH}/dependencies/macos.cmake")
else()
include("${CMAKE_MODULE_PATH}/dependencies/linux.cmake")
endif()
endif()