Skip to content

Commit 71f0518

Browse files
committed
Merge branch 'master' into xqp-feature/get_human_readable_ssl_errors
2 parents ba2e35b + e5350ba commit 71f0518

File tree

271 files changed

+5043
-13878
lines changed

Some content is hidden

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

271 files changed

+5043
-13878
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,8 @@ Intermediate/
6666
.vs/
6767
# Ignore cmake building directories
6868
build.*/
69-
docs/
69+
docs/
70+
# ignore NuGet artifacts
71+
.nuget/
72+
73+
Generated Files/

Build/version.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<CppRestBaseFileName>cpprest</CppRestBaseFileName>
55
<CppRestSDKVersionMajor>2</CppRestSDKVersionMajor>
6-
<CppRestSDKVersionMinor>9</CppRestSDKVersionMinor>
6+
<CppRestSDKVersionMinor>10</CppRestSDKVersionMinor>
77
<CppRestSDKVersionRevision>0</CppRestSDKVersionRevision>
88
<CppRestSDKVersionFileSuffix>$(CppRestSDKVersionMajor)_$(CppRestSDKVersionMinor)</CppRestSDKVersionFileSuffix>
99
<CppRestSDKVersionString>$(CppRestSDKVersionMajor).$(CppRestSDKVersionMinor)</CppRestSDKVersionString>

Build_android/openssl/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SHELL := /bin/bash
2-
OPENSSL_VER = openssl-1.0.2d
2+
OPENSSL_VER = openssl-1.0.2k
33

44
all: armeabi-v7a/lib/libssl.a x86/lib/libssl.a
55

NuGet.Config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<config>
4+
<add key="repositoryPath" value="packages" />
5+
</config>
6+
</configuration>

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,33 @@ For other platforms, install options, how to build from source, and more, take a
2424

2525
Once you have the library, look at our [tutorial](https://github.com/Microsoft/cpprestsdk/wiki/Getting-Started-Tutorial) to use the http_client. It walks through how to setup a project to use the C++ Rest SDK and make a basic Http request.
2626

27+
To use from CMake:
28+
```cmake
29+
cmake_minimum_required(VERSION 3.7)
30+
project(main)
31+
32+
find_path(CPPREST_INCLUDE cpprest/http_client.h)
33+
find_library(CPPREST_LIB NAMES cpprest_2_9d cpprest_2_9 cpprestd cpprest)
34+
find_package(Boost REQUIRED COMPONENTS random system thread filesystem chrono atomic date_time regex)
35+
find_package(OpenSSL 1.0.0 REQUIRED)
36+
37+
add_executable(main main.cpp)
38+
target_include_directories(main ${CPPREST_INCLUDE})
39+
target_link_libraries(main
40+
${CPPREST_LIB}
41+
Boost::boost
42+
Boost::random
43+
Boost::system
44+
Boost::thread
45+
Boost::filesystem
46+
Boost::chrono
47+
Boost::atomic
48+
Boost::date_time
49+
Boost::regex
50+
OpenSSL::SSL
51+
)
52+
```
53+
2754
## What's in the SDK:
2855

2956
* Features - HTTP client/server, JSON, URI, asynchronous streams, WebSockets client, oAuth

Release/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.ninja_*
2+
*.ninja
3+
CMakeFiles/
4+
CMakeCache.txt
5+
CTestTestfile.cmake
6+
cmake_install.cmake

Release/CMakeLists.txt

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
2-
cmake_minimum_required(VERSION 2.8.12)
2+
cmake_minimum_required(VERSION 3.0)
33
if(POLICY CMP0042)
44
cmake_policy(SET CMP0042 NEW) # use MACOSX_RPATH
55
endif()
6-
project(cpprest)
6+
if(UNIX)
7+
project(cpprest C CXX)
8+
else()
9+
project(cpprest CXX)
10+
endif()
711

812
enable_testing()
913

1014
set(WERROR ON CACHE BOOL "Treat Warnings as Errors.")
1115
set(CPPREST_EXCLUDE_WEBSOCKETS OFF CACHE BOOL "Exclude websockets functionality.")
1216
set(CPPREST_EXCLUDE_COMPRESSION OFF CACHE BOOL "Exclude compression functionality.")
13-
set(CPPREST_EXPORT_DIR lib/cpprest CACHE STRING "Directory to install CMake config files.")
14-
set(CPPREST_EXPORT_NAME cpprest-config CACHE STRING "Name for CMake config file.")
17+
set(CPPREST_EXPORT_DIR lib/cpprestsdk CACHE STRING "Directory to install CMake config files.")
1518
set(CPPREST_INSTALL_HEADERS ON CACHE BOOL "Install header files.")
19+
set(CPPREST_INSTALL ON CACHE BOOL "Add install commands.")
1620

1721
if(IOS OR ANDROID)
1822
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries")
@@ -111,7 +115,7 @@ elseif(ANDROID)
111115
)
112116
elseif(UNIX) # This includes OSX
113117
elseif(WIN32)
114-
add_definitions(-DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0600)
118+
add_definitions(-DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0600 -DWIN32 -D_SCL_SECURE_NO_WARNINGS)
115119

