Skip to content

Commit acdc6e9

Browse files
Cmake conan (#521)
* boost coroutine substituted with minicoro. 3rd party updates * cmake refactoring + conan * fix cmake * fix build with conan and change CI
1 parent 73a2b95 commit acdc6e9

27 files changed

+6798
-429
lines changed

.github/workflows/cmake_ubuntu.yml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,37 @@ jobs:
1919

2020
steps:
2121
- uses: actions/checkout@v2
22-
23-
- name: Install Dependencies (Linux)
24-
run: sudo apt-get install libboost-dev libzmq3-dev
22+
23+
- name: Install Conan
24+
id: conan
25+
uses: turtlebrowser/get-conan@main
26+
with:
27+
version: 1.59.0
28+
29+
- name: Create default profile
30+
run: conan profile new default --detect
31+
32+
- name: Update profile
33+
run: conan profile update settings.compiler.libcxx=libstdc++11 default
2534

2635
- name: Create Build Environment
2736
# Some projects don't allow in-source building, so create a separate build directory
2837
# We'll use this as our working directory for all subsequent commands
2938
run: cmake -E make_directory ${{github.workspace}}/build
3039

40+
- name: Install conan dependencies
41+
working-directory: ${{github.workspace}}/build
42+
run: conan install ${{github.workspace}}/conanfile.txt -s build_type=${{env.BUILD_TYPE}} --build=missing
43+
3144
- name: Configure CMake
32-
# Use a bash shell so we can use the same syntax for environment variable
33-
# access regardless of the host operating system
3445
shell: bash
3546
working-directory: ${{github.workspace}}/build
36-
# Note the current convention is to use the -S and -B options here to specify source
37-
# and build directories, but this is only available with CMake 3.13 and higher.
38-
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
39-
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
47+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
4048

4149
- name: Build
42-
working-directory: ${{github.workspace}}/build
4350
shell: bash
44-
# Execute the build. You can specify a specific target with "--target <NAME>"
45-
run: cmake --build . --config $BUILD_TYPE
51+
working-directory: ${{github.workspace}}/build
52+
run: cmake --build . --config ${{env.BUILD_TYPE}}
4653

4754
- name: run test (Linux)
4855
working-directory: ${{github.workspace}}/build

.github/workflows/cmake_windows.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,34 @@ jobs:
1919

2020
steps:
2121
- uses: actions/checkout@v2
22+
23+
- name: Install Conan
24+
id: conan
25+
uses: turtlebrowser/get-conan@main
26+
with:
27+
version: 1.59.0
28+
29+
- name: Create default profile
30+
run: conan profile new default --detect
2231

2332
- name: Create Build Environment
2433
# Some projects don't allow in-source building, so create a separate build directory
2534
# We'll use this as our working directory for all subsequent commands
2635
run: cmake -E make_directory ${{github.workspace}}/build
2736

37+
- name: Install conan dependencies
38+
working-directory: ${{github.workspace}}/build
39+
run: conan install ${{github.workspace}}/conanfile.txt -s build_type=${{env.BUILD_TYPE}} --build=missing
40+
2841
- name: Configure CMake
29-
# Use a bash shell so we can use the same syntax for environment variable
30-
# access regardless of the host operating system
3142
shell: bash
3243
working-directory: ${{github.workspace}}/build
33-
# Note the current convention is to use the -S and -B options here to specify source
34-
# and build directories, but this is only available with CMake 3.13 and higher.
35-
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
36-
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
44+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
3745

3846
- name: Build
3947
working-directory: ${{github.workspace}}/build
4048
shell: bash
41-
# Execute the build. You can specify a specific target with "--target <NAME>"
42-
run: cmake --build . --config $BUILD_TYPE
49+
run: cmake --build . --config ${{env.BUILD_TYPE}}
4350

4451
- name: run test (Windows)
4552
working-directory: ${{github.workspace}}/build

3rdparty/cppzmq/zmq.hpp

Lines changed: 78 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
#define ZMQ_DEPRECATED(msg) __declspec(deprecated(msg))
6868
#elif defined(__GNUC__)
6969
#define ZMQ_DEPRECATED(msg) __attribute__((deprecated(msg)))
70+
#else
71+
#define ZMQ_DEPRECATED(msg)
7072
#endif
7173

7274
#if defined(ZMQ_CPP17)
@@ -92,7 +94,7 @@
9294
#define ZMQ_CONSTEXPR_VAR const
9395
#define ZMQ_CPP11_DEPRECATED(msg)
9496
#endif
95-
#if defined(ZMQ_CPP14) && (!defined(_MSC_VER) || _MSC_VER > 1900)
97+
#if defined(ZMQ_CPP14) && (!defined(_MSC_VER) || _MSC_VER > 1900) && (!defined(__GNUC__) || __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 3))
9698
#define ZMQ_EXTENDED_CONSTEXPR
9799
#endif
98100
#if defined(ZMQ_CPP17)
@@ -145,7 +147,7 @@
145147

146148
/* Version macros for compile-time API version detection */
147149
#define CPPZMQ_VERSION_MAJOR 4
148-
#define CPPZMQ_VERSION_MINOR 8
150+
#define CPPZMQ_VERSION_MINOR 9
149151
#define CPPZMQ_VERSION_PATCH 0
150152

151153
#define CPPZMQ_VERSION \
@@ -299,66 +301,78 @@ class error_t : public std::exception
299301
int errnum;
300302
};
301303

