1 cmake_minimum_required(VERSION 2.6)
3 INCLUDE(CheckSymbolExists)
6 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
8 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
11 ADD_DEFINITIONS(-DHAVE_MBEDTLS)
12 SET(SSL_SRC ustream-mbedtls.c)
13 SET(SSL_LIB mbedtls mbedcrypto mbedx509 m)
15 ADD_DEFINITIONS(-DHAVE_WOLFSSL)
16 SET(SSL_SRC ustream-io-wolfssl.c ustream-openssl.c)
17 SET(SSL_LIB wolfssl m)
18 SET(CMAKE_REQUIRED_LIBRARIES "-lwolfssl -lm")
19 CHECK_SYMBOL_EXISTS (wolfSSL_SSLSetIORecv "wolfssl/ssl.h"
20 HAVE_WOLFSSL_SSLSETIORECV)
21 IF (NOT HAVE_WOLFSSL_SSLSETIORECV)
22 ADD_DEFINITIONS(-DNO_WOLFSSL_SSLSETIO_SEND_RECV)
24 CHECK_SYMBOL_EXISTS (wolfSSL_X509_check_host
25 "wolfssl/options.h;wolfssl/ssl.h"
26 HAVE_WOLFSSL_X509_CHECK_HOST)
27 IF (NOT HAVE_WOLFSSL_X509_CHECK_HOST)
28 ADD_DEFINITIONS(-DNO_X509_CHECK_HOST)
31 SET(SSL_SRC ustream-io-openssl.c ustream-openssl.c)
32 SET(SSL_LIB crypto ssl)
35 FIND_PATH(ubox_include_dir libubox/ustream.h)
36 INCLUDE_DIRECTORIES(${ubox_include_dir})
37 FIND_LIBRARY(ubox_library NAMES ubox)
39 ADD_LIBRARY(ustream-ssl SHARED ustream-ssl.c ${SSL_SRC})
40 TARGET_LINK_LIBRARIES(ustream-ssl ${ubox_library} ${SSL_LIB})
42 ADD_EXECUTABLE(ustream-example-server ustream-example-server.c)
43 TARGET_LINK_LIBRARIES(ustream-example-server ustream-ssl)
45 ADD_EXECUTABLE(ustream-example-client ustream-example-client.c)
46 TARGET_LINK_LIBRARIES(ustream-example-client ustream-ssl)
48 INSTALL(FILES ustream-ssl.h
49 DESTINATION include/libubox
51 INSTALL(TARGETS ustream-ssl
52 LIBRARY DESTINATION lib