116120
if(NOT BUILD_SHARED_LIBS)
117121
# This causes cmake to not link the test libraries separately, but instead hold onto their object files.
@@ -120,7 +124,7 @@ elseif(WIN32)
120124
else()
121125
set(Casablanca_DEFINITIONS "" CACHE INTERNAL "Definitions for consume casablanca library")
122126
endif()
123-
add_definitions(${Casablanca_DEFINITIONS} -D_WINSOCK_DEPRECATED_NO_WARNINGS -DWIN32)
127+
add_definitions(${Casablanca_DEFINITIONS} -D_WINSOCK_DEPRECATED_NO_WARNINGS)
124128
else()
125129
message(FATAL_ERROR "-- Unsupported Build Platform.")
126130
endif()
@@ -132,6 +136,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR IOS)
132136
if(ANDROID)
133137
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pedantic")
134138
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes -Wno-pointer-arith")
139+
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
140+
set(WARNINGS -Wall -Wextra -Wcast-qual -Wconversion -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-format-attribute -Wmissing-include-dirs -Wpacked -Wredundant-decls)
141+
set(LINUX_SUPPRESSIONS -Wno-overloaded-virtual -Wno-sign-conversion -Wno-deprecated -Wno-unknown-pragmas -Wno-reorder -Wno-char-subscripts -Wno-switch -Wno-unused-parameter -Wno-unused-variable -Wno-deprecated -Wno-unused-value -Wno-unknown-warning-option -Wno-return-type-c-linkage -Wno-unused-function -Wno-sign-compare -Wno-shorten-64-to-32 -Wno-reorder -Wno-unused-local-typedefs)
142+
set(WARNINGS ${WARNINGS} ${LINUX_SUPPRESSIONS})
143+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage -Wno-unneeded-internal-declaration")
135144
else()
136145
set(WARNINGS -Wall -Wextra -Wcast-qual -Wconversion -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-format-attribute -Wmissing-include-dirs -Wpacked -Wredundant-decls)
137146
set(OSX_SUPPRESSIONS -Wno-overloaded-virtual -Wno-sign-conversion -Wno-deprecated -Wno-unknown-pragmas -Wno-reorder -Wno-char-subscripts -Wno-switch -Wno-unused-parameter -Wno-unused-variable -Wno-deprecated -Wno-unused-value -Wno-unknown-warning-option -Wno-return-type-c-linkage -Wno-unused-function -Wno-sign-compare -Wno-shorten-64-to-32 -Wno-reorder -Wno-unused-local-typedefs)
@@ -172,35 +181,35 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries)
172181

173182
# These settings can be used by the test targets
174183
set(Casablanca_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include)
175-
set(Casablanca_SYSTEM_INCLUDE_DIRS)
176184
set(Casablanca_LIBRARY cpprest)
177185
set(Casablanca_LIBRARIES cpprest)
178186
get_directory_property(PARENT_DIR PARENT_DIRECTORY)
179187
if(NOT PARENT_DIR STREQUAL "")
180188
set(Casablanca_LIBRARIES ${Casablanca_LIBRARIES} PARENT_SCOPE)
181189
endif()
182190

