CMakeLists.txt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #
  2. # libwebsockets - small server side websockets and web server implementation
  3. #
  4. # Copyright (C) 2010 - 2020 Andy Green <[email protected]>
  5. #
  6. # Permission is hereby granted, free of charge, to any person obtaining a copy
  7. # of this software and associated documentation files (the "Software"), to
  8. # deal in the Software without restriction, including without limitation the
  9. # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  10. # sell copies of the Software, and to permit persons to whom the Software is
  11. # furnished to do so, subject to the following conditions:
  12. #
  13. # The above copyright notice and this permission notice shall be included in
  14. # all copies or substantial portions of the Software.
  15. #
  16. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  22. # IN THE SOFTWARE.
  23. #
  24. # The strategy is to only export to PARENT_SCOPE
  25. #
  26. # - changes to LIB_LIST
  27. # - changes to SOURCES
  28. # - includes via include_directories
  29. #
  30. # and keep everything else private
  31. include_directories(wrapper/include wrapper/include/internal)
  32. set(LWS_WITH_SSL ON)
  33. include_directories(wrapper/include)
  34. include_directories(wrapper/include/platform)
  35. include_directories(wrapper/include/internal)
  36. include_directories(wrapper/include/openssl)
  37. if (LWS_WITH_NETWORK)
  38. list(APPEND HDR_PRIVATE
  39. tls/mbedtls/wrapper/include/internal/ssl3.h
  40. tls/mbedtls/wrapper/include/internal/ssl_cert.h
  41. tls/mbedtls/wrapper/include/internal/ssl_code.h
  42. tls/mbedtls/wrapper/include/internal/ssl_dbg.h
  43. tls/mbedtls/wrapper/include/internal/ssl_lib.h
  44. tls/mbedtls/wrapper/include/internal/ssl_methods.h
  45. tls/mbedtls/wrapper/include/internal/ssl_pkey.h
  46. tls/mbedtls/wrapper/include/internal/ssl_stack.h
  47. tls/mbedtls/wrapper/include/internal/ssl_types.h
  48. tls/mbedtls/wrapper/include/internal/ssl_x509.h
  49. tls/mbedtls/wrapper/include/internal/tls1.h
  50. tls/mbedtls/wrapper/include/internal/x509_vfy.h)
  51. list(APPEND HDR_PRIVATE
  52. tls/mbedtls/wrapper/include/openssl/ssl.h)
  53. list(APPEND HDR_PRIVATE
  54. tls/mbedtls/wrapper/include/platform/ssl_pm.h
  55. tls/mbedtls/wrapper/include/platform/ssl_port.h)
  56. list(APPEND SOURCES
  57. tls/mbedtls/wrapper/library/ssl_cert.c
  58. tls/mbedtls/wrapper/library/ssl_lib.c
  59. tls/mbedtls/wrapper/library/ssl_methods.c
  60. tls/mbedtls/wrapper/library/ssl_pkey.c
  61. tls/mbedtls/wrapper/library/ssl_stack.c
  62. tls/mbedtls/wrapper/library/ssl_x509.c)
  63. list(APPEND SOURCES
  64. tls/mbedtls/wrapper/platform/ssl_pm.c
  65. tls/mbedtls/wrapper/platform/ssl_port.c)
  66. endif()
  67. set(_WANT_MBT 0)
  68. if (NOT LWS_PLAT_FREERTOS)
  69. if (NOT DEFINED LWS_MBEDTLS_LIBRARIES)
  70. set(_WANT_MBT 1)
  71. endif()
  72. if (NOT DEFINED LWS_MBEDTLS_INCLUDE_DIRS)
  73. set(_WANT_MBT 1)
  74. endif()
  75. endif()
  76. if (_WANT_MBT)
  77. find_path(LWS_MBEDTLS_INCLUDE_DIRS mbedtls/ssl.h)
  78. find_library(MBEDTLS_LIBRARY mbedtls)
  79. find_library(MBEDX509_LIBRARY mbedx509)
  80. find_library(MBEDCRYPTO_LIBRARY mbedcrypto)
  81. set(LWS_MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}" "${MBEDCRYPTO_LIBRARY}")
  82. include(FindPackageHandleStandardArgs)
  83. find_package_handle_standard_args(MBEDTLS DEFAULT_MSG
  84. LWS_MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
  85. mark_as_advanced(LWS_MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
  86. if ("${LWS_MBEDTLS_LIBRARIES}" STREQUAL "" OR "${LWS_MBEDTLS_INCLUDE_DIRS}" STREQUAL "")
  87. message(FATAL_ERROR "You must set LWS_MBEDTLS_LIBRARIES and LWS_MBEDTLS_INCLUDE_DIRS when LWS_WITH_MBEDTLS is turned on.")
  88. endif()
  89. endif()
  90. if (LWS_MBEDTLS_LIBRARIES)
  91. set(MBEDTLS_LIBRARIES ${LWS_MBEDTLS_LIBRARIES})
  92. endif()
  93. if (LWS_MBEDTLS_INCLUDE_DIRS)
  94. set(MBEDTLS_INCLUDE_DIRS ${LWS_MBEDTLS_INCLUDE_DIRS})
  95. endif()
  96. set(USE_MBEDTLS 1 PARENT_SCOPE)
  97. if (DEFINED MBEDTLS_INCLUDE_DIRS)
  98. include_directories(${MBEDTLS_INCLUDE_DIRS})
  99. endif()
  100. if (DEFINED MBEDTLS_LIBRARIES)
  101. list(APPEND LIB_LIST ${MBEDTLS_LIBRARIES})
  102. endif()
  103. # old mbedtls has everything in mbedtls/net.h
  104. CHECK_C_SOURCE_COMPILES("#include <mbedtls/net_sockets.h>\nint main(void) { return 0;}\n" LWS_HAVE_MBEDTLS_NET_SOCKETS)
  105. #
  106. # Keep explicit parent scope exports at end
  107. #
  108. exports_to_parent_scope()
  109. set(LWS_HAVE_MBEDTLS_NET_SOCKETS ${LWS_HAVE_MBEDTLS_NET_SOCKETS} PARENT_SCOPE)