From e5c4924e7a4264b42b1ea280694278abccc8baf6 Mon Sep 17 00:00:00 2001
From: Logan Aerl Arias <logana@srb2.org>
Date: Sun, 16 Feb 2025 23:05:15 -0500
Subject: [PATCH] Update CMakeLists.txt

only link iphlpapi if on Windows host
only copy MinGW DLLs if on Windows host
---
 src/CMakeLists.txt | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 03dbfbcd5c..9e60bdd53c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -469,7 +469,11 @@ endif()
 if(TARGET miniupnpc::miniupnpc)
 	if("${VCPKG_TARGET_TRIPLET}" MATCHES "-mingw-static$")
 		target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MINIUPNPC -DMINIUPNP_STATICLIB)
-		target_link_libraries(SRB2SDL2 PRIVATE miniupnpc::miniupnpc iphlpapi)
+		if("${VCPKG_HOST_TRIPLET}" MATCHES "-mingw-static$")
+			target_link_libraries(SRB2SDL2 PRIVATE miniupnpc::miniupnpc iphlpapi)
+		else()
+			target_link_libraries(SRB2SDL2 PRIVATE miniupnpc::miniupnpc)
+		endif()
 	else()
 		target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MINIUPNPC)
 		target_link_libraries(SRB2SDL2 PRIVATE miniupnpc::miniupnpc)
@@ -498,7 +502,7 @@ endif()
 # copy DLLs to bin/ directory if building internal shared on windows
 if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows AND NOT "${SRB2_CONFIG_INTERNAL_LIBRARIES}")
 	set(ADDITIONAL_DLLS "")
-	if("${CMAKE_C_COMPILER_ID}" STREQUAL GNU)
+	if("${CMAKE_C_COMPILER_ID}" STREQUAL GNU AND "${VCPKG_HOST_TRIPLET}" MATCHES "-mingw-static$")
 		# also copy implicitly linked system libraries
 		get_filename_component(MINGW_BIN_PATH ${CMAKE_CXX_COMPILER} PATH)
 		list(APPEND ADDITIONAL_DLLS
-- 
GitLab