Skip to content

Commit 819b240

Browse files
authored
Merge pull request #218 from jp-pino/master
Fix for Boost >= 1.87
2 parents 4e8f18b + b8c3340 commit 819b240

30 files changed

+440
-391
lines changed

.github/workflows/cmake-superbuild/CMakeLists.txt

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.0)
1+
cmake_minimum_required(VERSION 3.10)
22
project(azmq-super-build)
33

44
#options
@@ -23,12 +23,18 @@ endif ()
2323

2424
include(ExternalProject)
2525

26-
set(BOOST_177 "https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.bz2")
27-
set(BOOST_176 "https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2")
28-
set(BOOST_174 "https://boostorg.jfrog.io/artifactory/main/release/1.74.0/source/boost_1_74_0.tar.bz2")
29-
set(BOOST_172 "https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2")
30-
set(BOOST_170 "https://boostorg.jfrog.io/artifactory/main/release/1.70.0/source/boost_1_70_0.tar.bz2")
31-
set(BOOST_168 "https://boostorg.jfrog.io/artifactory/main/release/1.68.0/source/boost_1_68_0.tar.bz2")
26+
27+
set(BOOST_189 "https://archives.boost.io/release/1.89.0/source/boost_1_89_0.tar.bz2")
28+
set(BOOST_187 "https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.bz2")
29+
set(BOOST_186 "https://archives.boost.io/release/1.86.0/source/boost_1_86_0.tar.bz2")
30+
set(BOOST_184 "https://archives.boost.io/release/1.84.0/source/boost_1_84_0.tar.bz2")
31+
set(BOOST_181 "https://archives.boost.io/release/1.81.0/source/boost_1_81_0.tar.bz2")
32+
set(BOOST_177 "https://archives.boost.io/release/1.77.0/source/boost_1_77_0.tar.bz2")
33+
set(BOOST_176 "https://archives.boost.io/release/1.76.0/source/boost_1_76_0.tar.bz2")
34+
set(BOOST_174 "https://archives.boost.io/release/1.74.0/source/boost_1_74_0.tar.bz2")
35+
set(BOOST_172 "https://archives.boost.io/release/1.72.0/source/boost_1_72_0.tar.bz2")
36+
set(BOOST_170 "https://archives.boost.io/release/1.70.0/source/boost_1_70_0.tar.bz2")
37+
set(BOOST_168 "https://archives.boost.io/release/1.68.0/source/boost_1_68_0.tar.bz2")
3238

3339
set(DEVROOT ${CMAKE_BINARY_DIR}/devroot)
3440

@@ -76,13 +82,19 @@ if (NOT (BOOST_URL STREQUAL "system"))
7682
INSTALL_DIR ${DEVROOT}
7783
CONFIGURE_COMMAND ./bootstrap.sh --prefix=<INSTALL_DIR>
7884
BUILD_COMMAND ""
79-
INSTALL_COMMAND ./b2 install --prefix=<INSTALL_DIR> -j${CPU_COUNT})
85+
INSTALL_COMMAND ./b2 install --prefix=<INSTALL_DIR> -j${CPU_COUNT} --warnings-as-errors=off --without-python --without-math)
8086
list(APPEND LIBS boost)
8187
endif ()
8288

89+
cmake_policy(GET CMP0167 _cmp0167_value)
90+
if(_cmp0167_value)
91+
set(_policy_arg "-DCMAKE_POLICY_DEFAULT_CMP0167=${_cmp0167_value}")
92+
message(STATUS " Setting superbuild CMP0167 to ${_cmp0167_value} ")
93+
endif()
94+
8395
ExternalProject_Add(
8496
azmq
8597
DEPENDS ${LIBS}
86-
CMAKE_ARGS ${CMAKE_ARGS} -D AZMQ_BUILD_TESTS=YES
98+
CMAKE_ARGS ${CMAKE_ARGS} -D AZMQ_BUILD_TESTS=YES ${_policy_arg}
8799
SOURCE_DIR ${CMAKE_SOURCE_DIR}/../../..
88100
TEST_BEFORE_INSTALL YES)

.github/workflows/cmake.yml

Lines changed: 96 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,75 +7,126 @@ on:
77
pull_request:
88
branches: [master]
99

