Skip to content

Commit 49f0664

Browse files
Start trying to ifdef cpprestsdk out (#10)
1 parent 0852021 commit 49f0664

File tree

14 files changed

+613
-563
lines changed

14 files changed

+613
-563
lines changed

.azure/default-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828
- task: CMake@1
2929
inputs:
30-
cmakeArgs: .. ${{ parameters.cMakeRunArgs }} -DCMAKE_TOOLCHAIN_FILE=../submodules/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=${{ parameters.configuration }}
30+
cmakeArgs: .. ${{ parameters.cMakeRunArgs }} -DCMAKE_TOOLCHAIN_FILE=../submodules/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=${{ parameters.configuration }} -DUSE_CPPRESTSDK=true
3131
workingDirectory: 'build.${{ parameters.configuration }}'
3232
displayName: Create build files
3333
- task: CMake@1

CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@ else()
1414
set(EXTRA_FLAGS "-DSIGNALRCLIENT_EXPORTS")
1515
endif()
1616

17+
if(USE_CPPRESTSDK)
18+
string(APPEND EXTRA_FLAGS " -DUSE_CPPRESTSDK")
19+
endif()
20+
1721
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS}")
1822
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_LDFLAGS}")
1923

20-
find_package(cpprestsdk REQUIRED)
21-
set(CPPREST_LIB "cpprestsdk::cpprest")
24+
if(USE_CPPRESTSDK)
25+
find_package(cpprestsdk REQUIRED)
26+
set(CPPREST_LIB "cpprestsdk::cpprest")
27+
endif()
2228

2329
include_directories (include)
2430

CMakeSettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"inheritEnvironments": [ "msvc_x64_x64" ],
88
"buildRoot": "${projectDir}\\out\\build\\${name}",
99
"installRoot": "${projectDir}\\out\\install\\${name}",
10-
"cmakeCommandArgs": "-DBUILD_SAMPLES=true",
10+
"cmakeCommandArgs": "-DBUILD_SAMPLES=true -DUSE_CPPRESTSDK=true",
1111
"buildCommandArgs": "-v",
1212
"ctestCommandArgs": "",
1313
"cmakeToolchain": "${projectDir}\\submodules\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake",
@@ -19,7 +19,7 @@
1919
"configurationType": "Release",
2020
"buildRoot": "${projectDir}\\out\\build\\${name}",
2121
"installRoot": "${projectDir}\\out\\install\\${name}",
22-
"cmakeCommandArgs": "-DBUILD_SAMPLES=true",
22+
"cmakeCommandArgs": "-DBUILD_SAMPLES=true -DUSE_CPPRESTSDK=true",
2323
"buildCommandArgs": "-v",
2424
"ctestCommandArgs": "",
2525
"cmakeToolchain": "${projectDir}\\submodules\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake",

azure-pipelines.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ jobs:
1414
parameters:
1515
agentOs: macOs
1616
beforeBuild:
17-
- script: brew install gcc6
17+
# XCode 11 doesn't play nicely with gcc workaround by using XCode 10. We can try updating to a newer XCode in the future
18+
# Once the problem has been resolved
19+
- script: sudo xcode-select --switch /Applications/Xcode_10.3.app
20+
- script: brew install gcc
1821
- bash: "./submodules/vcpkg/bootstrap-vcpkg.sh"
1922
displayName: Bootstrap vcpkg
2023
- bash: "./submodules/vcpkg/vcpkg install cpprestsdk"
@@ -25,4 +28,4 @@ jobs:
2528
agentOs: Linux
2629
beforeBuild:
2730
- script: sudo vcpkg install cpprestsdk boost-system boost-chrono boost-thread --vcpkg-root ./submodules/vcpkg
28-
displayName: vcpkg install dependencies
31+
displayName: vcpkg install dependencies

include/signalrclient/signalr_client_config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33

44
#pragma once
55

6+
#ifdef USE_CPPRESTSDK
67
#include "cpprest/http_client.h"
78
#include "cpprest/ws_client.h"
9+
#endif
10+
811
#include "_exports.h"
912

1013
namespace signalr
1114
{
1215
class signalr_client_config
1316
{
17+
#ifdef USE_CPPRESTSDK
1418
public:
1519
SIGNALRCLIENT_API void __cdecl set_proxy(const web::web_proxy &proxy);
1620
// Please note that setting credentials does not work in all cases.
@@ -32,5 +36,6 @@ namespace signalr
3236
web::http::client::http_client_config m_http_client_config;
3337
web::websockets::client::websocket_client_config m_websocket_client_config;
3438
web::http::http_headers m_http_headers;
39+
#endif
3540
};
3641
}

src/signalrclient/CMakeLists.txt

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,25 @@ set (SOURCES
1919

2020
add_library (signalrclient SHARED ${SOURCES})
2121

22-
if(APPLE)
23-
target_link_libraries(signalrclient
24-
PUBLIC ${CPPREST_LIB}
25-
PRIVATE OpenSSL::SSL Boost::boost Boost::system Boost::chrono Boost::thread
26-
)
27-
elseif(NOT WIN32)
28-
target_link_libraries(signalrclient
29-
PUBLIC ${CPPREST_LIB}
30-
PRIVATE OpenSSL::SSL
31-
)
22+
if(NOT USE_CPPRESTSDK)
23+
target_link_libraries(signalrclient)
3224
else()
33-
target_link_libraries(signalrclient
34-
PUBLIC ${CPPREST_LIB}
35-
)
36-
endif()
25+
if(APPLE)
26+
target_link_libraries(signalrclient
27+
PUBLIC ${CPPREST_LIB}
28+
PRIVATE OpenSSL::SSL Boost::boost Boost::system Boost::chrono Boost::thread
29+
)
30+
elseif(NOT WIN32)
31+
target_link_libraries(signalrclient
32+
PUBLIC ${CPPREST_LIB}
33+
PRIVATE OpenSSL::SSL
34+
)
35+
else()
36+
target_link_libraries(signalrclient
37+
PUBLIC ${CPPREST_LIB}
38+
)
39+
endif()
40+
endif() # USE_CPPRESTSDK
3741

3842
include(GNUInstallDirs)
3943

src/signalrclient/connection_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#pragma once
55

66
#include <mutex>
7+
#include <atomic>
78
#include "signalrclient/http_client.h"
89
#include "signalrclient/trace_level.h"
910
#include "signalrclient/connection_state.h"

src/signalrclient/default_http_client.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
#include "stdafx.h"
5+
6+
#ifdef USE_CPPRESTSDK
57
#include "default_http_client.h"
68
#include <thread>
9+
#include "cpprest/http_client.h"
710

811
namespace signalr
912
{
@@ -72,3 +75,4 @@ namespace signalr
7275
});
7376
}
7477
}
78+
#endif

src/signalrclient/default_http_client.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#pragma once
55

66
#include "signalrclient/http_client.h"
7-
#include "cpprest/http_client.h"
87

98
namespace signalr
109
{

src/signalrclient/default_websocket_client.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
#include "stdafx.h"
5+
6+
#ifdef USE_CPPRESTSDK
57
#include "default_websocket_client.h"
68

79
namespace signalr
@@ -91,3 +93,4 @@ namespace signalr
9193
});
9294
}
9395
}
96+
#endif

0 commit comments

Comments
 (0)