ustream-ssl: add support for using a fd instead of ustream as backing
[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 SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
14
15 IF(MBEDTLS)
16 ADD_DEFINITIONS(-DHAVE_MBEDTLS)
17 SET(SSL_SRC ustream-mbedtls.c)
18 FIND_LIBRARY(mbedtls_library mbedtls)
19 FIND_LIBRARY(mbedx509_library mbedx509)
20 FIND_LIBRARY(mbedcrypto_library mbedcrypto)
21 SET(SSL_LIB ${mbedtls_library} ${mbedx509_library} ${mbedcrypto_library} m)
22 ELSEIF(WOLFSSL)
23 ADD_DEFINITIONS(-DHAVE_WOLFSSL)
24 FIND_LIBRARY(wolfssl_library wolfssl)
25 SET(SSL_SRC ustream-io-wolfssl.c ustream-openssl.c)
26 SET(SSL_LIB ${wolfssl_library} m)
27 SET(CMAKE_REQUIRED_LIBRARIES "${wolfssl_library} -lm")
28 ELSE()
29 SET(SSL_SRC ustream-io-openssl.c ustream-openssl.c)
30 SET(SSL_LIB crypto ssl)
31 ENDIF()
32
33 FIND_PATH(ubox_include_dir libubox/ustream.h)
34 INCLUDE_DIRECTORIES(${ubox_include_dir})
35 FIND_LIBRARY(ubox_library NAMES ubox)
36
37 ADD_LIBRARY(ustream-ssl SHARED ustream-ssl.c ${SSL_SRC})
38 TARGET_LINK_LIBRARIES(ustream-ssl ${ubox_library} ${SSL_LIB})
39
40 ADD_EXECUTABLE(ustream-example-server ustream-example-server.c)
41 TARGET_LINK_LIBRARIES(ustream-example-server ustream-ssl)
42
43 ADD_EXECUTABLE(ustream-example-client ustream-example-client.c)
44 TARGET_LINK_LIBRARIES(ustream-example-client ustream-ssl)
45
46 TARGET_COMPILE_DEFINITIONS(ustream-ssl PRIVATE $<$<CONFIG:Debug>:DEBUG>)
47
48 INSTALL(FILES ustream-ssl.h
49 DESTINATION include/libubox
50 )
51 INSTALL(TARGETS ustream-ssl
52 LIBRARY DESTINATION lib
53 )
54
55 IF(ABIVERSION)
56 SET_TARGET_PROPERTIES(ustream-ssl PROPERTIES VERSION ${ABIVERSION})
57 ENDIF()