10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
1014
jobs:
1115
build:
1216
strategy:
1317
fail-fast: false
1418
matrix:
15-
config:
16-
- {
17-
name: "ubuntu22",
18-
os: ubuntu-22.04,
19-
boost_url: system,
20-
zmq_tag: system,
21-
system_packages: "libboost-all-dev libzmq3-dev ",
22-
cc: "gcc",
23-
cxx: "g++",
24-
}
25-
- {
26-
name: "ubuntu20 stock",
27-
os: ubuntu-20.04,
28-
boost_url: system,
29-
zmq_tag: system,
30-
system_packages: "libboost-all-dev libzmq3-dev ",
31-
cc: "gcc",
32-
cxx: "g++",
33-
}
34-
- {
35-
name: "macos12 ",
36-
os: macos-12,
37-
boost_url: system,
38-
zmq_tag: system,
39-
system_packages: "zmq boost",
40-
cc: "clang",
41-
cxx: "clang++",
42-
}
43-
- {
44-
name: "macos11 ",
45-
os: macos-11,
46-
boost_url: system,
47-
zmq_tag: system,
48-
system_packages: "zmq boost",
49-
cc: "clang",
50-
cxx: "clang++",
51-
}
19+
config:
20+
- os: ubuntu-24.04
21+
family: ubuntu
22+
cc: gcc
23+
cxx: g++
24+
- os: ubuntu-22.04
25+
family: ubuntu
26+
cc: gcc
27+
cxx: g++
28+
- os: macos-26
29+
family: macos
30+
cc: clang
31+
cxx: clang++
32+
- os: macos-15
33+
family: macos
34+
cc: clang
35+
cxx: clang++
36+
- os: macos-14
37+
family: macos
38+
cc: clang
39+
cxx: clang++
40+
- os: macos-13
41+
family: macos
42+
cc: clang
43+
cxx: clang++
44+
boost:
45+
- url: system
46+
system_packages_ubuntu: libboost-all-dev
47+
system_packages_macos: boost
48+
extra_cmake_args: -DCMAKE_POLICY_DEFAULT_CMP0167=NEW
49+
- url: BOOST_189
50+
system_packages_ubuntu:
51+
system_packages_macos:
52+
extra_cmake_args: -DCMAKE_POLICY_DEFAULT_CMP0167=NEW
53+
- url: BOOST_187
54+
system_packages_ubuntu:
55+
system_packages_macos:
56+
extra_cmake_args: -DCMAKE_POLICY_DEFAULT_CMP0167=NEW
57+
- url: BOOST_184
58+
system_packages_ubuntu:
59+
system_packages_macos:
60+
extra_cmake_args: -DCMAKE_POLICY_DEFAULT_CMP0167=NEW
61+
- url: BOOST_181
62+
system_packages_ubuntu:
63+
system_packages_macos:
64+
extra_cmake_args: -DCMAKE_POLICY_DEFAULT_CMP0167=NEW
65+
- url: BOOST_176
66+
system_packages_ubuntu:
67+
system_packages_macos:
68+
extra_cmake_args: -DCMAKE_POLICY_DEFAULT_CMP0167=NEW
69+
- url: BOOST_174
70+
system_packages_ubuntu:
71+
system_packages_macos:
72+
extra_cmake_args: -DCMAKE_POLICY_DEFAULT_CMP0167=NEW
73+
- url: BOOST_168
74+
system_packages_ubuntu:
75+
system_packages_macos:
76+
extra_cmake_args: -DCMAKE_POLICY_DEFAULT_CMP0167=OLD
77+
zmq:
78+
- tag: system
79+
system_packages_ubuntu: libzmq3-dev
80+
system_packages_macos: zmq
81+
exclude:
82+
- config:
83+
family: macos
84+
boost:
85+
url: BOOST_176
86+
- config:
87+
family: macos
88+
boost:
89+
url: BOOST_174
90+
- config:
91+
family: macos
92+
boost:
93+
url: BOOST_168
94+
- config:
95+
os: macos-14
96+
boost:
97+
url: BOOST_181
5298

5399
runs-on: ${{ matrix.config.os }}
54100

55101
env:
56102
CC: ${{ matrix.config.cc }}
57103
CXX: ${{ matrix.config.cxx }}
58104
CTEST_OUTPUT_ON_FAILURE: 1
59-
PACKAGES: ${{ matrix.config.system_packages }}
105+
PACKAGES_UBUNTU: ${{ matrix.boost.system_packages_ubuntu }} ${{ matrix.zmq.system_packages_ubuntu }}
106+
PACKAGES_MACOS: ${{ matrix.boost.system_packages_macos }} ${{ matrix.zmq.system_packages_macos }}
107+
CONFIG_OS: ${{ matrix.config.os }}
108+
MATRIX: ${{ toJson(matrix) }}
60109