302-
inline int poll(zmq_pollitem_t *items_, size_t nitems_, long timeout_ = -1)
304+
namespace detail {
305+
inline int poll(zmq_pollitem_t *items_, size_t nitems_, long timeout_)
303306
{
304307
int rc = zmq_poll(items_, static_cast<int>(nitems_), timeout_);
305308
if (rc < 0)
306309
throw error_t();
307310
return rc;
308311
}
312+
}
313+
314+
#ifdef ZMQ_CPP11
315+
ZMQ_DEPRECATED("from 4.8.0, use poll taking std::chrono::duration instead of long")
316+
inline int poll(zmq_pollitem_t *items_, size_t nitems_, long timeout_)
317+
#else
318+
inline int poll(zmq_pollitem_t *items_, size_t nitems_, long timeout_ = -1)
319+
#endif
320+
{
321+
return detail::poll(items_, nitems_, timeout_);
322+
}
309323

310324
ZMQ_DEPRECATED("from 4.3.1, use poll taking non-const items")
311325
inline int poll(zmq_pollitem_t const *items_, size_t nitems_, long timeout_ = -1)
312326
{
313-
return poll(const_cast<zmq_pollitem_t *>(items_), nitems_, timeout_);
327+
return detail::poll(const_cast<zmq_pollitem_t *>(items_), nitems_, timeout_);
314328
}
315329

316330
#ifdef ZMQ_CPP11
317331
ZMQ_DEPRECATED("from 4.3.1, use poll taking non-const items")
318332
inline int
319333
poll(zmq_pollitem_t const *items, size_t nitems, std::chrono::milliseconds timeout)
320334
{
321-
return poll(const_cast<zmq_pollitem_t *>(items), nitems,
335+
return detail::poll(const_cast<zmq_pollitem_t *>(items), nitems,
322336
static_cast<long>(timeout.count()));
323337
}
324338

325339
ZMQ_DEPRECATED("from 4.3.1, use poll taking non-const items")
326340
inline int poll(std::vector<zmq_pollitem_t> const &items,
327341
std::chrono::milliseconds timeout)
328342
{
329-
return poll(const_cast<zmq_pollitem_t *>(items.data()), items.size(),
343+
return detail::poll(const_cast<zmq_pollitem_t *>(items.data()), items.size(),
330344
static_cast<long>(timeout.count()));
331345
}
332346

333347
ZMQ_DEPRECATED("from 4.3.1, use poll taking non-const items")
334348
inline int poll(std::vector<zmq_pollitem_t> const &items, long timeout_ = -1)
335349
{
336-
return poll(const_cast<zmq_pollitem_t *>(items.data()), items.size(), timeout_);
350+
return detail::poll(const_cast<zmq_pollitem_t *>(items.data()), items.size(), timeout_);
337351
}
338352

339353
inline int
340-
poll(zmq_pollitem_t *items, size_t nitems, std::chrono::milliseconds timeout)
354+
poll(zmq_pollitem_t *items, size_t nitems, std::chrono::milliseconds timeout = std::chrono::milliseconds{-1})
341355
{
342-
return poll(items, nitems, static_cast<long>(timeout.count()));
356+
return detail::poll(items, nitems, static_cast<long>(timeout.count()));
343357
}
344358

345359
inline int poll(std::vector<zmq_pollitem_t> &items,
346-
std::chrono::milliseconds timeout)
360+
std::chrono::milliseconds timeout = std::chrono::milliseconds{-1})
347361
{
348-
return poll(items.data(), items.size(), static_cast<long>(timeout.count()));
362+
return detail::poll(items.data(), items.size(), static_cast<long>(timeout.count()));
349363
}
350364

351-
ZMQ_DEPRECATED("from 4.3.1, use poll taking std::chrono instead of long")
352-
inline int poll(std::vector<zmq_pollitem_t> &items, long timeout_ = -1)
365+
ZMQ_DEPRECATED("from 4.3.1, use poll taking std::chrono::duration instead of long")
366+
inline int poll(std::vector<zmq_pollitem_t> &items, long timeout_)
353367
{
354-
return poll(items.data(), items.size(), timeout_);
368+
return detail::poll(items.data(), items.size(), timeout_);
355369
}
356370

357371
template<std::size_t SIZE>
358372
inline int poll(std::array<zmq_pollitem_t, SIZE> &items,
359-
std::chrono::milliseconds timeout)
373+
std::chrono::milliseconds timeout = std::chrono::milliseconds{-1})
360374
{
361-
return poll(items.data(), items.size(), static_cast<long>(timeout.count()));
375+
return detail::poll(items.data(), items.size(), static_cast<long>(timeout.count()));
362376
}
363377
#endif
364378

