CMakeLists.txt 1.8 KB

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