1# 2# libwebsockets - small server side websockets and web server implementation 3# 4# Copyright (C) 2010 - 2020 Andy Green <andy@warmcat.com> 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 32include_directories(wrapper/include wrapper/include/internal) 33 34 set(LWS_WITH_SSL ON) 35 36 include_directories(wrapper/include) 37 include_directories(wrapper/include/platform) 38 include_directories(wrapper/include/internal) 39 include_directories(wrapper/include/openssl) 40 41 if (LWS_WITH_NETWORK) 42 list(APPEND HDR_PRIVATE 43 tls/mbedtls/wrapper/include/internal/ssl3.h 44 tls/mbedtls/wrapper/include/internal/ssl_cert.h 45 tls/mbedtls/wrapper/include/internal/ssl_code.h 46 tls/mbedtls/wrapper/include/internal/ssl_dbg.h 47 tls/mbedtls/wrapper/include/internal/ssl_lib.h 48 tls/mbedtls/wrapper/include/internal/ssl_methods.h 49 tls/mbedtls/wrapper/include/internal/ssl_pkey.h 50 tls/mbedtls/wrapper/include/internal/ssl_stack.h 51 tls/mbedtls/wrapper/include/internal/ssl_types.h 52 tls/mbedtls/wrapper/include/internal/ssl_x509.h 53 tls/mbedtls/wrapper/include/internal/tls1.h 54 tls/mbedtls/wrapper/include/internal/x509_vfy.h) 55 56 list(APPEND HDR_PRIVATE 57 tls/mbedtls/wrapper/include/openssl/ssl.h) 58 59 list(APPEND HDR_PRIVATE 60 tls/mbedtls/wrapper/include/platform/ssl_pm.h 61 tls/mbedtls/wrapper/include/platform/ssl_port.h) 62 63 list(APPEND SOURCES 64 tls/mbedtls/wrapper/library/ssl_cert.c 65 tls/mbedtls/wrapper/library/ssl_lib.c 66 tls/mbedtls/wrapper/library/ssl_methods.c 67 tls/mbedtls/wrapper/library/ssl_pkey.c 68 tls/mbedtls/wrapper/library/ssl_stack.c 69 tls/mbedtls/wrapper/library/ssl_x509.c) 70 71 list(APPEND SOURCES 72 tls/mbedtls/wrapper/platform/ssl_pm.c 73 tls/mbedtls/wrapper/platform/ssl_port.c) 74 endif() 75 76 set(_WANT_MBT 0) 77 if (NOT LWS_PLAT_FREERTOS) 78 if (NOT DEFINED LWS_MBEDTLS_LIBRARIES) 79 set(_WANT_MBT 1) 80 endif() 81 if (NOT DEFINED LWS_MBEDTLS_INCLUDE_DIRS) 82 set(_WANT_MBT 1) 83 endif() 84 endif() 85 86 if (_WANT_MBT) 87 88 find_path(LWS_MBEDTLS_INCLUDE_DIRS mbedtls/ssl.h) 89 90 find_library(MBEDTLS_LIBRARY mbedtls) 91 find_library(MBEDX509_LIBRARY mbedx509) 92 find_library(MBEDCRYPTO_LIBRARY mbedcrypto) 93 94 set(LWS_MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}" "${MBEDCRYPTO_LIBRARY}") 95 96 include(FindPackageHandleStandardArgs) 97 find_package_handle_standard_args(MBEDTLS DEFAULT_MSG 98 LWS_MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY) 99 100 mark_as_advanced(LWS_MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY) 101 102 if ("${LWS_MBEDTLS_LIBRARIES}" STREQUAL "" OR "${LWS_MBEDTLS_INCLUDE_DIRS}" STREQUAL "") 103 message(FATAL_ERROR "You must set LWS_MBEDTLS_LIBRARIES and LWS_MBEDTLS_INCLUDE_DIRS when LWS_WITH_MBEDTLS is turned on.") 104 endif() 105 endif() 106 if (LWS_MBEDTLS_LIBRARIES) 107 set(MBEDTLS_LIBRARIES ${LWS_MBEDTLS_LIBRARIES}) 108 set(MBEDTLS_LIBRARIES ${LWS_MBEDTLS_LIBRARIES} PARENT_SCOPE) 109 endif() 110 if (LWS_MBEDTLS_INCLUDE_DIRS) 111 set(MBEDTLS_INCLUDE_DIRS ${LWS_MBEDTLS_INCLUDE_DIRS}) 112 set(MBEDTLS_INCLUDE_DIRS ${LWS_MBEDTLS_INCLUDE_DIRS} PARENT_SCOPE) 113 endif() 114 set(USE_MBEDTLS 1 PARENT_SCOPE) 115 if (DEFINED MBEDTLS_INCLUDE_DIRS) 116 include_directories(${MBEDTLS_INCLUDE_DIRS}) 117 set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${MBEDTLS_INCLUDE_DIRS}) 118 endif() 119 120 if (DEFINED MBEDTLS_LIBRARIES) 121 list(APPEND LIB_LIST ${MBEDTLS_LIBRARIES}) 122 endif() 123 124# old mbedtls has everything in mbedtls/net.h 125 126CHECK_C_SOURCE_COMPILES("#include <mbedtls/net_sockets.h>\nint main(void) { return 0;}\n" LWS_HAVE_MBEDTLS_NET_SOCKETS) 127 128# 129# Keep explicit parent scope exports at end 130# 131 132exports_to_parent_scope() 133set(LWS_HAVE_MBEDTLS_NET_SOCKETS ${LWS_HAVE_MBEDTLS_NET_SOCKETS} PARENT_SCOPE) 134