diff --git a/CMakeLists.txt b/CMakeLists.txt index c21cf680d..11befca65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,6 +95,7 @@ option(SRB2_CONFIG_NOVERIFYIWADS "Compile with IWAD verification turned off." OF set(SRB2_CONFIG_ASSET_DIRECTORY "" CACHE PATH "Path to directory that contains all asset files for the installer. If set, assets will be part of installation and cpack.") option(SRB2_CONFIG_LTO "Enable link time optimizations, improves performance at the cost of longer link times." ON) option(SRB2_CONFIG_TIDY "Enable clang tiny, checks compiled code for issues at the cost of longer compile times." OFF) +option(SRB2_CONFIG_UPNP "Enable UPnP support for networking." ON) if(SRB2_CONFIG_ENABLE_TESTS) # https://github.com/catchorg/Catch2 @@ -185,7 +186,6 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) add_subdirectory(src) add_subdirectory(assets) - ## config.h generation set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary") include(GitUtilities) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9ab1780f7..5a8d22f4b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -306,6 +306,11 @@ target_link_libraries(BLANKART PRIVATE Opus::opus) target_link_libraries(BLANKART PRIVATE Ogg::ogg) endif() +if(SRB2_CONFIG_UPNP) + target_compile_definitions(BLANKART PRIVATE -DHAVE_MINIUPNPC) + target_link_libraries(BLANKART PRIVATE miniupnpc) +endif() + target_link_libraries(BLANKART PRIVATE xxHash::xxhash) target_compile_definitions(BLANKART PRIVATE -DUSE_STUN) diff --git a/src/i_tcp.c b/src/i_tcp.c index acde57a8a..a65d996ff 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -118,10 +118,10 @@ typedef union } mysockaddr_t; #ifdef HAVE_MINIUPNPC - #include "miniwget.h" - #include "miniupnpc.h" - #include "upnpcommands.h" - static UINT8 UPNP_support = TRUE; + #include "miniupnpc/miniwget.h" + #include "miniupnpc/miniupnpc.h" + #include "miniupnpc/upnpcommands.h" + static UINT8 UPNP_support = true; #endif // HAVE_MINIUPNC #include "i_system.h" diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 138981377..c4b7cc010 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -28,3 +28,11 @@ add_subdirectory(tracy) add_subdirectory(tcbrindle_span) add_subdirectory(fmt) add_subdirectory(xxhash) + +if(SRB2_CONFIG_UPNP) + set(UPNPC_BUILD_STATIC ${NOT_SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}) + set(UPNPC_BUILD_SHARED ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}) + set(UPNPC_BUILD_TESTS FALSE) + set(UPNPC_BUILD_SAMPLE FALSE) + add_subdirectory("miniupnp/miniupnpc" EXCLUDE_FROM_ALL) +endif()