CMakeLists.txt 1.9 KB

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