ustream-io-cyassl.c: fix client-mode connections
[oweals/openwrt-ustream-ssl.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 INCLUDE(CheckSymbolExists)
4
5 PROJECT(ustream-ssl C)
6 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
7
8 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
9
10 IF(MBEDTLS)
11   ADD_DEFINITIONS(-DHAVE_MBEDTLS)
12   SET(SSL_SRC ustream-mbedtls.c)
13   SET(SSL_LIB mbedtls mbedcrypto mbedx509 m)
14 ELSEIF(WOLFSSL)
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)
23   ENDIF()
24 ELSE()
25   SET(SSL_SRC ustream-io-openssl.c ustream-openssl.c)
26   SET(SSL_LIB crypto ssl)
27 ENDIF()
28
29 FIND_PATH(ubox_include_dir libubox/ustream.h)
30 INCLUDE_DIRECTORIES(${ubox_include_dir})
31
32 ADD_LIBRARY(ustream-ssl SHARED ustream-ssl.c ${SSL_SRC})
33 TARGET_LINK_LIBRARIES(ustream-ssl ubox ${SSL_LIB})
34
35 ADD_EXECUTABLE(ustream-example-server ustream-example-server.c)
36 TARGET_LINK_LIBRARIES(ustream-example-server ustream-ssl)
37
38 ADD_EXECUTABLE(ustream-example-client ustream-example-client.c)
39 TARGET_LINK_LIBRARIES(ustream-example-client ustream-ssl)
40
41 INSTALL(FILES ustream-ssl.h
42         DESTINATION include/libubox
43 )
44 INSTALL(TARGETS ustream-ssl
45         LIBRARY DESTINATION lib
46 )