Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CPPREST_EXCLUDE_WEBSOCKETS option to CMake #30

Merged
merged 5 commits into from
Dec 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions Release/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ elseif(WIN32)
option(BUILD_SHARED_LIBS "Build shared Libraries." ON)
option(BUILD_TESTS "Build tests." ON)
option(BUILD_SAMPLES "Build samples." ON)
option(CPPREST_EXCLUDE_WEBSOCKETS "Exclude websockets functionality." OFF)
option(Boost_USE_STATIC_LIBS ON)

add_definitions(-DUNICODE -D_UNICODE)
Expand All @@ -114,8 +115,12 @@ elseif(WIN32)
endif()
add_definitions(${Casablanca_DEFINITIONS} -D_WINSOCK_DEPRECATED_NO_WARNINGS -DWIN32)

find_package(Boost 1.55 REQUIRED COMPONENTS random system thread filesystem chrono atomic)
find_package(OpenSSL 1.0 REQUIRED)
if (CPPREST_EXCLUDE_WEBSOCKETS)
add_definitions(-DCPPREST_EXCLUDE_WEBSOCKETS=1)
else()
find_package(Boost 1.55 REQUIRED COMPONENTS random system thread filesystem chrono atomic)
find_package(OpenSSL 1.0 REQUIRED)
endif()
else()
message(FATAL_ERROR "-- Unsupported Build Platform.")
endif()
Expand Down Expand Up @@ -165,20 +170,23 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries)

# These settings can be used by the test targets
set(Casablanca_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)

