1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-09-11 15:26:02 +00:00

Improve handling of Boost 1.89

This commit is contained in:
Carles Fernandez
2025-08-20 11:23:31 +02:00
parent c075f0f06e
commit 15a7a9bae3
6 changed files with 78 additions and 31 deletions

View File

@@ -797,19 +797,15 @@ set(BOOST_COMPONENTS atomic chrono date_time serialization system thread)
if(NOT ${FILESYSTEM_FOUND}) if(NOT ${FILESYSTEM_FOUND})
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} filesystem) set(BOOST_COMPONENTS ${BOOST_COMPONENTS} filesystem)
endif() endif()
if(CMAKE_VERSION VERSION_LESS 3.30) find_package(Boost ${GNSSSDR_BOOST_MIN_VERSION} COMPONENTS ${BOOST_COMPONENTS})
find_package(Boost ${GNSSSDR_BOOST_MIN_VERSION} COMPONENTS ${BOOST_COMPONENTS} REQUIRED) if(Boost_FOUND)
get_filename_component(BOOST_PREFIX ${Boost_INCLUDE_DIRS} DIRECTORY)
message(STATUS "Found Boost v${Boost_VERSION_STRING} at ${BOOST_PREFIX}")
else() else()
find_package(Boost ${GNSSSDR_BOOST_MIN_VERSION} COMPONENTS ${BOOST_COMPONENTS}) message(STATUS "Trying deprecated FindBoost Module ...")
if(Boost_FOUND) if(POLICY CMP0167)
get_filename_component(BOOST_PREFIX ${Boost_INCLUDE_DIRS} DIRECTORY) cmake_policy(SET CMP0167 OLD)
message(STATUS "Found Boost v${Boost_VERSION_STRING} at ${BOOST_PREFIX}") find_package(Boost ${GNSSSDR_BOOST_MIN_VERSION} REQUIRED COMPONENTS ${BOOST_COMPONENTS})
else()
message(STATUS "Trying deprecated FindBoost Module ...")
if(POLICY CMP0167)
cmake_policy(SET CMP0167 OLD)
find_package(Boost ${GNSSSDR_BOOST_MIN_VERSION} REQUIRED COMPONENTS ${BOOST_COMPONENTS})
endif()
endif() endif()
endif() endif()
if(NOT Boost_FOUND) if(NOT Boost_FOUND)
@@ -914,45 +910,47 @@ endif()
# Provide package descriptions if Boost >= 1.71.00 # Provide package descriptions if Boost >= 1.71.00
if(Boost_VERSION_STRING VERSION_GREATER 1.70.99) if(Boost_VERSION_STRING VERSION_GREATER 1.70.99)
set(boost_version_string "${Boost_VERSION_STRING}")
string(REPLACE "." "_" boost_version_underscored "${boost_version_string}")
set_package_properties(boost_headers PROPERTIES set_package_properties(boost_headers PROPERTIES
URL "https://www.boost.org/" URL "https://www.boost.org/libraries/${Boost_VERSION_STRING}/grid/"
DESCRIPTION "Header files of Boost libraries" DESCRIPTION "Header files of Boost libraries"
PURPOSE "Used widely across the source code." PURPOSE "Used widely across the source code."
TYPE REQUIRED TYPE REQUIRED
) )
set_package_properties(boost_atomic PROPERTIES set_package_properties(boost_atomic PROPERTIES
URL "https://www.boost.org/doc/libs/latest/libs/atomic/doc/html/index.html" URL "https://www.boost.org/doc/libs/${boost_version_underscored}/doc/html/index.html"
DESCRIPTION "Provides atomic data types and operations on those types" DESCRIPTION "Provides atomic data types and operations on those types"
PURPOSE "Required by Boost Thread." PURPOSE "Required by Boost Thread."
TYPE REQUIRED TYPE REQUIRED
) )
set_package_properties(boost_chrono PROPERTIES set_package_properties(boost_chrono PROPERTIES
URL "https://www.boost.org/doc/libs/latest/doc/html/chrono.html" URL "https://www.boost.org/doc/libs/${boost_version_underscored}/doc/html/chrono.html"
DESCRIPTION "Useful time utilities" DESCRIPTION "Useful time utilities"
PURPOSE "Required by Boost Thread." PURPOSE "Required by Boost Thread."
TYPE REQUIRED TYPE REQUIRED
) )
set_package_properties(boost_date_time PROPERTIES set_package_properties(boost_date_time PROPERTIES
URL "https://www.boost.org/doc/libs/latest/doc/html/date_time.html" URL "https://www.boost.org/doc/libs/${boost_version_underscored}/doc/html/date_time.html"
DESCRIPTION "A set of date-time libraries" DESCRIPTION "A set of date-time libraries"
PURPOSE "Required by Boost Thread." PURPOSE "Required by Boost Thread."
TYPE REQUIRED TYPE REQUIRED
) )
set_package_properties(boost_serialization PROPERTIES set_package_properties(boost_serialization PROPERTIES
URL "https://www.boost.org/doc/libs/latest/libs/serialization/doc/index.html" URL "https://www.boost.org/doc/libs/${boost_version_underscored}/libs/serialization/doc/index.html"
DESCRIPTION "Reversible deconstruction of C++ data structures to sequences of bytes" DESCRIPTION "Reversible deconstruction of C++ data structures to sequences of bytes"
PURPOSE "Used for serializing data." PURPOSE "Used for serializing data."
TYPE REQUIRED TYPE REQUIRED
) )
set_package_properties(boost_thread PROPERTIES set_package_properties(boost_thread PROPERTIES
URL "https://www.boost.org/doc/libs/latest/doc/html/thread.html" URL "https://www.boost.org/doc/libs/${boost_version_underscored}/doc/html/thread.html"
DESCRIPTION "Portable C++ multi-threading" DESCRIPTION "Portable C++ multi-threading"
PURPOSE "Used by GNU Radio multi-threading system." PURPOSE "Used by GNU Radio multi-threading system."
TYPE REQUIRED TYPE REQUIRED
) )
if(Boost_VERSION_STRING VERSION_LESS 1.88.99) if(Boost_VERSION_STRING VERSION_LESS 1.88.99)
set_package_properties(boost_system PROPERTIES set_package_properties(boost_system PROPERTIES
URL "https://www.boost.org/doc/libs/latest/libs/system/doc/html/system.html" URL "https://www.boost.org/doc/libs/${boost_version_underscored}/libs/system/doc/html/system.html"
DESCRIPTION "Extensible error reporting library" DESCRIPTION "Extensible error reporting library"
PURPOSE "Used for error reporting." PURPOSE "Used for error reporting."
TYPE REQUIRED TYPE REQUIRED
@@ -960,7 +958,7 @@ if(Boost_VERSION_STRING VERSION_GREATER 1.70.99)
endif() endif()
if(NOT ${FILESYSTEM_FOUND}) if(NOT ${FILESYSTEM_FOUND})
set_package_properties(boost_filesystem PROPERTIES set_package_properties(boost_filesystem PROPERTIES
URL "https://www.boost.org/doc/libs/release/libs/filesystem/doc/index.htm" URL "https://www.boost.org/doc/libs/${boost_version_underscored}/libs/filesystem/doc/index.htm"
DESCRIPTION "Portable facilities to manipulate paths and files" DESCRIPTION "Portable facilities to manipulate paths and files"
PURPOSE "Used for output file handling." PURPOSE "Used for output file handling."
TYPE REQUIRED TYPE REQUIRED
@@ -1023,8 +1021,10 @@ if(Boost_VERSION_STRING VERSION_GREATER 1.72.99)
endif() endif()
# Fix for Boost >= 1.89 - Boost::system becomes header-only # Fix for Boost >= 1.89 - Boost::system becomes header-only
if(Boost_VERSION_STRING VERSION_GREATER 1.88.99) if(Boost_VERSION_STRING VERSION_LESS 1.89.0)
add_library(Boost::system ALIAS Boost::headers) set(NEED_BOOST_SYSTEM ON)
else()
set(NEED_BOOST_SYSTEM OFF)
endif() endif()

View File

@@ -149,7 +149,7 @@ if(FILESYSTEM_FOUND)
endif() endif()
target_link_libraries(algorithms_libs PUBLIC std::filesystem) target_link_libraries(algorithms_libs PUBLIC std::filesystem)
else() else()
target_link_libraries(algorithms_libs PUBLIC Boost::filesystem Boost::system) target_link_libraries(algorithms_libs PUBLIC Boost::filesystem $<$<BOOL:${NEED_BOOST_SYSTEM}>:Boost::system>)
endif() endif()
if(has_span) if(has_span)
@@ -228,7 +228,12 @@ if(FILESYSTEM_FOUND)
endif() endif()
target_link_libraries(gnss_sdr_flags PRIVATE std::filesystem) target_link_libraries(gnss_sdr_flags PRIVATE std::filesystem)
else() else()
target_link_libraries(gnss_sdr_flags PRIVATE Boost::filesystem Boost::system) target_link_libraries(gnss_sdr_flags
PRIVATE
Boost::filesystem
$<$<BOOL:${NEED_BOOST_SYSTEM}>:Boost::system>
$<$<NOT:$<BOOL:${NEED_BOOST_SYSTEM}>>:Boost::headers>
)
endif() endif()
if(ENABLE_GLOG_AND_GFLAGS) if(ENABLE_GLOG_AND_GFLAGS)

View File

@@ -94,7 +94,12 @@ if(FILESYSTEM_FOUND)
endif() endif()
target_link_libraries(algorithms_libs_rtklib PUBLIC std::filesystem) target_link_libraries(algorithms_libs_rtklib PUBLIC std::filesystem)
else() else()
target_link_libraries(algorithms_libs_rtklib PUBLIC Boost::filesystem Boost::system) target_link_libraries(algorithms_libs_rtklib
PUBLIC
Boost::filesystem
$<$<BOOL:${NEED_BOOST_SYSTEM}>:Boost::system>
$<$<NOT:$<BOOL:${NEED_BOOST_SYSTEM}>>:Boost::headers>
)
endif() endif()
set_property(TARGET algorithms_libs_rtklib set_property(TARGET algorithms_libs_rtklib

View File

@@ -102,7 +102,7 @@ target_link_libraries(core_libs
PRIVATE PRIVATE
algorithms_libs algorithms_libs
Boost::serialization Boost::serialization
Boost::system $<$<BOOL:${NEED_BOOST_SYSTEM}>:Boost::system>
Pugixml::pugixml Pugixml::pugixml
) )

View File

@@ -44,7 +44,7 @@ endif()
target_link_libraries(core_monitor target_link_libraries(core_monitor
PUBLIC PUBLIC
Boost::headers Boost::headers
Boost::system $<$<BOOL:${NEED_BOOST_SYSTEM}>:Boost::system>
Gnuradio::runtime Gnuradio::runtime
protobuf::libprotobuf protobuf::libprotobuf
core_system_parameters core_system_parameters

View File

@@ -4,7 +4,7 @@
# SPDX-FileCopyrightText: 2021 C. Fernandez-Prades cfernandez(at)cttc.es # SPDX-FileCopyrightText: 2021 C. Fernandez-Prades cfernandez(at)cttc.es
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
cmake_minimum_required(VERSION 3.9...3.30) cmake_minimum_required(VERSION 3.9...4.0)
project(nav-msg-listener CXX) project(nav-msg-listener CXX)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
@@ -12,8 +12,45 @@ set(CMAKE_CXX_STANDARD 11)
set(NAVLISTENER_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # allows this to be a sub-project set(NAVLISTENER_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # allows this to be a sub-project
set(NAVLISTENER_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(NAVLISTENER_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Workaround for Macports
if(NOT BOOST_ROOT)
set(MACOS_PACKAGES_PREFIX "")
# Detect if MacPorts is installed on this system; if so, return base path and version
execute_process(COMMAND which port RESULT_VARIABLE DETECT_MACPORTS OUTPUT_VARIABLE MACPORTS_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(${DETECT_MACPORTS} EQUAL 0)
# "/opt/local/bin/port", so we get the parent directory
get_filename_component(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
# "/opt/local/bin", so we get the parent directory
get_filename_component(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
execute_process(COMMAND port version RESULT_VARIABLE DETECT_MACPORTS_VERSION OUTPUT_VARIABLE MACPORTS_VERSION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" MACPORTS_VERSION "${MACPORTS_VERSION}")
set(MACOS_PACKAGES_PREFIX ${MACPORTS_PREFIX})
endif()
if(EXISTS "${MACPORTS_PREFIX}/libexec/boost/1.88")
set(BOOST_ROOT "${MACPORTS_PREFIX}/libexec/boost/1.88")
elseif(EXISTS "${MACPORTS_PREFIX}/libexec/boost/1.87")
set(BOOST_ROOT "${MACPORTS_PREFIX}/libexec/boost/1.87")
elseif(EXISTS "${MACPORTS_PREFIX}/libexec/boost/1.81")
set(BOOST_ROOT "${MACPORTS_PREFIX}/libexec/boost/1.81")
elseif(EXISTS "${MACPORTS_PREFIX}/libexec/boost/1.78")
set(BOOST_ROOT "${MACPORTS_PREFIX}/libexec/boost/1.78")
elseif(EXISTS "${MACPORTS_PREFIX}/libexec/boost/1.76")
set(BOOST_ROOT "${MACPORTS_PREFIX}/libexec/boost/1.76")
elseif(EXISTS "${MACPORTS_PREFIX}/libexec/boost/1.71")
set(BOOST_ROOT "${MACPORTS_PREFIX}/libexec/boost/1.71")
endif()
endif()
endif()
set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_STATIC_LIBS OFF)
find_package(Boost COMPONENTS system REQUIRED) find_package(Boost COMPONENTS system)
if(Boost_VERSION_STRING VERSION_GREATER "1.88.99")
set(NEED_BOOST_SYSTEM OFF)
else()
set(NEED_BOOST_SYSTEM ON)
endif()
find_package(Protobuf REQUIRED) find_package(Protobuf REQUIRED)
if(${Protobuf_VERSION} VERSION_LESS "3.0.0") if(${Protobuf_VERSION} VERSION_LESS "3.0.0")
@@ -26,8 +63,8 @@ add_library(navmsg_lib ${NAVLISTENER_SOURCE_DIR}/nav_msg_udp_listener.cc ${PROTO
target_link_libraries(navmsg_lib target_link_libraries(navmsg_lib
PUBLIC PUBLIC
Boost::boost Boost::headers
Boost::system $<$<BOOL:${NEED_BOOST_SYSTEM}>:Boost::system>
protobuf::libprotobuf protobuf::libprotobuf
) )