ustream-mbedtls: fix comparison of integers of different signs
[project/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 FIND_LIBRARY(mbedtls_library mbedtls)
14 FIND_LIBRARY(mbedx509_library mbedx509)
15 FIND_LIBRARY(mbedcrypto_library mbedcrypto)
16 SET(SSL_LIB ${mbedtls_library} ${mbedx509_library} ${mbedcrypto_library} m)
17 ELSEIF(WOLFSSL)
18 ADD_DEFINITIONS(-DHAVE_WOLFSSL)
19 FIND_LIBRARY(wolfssl_library wolfssl)
20 SET(SSL_SRC ustream-io-wolfssl.c ustream-openssl.c)
21 SET(SSL_LIB ${wolfssl_library} m)
22 SET(CMAKE_REQUIRED_LIBRARIES "${wolfssl_library} -lm")
23 CHECK_SYMBOL_EXISTS (wolfSSL_SSLSetIORecv "wolfssl/ssl.h"
24 HAVE_WOLFSSL_SSLSETIORECV)
25 IF (NOT HAVE_WOLFSSL_SSLSETIORECV)
26 ADD_DEFINITIONS(-DNO_WOLFSSL_SSLSETIO_SEND_RECV)
27 ENDIF()
28 CHECK_SYMBOL_EXISTS (wolfSSL_X509_check_host
29 "wolfssl/options.h;wolfssl/ssl.h"
30 HAVE_WOLFSSL_X509_CHECK_HOST)
31 IF (NOT HAVE_WOLFSSL_X509_CHECK_HOST)
32 ADD_DEFINITIONS(-DNO_X509_CHECK_HOST)
33 ENDIF()
34 ELSE()
35 SET(SSL_SRC ustream-io-openssl.c ustream-openssl.c)
36 SET(SSL_LIB crypto ssl)
37 ENDIF()
38
39 FIND_PATH(ubox_include_dir libubox/ustream.h)
40 INCLUDE_DIRECTORIES(${ubox_include_dir})
41 FIND_LIBRARY(ubox_library NAMES ubox)
42
43 ADD_LIBRARY(ustream-ssl SHARED ustream-ssl.c ${SSL_SRC})
44 TARGET_LINK_LIBRARIES(ustream-ssl ${ubox_library} ${SSL_LIB})
45
46 ADD_EXECUTABLE(ustream-example-server ustream-example-server.c)
47 TARGET_LINK_LIBRARIES(ustream-example-server ustream-ssl)
48
49 ADD_EXECUTABLE(ustream-example-client ustream-example-client.c)
50 TARGET_LINK_LIBRARIES(ustream-example-client ustream-ssl)
51
52 INSTALL(FILES ustream-ssl.h
53 DESTINATION include/libubox
54 )
55 INSTALL(TARGETS ustream-ssl
56 LIBRARY DESTINATION lib
57 )