ustream-openssl: wolfSSL: provide detailed information in debug builds
[project/ustream-ssl.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 PROJECT(ustream-ssl C)
4
5 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3)
6 IF(CMAKE_C_COMPILER_VERSION VERSION_GREATER 6)
7 ADD_DEFINITIONS(-Wextra -Werror=implicit-function-declaration)
8 ADD_DEFINITIONS(-Wformat -Werror=format-security -Werror=format-nonliteral)
9 ENDIF()
10 ADD_DEFINITIONS(-Wno-unused-parameter -Wmissing-declarations)
11
12 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
13
14 IF(MBEDTLS)
15 ADD_DEFINITIONS(-DHAVE_MBEDTLS)
16 SET(SSL_SRC ustream-mbedtls.c)
17 FIND_LIBRARY(mbedtls_library mbedtls)
18 FIND_LIBRARY(mbedx509_library mbedx509)
19 FIND_LIBRARY(mbedcrypto_library mbedcrypto)
20 SET(SSL_LIB ${mbedtls_library} ${mbedx509_library} ${mbedcrypto_library} m)
21 ELSEIF(WOLFSSL)
22 ADD_DEFINITIONS(-DHAVE_WOLFSSL)
23 FIND_LIBRARY(wolfssl_library wolfssl)
24 SET(SSL_SRC ustream-io-wolfssl.c ustream-openssl.c)
25 SET(SSL_LIB ${wolfssl_library} m)
26 SET(CMAKE_REQUIRED_LIBRARIES "${wolfssl_library} -lm")
27 ELSE()
28 SET(SSL_SRC ustream-io-openssl.c ustream-openssl.c)
29 SET(SSL_LIB crypto ssl)
30 ENDIF()
31
32 FIND_PATH(ubox_include_dir libubox/ustream.h)
33 INCLUDE_DIRECTORIES(${ubox_include_dir})
34 FIND_LIBRARY(ubox_library NAMES ubox)
35
36 ADD_LIBRARY(ustream-ssl SHARED ustream-ssl.c ${SSL_SRC})
37 TARGET_LINK_LIBRARIES(ustream-ssl ${ubox_library} ${SSL_LIB})
38
39 ADD_EXECUTABLE(ustream-example-server ustream-example-server.c)
40 TARGET_LINK_LIBRARIES(ustream-example-server ustream-ssl)
41
42 ADD_EXECUTABLE(ustream-example-client ustream-example-client.c)
43 TARGET_LINK_LIBRARIES(ustream-example-client ustream-ssl)
44
45 TARGET_COMPILE_DEFINITIONS(ustream-ssl PRIVATE $<$<CONFIG:Debug>:DEBUG>)
46
47 INSTALL(FILES ustream-ssl.h
48 DESTINATION include/libubox
49 )
50 INSTALL(TARGETS ustream-ssl
51 LIBRARY DESTINATION lib
52 )
53
54 IF(ABIVERSION)
55 SET_TARGET_PROPERTIES(ustream-ssl PROPERTIES VERSION ${ABIVERSION})
56 ENDIF()