Update pingcheck to work with cmake 3.28 master
authorLudwig Jäck <ludwig.jaeck@intra2net.com>
Wed, 10 Apr 2024 14:23:55 +0000 (16:23 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Thu, 16 May 2024 13:18:20 +0000 (15:18 +0200)
Most prominent change: The way the boost libraries get linked.

20 files changed:
CMakeLists.txt
src/CMakeLists.txt
src/dns/dnscache.cpp
test/CMakeLists.test_configurationcommandline.txt
test/CMakeLists.test_configurationfile.txt
test/CMakeLists.test_configurationoptions.txt
test/CMakeLists.test_dns.txt
test/CMakeLists.test_hoststatus.txt
test/CMakeLists.test_icmppacket.txt
test/CMakeLists.test_icmpv4header.txt
test/CMakeLists.test_icmpv6header.txt
test/CMakeLists.test_ipv4header.txt
test/CMakeLists.test_ipv6header.txt
test/CMakeLists.test_linkstatus.txt
test/CMakeLists.test_loglevel.txt
test/CMakeLists.test_logoutput.txt
test/CMakeLists.test_messagepayload.txt
test/CMakeLists.test_pingprotocol.txt
test/CMakeLists.test_tcpheader.txt
test/data/dns_cache_compatibility_test.xml

index d36b471..24d4d58 100644 (file)
@@ -1,12 +1,13 @@
+cmake_minimum_required(VERSION 3.28 FATAL_ERROR)
+
 # project: definitions
 project(pingcheck)
-set(VERSION 0.7)
-set(VERSION_REVISION 1)
+set(VERSION 0.8)
+set(VERSION_REVISION 0)
 set(TARGET ${PROJECT_NAME})
 
 # cmake: build options
 set(CMAKE_COLOR_MAKEFILE ON)
-cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
 
 # compiler: add definitions and arguments to the compiler
 add_definitions(
index 268d58f..1ba31c9 100644 (file)
@@ -5,9 +5,8 @@ include(FindPkgConfig)
 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)
-include_directories(${Boost_INCLUDE_DIRS})
-link_directories(${Boost_LIBRARY_DIRS})
 
 # package: boost-custom
 include_directories(${CMAKE_SOURCE_DIR}/lib/boost-custom)
@@ -126,7 +125,11 @@ add_executable(${TARGET} ${SOURCES})
 # linker: link the program against the libraries
 target_link_libraries(
     ${TARGET}
-    ${Boost_LIBRARIES}
+    Boost::filesystem
+    Boost::program_options
+    Boost::system
+    Boost::serialization
+    Boost::date_time
     ${I2NCOMMON_LIBRARIES}
     pthread
 )
@@ -145,7 +148,11 @@ add_executable(feed_packet_data ${feed_packet_data_SOURCES})
 target_link_libraries(
     feed_packet_data
     lib_for_tools
-    ${Boost_LIBRARIES}
+    Boost::filesystem
+    Boost::program_options
+    Boost::system
+    Boost::serialization
+    Boost::date_time
     ${I2NCOMMON_LIBRARIES}
 )
 # no install! install(TARGETS feed_packet_data DESTINATION bin)
index 37d62c9..0e9a270 100644 (file)
@@ -26,6 +26,7 @@
 #include <fstream>
 #include <logfunc.hpp>
 #include <filefunc.hxx>   // I2n::file_exists
+#include <tmpfstream.hpp>
 #include <boost/foreach.hpp>
 #include <boost/bind.hpp>
 #include <boost/asio/placeholders.hpp>
@@ -137,7 +138,7 @@ void DnsCache::save_to_cachefile()
             std::string cache_save_time_str = boost::posix_time::to_iso_string(
                             boost::posix_time::second_clock::universal_time() );
 
-            std::ofstream ofs( CacheFile.c_str() );
+            I2n::tmpofcopystream ofs( CacheFile.c_str() );
             boost::archive::xml_oarchive oa(ofs);
             oa & BOOST_SERIALIZATION_NVP(IpCache);
             oa & BOOST_SERIALIZATION_NVP(CnameCache);
@@ -171,16 +172,22 @@ void DnsCache::load_from_cachefile()
             std::ifstream ifs( CacheFile.c_str() );
             boost::archive::xml_iarchive ia(ifs);
 
+            ip_map_type new_IpCache;
+            cname_map_type new_CnameCache;
             std::string cache_save_time_str;
 
-            ia & BOOST_SERIALIZATION_NVP(IpCache);
-            ia & BOOST_SERIALIZATION_NVP(CnameCache);
+            ia & BOOST_SERIALIZATION_NVP(new_IpCache);
+            ia & BOOST_SERIALIZATION_NVP(new_CnameCache);
             ia & BOOST_SERIALIZATION_NVP(cache_save_time_str);
 
-            boost::posix_time::ptime cache_save_time
+            const boost::posix_time::ptime cache_save_time
                     = boost::posix_time::from_iso_string(cache_save_time_str);
             GlobalLogger.info() << "DnsCache: loaded from file " << CacheFile;
 
+            // atomic switch over
+            IpCache.swap(new_IpCache);
+            CnameCache.swap(new_CnameCache);
+
             check_timestamps(cache_save_time);
         }
         catch (boost::archive::archive_exception &exc)
