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 FIND_LIBRARY(wolfssl_library wolfssl)
17 SET(SSL_SRC ustream-io-wolfssl.c ustream-openssl.c)
18 SET(SSL_LIB ${wolfssl_library} m)
19 SET(CMAKE_REQUIRED_LIBRARIES "${wolfssl_library} -lm")
20 CHECK_SYMBOL_EXISTS (wolfSSL_SSLSetIORecv "wolfssl/ssl.h"
21 HAVE_WOLFSSL_SSLSETIORECV)
22 IF (NOT HAVE_WOLFSSL_SSLSETIORECV)
23 ADD_DEFINITIONS(-DNO_WOLFSSL_SSLSETIO_SEND_RECV)
25 CHECK_SYMBOL_EXISTS (wolfSSL_X509_check_host
26 "wolfssl/options.h;wolfssl/ssl.h"
27 HAVE_WOLFSSL_X509_CHECK_HOST)
28 IF (NOT HAVE_WOLFSSL_X509_CHECK_HOST)
29 ADD_DEFINITIONS(-DNO_X509_CHECK_HOST)
32 SET(SSL_SRC ustream-io-openssl.c ustream-openssl.c)
33 SET(SSL_LIB crypto ssl)
36 FIND_PATH(ubox_include_dir libubox/ustream.h)
37 INCLUDE_DIRECTORIES(${ubox_include_dir})
38 FIND_LIBRARY(ubox_library NAMES ubox)
40 ADD_LIBRARY(ustream-ssl SHARED ustream-ssl.c ${SSL_SRC})
41 TARGET_LINK_LIBRARIES(ustream-ssl ${ubox_library} ${SSL_LIB})
43 ADD_EXECUTABLE(ustream-example-server ustream-example-server.c)
44 TARGET_LINK_LIBRARIES(ustream-example-server ustream-ssl)
46 ADD_EXECUTABLE(ustream-example-client ustream-example-client.c)
47 TARGET_LINK_LIBRARIES(ustream-example-client ustream-ssl)
49 INSTALL(FILES ustream-ssl.h
50 DESTINATION include/libubox
52 INSTALL(TARGETS ustream-ssl
53 LIBRARY DESTINATION lib