1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-09-09 22:36: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})
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} filesystem)
endif()
if(CMAKE_VERSION VERSION_LESS 3.30)
find_package(Boost ${GNSSSDR_BOOST_MIN_VERSION} COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
find_package(Boost ${GNSSSDR_BOOST_MIN_VERSION} COMPONENTS ${BOOST_COMPONENTS})
if(Boost_FOUND)
get_filename_component(BOOST_PREFIX ${Boost_INCLUDE_DIRS} DIRECTORY)
message(STATUS "Found Boost v${Boost_VERSION_STRING} at ${BOOST_PREFIX}")
else()
find_package(Boost ${GNSSSDR_BOOST_MIN_VERSION} COMPONENTS ${BOOST_COMPONENTS})
if(Boost_FOUND)
get_filename_component(BOOST_PREFIX ${Boost_INCLUDE_DIRS} DIRECTORY)
message(STATUS "Found Boost v${Boost_VERSION_STRING} at ${BOOST_PREFIX}")
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()
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()
if(NOT Boost_FOUND)
@@ -914,45 +910,47 @@ endif()
# Provide package descriptions if Boost >= 1.71.00
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
URL "https://www.boost.org/"
URL "https://www.boost.org/libraries/${Boost_VERSION_STRING}/grid/"
DESCRIPTION "Header files of Boost libraries"
PURPOSE "Used widely across the source code."
TYPE REQUIRED
)
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"
PURPOSE "Required by Boost Thread."
TYPE REQUIRED
)
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"
PURPOSE "Required by Boost Thread."
TYPE REQUIRED
)
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"
PURPOSE "Required by Boost Thread."
TYPE REQUIRED
)
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"
PURPOSE "Used for serializing data."
TYPE REQUIRED
)
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"
PURPOSE "Used by GNU Radio multi-threading system."
TYPE REQUIRED
)
if(Boost_VERSION_STRING VERSION_LESS 1.88.99)
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"
PURPOSE "Used for error reporting."
TYPE REQUIRED
@@ -960,7 +958,7 @@ if(Boost_VERSION_STRING VERSION_GREATER 1.70.99)
endif()
if(NOT ${FILESYSTEM_FOUND})
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"
PURPOSE "Used for output file handling."
TYPE REQUIRED
@@ -1023,8 +1021,10 @@ if(Boost_VERSION_STRING VERSION_GREATER 1.72.99)
endif()
# Fix for Boost >= 1.89 - Boost::system becomes header-only
if(Boost_VERSION_STRING VERSION_GREATER 1.88.99)
add_library(Boost::system ALIAS Boost::headers)
if(Boost_VERSION_STRING VERSION_LESS 1.89.0)
set(NEED_BOOST_SYSTEM ON)
else()
set(NEED_BOOST_SYSTEM OFF)
endif()

View File

@@ -149,7 +149,7 @@ if(FILESYSTEM_FOUND)
endif()
target_link_libraries(algorithms_libs PUBLIC std::filesystem)
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()
if(has_span)
@@ -228,7 +228,12 @@ if(FILESYSTEM_FOUND)
endif()
target_link_libraries(gnss_sdr_flags PRIVATE std::filesystem)
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()
if(ENABLE_GLOG_AND_GFLAGS)

View File

@@ -94,7 +94,12 @@ if(FILESYSTEM_FOUND)
endif()
target_link_libraries(algorithms_libs_rtklib PUBLIC std::filesystem)
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()
set_property(TARGET algorithms_libs_rtklib

View File

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

View File

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

View File

@@ -4,7 +4,7 @@
# SPDX-FileCopyrightText: 2021 C. Fernandez-Prades cfernandez(at)cttc.es
# 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)
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_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)
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)
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
PUBLIC
Boost::boost
Boost::system
Boost::headers
$<$<BOOL:${NEED_BOOST_SYSTEM}>:Boost::system>
protobuf::libprotobuf
)