1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-02-08 15:10:10 +00:00

Fix linking against Boost 1.87

CI: add boost in homebrew dependencies
This commit is contained in:
Carles Fernandez 2024-12-20 22:09:52 +01:00
parent 84e85111c5
commit 9158447892
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
13 changed files with 95 additions and 7 deletions

View File

@ -59,7 +59,7 @@ jobs:
rm /usr/local/bin/python3.1* || true rm /usr/local/bin/python3.1* || true
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
brew link --overwrite python@3.12 brew link --overwrite python@3.12
brew install ninja hdf5 automake armadillo lapack libmatio gnuradio openssl pugixml protobuf brew install ninja hdf5 automake armadillo lapack libmatio gnuradio openssl pugixml protobuf boost
pip3 install mako pip3 install mako
- name: configure - name: configure
run: cmake -S . -B build -GNinja run: cmake -S . -B build -GNinja
@ -93,7 +93,7 @@ jobs:
rm /usr/local/bin/python3.1* || true rm /usr/local/bin/python3.1* || true
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
brew link --overwrite python@3.12 brew link --overwrite python@3.12
brew install ninja pkg-config hdf5 automake armadillo lapack libmatio gnuradio openssl pugixml protobuf brew install ninja pkg-config hdf5 automake armadillo lapack libmatio gnuradio openssl pugixml protobuf boost
pip3 install mako pip3 install mako
- name: configure - name: configure
run: cmake -S . -B build -GXcode run: cmake -S . -B build -GXcode
@ -143,7 +143,7 @@ jobs:
rm /usr/local/bin/python3.1* || true rm /usr/local/bin/python3.1* || true
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
brew link --overwrite python@3.12 brew link --overwrite python@3.12
brew install ninja pkg-config hdf5 automake armadillo lapack libmatio gnuradio openssl pugixml protobuf llvm brew install ninja pkg-config hdf5 automake armadillo lapack libmatio gnuradio openssl pugixml protobuf llvm boost
pip3 install mako pip3 install mako
ln -s $(brew --prefix llvm)/bin/clang-tidy /usr/local/bin ln -s $(brew --prefix llvm)/bin/clang-tidy /usr/local/bin
ln -s $(brew --prefix llvm)/bin/clang-apply-replacements /usr/local/bin ln -s $(brew --prefix llvm)/bin/clang-apply-replacements /usr/local/bin
@ -195,7 +195,6 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: install dependencies - name: install dependencies
run: | run: |
sudo python -m pip install --upgrade pip
sudo pip install cmakelint sudo pip install cmakelint
- name: check CMake scripts - name: check CMake scripts
run: find . -iname "CMakeLists.txt" -o -iname "*.cmake" | xargs cmakelint --filter=-linelength,-readability/wonkycase run: find . -iname "CMakeLists.txt" -o -iname "*.cmake" | xargs cmakelint --filter=-linelength,-readability/wonkycase

View File

@ -831,7 +831,7 @@ Install the required dependencies:
``` ```
$ brew update && brew upgrade $ brew update && brew upgrade
$ brew install armadillo cmake hdf5 gnuradio libmatio openssl pkg-config protobuf pugixml $ brew install armadillo cmake hdf5 gnuradio libmatio openssl pkg-config protobuf pugixml boost
$ brew install --cask mactex # when completed, restart Terminal $ brew install --cask mactex # when completed, restart Terminal
$ brew install graphviz doxygen $ brew install graphviz doxygen
¢ pip3 install mako ¢ pip3 install mako

View File

@ -105,6 +105,7 @@ All notable changes to GNSS-SDR will be documented in this file.
transitioned to the Apache License 2.0, fully compatible with GPL v3.0. transitioned to the Apache License 2.0, fully compatible with GPL v3.0.
Accordingly, the GNSS-SDR building system now looks for OpenSSL in the first Accordingly, the GNSS-SDR building system now looks for OpenSSL in the first
place and, if not found, then it looks for GnuTLS as a fallback. place and, if not found, then it looks for GnuTLS as a fallback.
- Allow linking against Boost 1.87.0.
### Reliability ### Reliability

View File

@ -144,6 +144,21 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
endif() endif()
endif() endif()
# Fixes for Boost Asio > 1.86. address::from_string was deprecated in Boost 1.71
if(Boost_VERSION_STRING VERSION_LESS 1.71.0)
target_compile_definitions(pvt_libs
PRIVATE
-DBOOST_ASIO_USE_FROM_STRING=1
)
# resolver::iterator retired in Boost 1.87.0, alternative available since 1.71
# boost::asio::io_context::post deprecated in 1.84 in favor of boost::asio::post
target_compile_definitions(pvt_libs
PUBLIC
-DBOOST_ASIO_USE_RESOLVER_ITERATOR=1
-DBOOST_ASIO_USE_IOCONTEXT_POST=1
)
endif()
set_property(TARGET pvt_libs APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES set_property(TARGET pvt_libs APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
) )

