From fd2ab132761d293eb909f4734bc9b4eec341fa8e Mon Sep 17 00:00:00 2001
From: Kenton Groombridge <me@concord.sh>
Date: Sun, 21 Sep 2025 23:07:55 +0000
Subject: [PATCH] 3rdparty: fix GNS leaking absl symbols (#4576)

* 3rdparty: fix GNS leaking absl symbols

protobuf 22.0.0 uses absl for logging and leaks its symbols to static
libraries built without -DNDEBUG. Avoid this by always passing this flag
down to the GNS build.

* Use GameNetworkingSockets_s target

---------

Co-authored-by: pastdue <30942300+past-due@users.noreply.github.com>
---
 3rdparty/CMakeLists.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt
index c84e6614d32..6f39c7c04c8 100644
--- a/3rdparty/CMakeLists.txt
+++ b/3rdparty/CMakeLists.txt
@@ -311,6 +311,10 @@ if (ENABLE_GNS_NETWORK_BACKEND)
 	# Don't build the shared variant of the client library: we don't use it anyway, plus it causes build conflicts for macOS.
 	set(BUILD_SHARED_LIB OFF CACHE INTERNAL "Build the shared library version of the client library" FORCE)
 	add_subdirectory(GameNetworkingSockets EXCLUDE_FROM_ALL)
+	# Avoid absl symbol leaks with protobuf>=22.0.0 by always passing -DNDEBUG
+	if(TARGET GameNetworkingSockets_s)
+		target_compile_options(GameNetworkingSockets_s PRIVATE -DNDEBUG)
+	endif()
 	unset(BUILD_SHARED_LIB CACHE)
 else()
 	message(STATUS "GameNetworkingSockets backend support: DISABLED")
