Skip to content

Commit 40c5f02

Browse files
authored
Merge pull request #214 from robinlinden/conan-build
Add support for installing dependencies using a conanfile
2 parents 501c117 + e4dc248 commit 40c5f02

File tree

7 files changed

+64
-36
lines changed

7 files changed

+64
-36
lines changed

.github/workflows/ci.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ jobs:
2020
compiler: gcc
2121
version: "10"
2222

23+
- name: ubuntu-20.04-gcc-10-conan
24+
os: ubuntu-20.04
25+
compiler: gcc
26+
version: "10"
27+
conan: true
28+
cmake-args: -DCMAKE_PREFIX_PATH=`pwd`/build -DCMAKE_MODULE_PATH=`pwd`/build
29+
2330
steps:
2431
- uses: actions/checkout@v2
2532

@@ -29,14 +36,23 @@ jobs:
2936

3037
- name: Install
3138
run: |
32-
python -m pip install cmake==3.17.3 --upgrade
39+
python -m pip install cmake==3.17.3 conan==1.28.1 --upgrade
3340
sudo apt update
3441
sudo apt-get install -y g++-${{ matrix.version }} g++-${{ matrix.version }}-multilib
3542
echo "::set-env name=CC::gcc-${{ matrix.version }}"
3643
echo "::set-env name=CXX::g++-${{ matrix.version }}"
3744
38-
- name: Install dependencies
45+
- name: Install dependencies (system)
3946
run: sudo apt-get install -y libboost-all-dev libmsgpack-dev libwebsocketpp-dev
47+
if: ${{ !matrix.conan }}
48+
49+
- name: Install dependencies (conan)
50+
run: |
51+
conan profile new default --detect --force
52+
conan profile update settings.compiler.libcxx=libstdc++11 default
53+
mkdir -p build && cd build
54+
conan install .. --build=missing
55+
if: ${{ matrix.conan }}
4056

4157
- name: Build
4258
run: |

