From e075b72d501cd0537a9f62ee4de4461a0bb0ac34 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Sat, 27 Dec 2025 15:50:28 +0100 Subject: [PATCH] Modernize Boost module finding in CMake - Remove deprecated Boost_USE_* variables - Remove duplicate find_package calls from test CMakeLists files - Add missing iostreams component to find_package - Use conditional CMP0167 policy for CMake 3.30+ compatibility while maintaining backward compatibility with CMake 3.28+ This eliminates the FindBoost deprecation warning on CMake 3.30+. --- CMakeLists.txt | 7 +++++++ src/CMakeLists.txt | 8 ++------ test/CMakeLists.test_dns.txt | 7 ------- test/CMakeLists.test_icmppacket.txt | 7 ------- test/CMakeLists.txt | 9 ++------- 5 files changed, 11 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24d4d58..4258eff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,12 @@ cmake_minimum_required(VERSION 3.28 FATAL_ERROR) +# Modern Boost integration (CMake 3.30+) +# Use CMake's built-in Boost support instead of deprecated FindBoost module +# For CMake < 3.30, keep old behavior to avoid errors +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.30) + cmake_policy(SET CMP0167 NEW) +endif() + # project: definitions project(pingcheck) set(VERSION 0.8) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1ba31c9..32a4789 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,12 +1,8 @@ # package: find external packages include(FindPkgConfig) -# package: required boost libraries -set(Boost_USE_STATIC_LIBS OFF) -set(Boost_USE_MULTITHREADED OFF) -set(Boost_USE_STATIC_RUNTIME OFF) - -find_package(Boost 1.44 COMPONENTS filesystem program_options system serialization date_time REQUIRED) +# package: required boost libraries (CMake 3.30+ modern approach) +find_package(Boost 1.44 REQUIRED COMPONENTS filesystem program_options system serialization date_time iostreams) # package: boost-custom include_directories(${CMAKE_SOURCE_DIR}/lib/boost-custom) diff --git a/test/CMakeLists.test_dns.txt b/test/CMakeLists.test_dns.txt index 93b3da1..7ea036b 100644 --- a/test/CMakeLists.test_dns.txt +++ b/test/CMakeLists.test_dns.txt @@ -16,13 +16,6 @@ add_executable(test_dns test_dns.cpp ) -set(Boost_USE_STATIC_LIBS OFF) -set(Boost_USE_MULTITHREADED OFF) -set(Boost_USE_STATIC_RUNTIME OFF) -find_package(Boost 1.44 COMPONENTS serialization date_time REQUIRED) -include_directories(${Boost_INCLUDE_DIRS}) -link_directories(${Boost_LIBRARY_DIRS}) - # package: boost-net-dns include_directories(${CMAKE_SOURCE_DIR}/lib/boost-net-dns) diff --git a/test/CMakeLists.test_icmppacket.txt b/test/CMakeLists.test_icmppacket.txt index 921d7f2..b093012 100644 --- a/test/CMakeLists.test_icmppacket.txt +++ b/test/CMakeLists.test_icmppacket.txt @@ -21,13 +21,6 @@ add_executable(test_icmppacket test_icmppacket.cpp ) -set(Boost_USE_STATIC_LIBS OFF) -set(Boost_USE_MULTITHREADED OFF) -set(Boost_USE_STATIC_RUNTIME OFF) -find_package(Boost 1.44 COMPONENTS serialization date_time REQUIRED) -include_directories(${Boost_INCLUDE_DIRS}) -link_directories(${Boost_LIBRARY_DIRS}) - # linker: link the program against the libraries target_link_libraries( test_icmppacket diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8162a05..03bb845 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,13 +1,8 @@ # package: find external packages include(FindPkgConfig) -# package: required boost libraries -set(Boost_USE_STATIC_LIBS OFF) -set(Boost_USE_MULTITHREADED ON) -set(Boost_USE_STATIC_RUNTIME OFF) -find_package(Boost 1.44 COMPONENTS unit_test_framework system program_options date_time serialization REQUIRED) -include_directories(${Boost_INCLUDE_DIRS}) -link_directories(${Boost_LIBRARY_DIRS}) +# package: required boost libraries (CMake 3.30+ modern approach) +find_package(Boost 1.44 REQUIRED COMPONENTS unit_test_framework system program_options date_time serialization iostreams) # package: libi2ncommon pkg_check_modules(I2NCOMMON REQUIRED libi2ncommon) -- 1.7.1