index a6508b7..c2e1f0c 100644 (file)
@@ -42,7 +42,11 @@ add_executable(test_configurationcommandline
 target_link_libraries(
     test_configurationcommandline
     ${I2NCOMMON_LIBRARIES}
-    ${Boost_LIBRARIES}
+    Boost::unit_test_framework
+    Boost::system
+    Boost::program_options
+    Boost::date_time
+    Boost::serialization
     pthread
 )
 
index 0dad829..791ec63 100644 (file)
@@ -42,7 +42,11 @@ add_executable(test_configurationfile
 target_link_libraries(
     test_configurationfile
     ${I2NCOMMON_LIBRARIES}
-    ${Boost_LIBRARIES}
+    Boost::unit_test_framework
+    Boost::system
+    Boost::program_options
+    Boost::date_time
+    Boost::serialization
     pthread
 )
 
index faa41b5..5770f37 100644 (file)
@@ -40,7 +40,11 @@ add_executable(test_configurationoptions
 target_link_libraries(
     test_configurationoptions
     ${I2NCOMMON_LIBRARIES}
-    ${Boost_LIBRARIES}
+    Boost::unit_test_framework
+    Boost::system
+    Boost::program_options
+    Boost::date_time
+    Boost::serialization
     pthread
 )
 
index 5620a6a..93b3da1 100644 (file)
@@ -30,7 +30,11 @@ include_directories(${CMAKE_SOURCE_DIR}/lib/boost-net-dns)
 target_link_libraries(
     test_dns
     ${I2NCOMMON_LIBRARIES}
-    ${Boost_LIBRARIES}
+    Boost::unit_test_framework
+    Boost::system
+    Boost::program_options
+    Boost::date_time
+    Boost::serialization
     pthread
 )
 
index e60c237..420a155 100644 (file)
@@ -10,7 +10,11 @@ add_executable(test_hoststatus
 target_link_libraries(
     test_hoststatus
     ${I2NCOMMON_LIBRARIES}
-    ${Boost_LIBRARIES}
+    Boost::unit_test_framework
+    Boost::system
+    Boost::program_options
+    Boost::date_time
+    Boost::serialization
     pthread
 )
 
index 19a2471..921d7f2 100644 (file)
@@ -32,7 +32,11 @@ link_directories(${Boost_LIBRARY_DIRS})
 target_link_libraries(
     test_icmppacket
     ${I2NCOMMON_LIBRARIES}
-    ${Boost_LIBRARIES}
+    Boost::unit_test_framework
+    Boost::system
+    Boost::program_options
+    Boost::date_time
+    Boost::serialization
     pthread
 )
 
index 59b3e83..5ecfa32 100644 (file)
@@ -17,7 +17,11 @@ add_executable(test_icmpv4header
 target_link_libraries(
     test_icmpv4header
     ${I2NCOMMON_LIBRARIES}
-    ${Boost_LIBRARIES}
+    Boost::unit_test_framework
+    Boost::system
+    Boost::program_options
+    Boost::date_time
+    Boost::serialization
     pthread
 )
 
index fe5266a..c05d668 100644 (file)
@@ -17,7 +17,11 @@ add_executable(test_icmpv6header
 target_link_libraries(
     test_icmpv6header
     ${I2NCOMMON_LIBRARIES}
-    ${Boost_LIBRARIES}
+    Boost::unit_test_framework
+    Boost::system
+    Boost::program_options
+    Boost::date_time
+    Boost::serialization
     pthread
 )
 
index af8ec8d..09985ef 100644 (file)
@@ -11,7 +11,11 @@ add_executable(test_ipv4header
 target_link_libraries(
     test_ipv4header
     ${I2NCOMMON_LIBRARIES}
-    ${Boost_LIBRARIES}
+    Boost::unit_test_framework
+    Boost::system
+    Boost::program_options
+    Boost::date_time
+    Boost::serialization
     pthread
 )
 
index bae2ab9..21d5083 100644 (file)
@@ -11,7 +11,11 @@ add_executable(test_ipv6header
 target_link_libraries(
     test_ipv6header
     ${I2NCOMMON_LIBRARIES}
-    ${Boost_LIBRARIES}
+    Boost::unit_test_framework
+    Boost::system
+    Boost::program_options
+    Boost::date_time
+    Boost::serialization
     pthread
 )
 
index ad3b987..e58ea15 100644 (file)
@@ -1,6 +1,6 @@
 # compiler: creates the binaries
 add_executable(test_linkstatus
-    test_linkstatus
+    test_linkstatus.cpp
     ${CMAKE_SOURCE_DIR}/src/boost_assert_handler.cpp
     ${CMAKE_SOURCE_DIR}/src/link/linkstatus.cpp
     ${CMAKE_SOURCE_DIR}/src/dns/hostaddress.cpp
@@ -18,7 +18,11 @@ add_executable(test_linkstatus
 target_link_libraries(
     test_linkstatus
     ${I2NCOMMON_LIBRARIES}
-    ${Boost_LIBRARIES}
+    Boost::unit_test_framework
+    Boost::system
+    Boost::program_options
+    Boost::date_time
+    Boost::serialization
     pthread
 )
 
index 12a9e15..eea1cb2 100644 (file)
@@ -9,7 +9,11 @@ add_executable(test_loglevel
 target_link_libraries(
     test_loglevel
     ${I2NCOMMON_LIBRARIES}
-    ${Boost_LIBRARIES}
+    Boost::unit_test_framework
+    Boost::system
+    Boost::program_options
+    Boost::date_time
+    Boost::serialization
     pthread
 )
 
index b8cf2b6..bf5ba87 100644 (file)
@@ -9,7 +9,11 @@ add_executable(test_logoutput
 target_link_libraries(
     test_logoutput
     ${I2NCOMMON_LIBRARIES}
-    ${Boost_LIBRARIES}
+    Boost::unit_test_framework
+    Boost::system
+    Boost::program_options
+    Boost::date_time
+    Boost::serialization
     pthread
 )
 
index 07cc163..53b320b 100644 (file)
@@ -9,7 +9,11 @@ add_executable(test_messagepayload
 target_link_libraries(
     test_messagepayload
     ${I2NCOMMON_LIBRARIES}
-    ${Boost_LIBRARIES}
+    Boost::unit_test_framework
+    Boost::system
+    Boost::program_options
+    Boost::date_time
+    Boost::serialization
     pthread
 )
 
index 24cef29..85813a2 100644 (file)
@@ -9,7 +9,11 @@ add_executable(test_pingprotocol
 target_link_libraries(
     test_pingprotocol
     ${I2NCOMMON_LIBRARIES}
-    ${Boost_LIBRARIES}
+    Boost::unit_test_framework
+    Boost::system
+    Boost::program_options
+    Boost::date_time
+    Boost::serialization
     pthread
 )
 
index 8a41528..f551853 100644 (file)
@@ -10,7 +10,11 @@ add_executable(test_tcpheader
 target_link_libraries(
     test_tcpheader
     ${I2NCOMMON_LIBRARIES}
-    ${Boost_LIBRARIES}
+    Boost::unit_test_framework
+    Boost::system
+    Boost::program_options
+    Boost::date_time
+    Boost::serialization
     pthread
 )
 
index 6a1e045..eeaf240 100644 (file)
@@ -66,5 +66,5 @@
                </second>
        </item>
 </CnameCache>
+<cache_save_time_str>20150522T084242</cache_save_time_str>
 </boost_serialization>
-