183-
# Everything in the project needs access to the casablanca include directories
184-
include_directories( ${Casablanca_INCLUDE_DIRS})
185-
include_directories(SYSTEM ${Casablanca_SYSTEM_INCLUDE_DIRS})
186-
187191
# Finally, the tests all use the same style declaration to build themselves, so we use a function
188192
function(add_casablanca_test NAME SOURCES_VAR)
189193
add_library(${NAME} ${TEST_LIBRARY_TARGET_TYPE} ${${SOURCES_VAR}})
190194
message("-- Added test library ${NAME}")
191-
if (NOT TEST_LIBRARY_TARGET_TYPE STREQUAL "OBJECT")
195+
if(TEST_LIBRARY_TARGET_TYPE STREQUAL "OBJECT")
196+
foreach(_dep httptest_utilities common_utilities unittestpp cpprest)
197+
target_include_directories(${NAME} PRIVATE $<TARGET_PROPERTY:${_dep},INTERFACE_INCLUDE_DIRECTORIES>)
198+
target_compile_definitions(${NAME} PRIVATE $<TARGET_PROPERTY:${_dep},INTERFACE_COMPILE_DEFINITIONS>)
199+
endforeach()
200+
else()
192201
target_link_libraries(${NAME}
193202
httptest_utilities
194203
common_utilities
195204
unittestpp
196205
cpprest
197206
${ANDROID_STL_FLAGS}
198-
)
207+
)
199208
if (BUILD_SHARED_LIBS)
200209
add_test(NAME ${NAME}
201210
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
202211
COMMAND test_runner $<TARGET_FILE_NAME:${NAME}>
203-
)
212+
)
204213
endif()
205214
endif()
206215
endfunction()
Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
function(cpprest_find_boost)
2-
if(Boost_FOUND)
2+
if(TARGET cpprestsdk_boost_internal)
33
return()
44
endif()
55

