cmake: Find libubox/ustream.h header file
[project/ustream-ssl.git] / CMakeLists.txt
index a918e16d08dba2b4132787833a3e7ec6312fa80d..49e79a1f2694fe88ba70f62bf0daf1f4037250ff 100644 (file)
@@ -7,12 +7,11 @@ 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)
+IF(MBEDTLS)
+  ADD_DEFINITIONS(-DHAVE_MBEDTLS)
+  SET(SSL_SRC ustream-mbedtls.c)
+  SET(SSL_LIB mbedtls mbedcrypto mbedx509 m)
+ELSEIF(POLARSSL)
   ADD_DEFINITIONS(-DHAVE_POLARSSL)
   SET(SSL_SRC ustream-polarssl.c)
   SET(SSL_LIB polarssl m)
@@ -22,6 +21,7 @@ ELSEIF(CYASSL)
   IF (HAVE_CYASSL_VERSION_H)
     ADD_DEFINITIONS(-DHAVE_CYASSL_VERSION_H)
   ENDIF()
+  ADD_DEFINITIONS(-DHAVE_CYASSL)
   SET(SSL_SRC ustream-io-cyassl.c ustream-openssl.c)
   SET(SSL_LIB cyassl m)
 ELSE()
@@ -29,11 +29,17 @@ ELSE()
   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)
 
 INSTALL(FILES ustream-ssl.h
        DESTINATION include/libubox