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
project(libi2ncommon)
include(FindPkgConfig)
# Find Boost
-find_package(Boost 1.44 COMPONENTS iostreams unit_test_framework thread REQUIRED)
-include_directories(${Boost_INCLUDE_DIRS})
+find_package(Boost 1.44 REQUIRED COMPONENTS iostreams unit_test_framework thread)
+
+# CMake 3.28 compatibility: imported targets only available in CMake 3.30+
+if(CMAKE_VERSION VERSION_LESS 3.30)
+ include_directories(${Boost_INCLUDE_DIRS})
+endif()
# Find pcrecpp
pkg_check_modules(PCRECPP REQUIRED libpcrecpp)
add_library(i2ncommon SHARED ${cpp_sources} ${cpp_headers})
-target_link_libraries(i2ncommon
- ${Boost_IOSTREAMS_LIBRARIES}
- ${Boost_THREAD_LIBRARIES}
- ${ICONV_LIBRARIES}
- ${OPENSSL_LIBRARIES}
- ${PCRECPP_LIBRARIES})
+# CMake 3.30+ provides modern imported targets, CMake 3.28 uses old-style variables
+if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.30)
+ target_link_libraries(i2ncommon Boost::iostreams Boost::thread)
+else()
+ target_link_libraries(i2ncommon ${Boost_IOSTREAMS_LIBRARIES} ${Boost_THREAD_LIBRARIES})
+endif()
+target_link_libraries(i2ncommon ${ICONV_LIBRARIES} ${OPENSSL_LIBRARIES} ${PCRECPP_LIBRARIES})
set_target_properties(i2ncommon PROPERTIES VERSION ${VERSION} SOVERSION 8)
set_target_properties(i2ncommon PROPERTIES OUTPUT_NAME i2ncommon CLEAN_DIRECT_OUTPUT 1)
enable_testing()
add_test(test_i2ncommon test_i2ncommon)
-target_link_libraries(test_i2ncommon
- i2ncommon
- i2ncommon_utils
- i2ncommon_config
- ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}
-)
+# CMake 3.30+ provides modern imported targets, CMake 3.28 uses old-style variables
+if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.30)
+ target_link_libraries(test_i2ncommon Boost::unit_test_framework)
+else()
+ target_link_libraries(test_i2ncommon ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
+endif()
+target_link_libraries(test_i2ncommon i2ncommon i2ncommon_utils i2ncommon_config)