find_path(WEBSOCKETPP_CONFIG websocketpp-config.cmake
HINTS /usr/lib/cmake/websocketpp)
find_path(WEBSOCKETPP_CONFIG_VERSION websocketpp-configVersion.cmake
HINTS /usr/lib/cmake/websocketpp)
if(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
include(${WEBSOCKETPP_CONFIG}/websocketpp-config.cmake)
include(${WEBSOCKETPP_CONFIG}/websocketpp-configVersion.cmake)
message("-- Found websocketpp version " ${PACKAGE_VERSION} " on system")
set(Casablanca_INCLUDE_DIRS ${Casablanca_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${WEBSOCKETPP_INCLUDE_DIR})
else(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
set(Casablanca_INCLUDE_DIRS ${Casablanca_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/libs/websocketpp)
message("-- websocketpp not found, using the embedded version")
endif(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
if (NOT CPPREST_EXCLUDE_WEBSOCKETS)
find_path(WEBSOCKETPP_CONFIG websocketpp-config.cmake
HINTS /usr/lib/cmake/websocketpp)
find_path(WEBSOCKETPP_CONFIG_VERSION websocketpp-configVersion.cmake
HINTS /usr/lib/cmake/websocketpp)
if(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
include(${WEBSOCKETPP_CONFIG}/websocketpp-config.cmake)
include(${WEBSOCKETPP_CONFIG}/websocketpp-configVersion.cmake)
message("-- Found websocketpp version " ${PACKAGE_VERSION} " on system")
set(Casablanca_INCLUDE_DIRS ${Casablanca_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${WEBSOCKETPP_INCLUDE_DIR})
else(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
set(Casablanca_INCLUDE_DIRS ${Casablanca_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/libs/websocketpp)
message("-- websocketpp not found, using the embedded version")
endif(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
else()
set(Casablanca_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we setting this again in the else() part?

endif()

set(Casablanca_LIBRARY ${LIB}cpprest)
set(Casablanca_LIBRARIES ${Casablanca_LIBRARY} ${Boost_LIBRARIES} ${Boost_FRAMEWORK})
Expand Down
13 changes: 10 additions & 3 deletions Release/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
include_directories(pch ${OPENSSL_INCLUDE_DIR})
include_directories(../include pch)
if (NOT CPPREST_EXCLUDE_WEBSOCKETS)
include_directories(${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR})
endif()

set(SOURCES_COMMON
http/client/http_client_msg.cpp
Expand Down Expand Up @@ -67,8 +70,12 @@ elseif(WIN32)
httpapi.lib
Winhttp.lib
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNINGS} /Yustdafx.h /Zm200")
set_source_files_properties(pch/stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNINGS}")
if (${CMAKE_GENERATOR} MATCHES "Visual Studio .*")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Yustdafx.h /Zm200")
set_source_files_properties(pch/stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h")
endif()

if (BUILD_SHARED_LIBS)
add_definitions(-D_ASYNCRT_EXPORT -D_PPLX_EXPORT -D_USRDLL)
endif()
Expand Down
6 changes: 4 additions & 2 deletions Release/tests/common/TestRunner/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
include_directories(${Casablanca_INCLUDE_DIRS})
include_directories(${Casablanca_INCLUDE_DIRS}
../UnitTestpp
)

set(TR_SOURCES
test_runner.cpp
Expand Down Expand Up @@ -97,4 +99,4 @@ if(NOT IOS AND NOT ANDROID)
)
endif()
endif()
endif()
endif()
2 changes: 1 addition & 1 deletion Release/tests/functional/http/client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include_directories(
../utilities/include
../utilities/testlistener/include
${OPENSSL_INCLUDE_DIR}
${Casablanca_INCLUDE_DIRS}
)

set(SOURCES
Expand Down
4 changes: 4 additions & 0 deletions Release/tests/functional/streams/stdstream_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
#include "cpprest/filestream.h"
#include "cpprest/producerconsumerstream.h"

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

#if defined(__cplusplus_winrt)
using namespace Windows::Storage;
Expand Down Expand Up @@ -787,6 +789,7 @@ TEST(sync_on_async_close_with_exception)
}
}

#if !defined(_WIN32) || !defined(CPPREST_EXCLUDE_WEBSOCKETS)
TEST(ostream_full_throw_exception)
{
char tgt_buffer[5];
Expand All @@ -806,6 +809,7 @@ TEST(ostream_full_throw_exception)

VERIFY_THROWS(astream.read_to_end(os_streambuf).get(), std::exception);
}
#endif

}
}}}
Expand Down
26 changes: 14 additions & 12 deletions Release/tests/functional/websockets/client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
include_directories(../utilities)
if (NOT CPPREST_EXCLUDE_WEBSOCKETS)
include_directories(../utilities)

set(SOURCES
authentication_tests.cpp
client_construction.cpp
close_tests.cpp
error_tests.cpp
receive_msg_tests.cpp
send_msg_tests.cpp
)

set(SOURCES
authentication_tests.cpp
client_construction.cpp
close_tests.cpp
error_tests.cpp
receive_msg_tests.cpp
send_msg_tests.cpp
)

add_casablanca_test(${LIB}websocketclient_test SOURCES)
target_link_libraries(${LIB}websocketclient_test ${LIB}websockettest_utilities)
add_casablanca_test(${LIB}websocketclient_test SOURCES)
target_link_libraries(${LIB}websocketclient_test ${LIB}websockettest_utilities)
endif()
34 changes: 19 additions & 15 deletions Release/tests/functional/websockets/utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
include_directories(include)
if (NOT CPPREST_EXCLUDE_WEBSOCKETS)

if(WIN32)
add_definitions(-DWEBSOCKETTESTUTILITY_EXPORTS)
endif()
include_directories(include)

if(WIN32)
add_definitions(-DWEBSOCKETTESTUTILITY_EXPORTS)
endif()

set(SOURCES
test_websocket_server.cpp
)

add_library(${LIB}websockettest_utilities ${SOURCES})
target_link_libraries(${LIB}websockettest_utilities
${LIB}unittestpp
${LIB}common_utilities
${BOOST_LIBRARIES}
${Casablanca_LIBRARIES}
)

set(SOURCES
test_websocket_server.cpp
)

add_library(${LIB}websockettest_utilities ${SOURCES})
target_link_libraries(${LIB}websockettest_utilities
${LIB}unittestpp
${LIB}common_utilities
${BOOST_LIBRARIES}
${Casablanca_LIBRARIES}
)
endif()