2018-10-09 00:23:01 +02:00
|
|
|
#
|
|
|
|
# Author: Benjamin Sergeant
|
|
|
|
# Copyright (c) 2018 Machine Zone, Inc. All rights reserved.
|
|
|
|
#
|
|
|
|
|
|
|
|
cmake_minimum_required(VERSION 3.4.1)
|
2019-06-10 20:18:27 +02:00
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}")
|
|
|
|
|
2018-10-09 00:23:01 +02:00
|
|
|
project(ixwebsocket C CXX)
|
|
|
|
|
2019-01-12 06:25:06 +01:00
|
|
|
set (CMAKE_CXX_STANDARD 14)
|
2018-10-09 00:23:01 +02:00
|
|
|
set (CXX_STANDARD_REQUIRED ON)
|
|
|
|
set (CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
2019-09-10 21:19:22 +02:00
|
|
|
if (UNIX)
|
2019-03-21 18:06:59 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
|
2019-01-05 02:28:13 +01:00
|
|
|
endif()
|
2018-12-30 08:15:27 +01:00
|
|
|
|
2019-03-20 22:29:02 +01:00
|
|
|
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshorten-64-to-32")
|
|
|
|
endif()
|
|
|
|
|
2018-10-09 00:23:01 +02:00
|
|
|
set( IXWEBSOCKET_SOURCES
|
2020-03-25 04:53:25 +01:00
|
|
|
ixwebsocket/IXBench.cpp
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXCancellationRequest.cpp
|
|
|
|
ixwebsocket/IXConnectionState.cpp
|
|
|
|
ixwebsocket/IXDNSLookup.cpp
|
2019-08-30 21:46:35 +02:00
|
|
|
ixwebsocket/IXExponentialBackoff.cpp
|
2019-06-23 23:54:21 +02:00
|
|
|
ixwebsocket/IXHttp.cpp
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXHttpClient.cpp
|
2019-06-23 23:54:21 +02:00
|
|
|
ixwebsocket/IXHttpServer.cpp
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXNetSystem.cpp
|
|
|
|
ixwebsocket/IXSelectInterrupt.cpp
|
|
|
|
ixwebsocket/IXSelectInterruptFactory.cpp
|
2018-10-09 00:23:01 +02:00
|
|
|
ixwebsocket/IXSocket.cpp
|
2018-12-09 23:07:40 +01:00
|
|
|
ixwebsocket/IXSocketConnect.cpp
|
2019-03-01 06:54:03 +01:00
|
|
|
ixwebsocket/IXSocketFactory.cpp
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXSocketServer.cpp
|
2019-09-23 03:06:15 +02:00
|
|
|
ixwebsocket/IXSocketTLSOptions.cpp
|
2020-03-23 03:36:29 +01:00
|
|
|
ixwebsocket/IXUdpSocket.cpp
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXUrlParser.cpp
|
2019-08-30 21:48:18 +02:00
|
|
|
ixwebsocket/IXUserAgent.cpp
|
2018-10-09 00:23:01 +02:00
|
|
|
ixwebsocket/IXWebSocket.cpp
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXWebSocketCloseConstants.cpp
|
2019-01-03 05:07:54 +01:00
|
|
|
ixwebsocket/IXWebSocketHandshake.cpp
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXWebSocketHttpHeaders.cpp
|
2018-11-07 21:26:32 +01:00
|
|
|
ixwebsocket/IXWebSocketPerMessageDeflate.cpp
|
2019-01-05 02:28:13 +01:00
|
|
|
ixwebsocket/IXWebSocketPerMessageDeflateCodec.cpp
|
2018-11-10 03:23:49 +01:00
|
|
|
ixwebsocket/IXWebSocketPerMessageDeflateOptions.cpp
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXWebSocketServer.cpp
|
|
|
|
ixwebsocket/IXWebSocketTransport.cpp
|
2018-10-09 00:23:01 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
set( IXWEBSOCKET_HEADERS
|
2020-03-25 04:53:25 +01:00
|
|
|
ixwebsocket/IXBench.h
|
2018-12-30 03:33:15 +01:00
|
|
|
ixwebsocket/IXCancellationRequest.h
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXConnectionState.h
|
|
|
|
ixwebsocket/IXDNSLookup.h
|
2019-08-30 21:46:35 +02:00
|
|
|
ixwebsocket/IXExponentialBackoff.h
|
2019-06-23 23:54:21 +02:00
|
|
|
ixwebsocket/IXHttp.h
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXHttpClient.h
|
2019-06-23 23:54:21 +02:00
|
|
|
ixwebsocket/IXHttpServer.h
|
2019-04-26 01:26:53 +02:00
|
|
|
ixwebsocket/IXNetSystem.h
|
2019-02-21 03:59:07 +01:00
|
|
|
ixwebsocket/IXProgressCallback.h
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXSelectInterrupt.h
|
|
|
|
ixwebsocket/IXSelectInterruptFactory.h
|
|
|
|
ixwebsocket/IXSetThreadName.h
|
|
|
|
ixwebsocket/IXSocket.h
|
|
|
|
ixwebsocket/IXSocketConnect.h
|
|
|
|
ixwebsocket/IXSocketFactory.h
|
|
|
|
ixwebsocket/IXSocketServer.h
|
2019-09-23 03:06:15 +02:00
|
|
|
ixwebsocket/IXSocketTLSOptions.h
|
2020-03-23 03:36:29 +01:00
|
|
|
ixwebsocket/IXUdpSocket.h
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXUrlParser.h
|
2019-09-03 23:12:40 +02:00
|
|
|
ixwebsocket/IXUtf8Validator.h
|
2019-08-30 21:48:18 +02:00
|
|
|
ixwebsocket/IXUserAgent.h
|
2018-10-09 00:23:01 +02:00
|
|
|
ixwebsocket/IXWebSocket.h
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXWebSocketCloseConstants.h
|
2019-06-09 19:22:27 +02:00
|
|
|
ixwebsocket/IXWebSocketCloseInfo.h
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXWebSocketErrorInfo.h
|
|
|
|
ixwebsocket/IXWebSocketHandshake.h
|
2020-04-24 21:55:00 +02:00
|
|
|
ixwebsocket/IXWebSocketHandshakeKeyGen.h
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXWebSocketHttpHeaders.h
|
2019-10-13 22:37:34 +02:00
|
|
|
ixwebsocket/IXWebSocketInitResult.h
|
2019-06-09 19:22:27 +02:00
|
|
|
ixwebsocket/IXWebSocketMessage.h
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXWebSocketMessageType.h
|
|
|
|
ixwebsocket/IXWebSocketOpenInfo.h
|
2018-11-07 21:26:32 +01:00
|
|
|
ixwebsocket/IXWebSocketPerMessageDeflate.h
|
2019-01-05 02:28:13 +01:00
|
|
|
ixwebsocket/IXWebSocketPerMessageDeflateCodec.h
|
2018-11-10 03:23:49 +01:00
|
|
|
ixwebsocket/IXWebSocketPerMessageDeflateOptions.h
|
2019-06-10 20:18:27 +02:00
|
|
|
ixwebsocket/IXWebSocketSendInfo.h
|
|
|
|
ixwebsocket/IXWebSocketServer.h
|
|
|
|
ixwebsocket/IXWebSocketTransport.h
|
2019-08-30 21:48:18 +02:00
|
|
|
ixwebsocket/IXWebSocketVersion.h
|
2018-10-09 00:23:01 +02:00
|
|
|
)
|
|
|
|
|
2019-04-16 17:51:57 +02:00
|
|
|
if (UNIX)
|
|
|
|
# Linux, Mac, iOS, Android
|
|
|
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSelectInterruptPipe.cpp )
|
|
|
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSelectInterruptPipe.h )
|
|
|
|
endif()
|
|
|
|
|
2018-12-30 03:33:15 +01:00
|
|
|
# Platform specific code
|
|
|
|
if (APPLE)
|
|
|
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/apple/IXSetThreadName_apple.cpp)
|
2019-01-05 02:28:13 +01:00
|
|
|
elseif (WIN32)
|
|
|
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/windows/IXSetThreadName_windows.cpp)
|
2019-10-10 02:00:32 +02:00
|
|
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
|
|
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/freebsd/IXSetThreadName_freebsd.cpp)
|
2019-11-16 15:51:53 +01:00
|
|
|
else()
|
2018-12-30 03:33:15 +01:00
|
|
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/linux/IXSetThreadName_linux.cpp)
|
|
|
|
endif()
|
|
|
|
|
2020-01-07 23:57:47 +01:00
|
|
|
option(USE_TLS "Enable TLS support" FALSE)
|
2019-06-02 02:41:48 +02:00
|
|
|
|
2018-10-09 00:23:01 +02:00
|
|
|
if (USE_TLS)
|
2020-04-05 02:49:52 +02:00
|
|
|
option(USE_MBED_TLS "Use Mbed TLS" OFF)
|
2020-01-07 23:57:47 +01:00
|
|
|
option(USE_OPEN_SSL "Use OpenSSL" OFF)
|
2020-04-24 21:47:47 +02:00
|
|
|
option(USE_SECURE_TRANSPORT "Use Secure Transport" OFF)
|
2020-03-22 03:31:38 +01:00
|
|
|
|
2020-04-26 00:36:31 +02:00
|
|
|
# default to OpenSSL on windows if nothing is configured
|
|
|
|
if (WIN32 AND NOT USE_MBED_TLS)
|
|
|
|
option(USE_OPEN_SSL "Use OpenSSL" ON)
|
2020-04-05 02:49:52 +02:00
|
|
|
endif()
|
|
|
|
|
2020-04-24 21:47:47 +02:00
|
|
|
# default to securetranport on windows if nothing is configured
|
|
|
|
if (APPLE AND NOT USE_OPEN_SSL AND NOT USE_MBED_TLS)
|
|
|
|
option(USE_SECURE_TRANSPORT "Use Secure Transport" ON)
|
|
|
|
endif()
|
|
|
|
|
2019-06-02 02:41:48 +02:00
|
|
|
if (USE_MBED_TLS)
|
|
|
|
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketMbedTLS.h)
|
|
|
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketMbedTLS.cpp)
|
2020-04-24 21:47:47 +02:00
|
|
|
elseif (USE_SECURE_TRANSPORT)
|
2018-10-09 00:23:01 +02:00
|
|
|
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketAppleSSL.h)
|
|
|
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketAppleSSL.cpp)
|
|
|
|
else()
|
2020-01-07 23:57:47 +01:00
|
|
|
set(USE_OPEN_SSL ON)
|
2018-10-09 00:23:01 +02:00
|
|
|
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketOpenSSL.h)
|
|
|
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketOpenSSL.cpp)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_library( ixwebsocket STATIC
|
|
|
|
${IXWEBSOCKET_SOURCES}
|
|
|
|
${IXWEBSOCKET_HEADERS}
|
|
|
|
)
|
|
|
|
|
2019-09-07 23:07:00 +02:00
|
|
|
if (USE_TLS)
|
|
|
|
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_TLS)
|
|
|
|
if (USE_MBED_TLS)
|
|
|
|
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_MBED_TLS)
|
2019-09-30 00:34:58 +02:00
|
|
|
elseif (USE_OPEN_SSL)
|
|
|
|
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_OPEN_SSL)
|
2020-04-24 21:47:47 +02:00
|
|
|
elseif (USE_SECURE_TRANSPORT)
|
|
|
|
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_SECURE_TRANSPORT)
|
2019-09-07 23:07:00 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-01-07 23:57:47 +01:00
|
|
|
if (APPLE AND USE_TLS AND NOT USE_MBED_TLS AND NOT USE_OPEN_SSL)
|
2019-04-16 17:51:57 +02:00
|
|
|
target_link_libraries(ixwebsocket "-framework foundation" "-framework security")
|
2019-04-15 02:13:24 +02:00
|
|
|
endif()
|
|
|
|
|
2019-08-26 23:51:33 +02:00
|
|
|
if (WIN32)
|
2020-01-08 22:57:57 +01:00
|
|
|
target_link_libraries(ixwebsocket wsock32 ws2_32 shlwapi)
|
2019-08-26 23:51:33 +02:00
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
2020-04-26 00:36:31 +02:00
|
|
|
|
|
|
|
if (USE_TLS)
|
|
|
|
target_link_libraries(ixwebsocket Crypt32)
|
|
|
|
endif()
|
2019-08-26 23:51:33 +02:00
|
|
|
endif()
|
|
|
|
|
2019-06-10 22:39:22 +02:00
|
|
|
if (UNIX)
|
|
|
|
find_package(Threads)
|
|
|
|
target_link_libraries(ixwebsocket ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
endif()
|
|
|
|
|
2019-06-25 08:34:31 +02:00
|
|
|
if (USE_TLS AND USE_OPEN_SSL)
|
2019-09-30 00:34:58 +02:00
|
|
|
|
|
|
|
# Help finding Homebrew's OpenSSL on macOS
|
|
|
|
if (APPLE)
|
|
|
|
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /usr/local/opt/openssl/lib)
|
|
|
|
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /usr/local/opt/openssl/include)
|
|
|
|
endif()
|
|
|
|
|
2020-01-08 22:57:57 +01:00
|
|
|
if(NOT OPENSSL_FOUND)
|
|
|
|
find_package(OpenSSL REQUIRED)
|
|
|
|
endif()
|
2019-01-05 02:28:13 +01:00
|
|
|
add_definitions(${OPENSSL_DEFINITIONS})
|
|
|
|
message(STATUS "OpenSSL: " ${OPENSSL_VERSION})
|
|
|
|
include_directories(${OPENSSL_INCLUDE_DIR})
|
2019-04-16 17:51:57 +02:00
|
|
|
target_link_libraries(ixwebsocket ${OPENSSL_LIBRARIES})
|
2019-01-05 02:28:13 +01:00
|
|
|
endif()
|
|
|
|
|
2019-06-25 08:34:31 +02:00
|
|
|
if (USE_TLS AND USE_MBED_TLS)
|
2020-04-26 00:41:39 +02:00
|
|
|
find_package(MbedTLS REQUIRED)
|
|
|
|
target_include_directories(ixwebsocket PUBLIC ${MBEDTLS_INCLUDE_DIRS})
|
|
|
|
target_link_libraries(ixwebsocket ${MBEDTLS_LIBRARIES})
|
2019-06-02 02:41:48 +02:00
|
|
|
endif()
|
|
|
|
|
2020-03-26 17:39:51 +01:00
|
|
|
if (NOT ZLIB_FOUND)
|
|
|
|
find_package(ZLIB)
|
|
|
|
endif()
|
2019-06-10 20:18:27 +02:00
|
|
|
if (ZLIB_FOUND)
|
|
|
|
include_directories(${ZLIB_INCLUDE_DIRS})
|
|
|
|
target_link_libraries(ixwebsocket ${ZLIB_LIBRARIES})
|
|
|
|
else()
|
2019-04-19 18:14:03 +02:00
|
|
|
include_directories(third_party/zlib ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib)
|
2020-02-28 18:30:37 +01:00
|
|
|
add_subdirectory(third_party/zlib)
|
2019-08-26 23:51:33 +02:00
|
|
|
target_link_libraries(ixwebsocket zlibstatic)
|
2019-01-05 02:28:13 +01:00
|
|
|
endif()
|
2018-11-07 21:26:32 +01:00
|
|
|
|
2018-10-09 00:23:01 +02:00
|
|
|
set( IXWEBSOCKET_INCLUDE_DIRS
|
2020-01-07 23:57:47 +01:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
2019-04-16 17:51:57 +02:00
|
|
|
)
|
|
|
|
|
2019-04-25 16:41:01 +02:00
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|
|
|
# Build with Multiple Processes
|
|
|
|
target_compile_options(ixwebsocket PRIVATE /MP)
|
|
|
|
endif()
|
|
|
|
|
2019-06-10 20:18:27 +02:00
|
|
|
target_include_directories(ixwebsocket PUBLIC ${IXWEBSOCKET_INCLUDE_DIRS})
|
2019-02-22 07:21:29 +01:00
|
|
|
|
2019-04-21 20:41:37 +02:00
|
|
|
set_target_properties(ixwebsocket PROPERTIES PUBLIC_HEADER "${IXWEBSOCKET_HEADERS}")
|
|
|
|
|
|
|
|
install(TARGETS ixwebsocket
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
|
|
|
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ixwebsocket/
|
|
|
|
)
|
|
|
|
|
2019-09-10 21:19:22 +02:00
|
|
|
if (USE_WS OR USE_TEST)
|
|
|
|
add_subdirectory(ixcore)
|
|
|
|
add_subdirectory(ixcrypto)
|
|
|
|
add_subdirectory(ixcobra)
|
2019-09-23 20:46:16 +02:00
|
|
|
add_subdirectory(ixsnake)
|
2019-10-25 23:46:10 +02:00
|
|
|
add_subdirectory(ixsentry)
|
2020-03-11 23:55:45 +01:00
|
|
|
add_subdirectory(ixbots)
|
2019-09-10 21:19:22 +02:00
|
|
|
|
2019-09-29 20:13:24 +02:00
|
|
|
add_subdirectory(third_party/spdlog spdlog)
|
|
|
|
|
2019-09-10 21:19:22 +02:00
|
|
|
if (USE_WS)
|
|
|
|
add_subdirectory(ws)
|
|
|
|
endif()
|
|
|
|
if (USE_TEST)
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
2019-04-16 17:51:57 +02:00
|
|
|
endif()
|