From 52512ed425db36be292828a021cc80528880b7a4 Mon Sep 17 00:00:00 2001
From: Andrew Udvare <audvare@gmail.com>
Date: Sun, 5 Mar 2023 20:38:09 -0500
Subject: [PATCH 04/12] Support for system miniupnpc

---
 3rdparty/CMakeLists.txt       | 8 ++++++--
 rpcs3/Emu/NP/upnp_handler.cpp | 4 ++--
 rpcs3/Emu/NP/upnp_handler.h   | 2 +-
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt
index ed1ad9998..9481002b1 100644
--- a/3rdparty/CMakeLists.txt
+++ b/3rdparty/CMakeLists.txt
@@ -356,7 +356,11 @@ add_subdirectory(wolfssl EXCLUDE_FROM_ALL)
 add_subdirectory(curl EXCLUDE_FROM_ALL)
 
 # MINIUPNP
-add_subdirectory(miniupnp EXCLUDE_FROM_ALL)
+if (NOT USE_SYSTEM_MINIUPNP)
+	add_subdirectory(miniupnp EXCLUDE_FROM_ALL)
+else()
+	pkg_check_modules(PC_MINIUNPNPC REQUIRED IMPORTED_TARGET GLOBAL miniupnpc)
+endif()
 
 # RTMIDI
 add_subdirectory(rtmidi EXCLUDE_FROM_ALL)
@@ -398,7 +402,7 @@ add_library(3rdparty::wolfssl ALIAS wolfssl)
 add_library(3rdparty::libcurl ALIAS 3rdparty_libcurl)
 add_library(3rdparty::soundtouch ALIAS soundtouch)
 add_library(3rdparty::sdl3 ALIAS ${SDL3_TARGET})
-add_library(3rdparty::miniupnpc ALIAS 3rdparty_miniupnpc)
+add_library(3rdparty::miniupnpc ALIAS PkgConfig::PC_MINIUNPNPC)
 add_library(3rdparty::rtmidi ALIAS rtmidi)
 add_library(3rdparty::opencv ALIAS ${OPENCV_TARGET})
 add_library(3rdparty::fusion ALIAS Fusion)
diff --git a/rpcs3/Emu/NP/upnp_handler.cpp b/rpcs3/Emu/NP/upnp_handler.cpp
index dca00de98..b30bb2e81 100644
--- a/rpcs3/Emu/NP/upnp_handler.cpp
+++ b/rpcs3/Emu/NP/upnp_handler.cpp
@@ -2,8 +2,8 @@
 #include "upnp_handler.h"
 #include "util/logs.hpp"
 
-#include <miniwget.h>
-#include <upnpcommands.h>
+#include <miniupnpc/miniwget.h>
+#include <miniupnpc/upnpcommands.h>
 
 LOG_CHANNEL(upnp_log, "UPNP");
 
diff --git a/rpcs3/Emu/NP/upnp_handler.h b/rpcs3/Emu/NP/upnp_handler.h
index 40892f744..bb99b88ae 100644
--- a/rpcs3/Emu/NP/upnp_handler.h
+++ b/rpcs3/Emu/NP/upnp_handler.h
@@ -2,7 +2,7 @@
 
 #include <unordered_map>
 
-#include <miniupnpc.h>
+#include <miniupnpc/miniupnpc.h>
 
 #include "upnp_config.h"
 #include "Utilities/mutex.h"
-- 
2.51.1

