From 9ba4ea93c95af5aa271d0512f0b4c5af8887a3f1 Mon Sep 17 00:00:00 2001 From: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com> Date: Fri, 1 May 2026 00:03:36 +0200 Subject: [PATCH] add optional dnsmasq features to cmake Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com> --- src/CMakeLists.txt | 35 +++++++++++++++++++++++++++++++++++ src/FindDBus.cmake | 2 +- src/dnsmasq/config.h | 5 ----- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 95118ab02..8c0dc67de 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -370,7 +370,42 @@ endif() # (e.g. "src/args.c" instead of "/home/user/FTL/src/args.c"). target_compile_definitions(core PRIVATE SOURCE_ROOT="${CMAKE_SOURCE_DIR}/") +option(USE_CONNTRACK "Build FTL with dnsmasq conntrack support, if available" ON) + +check_include_file("libnetfilter_conntrack/libnetfilter_conntrack.h" HAVE_LIBNETFILTER_CONNTRACK_H) +find_library(LIBNETFILTER_CONNTRACK NAMES libnetfilter_conntrack${LIBRARY_SUFFIX} netfilter_conntrack) +if(HAVE_LIBNETFILTER_CONNTRACK_H AND LIBNETFILTER_CONNTRACK AND USE_CONNTRACK) + message(STATUS "Building FTL with dnsmasq conntrack support: YES") + target_compile_definitions(dnsmasq PRIVATE HAVE_CONNTRACK) + target_link_libraries(pihole-FTL ${LIBNETFILTER_CONNTRACK}) +else() + message(STATUS "Building FTL with dnsmasq conntrack support: NO") +endif() + +option(USE_NFTSET "Build FTL with dnsmasq nftset support, if available" ON) +check_include_file("nftables/libnftables.h" HAVE_LIBNFTABLES_H) +find_library(LIBNFTABLES NAMES libnftables${LIBRARY_SUFFIX} nftables) +if(HAVE_LIBNFTABLES_H AND LIBNFTABLES AND USE_NFTSET) + message(STATUS "Building FTL with dnsmasq nftset support: YES") + target_compile_definitions(dnsmasq PRIVATE HAVE_NFTSET) + target_link_libraries(pihole-FTL ${LIBNFTABLES}) +else() + message(STATUS "Building FTL with dnsmasq nftset support: NO") +endif() + +option(USE_DBUS "Build FTL with dnsmasq DBus support, if available" ON) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") +find_package(DBus) +if(DBUS_FOUND AND USE_DBUS) + message(STATUS "Building FTL with dnsmasq DBus support: YES") + target_compile_definitions(dnsmasq PRIVATE HAVE_DBUS) + target_include_directories(dnsmasq PRIVATE ${DBUS_INCLUDE_DIRS}) + target_link_libraries(pihole-FTL ${DBUS_LIBRARIES}) +else() + message(STATUS "Building FTL with dnsmasq DBus support: NO") +endif() option(USE_READLINE "Build FTL with readline support, if available" ON) diff --git a/src/FindDBus.cmake b/src/FindDBus.cmake index 4a1a18056..885c608e0 100644 --- a/src/FindDBus.cmake +++ b/src/FindDBus.cmake @@ -56,4 +56,4 @@ FIND_PATH(DBUS_ARCH_INCLUDE_DIR SET(DBUS_INCLUDE_DIRS ${DBUS_INCLUDE_DIR} ${DBUS_ARCH_INCLUDE_DIR}) INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(DBUS REQUIRED_VARS DBUS_INCLUDE_DIRS DBUS_LIBRARIES) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(DBus REQUIRED_VARS DBUS_INCLUDE_DIRS DBUS_LIBRARIES) diff --git a/src/dnsmasq/config.h b/src/dnsmasq/config.h index 5361667be..69550a134 100644 --- a/src/dnsmasq/config.h +++ b/src/dnsmasq/config.h @@ -210,11 +210,6 @@ RESOLVFILE #define HAVE_LUASCRIPT #define HAVE_LIBIDN2 #define HAVE_DNSSEC -#ifdef DNSMASQ_ALL_OPTS - #define HAVE_DBUS - #define HAVE_CONNTRACK - #define HAVE_NFTSET -#endif /***********************/ /* Default locations for important system files. */