66
if(IOS)
77
set(IOS_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../Build_iOS")
8-
set(Boost_FOUND 1 CACHE INTERNAL "")
9-
set(Boost_FRAMEWORK "-F ${IOS_SOURCE_DIR} -framework boost" CACHE INTERNAL "")
10-
set(Boost_INCLUDE_DIR "$<BUILD_INTERFACE:${IOS_SOURCE_DIR}/boost.framework/Headers>" CACHE INTERNAL "")
8+
set(Boost_LIBRARIES "${IOS_SOURCE_DIR}/boost.framework/boost" CACHE INTERNAL "")
9+
set(Boost_INCLUDE_DIR "${IOS_SOURCE_DIR}/boost.framework/Headers" CACHE INTERNAL "")
1110
elseif(ANDROID)
1211
set(Boost_COMPILER "-clang")
1312
if(ARM)
@@ -24,17 +23,57 @@ function(cpprest_find_boost)
2423
find_package(Boost REQUIRED COMPONENTS system date_time regex)
2524
endif()
2625

27-
set(Boost_FOUND 1 CACHE INTERNAL "")
28-
set(Boost_INCLUDE_DIR ${Boost_INCLUDE_DIR} CACHE INTERNAL "")
29-
set(Boost_LIBRARIES
30-
${Boost_SYSTEM_LIBRARY}
31-
${Boost_THREAD_LIBRARY}
32-
${Boost_ATOMIC_LIBRARY}
33-
${Boost_CHRONO_LIBRARY}
34-
${Boost_RANDOM_LIBRARY}
35-
${Boost_REGEX_LIBRARY}
36-
${Boost_DATE_TIME_LIBRARY}
37-
${Boost_FILESYSTEM_LIBRARY}
38-
${BOOST_FRAMEWORK}
39-
CACHE INTERNAL "")
40-
endfunction()
26+
add_library(cpprestsdk_boost_internal INTERFACE)
27+
# FindBoost continually breaks imported targets whenever boost updates.
28+
if(1)
29+
target_include_directories(cpprestsdk_boost_internal INTERFACE "$<BUILD_INTERFACE:${Boost_INCLUDE_DIR}>")
30+
set(_prev)
31+
set(_libs)
32+
foreach(_lib ${Boost_LIBRARIES})
33+
if(_lib STREQUAL "optimized" OR _lib STREQUAL "debug")
34+
else()
35+
if(_prev STREQUAL "optimized")
36+
list(APPEND _libs "$<$<NOT:$<CONFIG:Debug>>:${_lib}>")
37+
elseif(_prev STREQUAL "debug")
38+
list(APPEND _libs "$<$<CONFIG:Debug>:${_lib}>")
39+
else()
40+
list(APPEND _libs "${_lib}")
41+
endif()
42+
endif()
43+
set(_prev "${_lib}")
44+
endforeach()
45+
target_link_libraries(cpprestsdk_boost_internal INTERFACE "$<BUILD_INTERFACE:${_libs}>")
46+
47+
else()
48+
if(ANDROID)
49+
target_link_libraries(cpprestsdk_boost_internal INTERFACE
50+
Boost::boost
51+
Boost::random
52+
Boost::system
53+
Boost::thread
54+
Boost::filesystem
55+
Boost::chrono
56+
Boost::atomic
57+
)
58+
elseif(UNIX)
59+
target_link_libraries(cpprestsdk_boost_internal INTERFACE
60+
Boost::boost
61+
Boost::random
62+
Boost::system
63+
Boost::thread
64+
Boost::filesystem
65+
Boost::chrono
66+
Boost::atomic
67+
Boost::date_time
68+
Boost::regex
69+
)
70+
else()
71+
target_link_libraries(cpprestsdk_boost_internal INTERFACE
72+
Boost::boost
73+
Boost::system
74+
Boost::date_time
75+
Boost::regex
76+
)
77+
endif()
78+
endif()
79+
endfunction()
Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,70 @@
11
function(cpprest_find_openssl)
2-
if(OPENSSL_FOUND)
2+
if(TARGET cpprestsdk_openssl_internal)
33
return()
44
endif()
55

66
if(IOS)
77
set(IOS_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../Build_iOS")
8-
set(OPENSSL_FOUND 1 CACHE INTERNAL "")
9-
set(OPENSSL_INCLUDE_DIR "$<BUILD_INTERFACE:${IOS_SOURCE_DIR}/openssl/include>" CACHE INTERNAL "")
8+
9+
set(OPENSSL_INCLUDE_DIR "${IOS_SOURCE_DIR}/openssl/include" CACHE INTERNAL "")
1010
set(OPENSSL_LIBRARIES
1111
"${IOS_SOURCE_DIR}/openssl/lib/libcrypto.a"
1212
"${IOS_SOURCE_DIR}/openssl/lib/libssl.a"
1313
CACHE INTERNAL ""
1414
)
1515
set(_SSL_LEAK_SUPPRESS_AVAILABLE ON CACHE INTERNAL "")
16-
return()
1716
elseif(ANDROID)
18-
set(OPENSSL_FOUND 1 CACHE INTERNAL "")
1917
if(ARM)
20-
set(OPENSSL_INCLUDE_DIR "$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/../openssl/armeabi-v7a/include>" CACHE INTERNAL "")
18+
set(OPENSSL_INCLUDE_DIR "${CMAKE_BINARY_DIR}/../openssl/armeabi-v7a/include" CACHE INTERNAL "")
2119
set(OPENSSL_LIBRARIES
2220
"${CMAKE_BINARY_DIR}/../openssl/armeabi-v7a/lib/libssl.a"
2321
"${CMAKE_BINARY_DIR}/../openssl/armeabi-v7a/lib/libcrypto.a"
2422
CACHE INTERNAL ""
2523
)
2624
else()
27-
set(OPENSSL_INCLUDE_DIR "$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/../openssl/x86/include>" CACHE INTERNAL "")
25+
set(OPENSSL_INCLUDE_DIR "${CMAKE_BINARY_DIR}/../openssl/x86/include" CACHE INTERNAL "")
2826
set(OPENSSL_LIBRARIES
2927
"${CMAKE_BINARY_DIR}/../openssl/x86/lib/libssl.a"
3028
"${CMAKE_BINARY_DIR}/../openssl/x86/lib/libcrypto.a"
3129
CACHE INTERNAL ""
3230
)
3331
endif()
34-
elseif(APPLE)
35-
if(NOT DEFINED OPENSSL_ROOT_DIR)
36-
# Prefer a homebrew version of OpenSSL over the one in /usr/lib
37-
file(GLOB OPENSSL_ROOT_DIR /usr/local/Cellar/openssl/*)
38-
# Prefer the latest (make the latest one first)
39-
list(REVERSE OPENSSL_ROOT_DIR)
40-
endif()
41-
# This should prevent linking against the system provided 0.9.8y
42-
set(_OPENSSL_VERSION "")
43-
find_package(OpenSSL 1.0.0 REQUIRED)
32+
set(_SSL_LEAK_SUPPRESS_AVAILABLE ON CACHE INTERNAL "")
4433
else()
34+
if(APPLE)
35+
if(NOT DEFINED OPENSSL_ROOT_DIR)
36+
# Prefer a homebrew version of OpenSSL over the one in /usr/lib
37+
file(GLOB OPENSSL_ROOT_DIR /usr/local/Cellar/openssl/*)
38+
# Prefer the latest (make the latest one first)
39+
list(REVERSE OPENSSL_ROOT_DIR)
40+
endif()
41+
# This should prevent linking against the system provided 0.9.8y
42+
set(_OPENSSL_VERSION "")
43+
endif()
4544
find_package(OpenSSL 1.0.0 REQUIRED)
45+
46+
INCLUDE(CheckCXXSourceCompiles)
47+
set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}")
48+
set(CMAKE_REQUIRED_LIBRARIES "${OPENSSL_LIBRARIES}")
49+
CHECK_CXX_SOURCE_COMPILES("
50+
#include <openssl/ssl.h>
51+
int main()
52+
{
53+
::SSL_COMP_free_compression_methods();
54+
}
55+
" _SSL_LEAK_SUPPRESS_AVAILABLE)
4656
endif()
4757

48-
set(OPENSSL_FOUND 1 CACHE INTERNAL "")
49-
set(OPENSSL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR} CACHE INTERNAL "")
50-
set(OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} CACHE INTERNAL "")
58+
add_library(cpprestsdk_openssl_internal INTERFACE)
59+
if(TARGET OpenSSL::SSL)
60+
target_link_libraries(cpprestsdk_openssl_internal INTERFACE OpenSSL::SSL)
61+
else()
62+
target_link_libraries(cpprestsdk_openssl_internal INTERFACE "$<BUILD_INTERFACE:${OPENSSL_LIBRARIES}>")
63+
target_include_directories(cpprestsdk_openssl_internal INTERFACE "$<BUILD_INTERFACE:${OPENSSL_INCLUDE_DIR}>")
64+
endif()
5165

52-
INCLUDE(CheckCXXSourceCompiles)
53-
set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}")
54-
set(CMAKE_REQUIRED_LIBRARIES "${OPENSSL_LIBRARIES}")
55-
CHECK_CXX_SOURCE_COMPILES("
56-
#include <openssl/ssl.h>
57-
int main()
58-
{
59-
::SSL_COMP_free_compression_methods();
60-
}
61-
" _SSL_LEAK_SUPPRESS_AVAILABLE)
66+
if (NOT _SSL_LEAK_SUPPRESS_AVAILABLE)
67+
# libressl doesn't ship with the cleanup method being used in ws_client_wspp
68+
target_compile_definitions(cpprestsdk_openssl_internal INTERFACE -DCPPREST_NO_SSL_LEAK_SUPPRESS)
69+
endif()
6270
endfunction()
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function(cpprest_find_websocketpp)
2-
if(WEBSOCKETPP_FOUND)
2+
if(TARGET cpprestsdk_websocketpp_internal)
33
return()
44
endif()
55

@@ -9,7 +9,17 @@ function(cpprest_find_websocketpp)
99
set(WEBSOCKETPP_INCLUDE_DIR ${WEBSOCKETPP_INCLUDE_DIR} CACHE INTERNAL "")
1010
else()
1111
message("-- websocketpp not found, using the embedded version")
12-
set(WEBSOCKETPP_FOUND 1 CACHE INTERNAL "" FORCE)
1312
set(WEBSOCKETPP_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/libs/websocketpp CACHE INTERNAL "")
1413
endif()
14+
15+
cpprest_find_boost()
16+
cpprest_find_openssl()
17+
18+
add_library(cpprestsdk_websocketpp_internal INTERFACE)
19+
target_include_directories(cpprestsdk_websocketpp_internal INTERFACE "$<BUILD_INTERFACE:${WEBSOCKETPP_INCLUDE_DIR}>")
20+
target_link_libraries(cpprestsdk_websocketpp_internal
21+
INTERFACE
22+
cpprestsdk_boost_internal
23+
cpprestsdk_openssl_internal
24+
)
1525
endfunction()

0 commit comments

Comments
 (0)