61110
steps:
62111
- uses: actions/checkout@v3
63112
- name: buildtools on ubuntu
64-
if: startsWith(matrix.config.name, 'ubuntu')
113+
if: ${{ startsWith(matrix.config.os, 'ubuntu') }}
65114
shell: bash
66115
run: |
67-
if [ -n "$PACKAGES" ]; then
68-
sudo apt-get install -y $PACKAGES
116+
PACKAGES_UBUNTU=$(echo $PACKAGES_UBUNTU | sed 's/^[ ]*//;s/[ ]*$//')
117+
if [ -n "$PACKAGES_UBUNTU" ]; then
118+
sudo apt-get update && sudo apt-get install -y $PACKAGES_UBUNTU
69119
fi
70120
- name: buildtools on macos
71-
if: startsWith(matrix.config.name, 'macos') && matrix.config.*.system_packages
121+
if: ${{ startsWith(matrix.config.os, 'macos') }}
72122
shell: bash
73123
run: |
74-
if [ -n "$PACKAGES" ]; then
75-
brew install $PACKAGES
124+
PACKAGES_MACOS=$(echo $PACKAGES_MACOS | sed 's/^[ ]*//;s/[ ]*$//')
125+
if [ -n "$PACKAGES_MACOS" ]; then
126+
brew install $PACKAGES_MACOS
76127
fi
77128
- name: build
78129
shell: bash
79130
run: |
80-
cmake -DBOOST_URL=${{matrix.config.boost_url}} -DZMQ_TAG=${{matrix.config.zmq_tag}} -S .github/workflows/cmake-superbuild -B build
131+
cmake -DBOOST_URL=${{matrix.boost.url}} -DZMQ_TAG=${{matrix.zmq.tag}} ${{matrix.boost.extra_cmake_args}} -S .github/workflows/cmake-superbuild -B build
81132
cmake --build build

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@
1313
*.a
1414
*.pyc
1515
build/*
16+
build_*/*
17+
18+
# Other files
19+
.devcontainer
20+
.vscode
21+
.DS_Store

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Thomas W Rodgers <rodgert@twrodgers.com>
66
Andrey Upadyshev <oliora@gmail.com>
77
Tim Blechmann <tim@klingt.org>
88
Adam Boseley <adam.boseley@gmail.com>
9+
Juan Pablo Pino <jp.pinob@gmail.com>

AzmqCPack.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ in general, and Asio in particular.
88
99
The main abstraction exposed by the library is azmq::socket which
1010
provides an Asio style socket interface to the underlying zeromq socket
11-
and interfaces with Asio's io_service(). The socket implementation
12-
participates in the io_service's reactor for asynchronous IO and
11+
and interfaces with Asio's io_context(). The socket implementation
12+
participates in the io_context's reactor for asynchronous IO and
1313
may be freely mixed with other Asio socket types (raw TCP/UDP/Serial/etc.).")
1414
set(CPACK_PACKAGE_VERSION "1.1.0")
1515

CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
cmake_minimum_required(VERSION 3.16.3...3.25)
2-
# -- v3.16.3 is the default version in the current ubuntu lts release
1+
cmake_minimum_required(VERSION 3.22.1...3.29.2)
2+
# -- v3.22.1 is the default version in the current ubuntu lts release
33

44
project(azmq VERSION 1.1.0 LANGUAGES CXX)
55

@@ -21,13 +21,18 @@ set(CMAKE_CXX_EXTENSIONS OFF)
2121
# --- dependencies --
2222
find_package(
2323
Boost 1.68
24-
COMPONENTS system
25-
date_time
24+
COMPONENTS date_time
2625
thread
2726
chrono
2827
random
2928
REQUIRED)
3029

30+
# Try to find Boost::system
31+
find_package(Boost COMPONENTS system)
32+
if (NOT Boost_SYSTEM_FOUND)
33+
message(WARNING "Boost::system not found, some examples may not compile")
34+
endif()
35+
3136
include(FindAzmqLibzmq.cmake)
3237