@@ -851,7 +865,7 @@ class context_t
851865

852866
int rc;
853867
do {
854-
rc = zmq_ctx_destroy(ptr);
868+
rc = zmq_ctx_term(ptr);
855869
} while (rc == -1 && errno == EINTR);
856870

857871
ZMQ_ASSERT(rc == 0);
@@ -1362,6 +1376,39 @@ constexpr const_buffer operator"" _zbuf(const char32_t *str, size_t len) noexcep
13621376
}
13631377
}
13641378

1379+
#ifdef ZMQ_CPP11
1380+
enum class socket_type : int
1381+
{
1382+
req = ZMQ_REQ,
1383+
rep = ZMQ_REP,
1384+
dealer = ZMQ_DEALER,
1385+
router = ZMQ_ROUTER,
1386+
pub = ZMQ_PUB,
1387+
sub = ZMQ_SUB,
1388+
xpub = ZMQ_XPUB,
1389+
xsub = ZMQ_XSUB,
1390+
push = ZMQ_PUSH,
1391+
pull = ZMQ_PULL,
1392+
#if defined(ZMQ_BUILD_DRAFT_API) && ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 2, 0)
1393+
server = ZMQ_SERVER,
1394+
client = ZMQ_CLIENT,
1395+
radio = ZMQ_RADIO,
1396+
dish = ZMQ_DISH,
1397+
gather = ZMQ_GATHER,
1398+
scatter = ZMQ_SCATTER,
1399+
dgram = ZMQ_DGRAM,
1400+
#endif
1401+
#if defined(ZMQ_BUILD_DRAFT_API) && ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 3, 3)
1402+
peer = ZMQ_PEER,
1403+
channel = ZMQ_CHANNEL,
1404+
#endif
1405+
#if ZMQ_VERSION_MAJOR >= 4
1406+
stream = ZMQ_STREAM,
1407+
#endif
1408+
pair = ZMQ_PAIR
1409+
};
1410+
#endif
1411+
13651412
namespace sockopt
13661413
{
13671414
// There are two types of options,
@@ -1503,6 +1550,9 @@ ZMQ_DEFINE_INTEGRAL_BOOL_UNIT_OPT(ZMQ_MULTICAST_LOOP, multicast_loop, int);
15031550
#ifdef ZMQ_MULTICAST_MAXTPDU
15041551
ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_MULTICAST_MAXTPDU, multicast_maxtpdu, int);
15051552
#endif
1553+
#ifdef ZMQ_ONLY_FIRST_SUBSCRIBE
1554+
ZMQ_DEFINE_INTEGRAL_BOOL_UNIT_OPT(ZMQ_ONLY_FIRST_SUBSCRIBE, only_first_subscribe, int);
1555+
#endif
15061556
#ifdef ZMQ_PLAIN_SERVER
15071557
ZMQ_DEFINE_INTEGRAL_BOOL_UNIT_OPT(ZMQ_PLAIN_SERVER, plain_server, int);
15081558
#endif
@@ -1601,7 +1651,10 @@ ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_TOS, tos, int);
16011651
#endif
16021652
#ifdef ZMQ_TYPE
16031653
ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_TYPE, type, int);
1604-
#endif
1654+
#ifdef ZMQ_CPP11
1655+
ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_TYPE, socket_type, socket_type);
1656+
#endif // ZMQ_CPP11
1657+
#endif // ZMQ_TYPE
16051658
#ifdef ZMQ_UNSUBSCRIBE
16061659
ZMQ_DEFINE_ARRAY_OPT(ZMQ_UNSUBSCRIBE, unsubscribe);
16071660
#endif
@@ -1743,7 +1796,7 @@ class socket_base
17431796
template<int Opt, class T, bool BoolUnit>
17441797
ZMQ_NODISCARD T get(sockopt::integral_option<Opt, T, BoolUnit>) const
17451798
{
1746-
static_assert(std::is_integral<T>::value, "T must be integral");
1799+
static_assert(std::is_scalar<T>::value, "T must be scalar");
17471800
T val;
17481801
size_t size = sizeof val;
17491802
get_option(Opt, &val, &size);
@@ -2012,32 +2065,6 @@ class socket_base
20122065
};
20132066
} // namespace detail
20142067

