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)
|
|
|
|
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-02-23 06:27:49 +01:00
|
|
|
# -Wshorten-64-to-32 does not work with clang
|
2019-01-05 02:28:13 +01:00
|
|
|
if (NOT WIN32)
|
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
|
|
|
|
ixwebsocket/IXSocket.cpp
|
2019-01-06 21:01:33 +01:00
|
|
|
ixwebsocket/IXSocketServer.cpp
|
2018-12-09 23:07:40 +01:00
|
|
|
ixwebsocket/IXSocketConnect.cpp
|
2019-03-01 06:54:03 +01:00
|
|
|
ixwebsocket/IXSocketFactory.cpp
|
2018-12-15 01:28:11 +01:00
|
|
|
ixwebsocket/IXDNSLookup.cpp
|
2019-01-03 21:53:44 +01:00
|
|
|
ixwebsocket/IXCancellationRequest.cpp
|
2019-04-26 01:26:53 +02:00
|
|
|
ixwebsocket/IXNetSystem.cpp
|
2018-10-09 00:23:01 +02:00
|
|
|
ixwebsocket/IXWebSocket.cpp
|
2018-12-30 08:15:27 +01:00
|
|
|
ixwebsocket/IXWebSocketServer.cpp
|
2018-10-09 00:23:01 +02:00
|
|
|
ixwebsocket/IXWebSocketTransport.cpp
|
2019-01-03 05:07:54 +01:00
|
|
|
ixwebsocket/IXWebSocketHandshake.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-03-01 06:54:03 +01:00
|
|
|
ixwebsocket/IXWebSocketHttpHeaders.cpp
|
|
|
|
ixwebsocket/IXHttpClient.cpp
|
|
|
|
ixwebsocket/IXUrlParser.cpp
|
2019-05-06 23:45:02 +02:00
|
|
|
ixwebsocket/LUrlParser.cpp
|
2019-03-15 02:37:38 +01:00
|
|
|
ixwebsocket/IXSelectInterrupt.cpp
|
|
|
|
ixwebsocket/IXSelectInterruptFactory.cpp
|
2019-03-21 02:34:24 +01:00
|
|
|
ixwebsocket/IXConnectionState.cpp
|
2019-05-16 21:46:53 +02:00
|
|
|
ixwebsocket/IXWebSocketCloseConstants.cpp
|
2019-05-17 07:41:39 +02:00
|
|
|
ixwebsocket/IXWebSocketMessageQueue.cpp
|
2018-10-09 00:23:01 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
set( IXWEBSOCKET_HEADERS
|
|
|
|
ixwebsocket/IXSocket.h
|
2019-01-06 21:01:33 +01:00
|
|
|
ixwebsocket/IXSocketServer.h
|
2018-12-09 23:07:40 +01:00
|
|
|
ixwebsocket/IXSocketConnect.h
|
2019-03-01 06:54:03 +01:00
|
|
|
ixwebsocket/IXSocketFactory.h
|
2018-12-23 23:14:38 +01:00
|
|
|
ixwebsocket/IXSetThreadName.h
|
2018-12-15 01:28:11 +01:00
|
|
|
ixwebsocket/IXDNSLookup.h
|
2018-12-30 03:33:15 +01:00
|
|
|
ixwebsocket/IXCancellationRequest.h
|
2019-04-26 01:26:53 +02:00
|
|
|
ixwebsocket/IXNetSystem.h
|
2019-02-21 03:59:07 +01:00
|
|
|
ixwebsocket/IXProgressCallback.h
|
2018-10-09 00:23:01 +02:00
|
|
|
ixwebsocket/IXWebSocket.h
|
2018-12-30 08:15:27 +01:00
|
|
|
ixwebsocket/IXWebSocketServer.h
|
2018-10-09 00:23:01 +02:00
|
|
|
ixwebsocket/IXWebSocketTransport.h
|
2019-01-03 05:07:54 +01:00
|
|
|
ixwebsocket/IXWebSocketHandshake.h
|
2018-11-13 02:56:59 +01:00
|
|
|
ixwebsocket/IXWebSocketSendInfo.h
|
2018-12-30 03:33:15 +01:00
|
|
|
ixwebsocket/IXWebSocketErrorInfo.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
|
|
|
|
ixwebsocket/IXWebSocketHttpHeaders.h
|
2019-01-06 23:21:49 +01:00
|
|
|
ixwebsocket/libwshandshake.hpp
|
2019-03-01 06:54:03 +01:00
|
|
|
ixwebsocket/IXHttpClient.h
|
|
|
|
ixwebsocket/IXUrlParser.h
|
2019-05-06 23:45:02 +02:00
|
|
|
ixwebsocket/LUrlParser.h
|
2019-03-15 02:37:38 +01:00
|
|
|
ixwebsocket/IXSelectInterrupt.h
|
|
|
|
ixwebsocket/IXSelectInterruptFactory.h
|
2019-03-21 02:34:24 +01:00
|
|
|
ixwebsocket/IXConnectionState.h
|
2019-05-16 21:46:53 +02:00
|
|
|
ixwebsocket/IXWebSocketCloseConstants.h
|
2019-05-17 07:41:39 +02:00
|
|
|
ixwebsocket/IXWebSocketMessageQueue.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)
|
2018-12-30 03:33:15 +01:00
|
|
|
else()
|
|
|
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/linux/IXSetThreadName_linux.cpp)
|
2019-03-15 02:37:38 +01:00
|
|
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSelectInterruptEventFd.cpp)
|
|
|
|
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSelectInterruptEventFd.h)
|
2018-12-30 03:33:15 +01:00
|
|
|
endif()
|
|
|
|
|
2019-04-16 17:51:57 +02:00
|
|
|
set(USE_OPEN_SSL FALSE)
|
2018-10-09 00:23:01 +02:00
|
|
|
if (USE_TLS)
|
|
|
|
add_definitions(-DIXWEBSOCKET_USE_TLS)
|
|
|
|
|
|
|
|
if (APPLE)
|
|
|
|
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketAppleSSL.h)
|
|
|
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketAppleSSL.cpp)
|
2018-12-30 03:33:15 +01:00
|
|
|
elseif (WIN32)
|
|
|
|
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketSChannel.h)
|
|
|
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketSChannel.cpp)
|
2018-10-09 00:23:01 +02:00
|
|
|
else()
|
2019-04-16 17:51:57 +02:00
|
|
|
set(USE_OPEN_SSL TRUE)
|
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-04-15 02:13:24 +02:00
|
|
|
if (APPLE AND USE_TLS)
|
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-04-21 20:41:37 +02:00
|
|
|
if (USE_OPEN_SSL)
|
2019-01-05 02:28:13 +01:00
|
|
|
find_package(OpenSSL REQUIRED)
|
|
|
|
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()
|
|
|
|
|
|
|
|
if (WIN32)
|
2019-04-19 18:14:03 +02:00
|
|
|
add_subdirectory(third_party/zlib)
|
|
|
|
include_directories(third_party/zlib ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib)
|
|
|
|
target_link_libraries(ixwebsocket zlibstatic wsock32 ws2_32)
|
2019-01-05 02:28:13 +01:00
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
2019-04-16 17:51:57 +02:00
|
|
|
|
2019-01-05 02:28:13 +01:00
|
|
|
else()
|
2019-04-16 17:51:57 +02:00
|
|
|
# gcc/Linux needs -pthread
|
|
|
|
find_package(Threads)
|
|
|
|
|
2019-01-05 02:28:13 +01:00
|
|
|
target_link_libraries(ixwebsocket
|
2019-04-16 17:51:57 +02:00
|
|
|
z ${CMAKE_THREAD_LIBS_INIT})
|
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
|
|
|
|
.
|
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()
|
|
|
|
|
2018-10-09 00:23:01 +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-05-16 00:18:27 +02:00
|
|
|
if (USE_WS)
|
2019-04-16 17:51:57 +02:00
|
|
|
add_subdirectory(ws)
|
|
|
|
endif()
|