3338
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
@@ -37,7 +42,7 @@ find_package(Threads REQUIRED)
3742
add_library(${PROJECT_NAME} INTERFACE)
3843
add_library(Azmq::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
3944

40-
target_link_libraries(${PROJECT_NAME} INTERFACE Azmq::libzmq Boost::boost ${CMAKE_THREAD_LIBS_INIT})
45+
target_link_libraries(${PROJECT_NAME} INTERFACE Azmq::libzmq Boost::boost ${Boost_SYSTEM_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
4146
target_include_directories(${PROJECT_NAME} INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
4247
"$<INSTALL_INTERFACE:include>")
4348

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ in general, and Asio in particular.
99

1010
The main abstraction exposed by the library is azmq::socket which
1111
provides an Asio style socket interface to the underlying zeromq socket
12-
and interfaces with Asio's io_service(). The socket implementation
13-
participates in the io_service's reactor for asynchronous IO and
12+
and interfaces with Asio's io_context(). The socket implementation
13+
participates in the io_context's reactor for asynchronous IO and
1414
may be freely mixed with other Asio socket types (raw TCP/UDP/Serial/etc.).
1515

1616
## Building and installation
@@ -29,7 +29,7 @@ which supports C++11. Currently this has been tested with -
2929
* Microsoft Visual Studio 2013 on Windows Server 2008 R2
3030

3131
Library dependencies are -
32-
* Boost 1.48 or later
32+
* Boost 1.68 or later
3333
* ZeroMQ 4.0.x
3434

3535
Tests and example code require -
@@ -82,13 +82,13 @@ http://zeromq.org/intro:read-the-manual
8282
namespace asio = boost::asio;
8383

8484
int main(int argc, char** argv) {
85-
asio::io_service ios;
86-
azmq::sub_socket subscriber(ios);
85+
asio::io_context ioc;
86+
azmq::sub_socket subscriber(ioc);
8787
subscriber.connect("tcp://192.168.55.112:5556");
8888
subscriber.connect("tcp://192.168.55.201:7721");
8989
subscriber.set_option(azmq::socket::subscribe("NASDAQ"));
9090

91-
azmq::pub_socket publisher(ios);
91+
azmq::pub_socket publisher(ioc);
9292
publisher.bind("ipc://nasdaq-feed");
9393

9494
std::array<char, 256> buf;

azmq/actor.hpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "socket.hpp"
1313
#include "detail/actor_service.hpp"
1414

15-
#include <boost/asio/io_service.hpp>
15+
#include <boost/asio/io_context.hpp>
1616

1717
#include <functional>
1818

@@ -25,7 +25,7 @@ AZMQ_V1_INLINE_NAMESPACE_BEGIN
2525
using last_error = detail::actor_service::last_error;
2626

2727
/** \brief create an actor bound to one end of a pipe (pair of inproc sockets)
28-
* \param peer io_service to associate the peer (caller) end of the pipe
28+
* \param peer io_context to associate the peer (caller) end of the pipe
2929
* \param f Function accepting socket& as the first parameter and a
3030
* number of additional args
3131
* \returns peer socket
@@ -35,15 +35,15 @@ AZMQ_V1_INLINE_NAMESPACE_BEGIN
3535
* will be attached to the lifetime of the returned socket and will run
3636
* until it is destroyed.
3737
*
38-
* \remark Each actor has an associated io_service and the supplied socket
39-
* will be created on this io_service. The actor may access this by calling
40-
* get_io_service() on the supplied socket.
38+
* \remark Each actor has an associated io_context and the supplied socket
39+
* will be created on this io_context. The actor may access this by calling
40+
* get_io_context() on the supplied socket.
4141
*
42-
* \remark The associated io_service is configured to stop the spawned actor
42+
* \remark The associated io_context is configured to stop the spawned actor
4343
* on SIG_KILL and SIG_TERM.
4444
*
4545
* \remark Termination:
46-
* well behaved actors should ultimately call run() on the io_service
46+
* well behaved actors should ultimately call run() on the io_context
4747
* associated with the supplied socket. This allows the 'client' end of
4848
* the socket's lifetime to cleanly signal termination. If for some
4949
* reason, this is not possible, the caller should set the 'detached'
@@ -54,20 +54,20 @@ AZMQ_V1_INLINE_NAMESPACE_BEGIN
5454
* message.
5555
*
5656
* Also note, the default signal handling for the background thread is
57-
* designed to call stop() on the associated io_service, so not calling
57+
* designed to call stop() on the associated io_context, so not calling
5858
* run() in your handler means you are responsible for catching these
5959
* signals in some other way.
6060
*/
6161
template<typename Function, typename... Args>
62-
socket spawn(boost::asio::io_service & peer, bool defer_start, Function && f, Args&&... args) {
62+
socket spawn(boost::asio::io_context & peer, bool defer_start, Function && f, Args&&... args) {
6363
auto& t = boost::asio::use_service<detail::actor_service>(peer);
6464
return t.make_pipe(defer_start, std::bind(std::forward<Function>(f),
6565
std::placeholders::_1,
6666
std::forward<Args>(args)...));
6767
}
6868

6969
template<typename Function, typename... Args>
70-
socket spawn(boost::asio::io_service & peer, Function && f, Args&&... args) {
70+
socket spawn(boost::asio::io_context & peer, Function && f, Args&&... args) {
7171
auto& t = boost::asio::use_service<detail::actor_service>(peer);
7272
return t.make_pipe(false, std::bind(std::forward<Function>(f),
7373
std::placeholders::_1,
@@ -78,4 +78,3 @@ AZMQ_V1_INLINE_NAMESPACE_END
7878
} // namespace actor
7979
} // namespace azmq
8080
#endif // AZMQ_ACTOR_HPP_
81-

0 commit comments

Comments
 (0)