Skip to content

Commit 4ffcad6

Browse files
committed
Merge pull request #30 from ras0219/master
Add CPPREST_EXCLUDE_WEBSOCKETS option to CMake
2 parents 8f3a60d + fa9f015 commit 4ffcad6

File tree

7 files changed

+76
-49
lines changed

7 files changed

+76
-49
lines changed

Release/CMakeLists.txt

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ elseif(WIN32)
101101
option(BUILD_SHARED_LIBS "Build shared Libraries." ON)
102102
option(BUILD_TESTS "Build tests." ON)
103103
option(BUILD_SAMPLES "Build samples." ON)
104+
option(CPPREST_EXCLUDE_WEBSOCKETS "Exclude websockets functionality." OFF)
104105
option(Boost_USE_STATIC_LIBS ON)
105106

106107
add_definitions(-DUNICODE -D_UNICODE)
@@ -114,8 +115,12 @@ elseif(WIN32)
114115
endif()
115116
add_definitions(${Casablanca_DEFINITIONS} -D_WINSOCK_DEPRECATED_NO_WARNINGS -DWIN32)
116117

117-
find_package(Boost 1.55 REQUIRED COMPONENTS random system thread filesystem chrono atomic)
118-
find_package(OpenSSL 1.0 REQUIRED)
118+
if (CPPREST_EXCLUDE_WEBSOCKETS)
119+
add_definitions(-DCPPREST_EXCLUDE_WEBSOCKETS=1)
120+
else()
121+
find_package(Boost 1.55 REQUIRED COMPONENTS random system thread filesystem chrono atomic)
122+
find_package(OpenSSL 1.0 REQUIRED)
123+
endif()
119124
else()
120125
message(FATAL_ERROR "-- Unsupported Build Platform.")
121126
endif()
@@ -165,20 +170,23 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries)
165170

