ustream-io-cyassl.c: fix client-mode connections
[project/ustream-ssl.git] / CMakeLists.txt
index 1178c62763fb136c26b956f2083fe15e57e265a3..6b3fc8cec8a4ec881fb467fbba461295f786fda2 100644 (file)
@@ -1,35 +1,44 @@
 cmake_minimum_required(VERSION 2.6)
 
+INCLUDE(CheckSymbolExists)
+
 PROJECT(ustream-ssl C)
 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
 
 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
 
-IF(APPLE)
-  INCLUDE_DIRECTORIES(/opt/local/include)
-  LINK_DIRECTORIES(/opt/local/lib)
-ENDIF()
-
-IF(POLARSSL)
-  ADD_DEFINITIONS(-DHAVE_POLARSSL)
-  SET(SSL_SRC ustream-polarssl.c)
-  SET(SSL_LIB polarssl m)
-ELSEIF(CYASSL)
-  SET(SSL_SRC ustream-io-cyassl.c ustream-openssl.c)
-  SET(SSL_LIB cyassl m)
+IF(MBEDTLS)
+  ADD_DEFINITIONS(-DHAVE_MBEDTLS)
+  SET(SSL_SRC ustream-mbedtls.c)
+  SET(SSL_LIB mbedtls mbedcrypto mbedx509 m)
+ELSEIF(WOLFSSL)
+  ADD_DEFINITIONS(-DHAVE_WOLFSSL)
+  SET(SSL_SRC ustream-io-wolfssl.c ustream-openssl.c)
+  SET(SSL_LIB wolfssl m)
+  SET(CMAKE_REQUIRED_LIBRARIES "-lwolfssl -lm")
+  CHECK_SYMBOL_EXISTS (wolfSSL_SSLSetIORecv "wolfssl/ssl.h"
+                      HAVE_WOLFSSL_SSLSETIORECV)
+  IF (NOT HAVE_WOLFSSL_SSLSETIORECV)
+    ADD_DEFINITIONS(-DNO_WOLFSSL_SSLSETIO_SEND_RECV)
+  ENDIF()
 ELSE()
   SET(SSL_SRC ustream-io-openssl.c ustream-openssl.c)
   SET(SSL_LIB crypto ssl)
 ENDIF()
 
+FIND_PATH(ubox_include_dir libubox/ustream.h)
+INCLUDE_DIRECTORIES(${ubox_include_dir})
+
 ADD_LIBRARY(ustream-ssl SHARED ustream-ssl.c ${SSL_SRC})
 TARGET_LINK_LIBRARIES(ustream-ssl ubox ${SSL_LIB})
 
-ADD_EXECUTABLE(ustream-example ustream-example.c)
-TARGET_LINK_LIBRARIES(ustream-example ustream-ssl)
+ADD_EXECUTABLE(ustream-example-server ustream-example-server.c)
+TARGET_LINK_LIBRARIES(ustream-example-server ustream-ssl)
+
+ADD_EXECUTABLE(ustream-example-client ustream-example-client.c)
+TARGET_LINK_LIBRARIES(ustream-example-client ustream-ssl)
 
-FILE(GLOB headers *.h)
-INSTALL(FILES ${headers}
+INSTALL(FILES ustream-ssl.h
        DESTINATION include/libubox
 )
 INSTALL(TARGETS ustream-ssl