| 1 |
project(lws-minimal-ws-server-threads-foreign-libuv-smp C) |
| 2 |
cmake_minimum_required(VERSION 2.8.12) |
| 3 |
find_package(libwebsockets CONFIG REQUIRED) |
| 4 |
list(APPEND CMAKE_MODULE_PATH ${LWS_CMAKE_DIR}) |
| 5 |
include(CheckIncludeFile) |
| 6 |
include(CheckCSourceCompiles) |
| 7 |
include(LwsCheckRequirements) |
| 8 |
|
| 9 |
set(SAMP lws-minimal-ws-server-threads-foreign-smp) |
| 10 |
set(SRCS minimal-ws-server.c) |
| 11 |
|
| 12 |
set(requirements 1) |
| 13 |
require_pthreads(requirements) |
| 14 |
require_lws_config(LWS_ROLE_WS 1 requirements) |
| 15 |
require_lws_config(LWS_WITH_SERVER 1 requirements) |
| 16 |
require_lws_config(LWS_WITH_TLS 1 requirements) |
| 17 |
require_lws_config(LWS_WITH_LIBUV 1 requirements) |
| 18 |
|
| 19 |
CHECK_C_SOURCE_COMPILES("#include <libwebsockets.h>\nint main(void) {\n#if defined(LWS_WITH_LIBUV)\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" LWS_WITH_LIBUV) |
| 20 |
|
| 21 |
if (NOT LWS_WITH_LIBUV) |
| 22 |
set(requirements 0) |
| 23 |
endif() |
| 24 |
|
| 25 |
|
| 26 |
if (requirements) |
| 27 |
add_executable(${SAMP} ${SRCS}) |
| 28 |
|
| 29 |
find_path(LIBUV_INCLUDE_DIRS NAMES uv.h) |
| 30 |
find_library(LIBUV_LIBRARIES NAMES uv) |
| 31 |
message("libuv include dir: ${LIBUV_INCLUDE_DIRS}") |
| 32 |
message("libuv libraries: ${LIBUV_LIBRARIES}") |
| 33 |
include_directories("${LIBUV_INCLUDE_DIRS}") |
| 34 |
set(extralibs ${extralibs} ${LIBUV_LIBRARIES}) |
| 35 |
|
| 36 |
message("Extra libs: ${extralibs}") |
| 37 |
|
| 38 |
if (websockets_shared) |
| 39 |
target_link_libraries(${SAMP} websockets_shared ${extralibs} ${PTHREAD_LIB} ${LIBWEBSOCKETS_DEP_LIBS}) |
| 40 |
add_dependencies(${SAMP} websockets_shared) |
| 41 |
else() |
| 42 |
target_link_libraries(${SAMP} websockets ${extralibs} ${PTHREAD_LIB} ${LIBWEBSOCKETS_DEP_LIBS}) |
| 43 |
endif() |
| 44 |
endif() |