Skip to content

Commit 487bd06

Browse files
committed
Support newer Boost.Asio
Dependencies - Migrated to newer Boost.Asio: Boost 1.74 or above now required. - Removed Boost.Endian dependency. - Migrated test framework to Catch2: version 2.3 or greater now required. - RapidJSON and Msgpack-c dependencies are no longer mandatory if their respective codecs are not needed. - CMake minimum version is now 3.12. - Migrated to newer Doxygen for generating docs (tested with version 1.8.17) CMake - Overhauled CMake build to adopt modern practices. - CMake package config now provided when built and installed. - Separate CMake targets now provided for easy import into another CMake project Breaking API Changes - 'AsioService' now aliases 'boost::asio::io_context' - 'iosvc()' method in 'Event', 'Invocation', and 'Interruption' replaced with 'executor()' method. - Signed/unsigned comparisons of numeric 'Variants' are now performed correctly (in the mathematical sense). - Removed the following deprecated methods: 'Pub::withBlacklist', 'Pub::withWhiteList', 'Rpc::withBlacklist', 'Rpc::withWhitelist', 'Rpc::withExcludeMe' Other API Changes - Added API visibility macros for shared library builds. - 'Session', 'CoroSession', and 'connect(...)' now have overloads that accept boost::asio::any_executor. - Added 'TcpOptions' and 'UdsOptions' which encapsulate socket options. - 'TcpHost' and 'UsdPath' now prefer to take socket options via 'TcpOptions' and 'UdsOptions' respectively in their constructors. - Allow passing 'SO_OOBINLINE' socket option. - 'wamp::ValueTypeOf' now mimics 'std::remove_cvref_t' instead of 'std::decay_t'. Miscellaneous - Removed git submodules in favor of CMake FetchContent. - Removed vestigial Qt Creator and Mercurial stuff. - Fixed json.hpp and msgpack.hpp leaking internals in 'CPPWAMP_COMPILED_LIB' mode. - Removed CPPWAMP_TESTING_FOO macros in favor of Catch2 runtime tags. - WAMP tests now use any available codec. - Made header files self-contained to avoid clangd error messages. - Fixed '-Wall' warnings. - An 'AUTHENTICATE' message with empty signature is now sent to a router if a 'CHALLENGE' message is received and there is no registered challenge handler. This is to prevent deadlocking. - Installation directions are now in README instead of GitHub wiki. - Tutorials are now located in repo instead of GitHub wiki.
1 parent 435a1cf commit 487bd06

File tree

178 files changed

+10254
-7158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+10254
-7158
lines changed

.gitignore

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
ext/
2-
build/
1+
build*/
2+
_*/
3+
CMakeLists.txt.user
4+
CMakeUserPresets.json
35
key.priv
46
key.pub
5-
.hgtags
6-
.hg/
7-
*.pro.user
8-
CMakeLists.txt.user
7+
*.autosave
98
*.vpp~*
109
*.vpp.bak
11-

.gitmodules

Lines changed: 0 additions & 13 deletions
This file was deleted.

.hgignore

Lines changed: 0 additions & 11 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1+
v0.7.0
2+
======
3+
Migrated to newer Boost.Asio, CMake, and Catch.
4+
5+
### Dependencies
6+
7+
- Migrated to newer Boost.Asio: Boost 1.74 or above now required.
8+
- Removed Boost.Endian dependency.
9+
- Migrated test framework to Catch2: version 2.3 or greater now required.
10+
- RapidJSON and Msgpack-c dependencies are no longer mandatory if their respective codecs are not needed.
11+
- CMake minimum version is now 3.12.
12+
- Migrated to newer Doxygen for generating docs (tested with version 1.8.17)
13+
14+
### CMake
15+
16+
- Overhauled CMake build to adopt modern practices.
17+
- CMake package config now provided when built and installed.
18+
- Separate CMake targets now provided for easy import into another CMake project: `CppWAMP::headers`, `CppWAMP::core`, `CppWAMP::json`, `CppWAMP::msgpack`, and `CppWAMP::coro`.
19+
20+
### Breaking API Changes
21+
22+
- `AsioService` now aliases `boost::asio::io_context`
23+
- `iosvc()` method in `Event`, `Invocation`, and `Interruption` replaced with `executor()` method.
24+
- Signed/unsigned comparisons of numeric `Variants` are now performed correctly (in the mathematical sense).
25+
- Removed the following deprecated methods: `Pub::withBlacklist`, `Pub::withWhiteList`, `Rpc::withBlacklist`, `Rpc::withWhitelist`, `Rpc::withExcludeMe`
26+
27+
### Other API Changes
28+
29+
- Added API visibility macros for shared library builds.
30+
- `Session`, `CoroSession`, and `connect(...)` now have overloads that accept boost::asio::any_executor.
31+
- Added `TcpOptions` and `UdsOptions` which encapsulate socket options.
32+
- `TcpHost` and `UsdPath` now prefer to take socket options via `TcpOptions` and `UdsOptions` respectively in their constructors.
33+
- Allow passing `SO_OOBINLINE` socket option.
34+
- `wamp::ValueTypeOf` now mimics `std::remove_cvref_t` instead of `std::decay_t`.
35+
36+
### Miscellaneous
37+
38+
- Removed git submodules in favor of CMake FetchContent.
39+
- Removed vestigial Qt Creator and Mercurial stuff.
40+
- Fixed json.hpp and msgpack.hpp leaking internals in `CPPWAMP_COMPILED_LIB` mode.
41+
- Removed CPPWAMP_TESTING_FOO macros in favor of Catch2 runtime tags.
42+
- WAMP tests now use any available codec.
43+
- Made header files self-contained to avoid clangd error messages.
44+
- Fixed `-Wall` warnings.
45+
- An `AUTHENTICATE` message with empty signature is now sent to a router if a `CHALLENGE` message is received and there is no registered challenge handler. This is to prevent deadlocking.
46+
- Installation directions are now in README instead of GitHub wiki.
47+
- Tutorials are now located in repo instead of GitHub wiki.
48+
149
v0.6.3
250
======
351
Update for latest 3rd-party dependencies.

