Add version detection of CyaSSL and make the cyassl backend compatible with both...
[project/ustream-ssl.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 INCLUDE(CheckIncludeFiles)
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(APPLE)
11   INCLUDE_DIRECTORIES(/opt/local/include)
12   LINK_DIRECTORIES(/opt/local/lib)
13 ENDIF()
14
15 IF(POLARSSL)
16   ADD_DEFINITIONS(-DHAVE_POLARSSL)
17   SET(SSL_SRC ustream-polarssl.c)
18   SET(SSL_LIB polarssl m)
19 ELSEIF(CYASSL)
20   CHECK_INCLUDE_FILES (cyassl/version.h HAVE_CYASSL_VERSION_H)
21   SET(CMAKE_EXTRA_INCLUDE_FILES cyassl/ssl.h)
22   IF (HAVE_CYASSL_VERSION_H)
23     ADD_DEFINITIONS(-DHAVE_CYASSL_VERSION_H)
24   ENDIF()
25   SET(SSL_SRC ustream-io-cyassl.c ustream-openssl.c)
26   SET(SSL_LIB cyassl m)
27 ELSE()
28   SET(SSL_SRC ustream-io-openssl.c ustream-openssl.c)
29   SET(SSL_LIB crypto ssl)
30 ENDIF()
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 ustream-example.c)
36 TARGET_LINK_LIBRARIES(ustream-example ustream-ssl)
37
38 INSTALL(FILES ustream-ssl.h
39         DESTINATION include/libubox
40 )
41 INSTALL(TARGETS ustream-ssl
42         LIBRARY DESTINATION lib
43 )