autobahn/wamp_websocketpp_websocket_transport.ipp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ namespace autobahn {
4848
{
4949
// Bind the handlers we are using
5050
using websocketpp::lib::placeholders::_1;
51+
using websocketpp::lib::placeholders::_2;
5152
using websocketpp::lib::bind;
5253
m_client.set_open_handler(bind(&wamp_websocketpp_websocket_transport<Config>::on_ws_open, this, _1));
5354
m_client.set_close_handler(bind(&wamp_websocketpp_websocket_transport<Config>::on_ws_close, this, _1));
5455
m_client.set_fail_handler(bind(&wamp_websocketpp_websocket_transport<Config>::on_ws_fail, this, _1));
55-
m_client.set_message_handler(bind(&wamp_websocketpp_websocket_transport<Config>::on_ws_message, this, ::_1, ::_2));
56+
m_client.set_message_handler(bind(&wamp_websocketpp_websocket_transport<Config>::on_ws_message, this, _1, _2));
5657
if(!debug_enabled) {
5758
m_client.clear_access_channels(websocketpp::log::alevel::all);
5859
}

cmake/Includes/CMakeLists.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,18 @@ endif()
5353

5454
find_package(Boost REQUIRED COMPONENTS program_options system thread random)
5555

56-
find_package(Msgpack REQUIRED)
57-
find_package(Websocketpp REQUIRED)
56+
find_package(msgpack REQUIRED)
57+
find_package(websocketpp REQUIRED)
5858

5959
MESSAGE( STATUS "AUTOBAHN_BUILD_EXAMPLES: " ${AUTOBAHN_BUILD_EXAMPLES} )
6060
MESSAGE( STATUS "CMAKE_ROOT: " ${CMAKE_ROOT} )
6161
MESSAGE( STATUS "CMAKE_INSTALL_PREFIX: " ${CMAKE_INSTALL_PREFIX} )
6262
MESSAGE( STATUS "Boost_INCLUDE_DIRS: " ${Boost_INCLUDE_DIRS} )
6363
MESSAGE( STATUS "Boost_LIBRARIES: " ${Boost_LIBRARIES} )
64-
MESSAGE( STATUS "Msgpack_INCLUDE_DIRS: " ${Msgpack_INCLUDE_DIRS} )
65-
MESSAGE( STATUS "Msgpack_LIBRARIES: " ${Msgpack_LIBRARIES} )
66-
MESSAGE( STATUS "Websocketpp_INCLUDE_DIRS: " ${Websocketpp_INCLUDE_DIRS} )
67-
MESSAGE( STATUS "Websocketpp_LIBRARIES: " ${Websocketpp_LIBRARIES} )
64+
MESSAGE( STATUS "msgpack_INCLUDE_DIRS: " ${msgpack_INCLUDE_DIRS} )
65+
MESSAGE( STATUS "msgpack_LIBRARIES: " ${msgpack_LIBRARIES} )
66+
MESSAGE( STATUS "websocketpp_INCLUDE_DIRS: " ${websocketpp_INCLUDE_DIRS} )
67+
MESSAGE( STATUS "websocketpp_LIBRARIES: " ${websocketpp_LIBRARIES} )
6868

6969
set(PUBLIC_HEADERS
7070
${CMAKE_CURRENT_SOURCE_DIR}/autobahn/autobahn.hpp
@@ -133,12 +133,14 @@ target_include_directories(autobahn_cpp INTERFACE
133133
${CMAKE_CURRENT_SOURCE_DIR}
134134
${Boost_INCLUDE_DIRS}
135135
${OPENSSL_INCLUDE_DIR}
136-
${Websocketpp_INCLUDE_DIRS}
137-
${Msgpack_INCLUDE_DIRS})
136+
${websocketpp_INCLUDE_DIRS}
137+
${msgpack_INCLUDE_DIRS})
138138

139139
target_link_libraries(autobahn_cpp INTERFACE
140140
${Boost_LIBRARIES}
141141
${OPENSSL_LIBRARIES}
142+
${websocketpp_LIBRARIES}
143+
${msgpack_LIBRARIES}
142144
${CMAKE_THREAD_LIBS_INIT}
143145
${CMAKE_DL_LIBS})
144146

cmake/Modules/FindMsgpack.cmake

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# - Try to find msgpack
22
# Once done this will define
3-
# Msgpack_FOUND - System has msgpack
4-
# Msgpack_INCLUDE_DIRS - The msgpack include directories
3+
# msgpack_FOUND - System has msgpack
4+
# msgpack_INCLUDE_DIRS - The msgpack include directories
55

66
set(_env "$ENV{MSGPACK_ROOT}")
77
if(_env)
88

9-
set(Msgpack_FOUND TRUE)
10-
set(Msgpack_INCLUDE_DIRS "$ENV{MSGPACK_ROOT}/include")
11-
set(Msgpack_LIBRARIES "$ENV{MSGPACK_ROOT}/libs")
9+
set(msgpack_FOUND TRUE)
10+
set(msgpack_INCLUDE_DIRS "$ENV{MSGPACK_ROOT}/include")
11+
set(msgpack_LIBRARIES "$ENV{MSGPACK_ROOT}/libs")
1212

1313
else()
1414

@@ -18,18 +18,18 @@ else()
1818
pkg_check_modules(PC_MSGPACK QUIET msgpack)
1919
endif (PKG_CONFIG_FOUND)
2020

21-
find_path(Msgpack_INCLUDE_DIR msgpack.hpp
21+
find_path(msgpack_INCLUDE_DIR msgpack.hpp
2222
HINTS ${PC_MSGPACK_INCLUDEDIR} ${PC_MSGPACK_INCLUDE_DIRS})
2323

24-
set(Msgpack_INCLUDE_DIRS ${Msgpack_INCLUDE_DIR})
24+
set(msgpack_INCLUDE_DIRS ${msgpack_INCLUDE_DIR})
2525

2626
include(FindPackageHandleStandardArgs)
2727
# handle the QUIETLY and REQUIRED arguments and set Msgpack_FOUND to TRUE
2828
# if all listed variables are TRUE
29-
find_package_handle_standard_args(Msgpack DEFAULT_MSG
30-
Msgpack_INCLUDE_DIR
31-
Msgpack_INCLUDE_DIRS)
29+
find_package_handle_standard_args(msgpack DEFAULT_MSG
30+
msgpack_INCLUDE_DIR
31+
msgpack_INCLUDE_DIRS)
3232

33-
mark_as_advanced(Msgpack_INCLUDE_DIR)
33+
mark_as_advanced(msgpack_INCLUDE_DIR)
3434

3535
endif()
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# - Try to find websocketpp
22
# Once done this will define
3-
# Websocketpp_FOUND - System has websocketpp
4-
# Websocketpp_INCLUDE_DIRS - The websocketpp include directories
3+
# websocketpp_FOUND - System has websocketpp
4+
# websocketpp_INCLUDE_DIRS - The websocketpp include directories
55

66
set(_env "$ENV{WEBSOCKETPP_ROOT}")
77
if(_env)
88

9-
set(Websocketpp_FOUND TRUE)
10-
set(Websocketpp_INCLUDE_DIRS "$ENV{WEBSOCKETPP_ROOT}/include")
11-
set(Websocketpp_LIBRARIES "$ENV{WEBSOCKETPP_ROOT}/libs")
9+
set(websocketpp_FOUND TRUE)
10+
set(websocketpp_INCLUDE_DIRS "$ENV{WEBSOCKETPP_ROOT}/include")
11+
set(websocketpp_LIBRARIES "$ENV{WEBSOCKETPP_ROOT}/libs")
1212

1313
else()
1414

@@ -18,18 +18,18 @@ else()
1818
pkg_check_modules(PC_WEBSOCKETPP QUIET websocketpp)
1919
endif (PKG_CONFIG_FOUND)
2020

21-
find_path(Websocketpp_INCLUDE_DIR websocketpp
21+
find_path(websocketpp_INCLUDE_DIR websocketpp
2222
HINTS ${PC_WEBSOCKETPP_INCLUDEDIR} ${PC_WEBSOCKETPP_INCLUDE_DIRS})
2323

24-
set(Websocketpp_INCLUDE_DIRS ${Websocketpp_INCLUDE_DIR})
24+
set(websocketpp_INCLUDE_DIRS ${websocketpp_INCLUDE_DIR})
2525

2626
include(FindPackageHandleStandardArgs)
27-
# handle the QUIETLY and REQUIRED arguments and set Websocketpp_FOUND to TRUE
27+
# handle the QUIETLY and REQUIRED arguments and set websocketpp_FOUND to TRUE
2828
# if all listed variables are TRUE
29-
find_package_handle_standard_args(Websocketpp DEFAULT_MSG
30-
Websocketpp_INCLUDE_DIR
31-
Websocketpp_INCLUDE_DIRS)
29+
find_package_handle_standard_args(websocketpp DEFAULT_MSG
30+
websocketpp_INCLUDE_DIR
31+
websocketpp_INCLUDE_DIRS)
3232

33-
mark_as_advanced(Websocketpp_INCLUDE_DIR)
33+
mark_as_advanced(websocketpp_INCLUDE_DIR)
3434

3535
endif()

conanfile.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[requires]
2+
boost/1.73.0
3+
msgpack/3.2.1
4+
websocketpp/0.8.2
5+
6+
[generators]
7+
cmake_find_package

examples/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
set(CMAKE_EXE_LINKER_FLAGS " -static")
22

33
add_library(examples_parameters parameters.cpp parameters.hpp)
4+
target_include_directories(examples_parameters PUBLIC ${Boost_INCLUDE_DIRS})
5+
target_link_libraries(examples_parameters PRIVATE ${Boost_LIBRARIES})
46

57
function(make_example name src)
68
add_executable(${name} ${src} ${PUBLIC_HEADERS})
7-
target_link_libraries(${name} examples_parameters autobahn_cpp ${ARGN})
9+
target_link_libraries(${name} examples_parameters autobahn_cpp)
810
endfunction()
911

1012
make_example(caller caller.cpp)
1113
make_example(callee callee.cpp)
1214
make_example(provide_prefix provide_prefix.cpp)
1315
make_example(publisher publisher.cpp)
1416
make_example(subscriber subscriber.cpp)
15-
make_example(wampcra wampcra.cpp crypto)
17+
make_example(wampcra wampcra.cpp)
1618
make_example(websocket_callee websocket_callee.cpp)
1719

1820
if(UNIX)

0 commit comments

Comments
 (0)