CMakeLists.txt

Lines changed: 153 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,174 @@
11
#-------------------------------------------------------------------------------
2-
# Copyright Butterfly Energy Systems 2014-2015.
2+
# Copyright Butterfly Energy Systems 2014-2015, 2018, 2022.
33
# Distributed under the Boost Software License, Version 1.0.
44
# (See accompanying file LICENSE_1_0.txt or copy at
55
# http://www.boost.org/LICENSE_1_0.txt)
66
#-------------------------------------------------------------------------------
77

8-
cmake_minimum_required (VERSION 2.8)
9-
project (cppwamp)
10-
11-
# First attempt to find Boost library directories
12-
set(BOOST_MIN_VERSION 1.58.0)
13-
set(BOOST_COMPONENTS coroutine context thread system)
14-
set(BOOST_ROOT ./ext/boost)
15-
find_package(Boost ${BOOST_MIN_VERSION} COMPONENTS ${BOOST_COMPONENTS})
16-
if(Boost_FOUND)
17-
set(SUGGESTED_BOOST_INCLUDE_PATH ${Boost_INCLUDE_DIRS})
18-
set(SUGGESTED_BOOST_LIBRARY_PATH ${Boost_LIBRARY_DIRS})
19-
else()
20-
set(SUGGESTED_BOOST_INCLUDE_PATH ./ext/boost)
21-
set(SUGGESTED_BOOST_LIBRARY_PATH ./ext/boost/stage/lib)
8+
#-------------------------------------------------------------------------------
9+
# This project defines one of more of the following targets, depending
10+
# on the how the CPPWAMP_OPT_X options are set:
11+
#
12+
# Target | Import alias | All | Description
13+
# ----------------------- | ------------------------ | --- | -----------
14+
# cppwamp-core | CppWAMP::core | Yes | Compiled libcppwamp-core library
15+
# cppwamp-core-headers | CppWAMP::core-headers | Yes | Header-only usage requirements
16+
# cppwamp-coro-headers | CppWAMP::coro-headers | Yes | Boost.Coroutine usage requirements
17+
# cppwamp-json | CppWAMP::json | Yes | Compiled libcppwamp-json library for JSON codec support
18+
# cppwmap-json-headers | CppWAMP::json-headers | Yes | Header-only RapidJSON usage requirements
19+
# cppwamp-msgpack | CppWAMP::msgpack | Yes | Compiled libcppwamp-msgpack library for Msgpack codec support
20+
# cppwamp-msgpack-headers | CppWAMP::msgpack-headers | Yes | Header-only Msgpack usage requirements
21+
# cppwamp-doc | <none> | No | Doxygen documentation
22+
# cppwamp-examples | <none> | No | Compiled example programs
23+
# cppwamp-test | <none> | No | Compiled test suite program
24+
#
25+
# 'All' means that the target (if enabled) is built as part of the 'all' target.
26+
# 'Usage requirements' means that the appropriate compiler flags will be set
27+
# if you add the target to target_link_libraries in your CMake project.
28+
#
29+
# This project supports inclusion into another CMake project via either
30+
# add_subdirectory(cppwamp) or find_package(CppWAMP ...).
31+
#-------------------------------------------------------------------------------
32+
33+
34+
# Version 3.11 needed for FetchContent
35+
# Version 3.12 needed for find_path's <PackageName>_ROOT support
36+
# Version 3.12 needed for install(TARGETS ... NAMELINK_COMPONENT ...)
37+
# Version 3.12 needed for $<TARGET_EXISTS:target> generator expression
38+
cmake_minimum_required (VERSION 3.12)
39+
40+
# Include guard in case this project becomes a diamond dependency via multiple
41+
# add_directory(cppwamp) calls.
42+
include_guard()
43+
44+
project(CppWAMP
45+
VERSION 0.7.0
46+
LANGUAGES CXX)
47+
48+
include(ProcessorCount)
49+
ProcessorCount(CPPWAMP_CORE_COUNT)
50+
if(CPPWAMP_CORE_COUNT EQUAL 0)
51+
set(CPPWAMP_CORE_COUNT 1)
2252
endif()
2353

