From c45c296d8fd8d23e1f8cf0b154c23556d90973b0 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 18 Sep 2025 16:25:39 +0200 Subject: [PATCH] cmake: Remove Boost::system from component list This has multiple reasons: - We use CMake's FindBoost (https://cmake.org/cmake/help/v3.12/module/FindBoost.html) which can resolve dependencies itself. We only use boost::system in tandem with Boost::asio, which we already list as a dependency. - There are combinations of CMake versions and Boost versions, where specifying this will link against the stub library of Boost::system (this is a header-only library since Boost 1.69). Removing it from the list avoids any kind of linkage. Note that UHDBoost.cmake has some compatibility hacks for Boost::system, which we now also remove. --- host/CMakeLists.txt | 6 +++--- host/cmake/Modules/UHDBoost.cmake | 8 -------- host/lib/CMakeLists.txt | 1 - host/python/CMakeLists.txt | 4 ++-- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 3859e5f6e..f62897312 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -320,8 +320,8 @@ set(UHD_BOOST_REQUIRED_COMPONENTS date_time filesystem program_options - system serialization + #system Boost.System is used, but explicitly listing it causes errors on some systems. thread unit_test_framework ) @@ -591,9 +591,9 @@ endif(NOT CMAKE_MODULES_DIR) list(APPEND UHD_LINK_LIST_STATIC "dl") list(APPEND UHD_LINK_LIST_STATIC "pthread") foreach(Boost_Comp ${UHD_BOOST_REQUIRED_COMPONENTS}) - if(NOT ${Boost_Comp} STREQUAL "unit_test_framework") + if(NOT ${Boost_Comp} STREQUAL "unit_test_framework" AND NOT ${Boost_Comp} STREQUAL "system") list(APPEND UHD_LINK_LIST_STATIC "boost_${Boost_Comp}") - endif(NOT ${Boost_Comp} STREQUAL "unit_test_framework") + endif() endforeach(Boost_Comp) if(ENABLE_USB) list(APPEND UHD_LINK_LIST_STATIC "usb-1.0") diff --git a/host/cmake/Modules/UHDBoost.cmake b/host/cmake/Modules/UHDBoost.cmake index 94fc42608..39b8124d6 100644 --- a/host/cmake/Modules/UHDBoost.cmake +++ b/host/cmake/Modules/UHDBoost.cmake @@ -100,14 +100,6 @@ if(MINGW) endif() endif() -# if 'system' is in the list, make sure it comes last; sometimes this -# linkage makes a difference -list(FIND UHD_BOOST_REQUIRED_COMPONENTS "system" SYSTEM_NDX) -if(NOT ${SYSTEM_NDX} EQUAL -1) - list(REMOVE_AT UHD_BOOST_REQUIRED_COMPONENTS ${SYSTEM_NDX}) - list(APPEND UHD_BOOST_REQUIRED_COMPONENTS "system") -endif() - # special library directory that's used by some Linux if(UNIX AND NOT BOOST_ROOT AND EXISTS "/usr/lib64") list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index 8bd5d99f1..c92d1195c 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -182,7 +182,6 @@ target_link_libraries(uhd Boost::date_time Boost::filesystem Boost::serialization - Boost::system Boost::thread ${libuhd_libs} PRIVATE uhd_rc diff --git a/host/python/CMakeLists.txt b/host/python/CMakeLists.txt index 00c088237..c9a020ee5 100644 --- a/host/python/CMakeLists.txt +++ b/host/python/CMakeLists.txt @@ -154,11 +154,11 @@ target_include_directories(pyuhd PUBLIC ) if(WIN32) - target_link_libraries(pyuhd ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} uhd) + target_link_libraries(pyuhd ${PYTHON_LIBRARIES} uhd) else() # for extension module, proper to NOT link against python library and instead # add dynamic lookup link option on OSX - target_link_libraries(pyuhd ${Boost_LIBRARIES} uhd) + target_link_libraries(pyuhd uhd) if(APPLE) target_link_options(pyuhd PRIVATE "LINKER:-undefined,dynamic_lookup") endif(APPLE)