From 0166b3b0de5cb32b255232bd97fe4b4bd284206e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Wed, 19 Nov 2025 14:51:59 -0500
Subject: [PATCH] Add NATPMP_BUILD_TOOLS option to conditionally build natpmpc
 and testgetgateway

---
 CMakeLists.txt | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 16af4aa..df5f117 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,6 +19,7 @@ if (WIN32)
 endif (WIN32)
 
 option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
+option(NATPMP_BUILD_TOOLS "Build natpmpc and testgetgateway executables" ON)
 
 # Library itself
 add_library(natpmp ${NATPMP_SOURCES})
@@ -39,24 +40,31 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Haiku")
 endif ()
 
 # Executables
-add_executable(natpmpc natpmpc.c)
-target_link_libraries(natpmpc natpmp)
+if (NATPMP_BUILD_TOOLS)
+	add_executable(natpmpc natpmpc.c)
+	target_link_libraries(natpmpc natpmp)
 
-add_executable(testgetgateway
-	testgetgateway.c
-	getgateway.c)
-target_link_libraries(testgetgateway natpmp)
+	add_executable(testgetgateway
+		testgetgateway.c
+		getgateway.c)
+	target_link_libraries(testgetgateway natpmp)
+endif()
 
 # natpmp.pc
 include(GNUInstallDirs)
 configure_file(natpmp.pc.in natpmp.pc @ONLY)
 
 # install
-install(TARGETS natpmp natpmpc
+install(TARGETS natpmp
         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
         ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
 
+if (NATPMP_BUILD_TOOLS)
+	install(TARGETS natpmpc
+		RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+endif()
+
 install(FILES natpmp.h natpmp_declspec.h
         DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
-- 
2.50.1 (Apple Git-155)