24-
# Add GUI variables that let the user specify where the Boost directories
25-
# are, using the above initial search for default locations.
26-
set(PATH_INCLUDE_BOOST ${SUGGESTED_BOOST_INCLUDE_PATH} CACHE PATH
27-
"Boost include path")
28-
set(PATH_LIB_BOOST ${SUGGESTED_BOOST_LIBRARY_PATH} CACHE PATH
29-
"Boost library path")
30-
31-
# Add GUI variables that let the user specify the include path for other
32-
# third-party libraries.
33-
set(PATH_INCLUDE_RAPIDJSON ${PROJECT_SOURCE_DIR}/ext/rapidjson/include CACHE PATH
34-
"RapidJson include path")
35-
set(PATH_INCLUDE_MSGPACK ${PROJECT_SOURCE_DIR}/ext/msgpack-c/include CACHE PATH
36-
"Msgpack-c include path")
37-
set(PATH_INCLUDE_CATCH ${PROJECT_SOURCE_DIR}/ext/Catch/include CACHE PATH
38-
"Catch include path")
39-
40-
# Confirm that the user's choices for the Boost library paths are valid.
41-
unset(BOOST_ROOT)
42-
set(BOOST_INCLUDEDIR ${PATH_INCLUDE_BOOST})
43-
set(BOOST_LIBRARYDIR ${PATH_LIB_BOOST})
44-
set(Boost_NO_SYSTEM_PATHS ON)
45-
find_package(Boost ${BOOST_MIN_VERSION} COMPONENTS ${BOOST_COMPONENTS})
46-
47-
# Set a default build type if none was specified.
48-
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
54+
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
55+
56+
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}"
57+
isTopLevel)
58+
59+
#----------------------------- User options ------------------------------------
60+
61+
if(NOT isMultiConfig AND NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
4962
message(STATUS "Setting build type to 'Release' as none was specified.")
50-
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
51-
# Set the possible values of build type for cmake-gui
63+
set(CMAKE_BUILD_TYPE Release CACHE STRING "The type of build" FORCE)
5264
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
5365
"MinSizeRel" "RelWithDebInfo")
5466
endif()
5567

56-
# Add the include paths to third-party libraries
57-
include_directories(
58-
${PATH_INCLUDE_BOOST}
59-
${PATH_INCLUDE_RAPIDJSON}
60-
${PATH_INCLUDE_MSGPACK}
61-
)
68+
option(BUILD_SHARED_LIBS
69+
"Determines whether a shared or static library will be built. If already set \
70+
by a superproject, the CPPWAMP_OPT_SHARED_LIBS non-cache variable may be set \
71+
to override the shared/static setting specifically for CppWAMP."
72+
OFF)
6273