166171
# These settings can be used by the test targets
167172
set(Casablanca_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
168-
169-
find_path(WEBSOCKETPP_CONFIG websocketpp-config.cmake
170-
HINTS /usr/lib/cmake/websocketpp)
171-
find_path(WEBSOCKETPP_CONFIG_VERSION websocketpp-configVersion.cmake
172-
HINTS /usr/lib/cmake/websocketpp)
173-
if(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
174-
include(${WEBSOCKETPP_CONFIG}/websocketpp-config.cmake)
175-
include(${WEBSOCKETPP_CONFIG}/websocketpp-configVersion.cmake)
176-
message("-- Found websocketpp version " ${PACKAGE_VERSION} " on system")
177-
set(Casablanca_INCLUDE_DIRS ${Casablanca_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${WEBSOCKETPP_INCLUDE_DIR})
178-
else(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
179-
set(Casablanca_INCLUDE_DIRS ${Casablanca_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/libs/websocketpp)
180-
message("-- websocketpp not found, using the embedded version")
181-
endif(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
173+
if (NOT CPPREST_EXCLUDE_WEBSOCKETS)
174+
find_path(WEBSOCKETPP_CONFIG websocketpp-config.cmake
175+
HINTS /usr/lib/cmake/websocketpp)
176+
find_path(WEBSOCKETPP_CONFIG_VERSION websocketpp-configVersion.cmake
177+
HINTS /usr/lib/cmake/websocketpp)
178+
if(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
179+
include(${WEBSOCKETPP_CONFIG}/websocketpp-config.cmake)
180+
include(${WEBSOCKETPP_CONFIG}/websocketpp-configVersion.cmake)
181+
message("-- Found websocketpp version " ${PACKAGE_VERSION} " on system")
182+
set(Casablanca_INCLUDE_DIRS ${Casablanca_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${WEBSOCKETPP_INCLUDE_DIR})
183+
else(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
184+
set(Casablanca_INCLUDE_DIRS ${Casablanca_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/libs/websocketpp)
185+
message("-- websocketpp not found, using the embedded version")
186+
endif(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
187+
else()
188+
set(Casablanca_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include)
189+
endif()
182190

183191
set(Casablanca_LIBRARY ${LIB}cpprest)
184192
set(Casablanca_LIBRARIES ${Casablanca_LIBRARY} ${Boost_LIBRARIES} ${Boost_FRAMEWORK})

Release/src/CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
include_directories(pch ${OPENSSL_INCLUDE_DIR})
1+
include_directories(../include pch)
2+
if (NOT CPPREST_EXCLUDE_WEBSOCKETS)
3+
include_directories(${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR})
4+
endif()
25

36
set(SOURCES_COMMON
47
http/client/http_client_msg.cpp
@@ -67,8 +70,12 @@ elseif(WIN32)
6770
httpapi.lib
6871
Winhttp.lib
6972
)
70-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNINGS} /Yustdafx.h /Zm200")
71-
set_source_files_properties(pch/stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h")
73+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNINGS}")
74+
if (${CMAKE_GENERATOR} MATCHES "Visual Studio .*")
75+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Yustdafx.h /Zm200")
76+
set_source_files_properties(pch/stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h")
77+
endif()
78+
7279
if (BUILD_SHARED_LIBS)
7380
add_definitions(-D_ASYNCRT_EXPORT -D_PPLX_EXPORT -D_USRDLL)
7481
endif()

Release/tests/common/TestRunner/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
include_directories(${Casablanca_INCLUDE_DIRS})
1+
include_directories(${Casablanca_INCLUDE_DIRS}
2+
../UnitTestpp
3+
)
24

35
set(TR_SOURCES
46
test_runner.cpp
@@ -97,4 +99,4 @@ if(NOT IOS AND NOT ANDROID)
9799
)
98100
endif()
99101
endif()
100-
endif()
102+
endif()

Release/tests/functional/http/client/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include_directories(
22
../utilities/include
33
../utilities/testlistener/include
4-
${OPENSSL_INCLUDE_DIR}
4+
${Casablanca_INCLUDE_DIRS}
55
)
66

77
set(SOURCES

Release/tests/functional/streams/stdstream_tests.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
#include "cpprest/filestream.h"
2727
#include "cpprest/producerconsumerstream.h"
2828

29+
#if !defined(_WIN32) || !defined(CPPREST_EXCLUDE_WEBSOCKETS)
2930
#include <boost/interprocess/streams/bufferstream.hpp>
31+
#endif
3032

3133
#if defined(__cplusplus_winrt)
3234
using namespace Windows::Storage;
@@ -787,6 +789,7 @@ TEST(sync_on_async_close_with_exception)
787789
}
788790
}
789791

792+
#if !defined(_WIN32) || !defined(CPPREST_EXCLUDE_WEBSOCKETS)
790793
TEST(ostream_full_throw_exception)
791794
{
792795
char tgt_buffer[5];
@@ -806,6 +809,7 @@ TEST(ostream_full_throw_exception)
806809

807810
VERIFY_THROWS(astream.read_to_end(os_streambuf).get(), std::exception);
808811
}
812+
#endif
809813

810814
}
811815
}}}
Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
include_directories(../utilities)
1+
if (NOT CPPREST_EXCLUDE_WEBSOCKETS)
2+
include_directories(../utilities)
3+
4+
set(SOURCES
5+
authentication_tests.cpp
6+
client_construction.cpp
7+
close_tests.cpp
8+
error_tests.cpp
9+
receive_msg_tests.cpp
10+
send_msg_tests.cpp
11+
)
212

3-
set(SOURCES
4-
authentication_tests.cpp
5-
client_construction.cpp
6-
close_tests.cpp
7-
error_tests.cpp
8-
receive_msg_tests.cpp
9-
send_msg_tests.cpp
10-
)
11-
12-
add_casablanca_test(${LIB}websocketclient_test SOURCES)
13-
target_link_libraries(${LIB}websocketclient_test ${LIB}websockettest_utilities)
13+
add_casablanca_test(${LIB}websocketclient_test SOURCES)
14+
target_link_libraries(${LIB}websocketclient_test ${LIB}websockettest_utilities)
15+
endif()
Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
include_directories(include)
1+
if (NOT CPPREST_EXCLUDE_WEBSOCKETS)
22

3-
if(WIN32)
4-
add_definitions(-DWEBSOCKETTESTUTILITY_EXPORTS)
5-
endif()
3+
include_directories(include)
4+
5+
if(WIN32)
6+
add_definitions(-DWEBSOCKETTESTUTILITY_EXPORTS)
7+
endif()
8+
9+
set(SOURCES
10+
test_websocket_server.cpp
11+
)
12+
13+
add_library(${LIB}websockettest_utilities ${SOURCES})
14+
target_link_libraries(${LIB}websockettest_utilities
15+
${LIB}unittestpp
16+
${LIB}common_utilities
17+
${BOOST_LIBRARIES}
18+
${Casablanca_LIBRARIES}
19+
)
620

7-
set(SOURCES
8-
test_websocket_server.cpp
9-
)
10-
11-
add_library(${LIB}websockettest_utilities ${SOURCES})
12-
target_link_libraries(${LIB}websockettest_utilities
13-
${LIB}unittestpp
14-
${LIB}common_utilities
15-
${BOOST_LIBRARIES}
16-
${Casablanca_LIBRARIES}
17-
)
21+
endif()

0 commit comments

Comments
 (0)