From 834491eebc5222ec4d5a54b29c0f7afac46e59ec Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Tue, 12 Apr 2016 15:45:17 -0700 Subject: [PATCH] Improve CMake support for windows. Added experimental support for building UWP. Added support for accessing NuGet packages. Renamed project to 'cpprest'. Removed superfluous ${LIB} prefix on all libs. Enabled MultiToolTask for android build. Added header files to the cpprest library, improving IDE support. --- .gitignore | 4 +- Release/CMakeLists.txt | 61 ++++++++++---- Release/samples/BingRequest/CMakeLists.txt | 6 +- Release/samples/BlackJack/CMakeLists.txt | 8 +- Release/samples/Oauth1Client/CMakeLists.txt | 15 ++-- Release/samples/Oauth2Client/CMakeLists.txt | 13 +-- Release/samples/SearchFile/CMakeLists.txt | 6 +- Release/src/CMakeLists.txt | 83 +++++++++++++------ .../casablanca140.android.vcxproj | 8 ++ .../tests/common/TestRunner/CMakeLists.txt | 73 +++++++++------- .../tests/common/UnitTestpp/CMakeLists.txt | 8 +- Release/tests/common/utilities/CMakeLists.txt | 6 +- .../functional/http/client/CMakeLists.txt | 2 +- .../functional/http/listener/CMakeLists.txt | 42 +++++----- .../functional/http/utilities/CMakeLists.txt | 8 +- Release/tests/functional/json/CMakeLists.txt | 6 +- .../functional/pplx/pplx_test/CMakeLists.txt | 2 +- .../tests/functional/streams/CMakeLists.txt | 11 ++- .../functional/websockets/CMakeLists.txt | 23 ++++- .../websockets/client/CMakeLists.txt | 6 +- .../websockets/utilities/CMakeLists.txt | 21 ----- 21 files changed, 258 insertions(+), 154 deletions(-) delete mode 100644 Release/tests/functional/websockets/utilities/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 8cba58c6d3..d0ff65b0ac 100644 --- a/.gitignore +++ b/.gitignore @@ -63,4 +63,6 @@ Intermediate/ **/packages/* # except build/, which is used as an MSBuild target. !**/packages/build/ - +.vs/ +# Ignore cmake building directories +build.*/ diff --git a/Release/CMakeLists.txt b/Release/CMakeLists.txt index e229106951..cbe840b663 100644 --- a/Release/CMakeLists.txt +++ b/Release/CMakeLists.txt @@ -1,6 +1,6 @@ set(CMAKE_LEGACY_CYGWIN_WIN32 0) cmake_minimum_required(VERSION 2.6) -project(casablanca) +project(cpprest) enable_testing() @@ -8,6 +8,8 @@ set(WARNINGS) set(ANDROID_STL_FLAGS) option(WERROR "Threat Warnings as Errors" ON) +option(BUILD_TESTS "Build tests." ON) +option(CPPREST_EXCLUDE_WEBSOCKETS "Exclude websockets functionality." OFF) # Platform (not compiler) specific settings if(IOS) @@ -27,7 +29,6 @@ if(IOS) set(BUILD_SHARED_LIBS OFF) set(BUILD_SAMPLES OFF) - option(BUILD_TESTS "Build tests." ON) elseif(ANDROID) set(Boost_COMPILER "-clang") set(Boost_USE_STATIC_LIBS ON) @@ -73,7 +74,6 @@ elseif(ANDROID) option(BUILD_SHARED_LIBS "Build shared Libraries." OFF) set(BUILD_SAMPLES OFF) - option(BUILD_TESTS "Build tests." ON) elseif(UNIX) # This includes OSX find_package(Boost 1.54 REQUIRED COMPONENTS random chrono system thread regex filesystem) find_package(Threads REQUIRED) @@ -88,7 +88,6 @@ elseif(UNIX) # This includes OSX find_package(OpenSSL 1.0.0 REQUIRED) option(BUILD_SHARED_LIBS "Build shared Libraries." ON) - option(BUILD_TESTS "Build tests." ON) option(BUILD_SAMPLES "Build samples." ON) option(CASA_INSTALL_HEADERS "Install header files." ON) if(CASA_INSTALL_HEADERS) @@ -101,9 +100,7 @@ elseif(UNIX) # This includes OSX endif() 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) @@ -117,11 +114,31 @@ elseif(WIN32) endif() add_definitions(${Casablanca_DEFINITIONS} -D_WINSOCK_DEPRECATED_NO_WARNINGS -DWIN32) - 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) + if (NOT CPPREST_EXCLUDE_WEBSOCKETS) + set(NUGET_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../packages") + set(PACKAGE_PATHS) + list(APPEND PACKAGE_PATHS "${NUGET_PATH}/boost.1.58.0.0/") + list(APPEND PACKAGE_PATHS "${NUGET_PATH}/boost_system-vc140.1.58.0-vs140rc/") + list(APPEND PACKAGE_PATHS "${NUGET_PATH}/boost_date_time-vc140.1.58.0-vs140rc/") + list(APPEND PACKAGE_PATHS "${NUGET_PATH}/boost_regex-vc140.1.58.0-vs140rc/") + list(APPEND PACKAGE_PATHS "${NUGET_PATH}/openssl.v140.windesktop.msvcstl.static.rt-dyn.x64.1.0.2.1/") + list(APPEND PACKAGE_PATHS "${NUGET_PATH}/zlib.v140.windesktop.msvcstl.static.rt-dyn.1.2.8.8/") + + if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE) + find_library(Boost_SYSTEM_LIBRARY libboost_system-vc140-mt-gd-1_58.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/address-model-64/lib) + find_library(Boost_DATE_TIME_LIBRARY libboost_date_time-vc140-mt-gd-1_58.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/address-model-64/lib) + find_library(Boost_REGEX_LIBRARY libboost_regex-vc140-mt-gd-1_58.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/address-model-64/lib) + set(Boost_LIBRARIES ${Boost_REGEX_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_DATE_TIME_LIBRARY}) + + find_library(OpenSSL_libeay_LIBRARY libeay32.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/v140/windesktop/msvcstl/static/rt-dyn/x64/debug) + find_library(OpenSSL_ssleay_LIBRARY ssleay32.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/v140/windesktop/msvcstl/static/rt-dyn/x64/debug) + find_library(ZLIB_LIBRARY zlibstaticd.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/v140/windesktop/msvcstl/static/rt-dyn/x64/debug) + set(OPENSSL_LIBRARIES ${OpenSSL_ssleay_LIBRARY} ${OpenSSL_libeay_LIBRARY} ${ZLIB_LIBRARY}) + + set(OPENSSL_INCLUDE_DIR "${NUGET_PATH}/openssl.v140.windesktop.msvcstl.static.rt-dyn.x64.1.0.2.1/build/native/include") + endif() + + set(Boost_INCLUDE_DIR "${NUGET_PATH}/boost.1.58.0.0/lib/native/include") endif() else() message(FATAL_ERROR "-- Unsupported Build Platform.") @@ -160,11 +177,20 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") message("-- Setting msvc options") set(WARNINGS) + set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4264") + add_compile_options(/bigobj) + if (WINDOWS_STORE OR WINDOWS_PHONE) + add_compile_options(/ZW) + endif() else() message("-- Unknown compiler, success is doubtful.") message("CMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}") endif() +if (CPPREST_EXCLUDE_WEBSOCKETS) + add_definitions(-DCPPREST_EXCLUDE_WEBSOCKETS=1) +endif() + # Reconfigure final output directory set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries) @@ -190,9 +216,8 @@ else() set(Casablanca_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include) endif() -set(Casablanca_LIBRARY ${LIB}cpprest) -set(Casablanca_LIBRARIES ${Casablanca_LIBRARY} - ${Boost_LIBRARIES}) +set(Casablanca_LIBRARY cpprest) +set(Casablanca_LIBRARIES cpprest ${Boost_LIBRARIES}) # Everything in the project needs access to the casablanca include directories include_directories(${Casablanca_INCLUDE_DIRS}) @@ -203,16 +228,16 @@ function(add_casablanca_test NAME SOURCES_VAR) message("-- Added test library ${NAME}") if (NOT TEST_LIBRARY_TARGET_TYPE STREQUAL "OBJECT") target_link_libraries(${NAME} - ${LIB}httptest_utilities - ${LIB}common_utilities - ${LIB}unittestpp + httptest_utilities + common_utilities + unittestpp ${Casablanca_LIBRARIES} ${ANDROID_STL_FLAGS} ) if (BUILD_SHARED_LIBS) add_test(NAME ${NAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - COMMAND test_runner lib${NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} + COMMAND test_runner $ ) endif() endif() diff --git a/Release/samples/BingRequest/CMakeLists.txt b/Release/samples/BingRequest/CMakeLists.txt index f4de12f102..261078cb76 100644 --- a/Release/samples/BingRequest/CMakeLists.txt +++ b/Release/samples/BingRequest/CMakeLists.txt @@ -1,2 +1,4 @@ -add_executable(BingRequest bingrequest.cpp) -target_link_libraries(BingRequest ${Casablanca_LIBRARIES}) \ No newline at end of file +if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE) + add_executable(BingRequest bingrequest.cpp) + target_link_libraries(BingRequest ${Casablanca_LIBRARIES}) +endif() \ No newline at end of file diff --git a/Release/samples/BlackJack/CMakeLists.txt b/Release/samples/BlackJack/CMakeLists.txt index be0ea12e9e..422ec4c4cc 100644 --- a/Release/samples/BlackJack/CMakeLists.txt +++ b/Release/samples/BlackJack/CMakeLists.txt @@ -1,2 +1,6 @@ -add_subdirectory(BlackJack_Server) -add_subdirectory(BlackJack_Client) +if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE) + add_subdirectory(BlackJack_Server) + add_subdirectory(BlackJack_Client) +else() + # TODO: add BlackJack_UIClient +endif() diff --git a/Release/samples/Oauth1Client/CMakeLists.txt b/Release/samples/Oauth1Client/CMakeLists.txt index a67ab7f547..ee8c82f2dc 100644 --- a/Release/samples/Oauth1Client/CMakeLists.txt +++ b/Release/samples/Oauth1Client/CMakeLists.txt @@ -1,7 +1,8 @@ - -add_executable(oauth1client - Oauth1Client.cpp - stdafx.cpp - ) - -target_link_libraries(oauth1client ${Casablanca_LIBRARIES}) +if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE) + add_executable(oauth1client + Oauth1Client.cpp + stdafx.cpp + ) + + target_link_libraries(oauth1client ${Casablanca_LIBRARIES}) +endif() \ No newline at end of file diff --git a/Release/samples/Oauth2Client/CMakeLists.txt b/Release/samples/Oauth2Client/CMakeLists.txt index 0ed8385cf6..212afb2001 100644 --- a/Release/samples/Oauth2Client/CMakeLists.txt +++ b/Release/samples/Oauth2Client/CMakeLists.txt @@ -1,7 +1,8 @@ +if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE) + add_executable(oauth2client + Oauth2Client.cpp + stdafx.cpp + ) -add_executable(oauth2client - Oauth2Client.cpp - stdafx.cpp - ) - -target_link_libraries(oauth2client ${Casablanca_LIBRARIES}) + target_link_libraries(oauth2client ${Casablanca_LIBRARIES}) +endif() \ No newline at end of file diff --git a/Release/samples/SearchFile/CMakeLists.txt b/Release/samples/SearchFile/CMakeLists.txt index e1313e6405..d933df6781 100644 --- a/Release/samples/SearchFile/CMakeLists.txt +++ b/Release/samples/SearchFile/CMakeLists.txt @@ -1,2 +1,4 @@ -add_executable(SearchFile searchfile.cpp) -target_link_libraries(SearchFile ${Casablanca_LIBRARIES}) +if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE) + add_executable(SearchFile searchfile.cpp) + target_link_libraries(SearchFile ${Casablanca_LIBRARIES}) +endif() diff --git a/Release/src/CMakeLists.txt b/Release/src/CMakeLists.txt index ade7c93b5b..51ea088418 100644 --- a/Release/src/CMakeLists.txt +++ b/Release/src/CMakeLists.txt @@ -3,8 +3,21 @@ if (NOT CPPREST_EXCLUDE_WEBSOCKETS) include_directories(${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR}) endif() +add_definitions(${WARNINGS}) + +file(GLOB SOURCES_CPPREST "../include/cpprest/*.h") +file(GLOB SOURCES_PPLX "../include/pplx/*.h") +file(GLOB SOURCES_DETAILS "../include/cpprest/details/*.h") +source_group("Header Files\\cpprest" FILES ${SOURCES_CPPREST}) +source_group("Header Files\\pplx" FILES ${SOURCES_PPLX}) +source_group("Header Files\\cpprest\\details" FILES ${SOURCES_DETAILS}) set(SOURCES_COMMON + ${SOURCES_CPPREST} + ${SOURCES_PPLX} + ${SOURCES_DETAILS} + http/client/http_client.cpp http/client/http_client_msg.cpp + http/client/http_client_impl.h http/client/x509_cert_utilities.cpp http/common/http_helpers.cpp http/common/http_msg.cpp @@ -25,7 +38,6 @@ set(SOURCES_COMMON utilities/web_utilities.cpp websockets/client/ws_msg.cpp websockets/client/ws_client.cpp - websockets/client/ws_client_wspp.cpp ) # THE ORDER OF FILES IS VERY /VERY/ IMPORTANT @@ -37,6 +49,9 @@ if(UNIX) http/client/http_client_asio.cpp http/listener/http_server_asio.cpp ) + if (NOT CPPREST_EXCLUDE_WEBSOCKETS) + list(APPEND SOURCES websockets/client/ws_client_wspp.cpp) + endif() if(APPLE) list(APPEND SOURCES pplx/pplxapple.cpp @@ -55,45 +70,61 @@ if(UNIX) endif() if(WERROR) - set(WARNINGS "${WARNINGS} -Werror") + add_compile_options(-Werror) endif() - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNINGS} -pedantic") + add_compile_options(-pedantic) elseif(WIN32) - set(SOURCES - ${SOURCES_COMMON} - http/client/http_client_winhttp.cpp - http/client/x509_cert_utilities_win32.cpp - http/listener/http_server_httpsys.cpp + set(SOURCES ${SOURCES_COMMON} pplx/pplxwin.cpp - streams/fileio_win32.cpp - pch/stdafx.cpp ) - set(EXTRALINKS - bcrypt.lib - crypt32.lib - httpapi.lib - Winhttp.lib - ) - 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") + if (WINDOWS_PHONE OR WINDOWS_STORE) + list(APPEND SOURCES + http/client/http_client_winrt.cpp + streams/fileio_winrt.cpp + websockets/client/ws_client_winrt.cpp + ) + else() + list(APPEND SOURCES + http/client/http_client_winhttp.cpp + http/listener/http_server_httpsys.cpp + streams/fileio_win32.cpp + ) + if (NOT CPPREST_EXCLUDE_WEBSOCKETS) + list(APPEND SOURCES websockets/client/ws_client_wspp.cpp) + endif() + set(EXTRALINKS + bcrypt.lib + crypt32.lib + httpapi.lib + Winhttp.lib + ) endif() + add_compile_options(/Yustdafx.h /Zm200) + set_source_files_properties(pch/stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h") + + if (NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio .*") + set_property(SOURCE pch/stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") + set_property(SOURCE ${SOURCES} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") + endif() + + list(APPEND SOURCES pch/stdafx.cpp pch/stdafx.h) if (BUILD_SHARED_LIBS) add_definitions(-D_ASYNCRT_EXPORT -D_PPLX_EXPORT -D_USRDLL) endif() endif() -add_library(${Casablanca_LIBRARY} ${SOURCES}) +add_library(cpprest ${SOURCES}) -target_link_libraries(${Casablanca_LIBRARY} +target_link_libraries(cpprest ${CMAKE_THREAD_LIBS_INIT} ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_ATOMIC_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_RANDOM_LIBRARY} + ${Boost_REGEX_LIBRARY} + ${Boost_DATE_TIME_LIBRARY} ${EXTRALINKS} ${Boost_FRAMEWORK} ${OPENSSL_LIBRARIES} @@ -107,17 +138,17 @@ set (CPPREST_VERSION_MINOR 8) set (CPPREST_VERSION_REVISION 0) if(WIN32) - set_target_properties(${Casablanca_LIBRARY} PROPERTIES - OUTPUT_NAME "${Casablanca_LIBRARY}_${CPPREST_VERSION_MAJOR}_${CPPREST_VERSION_MINOR}") + set_target_properties(cpprest PROPERTIES + OUTPUT_NAME "cpprest_${CPPREST_VERSION_MAJOR}_${CPPREST_VERSION_MINOR}") elseif(ANDROID) # Do not use SOVERSION on android. It is completely unsupported (and causes problems). # Perhaps revisit in the future? (NDK r9d, 8/7/14) else() - set_target_properties(${Casablanca_LIBRARY} PROPERTIES + set_target_properties(cpprest PROPERTIES SOVERSION ${CPPREST_VERSION_MAJOR}.${CPPREST_VERSION_MINOR}) install( - TARGETS ${Casablanca_LIBRARY} + TARGETS cpprest LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) diff --git a/Release/src/build/vs14.android/casablanca140.android.vcxproj b/Release/src/build/vs14.android/casablanca140.android.vcxproj index 72b51b7e3f..6e7d82feaf 100644 --- a/Release/src/build/vs14.android/casablanca140.android.vcxproj +++ b/Release/src/build/vs14.android/casablanca140.android.vcxproj @@ -60,8 +60,10 @@ + true + true @@ -113,6 +115,12 @@ $(CppRestBaseFileName)140$(DebugFileSuffix)_android_$(CppRestSDKVersionFileSuffix) + + true + + + true + diff --git a/Release/tests/common/TestRunner/CMakeLists.txt b/Release/tests/common/TestRunner/CMakeLists.txt index 19bd2162aa..29669d277a 100644 --- a/Release/tests/common/TestRunner/CMakeLists.txt +++ b/Release/tests/common/TestRunner/CMakeLists.txt @@ -7,7 +7,13 @@ set(TR_SOURCES test_module_loader.cpp ) -add_definitions(-DDESKTOP_TEST_RUNNER) +if (WIN32) + if (WINDOWS_STORE OR WINDOWS_PHONE) + add_definitions(-DWINRT_TEST_RUNNER -D_CONSOLE) + else() + add_definitions(-DDESKTOP_TEST_RUNNER) + endif() +endif() if(NOT IOS AND NOT ANDROID) if(BUILD_SHARED_LIBS) @@ -18,7 +24,7 @@ if(NOT IOS AND NOT ANDROID) target_link_libraries(test_runner ${Boost_LIBRARIES} - ${LIB}unittestpp + unittestpp ${CMAKE_DL_LIBS} ) else() @@ -30,28 +36,28 @@ if(NOT IOS AND NOT ANDROID) target_link_libraries(test_runner ${Boost_LIBRARIES} - ${LIB}unittestpp + unittestpp ${CMAKE_DL_LIBS} -Wl,-force_load - ${LIB}httpclient_test + httpclient_test -Wl,-force_load - ${LIB}json_test + json_test -Wl,-force_load - ${LIB}uri_test + uri_test -Wl,-force_load - ${LIB}pplx_test + pplx_test -Wl,-force_load - ${LIB}httplistener_test + httplistener_test -Wl,-force_load - ${LIB}streams_test + streams_test -Wl,-force_load - ${LIB}utils_test + utils_test ) elseif(UNIX) add_executable(test_runner @@ -61,36 +67,47 @@ if(NOT IOS AND NOT ANDROID) target_link_libraries(test_runner ${Boost_LIBRARIES} - ${LIB}unittestpp + unittestpp ${CMAKE_DL_LIBS} -Wl,--whole-archive - ${LIB}httpclient_test - ${LIB}json_test - ${LIB}uri_test - ${LIB}pplx_test - ${LIB}httplistener_test - ${LIB}streams_test - ${LIB}utils_test + httpclient_test + json_test + uri_test + pplx_test + httplistener_test + streams_test + utils_test -Wl,--no-whole-archive ) else() # In order to achieve --whole-archive on windows, we link all the test files into the test_runner directly # This means that the tests themselves must be created as "OBJECT" libraries - add_executable(test_runner + set(SOURCES test_runner.cpp - test_module_loader.cpp - $ - $ - $ - $ - $ - $ - $ + $ + $ + $ + $ + $ + $ + ) + if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE) + list(APPEND SOURCES + test_module_loader.cpp + $ ) + endif() + add_executable(test_runner ${SOURCES}) target_link_libraries(test_runner - ${LIB}unittestpp + unittestpp + common_utilities + httptest_utilities + cpprest ${CMAKE_DL_LIBS} ) + if (WINDOWS_STORE) + target_link_libraries(test_runner ucrtd.lib vcruntimed.lib vccorlibd.lib msvcrtd.lib msvcprtd.lib concrtd.lib RuntimeObject.lib) + endif() endif() endif() endif() diff --git a/Release/tests/common/UnitTestpp/CMakeLists.txt b/Release/tests/common/UnitTestpp/CMakeLists.txt index c8e229dd7e..2c8205aa13 100644 --- a/Release/tests/common/UnitTestpp/CMakeLists.txt +++ b/Release/tests/common/UnitTestpp/CMakeLists.txt @@ -38,15 +38,15 @@ set(TEST_SOURCES ) if(UNIX) - set(UT_SOURCES ${UT_SOURCES} + list(APPEND UT_SOURCES src/Posix/SignalTranslator.cpp src/Posix/TimeHelpers.cpp ) elseif(WIN32) - set(UT_SOURCES ${UT_SOURCES} src/Win32/TimeHelpers.cpp) + list(APPEND UT_SOURCES src/Win32/TimeHelpers.cpp) add_definitions(-DWIN32 -D_USRDLL -D_CRT_SECURE_NO_DEPRECATE -DUNITTEST_DLL_EXPORT) endif() -add_library(${LIB}unittestpp ${UT_SOURCES}) -target_link_libraries(${LIB}unittestpp ${ANDROID_STL_FLAGS}) \ No newline at end of file +add_library(unittestpp ${UT_SOURCES}) +target_link_libraries(unittestpp ${ANDROID_STL_FLAGS}) \ No newline at end of file diff --git a/Release/tests/common/utilities/CMakeLists.txt b/Release/tests/common/utilities/CMakeLists.txt index 0b5996c834..6ff564f84e 100644 --- a/Release/tests/common/utilities/CMakeLists.txt +++ b/Release/tests/common/utilities/CMakeLists.txt @@ -4,14 +4,14 @@ if(WIN32) add_definitions(-DCOMMONUTILITIES_EXPORTS) endif() -add_library(${LIB}common_utilities +add_library(common_utilities os_utilities.cpp stdafx.cpp ) -target_link_libraries(${LIB}common_utilities +target_link_libraries(common_utilities ${Casablanca_LIBRARY} - ${LIB}unittestpp + unittestpp ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} ) diff --git a/Release/tests/functional/http/client/CMakeLists.txt b/Release/tests/functional/http/client/CMakeLists.txt index dd9a2b89d0..d18060894f 100644 --- a/Release/tests/functional/http/client/CMakeLists.txt +++ b/Release/tests/functional/http/client/CMakeLists.txt @@ -29,4 +29,4 @@ set(SOURCES http_client_fuzz_tests.cpp ) -add_casablanca_test(${LIB}httpclient_test SOURCES) +add_casablanca_test(httpclient_test SOURCES) diff --git a/Release/tests/functional/http/listener/CMakeLists.txt b/Release/tests/functional/http/listener/CMakeLists.txt index 209e4026d8..270b89de25 100644 --- a/Release/tests/functional/http/listener/CMakeLists.txt +++ b/Release/tests/functional/http/listener/CMakeLists.txt @@ -1,20 +1,22 @@ -include_directories (../utilities/include) - -set (SOURCES - building_response_tests.cpp - connections_and_errors.cpp - header_tests.cpp - listener_construction_tests.cpp - reply_helper_tests.cpp - request_extract_tests.cpp - request_handler_tests.cpp - request_relative_uri_tests.cpp - request_stream_tests.cpp - requests_tests.cpp - response_stream_tests.cpp - status_code_reason_phrase_tests.cpp - to_string_tests.cpp - stdafx.cpp -) - -add_casablanca_test(${LIB}httplistener_test SOURCES) +if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE) + include_directories (../utilities/include) + + set (SOURCES + building_response_tests.cpp + connections_and_errors.cpp + header_tests.cpp + listener_construction_tests.cpp + reply_helper_tests.cpp + request_extract_tests.cpp + request_handler_tests.cpp + request_relative_uri_tests.cpp + request_stream_tests.cpp + requests_tests.cpp + response_stream_tests.cpp + status_code_reason_phrase_tests.cpp + to_string_tests.cpp + stdafx.cpp + ) + + add_casablanca_test(httplistener_test SOURCES) +endif () \ No newline at end of file diff --git a/Release/tests/functional/http/utilities/CMakeLists.txt b/Release/tests/functional/http/utilities/CMakeLists.txt index 08f6bcf351..a36e9614e3 100644 --- a/Release/tests/functional/http/utilities/CMakeLists.txt +++ b/Release/tests/functional/http/utilities/CMakeLists.txt @@ -11,10 +11,10 @@ set(SOURCES test_server_utilities.cpp ) -add_library(${LIB}httptest_utilities ${SOURCES}) -target_link_libraries(${LIB}httptest_utilities - ${LIB}unittestpp - ${LIB}common_utilities +add_library(httptest_utilities ${SOURCES}) +target_link_libraries(httptest_utilities + unittestpp + common_utilities ${BOOST_LIBRARIES} ${Casablanca_LIBRARIES} ) diff --git a/Release/tests/functional/json/CMakeLists.txt b/Release/tests/functional/json/CMakeLists.txt index c83741c940..f6d6ff7587 100644 --- a/Release/tests/functional/json/CMakeLists.txt +++ b/Release/tests/functional/json/CMakeLists.txt @@ -3,9 +3,11 @@ set (SOURCES negative_parsing_tests.cpp parsing_tests.cpp to_as_and_operators_tests.cpp - fuzz_tests.cpp iterator_tests.cpp json_numbers_tests.cpp ) +if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE) + list(APPEND SOURCES fuzz_tests.cpp) +endif() -add_casablanca_test(${LIB}json_test SOURCES) +add_casablanca_test(json_test SOURCES) diff --git a/Release/tests/functional/pplx/pplx_test/CMakeLists.txt b/Release/tests/functional/pplx/pplx_test/CMakeLists.txt index 000442f7ab..01c56f7522 100644 --- a/Release/tests/functional/pplx/pplx_test/CMakeLists.txt +++ b/Release/tests/functional/pplx/pplx_test/CMakeLists.txt @@ -5,4 +5,4 @@ set(SOURCES stdafx.cpp ) -add_casablanca_test(${LIB}pplx_test SOURCES) +add_casablanca_test(pplx_test SOURCES) diff --git a/Release/tests/functional/streams/CMakeLists.txt b/Release/tests/functional/streams/CMakeLists.txt index 72ce8177dd..c7e1147966 100644 --- a/Release/tests/functional/streams/CMakeLists.txt +++ b/Release/tests/functional/streams/CMakeLists.txt @@ -4,6 +4,13 @@ set(SOURCES memstream_tests.cpp ostream_tests.cpp stdstream_tests.cpp - fuzz_tests.cpp ) -add_casablanca_test(${LIB}streams_test SOURCES) +if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE) + list(APPEND SOURCES fuzz_tests.cpp) + if (WIN32) + list(APPEND SOURCES CppSparseFile.cpp) + endif () +else () + list(APPEND SOURCES winrt_interop_tests.cpp) +endif () +add_casablanca_test(streams_test SOURCES) diff --git a/Release/tests/functional/websockets/CMakeLists.txt b/Release/tests/functional/websockets/CMakeLists.txt index 415f5510fb..cd373a50d5 100644 --- a/Release/tests/functional/websockets/CMakeLists.txt +++ b/Release/tests/functional/websockets/CMakeLists.txt @@ -1,2 +1,21 @@ -add_subdirectory(client) -add_subdirectory(utilities) +if (NOT CPPREST_EXCLUDE_WEBSOCKETS) + + include_directories(utilities/include) + + set(SOURCES + utilities/test_websocket_server.cpp + ) + + add_library(websockettest_utilities ${TEST_LIBRARY_TARGET_TYPE} ${SOURCES}) + target_compile_definitions(websockettest_utilities PRIVATE -DWEBSOCKETTESTUTILITY_EXPORTS) + if (NOT TEST_LIBRARY_TARGET_TYPE STREQUAL "OBJECT") + target_link_libraries(websockettest_utilities + unittestpp + common_utilities + ${BOOST_LIBRARIES} + ${Casablanca_LIBRARIES} + ) + endif() + + add_subdirectory(client) +endif() diff --git a/Release/tests/functional/websockets/client/CMakeLists.txt b/Release/tests/functional/websockets/client/CMakeLists.txt index e4bd7a3625..9cb347ebb5 100644 --- a/Release/tests/functional/websockets/client/CMakeLists.txt +++ b/Release/tests/functional/websockets/client/CMakeLists.txt @@ -10,6 +10,8 @@ if (NOT CPPREST_EXCLUDE_WEBSOCKETS) send_msg_tests.cpp ) - add_casablanca_test(${LIB}websocketclient_test SOURCES) - target_link_libraries(${LIB}websocketclient_test ${LIB}websockettest_utilities) + add_casablanca_test(websocketclient_test SOURCES) + if (NOT TEST_LIBRARY_TARGET_TYPE STREQUAL "OBJECT") + target_link_libraries(websocketclient_test websockettest_utilities) + endif() endif() \ No newline at end of file diff --git a/Release/tests/functional/websockets/utilities/CMakeLists.txt b/Release/tests/functional/websockets/utilities/CMakeLists.txt deleted file mode 100644 index e1c5b1edba..0000000000 --- a/Release/tests/functional/websockets/utilities/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -if (NOT CPPREST_EXCLUDE_WEBSOCKETS) - - 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} - ) - -endif() \ No newline at end of file