63-
# Add the compiler flag for C++11
64-
if(UNIX)
65-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
66-
endif()
74+
option(CPPWAMP_OPT_HEADERS_ONLY
75+
"Don't build libraries/tests/examples and only create targets for \
76+
header-only use."
77+
OFF)
78+
79+
option(CPPWAMP_OPT_VENDORIZE
80+
"Fetches and builds dependencies during configuration. If disabled, the \
81+
dependencies will be searched via find_package. The searching can be \
82+
directed by defining <dependency>_ROOT variables. If the dependent targets are \
83+
already imported by a superproject, find_package calls will be skipped."
84+
OFF)
85+
86+
option(CPPWAMP_OPT_WITH_JSON
87+
"Adds the RapidJSON dependency and builds the cppwamp-json library"
88+
ON)
89+
90+
option(CPPWAMP_OPT_WITH_MSGPACK
91+
"Adds the msgpack-c dependency and builds the cppwamp-msgpack library"
92+
ON)
93+
94+
option(CPPWAMP_OPT_WITH_CORO
95+
"Adds the Boost.Coroutine dependency and build tests and examples \
96+
that depend on it"
97+
ON)
98+
99+
option(CPPWAMP_OPT_WITH_DOCS
100+
"Creates a build target for generating documentation"
101+
${isTopLevel})
102+
103+
option(CPPWAMP_OPT_WITH_TESTS
104+
"Adds the Catch2 dependency and creates a build target for unit tests"
105+
${isTopLevel})
106+
107+
option(CPPWAMP_OPT_WITH_EXAMPLES
108+
"Creates a build target for examples"
109+
${isTopLevel})
110+
111+
option(CPPWAMP_OPT_WITH_PACKAGING
112+
"Generates libary packaging rules"
113+
${isTopLevel})
114+
115+
#--------------------------- Advanced options ----------------------------------
67116

68-
# Add the -pthread compiler flag, if applicable.
69-
# Note that ${Boost_LIBRARIES} already includes a linker flag for -lpthread.
70-
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
71-
find_package(Threads REQUIRED)
72-
if(CMAKE_USE_PTHREADS_INIT)
73-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
117+
set(CPPWAMP_OPT_BOOST_CONFIG "" CACHE FILEPATH
118+
"The user-config file to use when building Boost (optional)")
119+
mark_as_advanced(CPPWAMP_OPT_BOOST_CONFIG)
120+
121+
set(CPPWAMP_OPT_BOOST_JOBS ${CPPWAMP_CORE_COUNT} CACHE STRING
122+
"Number of threads (-j option) to use when building Boost")
123+
mark_as_advanced(CPPWAMP_OPT_BOOST_JOBS)
124+
125+
#------------------------ End of user options ----------------------------------
126+
127+
set(CPPWAMP_PREVIOUSLY_VENDORIZED OFF CACHE INTERNAL "")
128+
129+
if(DEFINED CPPWAMP_OPT_SHARED_LIBS)
130+
set(BUILD_SHARED_LIBS "${CPPWAMP_OPT_SHARED_LIBS}")
74131
endif()
75132

76-
# Add the appropriate preprocessor macro define if the user specified
77-
# non-handshaking transports.
78-
if(CPPWAMP_USE_NON_HANDSHAKING_TRANSPORTS)
79-
add_definitions(-DCPPWAMP_USE_LEGACY_CONNECTORS)
133+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
134+
135+
# Set default export visibility to hidden for all targets
136+
if(NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET AND
137+
NOT DEFINED CMAKE_VISIBILITY_INLINES_HIDDEN)
138+
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
139+
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
80140
endif()
81141

82-
# Disable Boost.Coroutine deprecation warning
83-
add_definitions(-DBOOST_COROUTINE_NO_DEPRECATION_WARNING)
84-
add_definitions(-DBOOST_COROUTINES_NO_DEPRECATION_WARNING)
142+
# Fetch or find dependencies
143+
include(CppWAMPDependencies)
144+
cppwamp_resolve_dependencies()
85145

86-
# Add targets for the cppwamp library itself, units tests, and examples.
87146
add_subdirectory(cppwamp)
88-
add_subdirectory(test)
89-
add_subdirectory(examples)
147+
148+
if(CPPWAMP_OPT_WITH_JSON)
149+
add_subdirectory(cppwamp-json)
150+
endif()
151+
152+
if(CPPWAMP_OPT_WITH_MSGPACK)
153+
add_subdirectory(cppwamp-msgpack)
154+
endif()
155+
156+
if(CPPWAMP_OPT_WITH_CORO)
157+
add_subdirectory(cppwamp-coro)
158+
endif()
159+
160+
if(CPPWAMP_OPT_WITH_DOCS AND NOT CPPWAMP_OPT_HEADERS_ONLY)
161+
add_subdirectory(doc)
162+
endif()
163+
164+
if(CPPWAMP_OPT_WITH_TESTS AND NOT CPPWAMP_OPT_HEADERS_ONLY)
165+
add_subdirectory(test)
166+
endif()
167+
168+
if(CPPWAMP_OPT_WITH_EXAMPLES AND NOT CPPWAMP_OPT_HEADERS_ONLY)
169+
add_subdirectory(examples)
170+
endif()
171+
172+
if(CPPWAMP_OPT_WITH_PACKAGING)
173+
add_subdirectory(packaging)
174+
endif()

0 commit comments

Comments
 (0)