-set(TEST_APP_LIST)
-if (NOT LWS_WITHOUT_TESTAPPS)
- #
- # Helper function for adding a test app.
- #
- macro(create_test_app TEST_NAME MAIN_SRC S2 S3 S4 S5 S6)
-
- set(TEST_SRCS ${MAIN_SRC})
- set(TEST_HDR)
- if ("${S2}" STREQUAL "")
- else()
- list(APPEND TEST_SRCS ${S2})
- endif()
- if ("${S3}" STREQUAL "")
- else()
- list(APPEND TEST_SRCS ${S3})
- endif()
- if ("${S4}" STREQUAL "")
- else()
- list(APPEND TEST_SRCS ${S4})
- endif()
- if ("${S5}" STREQUAL "")
- else()
- list(APPEND TEST_SRCS ${S5})
- endif()
- if ("${S6}" STREQUAL "")
- else()
- list(APPEND TEST_SRCS ${S6})
- endif()
- if (WIN32)
- list(APPEND TEST_SRCS
- ${WIN32_HELPERS_PATH}/getopt.c
- ${WIN32_HELPERS_PATH}/getopt_long.c
- ${WIN32_HELPERS_PATH}/gettimeofday.c
- )
-
- list(APPEND TEST_HDR
- ${WIN32_HELPERS_PATH}/getopt.h
- ${WIN32_HELPERS_PATH}/gettimeofday.h
- )
- endif(WIN32)
-
- source_group("Headers Private" FILES ${TEST_HDR})
- source_group("Sources" FILES ${TEST_SRCS})
- add_executable(${TEST_NAME} ${TEST_SRCS} ${TEST_HDR})
-
- if (LWS_LINK_TESTAPPS_DYNAMIC)
- if (NOT LWS_WITH_SHARED)
- message(FATAL_ERROR "Build of the shared library is disabled. LWS_LINK_TESTAPPS_DYNAMIC must be combined with LWS_WITH_SHARED.")
- endif()
- target_link_libraries(${TEST_NAME} websockets_shared)
- add_dependencies(${TEST_NAME} websockets_shared)
- else()
- if (NOT LWS_WITH_STATIC)
- message(FATAL_ERROR "Build of the static library is disabled. Disabled LWS_LINK_TESTAPPS_DYNAMIC must be combined with LWS_WITH_STATIC.")
- endif()
- target_link_libraries(${TEST_NAME} websockets)
- add_dependencies(${TEST_NAME} websockets)
- endif()
-
- # Set test app specific defines.
- set_property(TARGET ${TEST_NAME}
- PROPERTY COMPILE_DEFINITIONS
- INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/share"
- )
-
- # Prefix the binary names with libwebsockets.
- set_target_properties(${TEST_NAME}
- PROPERTIES
- OUTPUT_NAME libwebsockets-${TEST_NAME})
-
- # Add to the list of tests.
- list(APPEND TEST_APP_LIST ${TEST_NAME})
- endmacro()
-
- if (LWS_WITH_SSL AND NOT LWS_USE_WOLFSSL)
- message("Searching for OpenSSL executable and dlls")
- find_package(OpenSSLbins)
- message("OpenSSL executable: ${OPENSSL_EXECUTABLE}")
- endif()
-
- if (UNIX AND LWS_WITH_PLUGINS)
- set(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
- target_link_libraries(websockets dl)
- endif()
-
- if (NOT LWS_WITHOUT_SERVER)
- #
- # test-server
- #
- if (NOT LWS_WITHOUT_TEST_SERVER)
- create_test_app(test-server "test-server/test-server.c"
- "test-server/test-server-http.c"
- "test-server/test-server-dumb-increment.c"
- "test-server/test-server-mirror.c"
- "test-server/test-server-status.c"
- "test-server/test-server-echogen.c")
- if (UNIX)
- create_test_app(test-fuzxy "test-server/fuzxy.c"
- ""
- ""
- ""
- ""
- "")
- endif()
- if (UNIX AND NOT ((CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")))
- create_test_app(test-server-pthreads
- "test-server/test-server-pthreads.c"
- "test-server/test-server-http.c"
- "test-server/test-server-dumb-increment.c"
- "test-server/test-server-mirror.c"
- "test-server/test-server-status.c"
- "test-server/test-server-echogen.c")
- endif()
- if (NOT ((CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
- AND LWS_WITH_LIBEV)
- create_test_app(test-server-libev
- "test-server/test-server-libev.c"
- "test-server/test-server-http.c"
- "test-server/test-server-dumb-increment.c"
- "test-server/test-server-mirror.c"
- "test-server/test-server-status.c"
- "test-server/test-server-echogen.c")
- endif()
- if (NOT ((CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
- AND LWS_WITH_LIBUV)
- create_test_app(test-server-libuv
- "test-server/test-server-libuv.c"
- "test-server/test-server-http.c"
- "test-server/test-server-dumb-increment.c"
- "test-server/test-server-mirror.c"
- "test-server/test-server-status.c"
- "test-server/test-server-echogen.c")
- endif()
- endif()
-
- #
- # test-server-extpoll
- #
- if (NOT LWS_WITHOUT_TEST_SERVER_EXTPOLL)
- create_test_app(test-server-extpoll "test-server/test-server.c"
- "test-server/test-server-http.c"
- "test-server/test-server-dumb-increment.c"
- "test-server/test-server-mirror.c"
- "test-server/test-server-status.c"
- "test-server/test-server-echogen.c")
- # Set defines for this executable only.
- set_property(
- TARGET test-server-extpoll
- PROPERTY COMPILE_DEFINITIONS
- EXTERNAL_POLL
- INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/share"
- )
-
- # We need to link against winsock code.
- if (WIN32)
- target_link_libraries(test-server-extpoll ws2_32.lib)
- endif(WIN32)
- endif()
-
- #
- # test-server-v2.0
- #
- if (LWS_WITH_PLUGINS)
- create_test_app(
- test-server-v2.0
- "test-server/test-server-v2.0.c"
- ""
- ""
- ""
- ""
- "")
- endif()