2015-
#ifdef ZMQ_CPP11
2016-
enum class socket_type : int
2017-
{
2018-
req = ZMQ_REQ,
2019-
rep = ZMQ_REP,
2020-
dealer = ZMQ_DEALER,
2021-
router = ZMQ_ROUTER,
2022-
pub = ZMQ_PUB,
2023-
sub = ZMQ_SUB,
2024-
xpub = ZMQ_XPUB,
2025-
xsub = ZMQ_XSUB,
2026-
push = ZMQ_PUSH,
2027-
pull = ZMQ_PULL,
2028-
#if defined(ZMQ_BUILD_DRAFT_API) && ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 2, 0)
2029-
server = ZMQ_SERVER,
2030-
client = ZMQ_CLIENT,
2031-
radio = ZMQ_RADIO,
2032-
dish = ZMQ_DISH,
2033-
#endif
2034-
#if ZMQ_VERSION_MAJOR >= 4
2035-
stream = ZMQ_STREAM,
2036-
#endif
2037-
pair = ZMQ_PAIR
2038-
};
2039-
#endif
2040-
20412068
struct from_handle_t
20422069
{
20432070
struct _private
@@ -2315,7 +2342,11 @@ class monitor_t
23152342
{_monitor_socket.handle(), 0, ZMQ_POLLIN, 0},
23162343
};
23172344

2345+
#ifdef ZMQ_CPP11
2346+
zmq::poll(&items[0], 1, std::chrono::milliseconds(timeout));
2347+
#else
23182348
zmq::poll(&items[0], 1, timeout);
2349+
#endif
23192350

23202351
if (items[0].revents & ZMQ_POLLIN) {
23212352
int rc = zmq_msg_recv(eventMsg.handle(), _monitor_socket.handle(), 0);
@@ -2390,8 +2421,7 @@ class monitor_t
23902421
case ZMQ_EVENT_DISCONNECTED:
23912422
on_event_disconnected(*event, address.c_str());
23922423
break;
2393-
#ifdef ZMQ_BUILD_DRAFT_API
2394-
#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 2, 3)
2424+
#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 3, 0) || (defined(ZMQ_BUILD_DRAFT_API) && ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 2, 3))
23952425
case ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL:
23962426
on_event_handshake_failed_no_detail(*event, address.c_str());
23972427
break;
@@ -2404,14 +2434,13 @@ class monitor_t
24042434
case ZMQ_EVENT_HANDSHAKE_SUCCEEDED:
24052435
on_event_handshake_succeeded(*event, address.c_str());
24062436
break;
2407-
#elif ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 2, 1)
2437+
#elif defined(ZMQ_BUILD_DRAFT_API) && ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 2, 1)
24082438
case ZMQ_EVENT_HANDSHAKE_FAILED:
24092439
on_event_handshake_failed(*event, address.c_str());
24102440
break;
24112441
case ZMQ_EVENT_HANDSHAKE_SUCCEED:
24122442
on_event_handshake_succeed(*event, address.c_str());
24132443
break;
2414-
#endif
24152444
#endif
24162445
default:
24172446
on_event_unknown(*event, address.c_str());
@@ -2685,4 +2714,3 @@ inline std::ostream &operator<<(std::ostream &os, const message_t &msg)
26852714
} // namespace zmq
26862715

26872716
#endif // __ZMQ_HPP_INCLUDED__
2688-

0 commit comments

Comments
 (0)