Optionally allow the system installation of MiniUPnP to be used (#1959)

This commit is contained in:
James Le Cuirot 2024-01-01 01:04:04 +00:00 committed by GitHub
parent fe3bf0ee6f
commit 44b34d1e23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 14 deletions

View File

@ -118,7 +118,7 @@ else()
endif()
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
libminiupnpc-static
${MINIUPNP_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
enet
opus

View File

@ -9,13 +9,33 @@ add_subdirectory(third-party/moonlight-common-c/enet)
# web server
add_subdirectory(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
set(UPNPC_BUILD_SHARED OFF CACHE BOOL "No shared libraries")
set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Don't build tests for miniupnpc")
set(UPNPC_BUILD_SAMPLE OFF CACHE BOOL "Don't build samples for miniupnpc")
set(UPNPC_NO_INSTALL ON CACHE BOOL "Don't install any libraries build for miniupnpc")
add_subdirectory(third-party/miniupnp/miniupnpc)
include_directories(SYSTEM third-party/miniupnp/miniupnpc/include)
if(SUNSHINE_SYSTEM_MINIUPNP)
pkg_check_modules(MINIUPNP miniupnpc REQUIRED)
# Use includedir pkg-config variable rather than MINIUPNP_INCLUDE_DIRS
# defined above. The latter may be blank, as pkg-config sometimes omits -I
# flags for directories that are searched by default (e.g. /usr/include),
# but we need a value to append /miniupnpc to. Normally source files would
# prefix their #include directives with miniupnpc/, but this does not align
# with the directory structure of the git submodule used below.
pkg_get_variable(MINIUPNP_INCLUDE_DIR miniupnpc includedir)
include_directories(SYSTEM ${MINIUPNP_INCLUDE_DIR}/miniupnpc)
else()
set(UPNPC_BUILD_SHARED OFF CACHE BOOL "No shared libraries")
set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Don't build tests for miniupnpc")
set(UPNPC_BUILD_SAMPLE OFF CACHE BOOL "Don't build samples for miniupnpc")
set(UPNPC_NO_INSTALL ON CACHE BOOL "Don't install any libraries build for miniupnpc")
set(MINIUPNP_LIBRARIES libminiupnpc-static)
add_subdirectory(third-party/miniupnp/miniupnpc)
include_directories(SYSTEM third-party/miniupnp/miniupnpc/include)
endif()
# ffmpeg pre-compiled binaries
if(WIN32)
@ -66,12 +86,6 @@ set(FFMPEG_LIBRARIES
${HDR10_PLUS_LIBRARY}
${FFMPEG_PLATFORM_LIBRARIES})
# common dependencies
find_package(OpenSSL REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(Threads REQUIRED)
pkg_check_modules(CURL REQUIRED libcurl)
# platform specific dependencies
if(WIN32)
include(${CMAKE_MODULE_PATH}/dependencies/windows.cmake)
@ -84,4 +98,3 @@ elseif(UNIX)
include(${CMAKE_MODULE_PATH}/dependencies/linux.cmake)
endif()
endif()

View File

@ -4,6 +4,8 @@ option(SUNSHINE_CONFIGURE_ONLY "Configure special files only, then exit." OFF)
option(SUNSHINE_ENABLE_TRAY "Enable system tray icon. This option will be ignored on macOS." ON)
option(SUNSHINE_REQUIRE_TRAY "Require system tray icon. Fail the build if tray requirements are not met." ON)
option(SUNSHINE_SYSTEM_MINIUPNP "Use system installation of MiniUPnP rather than the submodule." OFF)
if(APPLE)
option(SUNSHINE_CONFIGURE_PORTFILE
"Configure macOS Portfile. Recommended to use with SUNSHINE_CONFIGURE_ONLY" OFF)