IXWebSocket/test/CMakeLists.txt

99 lines
2.7 KiB
CMake
Raw Permalink Normal View History

2018-12-30 03:33:15 +01:00
#
# Author: Benjamin Sergeant
# Copyright (c) 2018 Machine Zone, Inc. All rights reserved.
#
cmake_minimum_required (VERSION 3.14)
2019-01-08 03:04:28 +01:00
project (ixwebsocket_unittest)
2018-12-30 03:33:15 +01:00
2020-11-16 06:08:45 +01:00
set (CMAKE_CXX_STANDARD 11)
2018-12-30 03:33:15 +01:00
option(USE_TLS "Add TLS support" ON)
2018-12-30 03:33:15 +01:00
2019-01-05 23:40:17 +01:00
# Shared sources
2020-11-11 20:11:34 +01:00
set (TEST_TARGET_NAMES
IXSocketTest
IXSocketConnectTest
IXWebSocketServerTest
IXWebSocketTestConnectionDisconnection
IXUrlParserTest
# IXHttpClientTest ## FIXME httpbin.org does not seem normal
2020-11-11 20:11:34 +01:00
IXUnityBuildsTest
IXHttpTest
IXDNSLookupTest
IXWebSocketSubProtocolTest
# IXWebSocketBroadcastTest ## FIXME was depending on cobra / take a broadcast server from ws
IXStrCaseCompareTest
IXExponentialBackoffTest
IXWebSocketCloseTest
2018-12-30 03:33:15 +01:00
)
2019-01-05 23:40:17 +01:00
# Some unittest don't work on windows yet
# Windows without TLS does not have hmac yet
if (UNIX)
2020-11-11 20:11:34 +01:00
list(APPEND TEST_TARGET_NAMES
2020-12-26 21:44:06 +01:00
# Fail on Windows in CI probably because the pathing is wrong and
# some resource files cannot be found
IXHttpServerTest
IXWebSocketChatTest
)
endif()
if (USE_ZLIB)
list(APPEND TEST_TARGET_NAMES
IXWebSocketPerMessageDeflateCompressorTest
2019-01-05 23:40:17 +01:00
)
endif()
# Ping test fails intermittently, disabling them for now
# IXWebSocketPingTest.cpp
# IXWebSocketPingTimeoutTest.cpp
# IXWebSocketLeakTest.cpp # commented until we have a fix for #224 /
# that was was fixed but now the test does not compile
# Disable tests for now that are failing or not reliable
2020-11-11 20:11:34 +01:00
add_library(ixwebsocket_test)
target_sources(ixwebsocket_test PRIVATE
${JSONCPP_SOURCES}
test_runner.cpp
IXTest.cpp
../third_party/msgpack11/msgpack11.cpp
)
target_compile_definitions(ixwebsocket_test PRIVATE ${TEST_PROGRAMS_DEFINITIONS})
target_include_directories(ixwebsocket_test PRIVATE
${PROJECT_SOURCE_DIR}/Catch2/single_include
../third_party
)
target_link_libraries(ixwebsocket_test ixwebsocket)
target_link_libraries(ixwebsocket_test spdlog)
foreach(TEST_TARGET_NAME ${TEST_TARGET_NAMES})
add_executable(${TEST_TARGET_NAME}
${TEST_TARGET_NAME}.cpp
)
target_include_directories(${TEST_TARGET_NAME} PRIVATE
${PROJECT_SOURCE_DIR}/Catch2/single_include
../third_party
../third_party/msgpack11
)
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE SPDLOG_COMPILED_LIB=1)
if (APPLE AND USE_TLS)
target_link_libraries(${TEST_TARGET_NAME} "-framework foundation" "-framework security")
endif()
# library with the most dependencies come first
2020-11-11 20:23:51 +01:00
target_link_libraries(${TEST_TARGET_NAME} ixwebsocket_test)
2020-11-11 20:11:34 +01:00
target_link_libraries(${TEST_TARGET_NAME} ixwebsocket)
target_link_libraries(${TEST_TARGET_NAME} spdlog)
add_test(NAME ${TEST_TARGET_NAME}
COMMAND ${TEST_TARGET_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
2020-11-11 20:11:34 +01:00
endforeach()