View File

@ -28,7 +28,11 @@ Monitor_Ephemeris_Udp_Sink::Monitor_Ephemeris_Udp_Sink(const std::vector<std::st
{ {
for (const auto& address : addresses) for (const auto& address : addresses)
{ {
#if BOOST_ASIO_USE_FROM_STRING
boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string(address, error), port); boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string(address, error), port);
#else
boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::make_address(address, error), port);
#endif
endpoints.push_back(endpoint); endpoints.push_back(endpoint);
} }
if (use_protobuf) if (use_protobuf)

View File

@ -32,7 +32,11 @@ Monitor_Pvt_Udp_Sink::Monitor_Pvt_Udp_Sink(
{ {
for (const auto& port : ports) for (const auto& port : ports)
{ {
#if BOOST_ASIO_USE_FROM_STRING
boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string(address, error), boost::lexical_cast<int>(port)); boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string(address, error), boost::lexical_cast<int>(port));
#else
boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::make_address(address, error), boost::lexical_cast<int>(port));
#endif
endpoints.push_back(endpoint); endpoints.push_back(endpoint);
} }
} }

View File

@ -801,21 +801,38 @@ private:
{ {
public: public:
Tcp_Internal_Client(b_io_context& io_context, Tcp_Internal_Client(b_io_context& io_context,
#if BOOST_ASIO_USE_RESOLVER_ITERATOR
boost::asio::ip::tcp::resolver::iterator endpoint_iterator) boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
: io_context_(io_context), socket_(io_context) : io_context_(io_context), socket_(io_context)
{ {
do_connect(std::move(endpoint_iterator)); do_connect(std::move(endpoint_iterator));
} }
#else
boost::asio::ip::tcp::resolver::results_type endpoints)
: io_context_(io_context), socket_(io_context)
{
do_connect(std::move(endpoints));
}
#endif
inline void close() inline void close()
{ {
#if BOOST_ASIO_USE_IOCONTEXT_POST
io_context_.post([this]() { socket_.close(); }); io_context_.post([this]() { socket_.close(); });
#else
boost::asio::post(io_context_, [this]() { socket_.close(); });
#endif
} }
inline void write(const Rtcm_Message& msg) inline void write(const Rtcm_Message& msg)
{ {
#if BOOST_ASIO_USE_IOCONTEXT_POST
io_context_.post( io_context_.post(
[this, &msg]() { [this, &msg]() {
#else
boost::asio::post(io_context_,
[this, msg]() {
#endif
bool write_in_progress = !write_msgs_.empty(); bool write_in_progress = !write_msgs_.empty();
write_msgs_.push_back(msg); write_msgs_.push_back(msg);
if (!write_in_progress) if (!write_in_progress)
@ -826,10 +843,17 @@ private:
} }
private: private:
#if BOOST_ASIO_USE_RESOLVER_ITERATOR
inline void do_connect(boost::asio::ip::tcp::resolver::iterator endpoint_iterator) inline void do_connect(boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
{ {
boost::asio::async_connect(socket_, std::move(endpoint_iterator), boost::asio::async_connect(socket_, std::move(endpoint_iterator),
[this](boost::system::error_code ec, boost::asio::ip::tcp::resolver::iterator) { [this](boost::system::error_code ec, boost::asio::ip::tcp::resolver::iterator) {
#else
inline void do_connect(boost::asio::ip::tcp::resolver::results_type endpoints)
{
boost::asio::async_connect(socket_, std::move(endpoints),
[this](boost::system::error_code ec, boost::asio::ip::tcp::endpoint) {
#endif
if (!ec) if (!ec)
{ {
do_read_message(); do_read_message();
@ -893,8 +917,13 @@ private:
boost::asio::ip::tcp::resolver resolver(io_context); boost::asio::ip::tcp::resolver resolver(io_context);
std::string host("localhost"); std::string host("localhost");
std::string port_str = std::to_string(port); std::string port_str = std::to_string(port);
#if BOOST_ASIO_USE_RESOLVER_ITERATOR
auto queue_endpoint_iterator = resolver.resolve({host.c_str(), port_str.c_str()}); auto queue_endpoint_iterator = resolver.resolve({host.c_str(), port_str.c_str()});
c = std::make_shared<Tcp_Internal_Client>(io_context, queue_endpoint_iterator); c = std::make_shared<Tcp_Internal_Client>(io_context, queue_endpoint_iterator);
#else
auto endpoints = resolver.resolve(host, port_str);
c = std::make_shared<Tcp_Internal_Client>(io_context, endpoints);
#endif
} }
inline void do_read_queue() inline void do_read_queue()

View File

@ -132,6 +132,14 @@ if(USE_BOOST_BIND_PLACEHOLDERS)
) )
endif() endif()
# Fix for Boost Asio > 1.86. address::from_string was deprecated in Boost 1.71
if(Boost_VERSION_STRING VERSION_LESS 1.71.0)
target_compile_definitions(signal_source_gr_blocks
PRIVATE
-DBOOST_ASIO_USE_FROM_STRING=1
)
endif()
if(USE_GENERIC_LAMBDAS) if(USE_GENERIC_LAMBDAS)
set(has_generic_lambdas HAS_GENERIC_LAMBDA=1) set(has_generic_lambdas HAS_GENERIC_LAMBDA=1)
set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0) set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0)

View File

@ -68,9 +68,11 @@ rtl_tcp_signal_source_c::rtl_tcp_signal_source_c(const std::string &address,
{ {
lookup_[i] = (static_cast<float>(i & 0xff) - 127.4F) * (1.0F / 128.0F); lookup_[i] = (static_cast<float>(i & 0xff) - 127.4F) * (1.0F / 128.0F);
} }
#if BOOST_ASIO_USE_FROM_STRING
// 2. Set socket options
ip::address addr = ip::address::from_string(address, ec); ip::address addr = ip::address::from_string(address, ec);
#else
ip::address addr = ip::make_address(address, ec);
#endif
if (ec) if (ec)
{ {
std::cout << address << " is not an IP address\n"; std::cout << address << " is not an IP address\n";
@ -78,6 +80,8 @@ rtl_tcp_signal_source_c::rtl_tcp_signal_source_c(const std::string &address,
return; return;
} }
ip::tcp::endpoint ep(addr, port); ip::tcp::endpoint ep(addr, port);
// 2. Set socket options
socket_.open(ep.protocol(), ec); // NOLINT(bugprone-unused-return-value) socket_.open(ep.protocol(), ec); // NOLINT(bugprone-unused-return-value)
if (ec) if (ec)
{ {

View File

@ -170,6 +170,14 @@ if(PMT_USES_BOOST_ANY)
) )
endif() endif()
# Fix for Boost Asio > 1.86. address::from_string was deprecated in Boost 1.71
if(Boost_VERSION_STRING VERSION_LESS 1.71.0)
target_compile_definitions(core_libs
PRIVATE
-DBOOST_ASIO_USE_FROM_STRING=1
)
endif()
# Do not apply clang-tidy fixes to protobuf generated headers # Do not apply clang-tidy fixes to protobuf generated headers
get_filename_component(PROTO_INCLUDE_HEADERS_DIR ${PROTO_HDRS} DIRECTORY) get_filename_component(PROTO_INCLUDE_HEADERS_DIR ${PROTO_HDRS} DIRECTORY)
target_include_directories(core_libs target_include_directories(core_libs

View File

@ -30,7 +30,11 @@ Nav_Message_Udp_Sink::Nav_Message_Udp_Sink(const std::vector<std::string>& addre
{ {
for (const auto& address : addresses) for (const auto& address : addresses)
{ {
#if BOOST_ASIO_USE_FROM_STRING
boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string(address, error), port); boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string(address, error), port);
#else
boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::make_address(address, error), port);
#endif
endpoints.push_back(endpoint); endpoints.push_back(endpoint);
} }
serdes_nav = Serdes_Nav_Message(); serdes_nav = Serdes_Nav_Message();

View File

@ -97,6 +97,14 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
endif() endif()
endif() endif()
# Fix for Boost Asio > 1.86. address::from_string was deprecated in Boost 1.71
if(Boost_VERSION_STRING VERSION_LESS 1.71.0)
target_compile_definitions(core_monitor
PRIVATE
-DBOOST_ASIO_USE_FROM_STRING=1
)
endif()
set_property(TARGET core_monitor set_property(TARGET core_monitor
APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>

View File

@ -38,7 +38,11 @@ Gnss_Synchro_Udp_Sink::Gnss_Synchro_Udp_Sink(
for (const auto& port : ports) for (const auto& port : ports)
{ {
boost::asio::ip::udp::endpoint endpoint( boost::asio::ip::udp::endpoint endpoint(
#if BOOST_ASIO_USE_FROM_STRING
boost::asio::ip::address::from_string(address, error), boost::asio::ip::address::from_string(address, error),
#else
boost::asio::ip::make_address(address, error),
#endif
boost::lexical_cast<int>(port)); boost::lexical_cast<int>(port));
endpoints.push_back(endpoint); endpoints.push_back(endpoint);
} }