Skip to content

Commit

Permalink
Optionally allow the system installation of MiniUPnP to be used (Liza…
Browse files Browse the repository at this point in the history
  • Loading branch information
chewi authored and e-dong committed Jul 26, 2024
1 parent e9ca6d1 commit 0a17e31
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmake/compile_definitions/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ else()
endif()

list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
libminiupnpc-static
${MINIUPNP_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
enet
opus
Expand Down
39 changes: 26 additions & 13 deletions cmake/dependencies/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -84,4 +98,3 @@ elseif(UNIX)
include(${CMAKE_MODULE_PATH}/dependencies/linux.cmake)
endif()
endif()

2 changes: 2 additions & 0 deletions cmake/prep/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0a17e31

Please sign in to comment.