Skip to content

Commit 3e37056

Browse files
committed
Use of cmake-conan.
1 parent 3f5d760 commit 3e37056

File tree

8 files changed

+31
-70
lines changed

8 files changed

+31
-70
lines changed

CMakeLists.txt

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,33 @@ cmake_minimum_required(VERSION 3.21)
22

33
project(autobahn-cpp)
44

5-
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
6-
conan_basic_setup(TARGETS)
5+
if (NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
6+
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
7+
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/develop/conan.cmake"
8+
"${CMAKE_BINARY_DIR}/conan.cmake"
9+
TLS_VERIFY ON)
10+
endif ()
711

8-
set(CMAKE_CXX_STANDARD 20)
12+
file(COPY ${CMAKE_SOURCE_DIR}/conanfile.py DESTINATION ${CMAKE_BINARY_DIR})
13+
14+
include(${CMAKE_BINARY_DIR}/conan.cmake)
15+
16+
set(CMAKE_CXX_STANDARD 17)
917

1018
option(AUTOBAHN_BUILD_EXAMPLES "Build examples" ON)
1119
option(AUTOBAHN_TESTS "Test" ON)
1220

21+
conan_cmake_run(CONANFILE ${CMAKE_SOURCE_DIR}/conanfile.py
22+
BASIC_SETUP CMAKE_TARGETS
23+
BUILD missing)
24+
25+
conan_cmake_autodetect(settings)
26+
27+
conan_cmake_install(PATH_OR_REFERENCE .
28+
BUILD missing
29+
REMOTE conancenter
30+
SETTINGS ${settings})
31+
1332
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Includes/CMakeLists.txt)
1433
if (AUTOBAHN_BUILD_EXAMPLES)
1534
add_subdirectory(examples)
@@ -18,5 +37,4 @@ endif (AUTOBAHN_BUILD_EXAMPLES)
1837
if (AUTOBAHN_TESTS)
1938
include(CTest)
2039
add_subdirectory(test)
21-
endif()
22-
40+
endif ()

CMakePresets.json

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

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class autobahn_cppConan(ConanFile):
77
author = "Crossbar.io Technologies GmbH and contributors"
88
description = "WAMP for C++ on Boost/ASIO"
99
url = "https://github.com/crossbario/autobahn-cpp"
10-
requires = "boost/1.77.0", "msgpack-cxx/4.0.3", "websocketpp/0.8.2", "openssl/3.0.1", "botan/2.19.1"
10+
requires = "boost/1.77.0", "msgpack-cxx/4.0.3", "websocketpp/0.8.2", "openssl/3.0.1", "botan/2.19.1", "catch2/2.13.8"
1111
generators = "cmake"
1212
scm = {
1313
"type": "git",

test/CMakeLists.txt

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
Include(FetchContent)
2-
FetchContent_Declare(
3-
Catch2
4-
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
5-
GIT_TAG v3.0.0-preview3
6-
)
7-
FetchContent_MakeAvailable(Catch2)
8-
91
function(make_test name src)
102
# By default MSVC has a 2^16 limit on the number of sections in an object file,
113
# and this needs more than that.
124
if (MSVC)
135
set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS /bigobj)
146
endif ()
157

16-
add_executable(${name} ${src} wamp_test.hpp ${PUBLIC_HEADERS})
17-
target_link_libraries(${name} PRIVATE Catch2::Catch2WithMain autobahn_cpp)
8+
add_executable(${name} ${src} wamp_test.hpp test_main.cpp ${PUBLIC_HEADERS})
9+
target_link_libraries(${name} PRIVATE CONAN_PKG::catch2 autobahn_cpp)
1810
string(REPLACE "test_" "" pure_name ${name})
1911
add_test(NAME ${name} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh "${CMAKE_CURRENT_SOURCE_DIR}/${pure_name}" "$<TARGET_FILE:${name}>")
2012
endfunction()

test/auth/auth.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
///////////////////////////////////////////////////////////////////////////////
3030

3131
#include "test/wamp_test.hpp"
32-
#include <catch2/catch_all.hpp>
32+
#include <catch2/catch.hpp>
3333

3434
struct Config
3535
{

test/calls/calls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
///////////////////////////////////////////////////////////////////////////////
3030

3131
#include "test/wamp_test.hpp"
32-
#include <catch2/catch_all.hpp>
32+
#include <catch2/catch.hpp>
3333

3434
struct Config
3535
{

test/pubsub/pubsub.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
///////////////////////////////////////////////////////////////////////////////
3030

3131
#include "test/wamp_test.hpp"
32-
#include <catch2/catch_all.hpp>
32+
#include <catch2/catch.hpp>
3333

3434
struct Config
3535
{

test/test_main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define CATCH_CONFIG_MAIN
2+
#include <catch2/catch.hpp>

0 commit comments

Comments
 (0)