Brown, Matthew | b0ff623 | 2016-09-27 05:32:40 +0800 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.8.9) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 2 | |
Andy Green | 46ee071 | 2017-11-10 08:56:44 +0800 | [diff] [blame] | 3 | # General Advice |
| 4 | # |
| 5 | # For selecting between DEBUG / RELEASE, use -DCMAKE_BUILD_TYPE=DEBUG or =RELEASE |
| 6 | # debug builds include source level debug info and extra logging |
| 7 | |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 8 | set(LWS_WITH_BUNDLED_ZLIB_DEFAULT OFF) |
| 9 | if(WIN32) |
| 10 | set(LWS_WITH_BUNDLED_ZLIB_DEFAULT ON) |
| 11 | endif() |
Andy Green | 16a9071 | 2018-04-27 15:20:56 +0800 | [diff] [blame] | 12 | |
Andy Green | 27e86e2 | 2018-04-25 08:42:18 +0800 | [diff] [blame] | 13 | set(LWS_ROLE_RAW 1) |
Andy Green | d37b383 | 2018-04-29 10:44:36 +0800 | [diff] [blame] | 14 | set(LWS_WITH_POLL 1) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 15 | |
| 16 | # |
Andy Green | 1d9d04f | 2018-01-27 08:01:33 +0800 | [diff] [blame] | 17 | # Select features recommended for PC distro packaging |
| 18 | # |
| 19 | option(LWS_WITH_DISTRO_RECOMMENDED "Enable features recommended for distro packaging" OFF) |
Andy Green | aa4143a | 2018-11-12 15:24:42 +0800 | [diff] [blame] | 20 | option(LWS_FOR_GITOHASHI "Enable features recommended for use with gitohashi" OFF) |
Andy Green | 1d9d04f | 2018-01-27 08:01:33 +0800 | [diff] [blame] | 21 | |
| 22 | # |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 23 | # Major individual features |
| 24 | # |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 25 | option(LWS_WITH_NETWORK "Compile with network-related code" ON) |
Andy Green | 16a9071 | 2018-04-27 15:20:56 +0800 | [diff] [blame] | 26 | option(LWS_ROLE_H1 "Compile with support for http/1 (needed for ws)" ON) |
Andy Green | 27e86e2 | 2018-04-25 08:42:18 +0800 | [diff] [blame] | 27 | option(LWS_ROLE_WS "Compile with support for websockets" ON) |
Andy Green | 31dfc4a | 2018-10-02 10:50:24 +0800 | [diff] [blame] | 28 | option(LWS_ROLE_DBUS "Compile with support for DBUS" OFF) |
Andy Green | 08b5ad9 | 2018-11-29 08:29:48 +0800 | [diff] [blame] | 29 | option(LWS_ROLE_RAW_PROXY "Raw packet proxy" OFF) |
Andy Green | aa4143a | 2018-11-12 15:24:42 +0800 | [diff] [blame] | 30 | option(LWS_WITH_HTTP2 "Compile with server support for HTTP/2" ON) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 31 | option(LWS_WITH_LWSWS "Libwebsockets Webserver" OFF) |
| 32 | option(LWS_WITH_CGI "Include CGI (spawn process with network-connected stdin/out/err) APIs" OFF) |
| 33 | option(LWS_IPV6 "Compile with support for ipv6" OFF) |
Andy Green | aa4143a | 2018-11-12 15:24:42 +0800 | [diff] [blame] | 34 | option(LWS_UNIX_SOCK "Compile with support for UNIX domain socket" OFF) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 35 | option(LWS_WITH_PLUGINS "Support plugins for protocols and extensions" OFF) |
Andy Green | aa4143a | 2018-11-12 15:24:42 +0800 | [diff] [blame] | 36 | option(LWS_WITH_HTTP_PROXY "Support for HTTP proxying" OFF) |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 37 | option(LWS_WITH_ZIP_FOPS "Support serving pre-zipped files" OFF) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 38 | option(LWS_WITH_SOCKS5 "Allow use of SOCKS5 proxy on client connections" OFF) |
| 39 | option(LWS_WITH_GENERIC_SESSIONS "With the Generic Sessions plugin" OFF) |
| 40 | option(LWS_WITH_PEER_LIMITS "Track peers and restrict resources a single peer can allocate" OFF) |
| 41 | option(LWS_WITH_ACCESS_LOG "Support generating Apache-compatible access logs" OFF) |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 42 | option(LWS_WITH_RANGES "Support http ranges (RFC7233)" OFF) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 43 | option(LWS_WITH_SERVER_STATUS "Support json + jscript server monitoring" OFF) |
Andy Green | aa4143a | 2018-11-12 15:24:42 +0800 | [diff] [blame] | 44 | option(LWS_WITH_THREADPOOL "Managed worker thread pool support (relies on pthreads)" OFF) |
Andy Green | d588286 | 2018-09-02 14:43:05 +0800 | [diff] [blame] | 45 | option(LWS_WITH_HTTP_STREAM_COMPRESSION "Support HTTP stream compression" OFF) |
| 46 | option(LWS_WITH_HTTP_BROTLI "Also offer brotli http stream compression (requires LWS_WITH_HTTP_STREAM_COMPRESSION)" OFF) |
Andy Green | 3ec7c1a | 2017-10-21 06:36:35 +0800 | [diff] [blame] | 47 | option(LWS_WITH_ACME "Enable support for ACME automatic cert acquisition + maintenance (letsencrypt etc)" OFF) |
Andy Green | fd810f1 | 2018-09-04 08:06:46 +0800 | [diff] [blame] | 48 | option(LWS_WITH_HUBBUB "Enable libhubbub rewriting support" OFF) |
Andy Green | aa4143a | 2018-11-12 15:24:42 +0800 | [diff] [blame] | 49 | option(LWS_WITH_FTS "Full Text Search support" OFF) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 50 | # |
| 51 | # TLS library options... all except mbedTLS are basically OpenSSL variants. |
| 52 | # |
| 53 | option(LWS_WITH_SSL "Include SSL support (defaults to OpenSSL or similar, mbedTLS if LWS_WITH_MBEDTLS is set)" ON) |
| 54 | option(LWS_WITH_MBEDTLS "Use mbedTLS (>=2.0) replacement for OpenSSL. When setting this, you also may need to specify LWS_MBEDTLS_LIBRARIES and LWS_MBEDTLS_INCLUDE_DIRS" OFF) |
| 55 | option(LWS_WITH_BORINGSSL "Use BoringSSL replacement for OpenSSL" OFF) |
| 56 | option(LWS_WITH_CYASSL "Use CyaSSL replacement for OpenSSL. When setting this, you also need to specify LWS_CYASSL_LIBRARIES and LWS_CYASSL_INCLUDE_DIRS" OFF) |
| 57 | option(LWS_WITH_WOLFSSL "Use wolfSSL replacement for OpenSSL. When setting this, you also need to specify LWS_WOLFSSL_LIBRARIES and LWS_WOLFSSL_INCLUDE_DIRS" OFF) |
| 58 | option(LWS_SSL_CLIENT_USE_OS_CA_CERTS "SSL support should make use of the OS-installed CA root certs" ON) |
| 59 | # |
| 60 | # Event library options (may select multiple, or none for default poll() |
| 61 | # |
| 62 | option(LWS_WITH_LIBEV "Compile with support for libev" OFF) |
| 63 | option(LWS_WITH_LIBUV "Compile with support for libuv" OFF) |
| 64 | option(LWS_WITH_LIBEVENT "Compile with support for libevent" OFF) |
| 65 | # |
| 66 | # Static / Dynamic build options |
| 67 | # |
| 68 | option(LWS_WITH_STATIC "Build the static version of the library" ON) |
| 69 | option(LWS_WITH_SHARED "Build the shared version of the library" ON) |
| 70 | option(LWS_LINK_TESTAPPS_DYNAMIC "Link the test apps to the shared version of the library. Default is to link statically" OFF) |
| 71 | option(LWS_STATIC_PIC "Build the static version of the library with position-independent code" OFF) |
| 72 | # |
| 73 | # Specific platforms |
| 74 | # |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 75 | option(LWS_WITH_ESP32 "Build for ESP32" OFF) |
| 76 | option(LWS_PLAT_OPTEE "Build for OPTEE" OFF) |
| 77 | # |
| 78 | # Client / Server / Test Apps build control |
| 79 | # |
| 80 | option(LWS_WITHOUT_CLIENT "Don't build the client part of the library" OFF) |
| 81 | option(LWS_WITHOUT_SERVER "Don't build the server part of the library" OFF) |
| 82 | option(LWS_WITHOUT_TESTAPPS "Don't build the libwebsocket-test-apps" OFF) |
| 83 | option(LWS_WITHOUT_TEST_SERVER "Don't build the test server" OFF) |
| 84 | option(LWS_WITHOUT_TEST_SERVER_EXTPOLL "Don't build the test server version that uses external poll" OFF) |
| 85 | option(LWS_WITHOUT_TEST_PING "Don't build the ping test application" OFF) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 86 | option(LWS_WITHOUT_TEST_CLIENT "Don't build the client test application" OFF) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 87 | # |
| 88 | # Extensions (permessage-deflate) |
| 89 | # |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 90 | option(LWS_WITHOUT_EXTENSIONS "Don't compile with extensions" ON) |
| 91 | option(LWS_WITH_ZLIB "Include zlib support (required for extensions)" OFF) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 92 | option(LWS_WITH_BUNDLED_ZLIB "Use bundled zlib version (Windows only)" ${LWS_WITH_BUNDLED_ZLIB_DEFAULT}) |
| 93 | # |
| 94 | # Helpers + misc |
| 95 | # |
| 96 | option(LWS_WITHOUT_BUILTIN_GETIFADDRS "Don't use the BSD getifaddrs implementation from libwebsockets if it is missing (this will result in a compilation error) ... The default is to assume that your libc provides it. On some systems such as uclibc it doesn't exist." OFF) |
| 97 | option(LWS_FALLBACK_GETHOSTBYNAME "Also try to do dns resolution using gethostbyname if getaddrinfo fails" OFF) |
| 98 | option(LWS_WITHOUT_BUILTIN_SHA1 "Don't build the lws sha-1 (eg, because openssl will provide it" OFF) |
| 99 | option(LWS_WITH_LATENCY "Build latency measuring code into the library" OFF) |
| 100 | option(LWS_WITHOUT_DAEMONIZE "Don't build the daemonization api" ON) |
| 101 | option(LWS_SSL_SERVER_WITH_ECDH_CERT "Include SSL server use ECDH certificate" OFF) |
Andy Green | f37454a | 2018-08-05 18:18:40 +0800 | [diff] [blame] | 102 | option(LWS_WITH_LEJP "With the Lightweight JSON Parser" ON) |
| 103 | option(LWS_WITH_LEJP_CONF "With LEJP configuration parser as used by lwsws" ON) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 104 | option(LWS_WITH_SQLITE3 "Require SQLITE3 support" OFF) |
| 105 | option(LWS_WITH_SMTP "Provide SMTP support" OFF) |
| 106 | option(LWS_WITH_NO_LOGS "Disable all logging from being compiled in" OFF) |
| 107 | option(LWS_AVOID_SIGPIPE_IGN "Android 7+ reportedly needs this" OFF) |
| 108 | option(LWS_WITH_STATS "Keep statistics of lws internal operations" OFF) |
Andy Green | eda102e | 2018-12-13 20:05:12 +0800 | [diff] [blame] | 109 | option(LWS_WITH_JOSE "JSON Web Signature / Encryption / Keys (RFC7515/6/) API" OFF) |
| 110 | option(LWS_WITH_GENCRYPTO "Enable support for Generic Crypto apis independent of TLS backend" OFF) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 111 | option(LWS_WITH_SELFTESTS "Selftests run at context creation" OFF) |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 112 | option(LWS_WITH_GCOV "Build with gcc gcov coverage instrumentation" OFF) |
Alexey Reznichenko | 9384613 | 2017-11-20 12:41:29 +0100 | [diff] [blame] | 113 | option(LWS_WITH_EXPORT_LWSTARGETS "Export libwebsockets CMake targets. Disable if they conflict with an outer cmake project." ON) |
Alexander Couzens | d7b6c04 | 2017-12-10 00:54:06 +0100 | [diff] [blame] | 114 | option(LWS_REPRODUCIBLE "Build libwebsockets reproducible. It removes the build user and hostname from the build" ON) |
Andy Green | e4a3e8c | 2018-03-17 06:43:12 +0800 | [diff] [blame] | 115 | option(LWS_WITH_MINIMAL_EXAMPLES "Also build the normally standalone minimal examples, for QA" OFF) |
Andy Green | a5b2248 | 2018-10-14 06:12:27 +0800 | [diff] [blame] | 116 | option(LWS_WITH_LWSAC "lwsac Chunk Allocation api" ON) |
Andy Green | 986bb37 | 2019-02-26 17:18:24 +0800 | [diff] [blame] | 117 | option(LWS_WITH_CUSTOM_HEADERS "Store and allow querying custom HTTP headers (H1 only)" ON) |
Andy Green | aa4143a | 2018-11-12 15:24:42 +0800 | [diff] [blame] | 118 | option(LWS_WITH_DISKCACHE "Hashed cache directory with lazy LRU deletion to size limit" OFF) |
Andy Green | cbb8b1d | 2018-11-03 14:47:48 +0800 | [diff] [blame] | 119 | option(LWS_WITH_ASAN "Build with gcc runtime sanitizer options enabled (needs libasan)" OFF) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 120 | # |
| 121 | # End of user settings |
| 122 | # |
| 123 | |
Andy Green | aa4143a | 2018-11-12 15:24:42 +0800 | [diff] [blame] | 124 | if (LWS_FOR_GITOHASHI) |
| 125 | set(LWS_WITH_THREADPOOL 1) |
| 126 | set(LWS_WITH_HTTP2 1) |
| 127 | set(LWS_UNIX_SOCK 1) |
| 128 | set(LWS_WITH_HTTP_PROXY 1) |
| 129 | set(LWS_WITH_FTS 1) |
| 130 | set(LWS_WITH_DISKCACHE 1) |
| 131 | set(LWS_WITH_LWSAC 1) |
| 132 | set(LWS_WITH_LEJP_CONF 1) |
| 133 | endif() |
Andy Green | 1d9d04f | 2018-01-27 08:01:33 +0800 | [diff] [blame] | 134 | |
| 135 | if(LWS_WITH_DISTRO_RECOMMENDED) |
| 136 | set(LWS_WITH_HTTP2 1) |
| 137 | set(LWS_WITH_LWSWS 1) |
| 138 | set(LWS_WITH_CGI 1) |
| 139 | set(LWS_IPV6 1) |
| 140 | set(LWS_WITH_ZIP_FOPS 1) |
| 141 | set(LWS_WITH_SOCKS5 1) |
| 142 | set(LWS_WITH_RANGES 1) |
| 143 | set(LWS_WITH_ACME 1) |
| 144 | set(LWS_WITH_SERVER_STATUS 1) |
| 145 | set(LWS_WITH_LIBUV 1) |
| 146 | set(LWS_WITH_LIBEV 1) |
Andy Green | ff2f5f6 | 2018-02-19 10:39:01 +0800 | [diff] [blame] | 147 | # libev + libevent cannot coexist at build-time |
| 148 | set(LWS_WITH_LIBEVENT 0) |
Andy Green | 1d9d04f | 2018-01-27 08:01:33 +0800 | [diff] [blame] | 149 | set(LWS_WITHOUT_EXTENSIONS 0) |
Andy Green | 31dfc4a | 2018-10-02 10:50:24 +0800 | [diff] [blame] | 150 | set(LWS_ROLE_DBUS 1) |
Andy Green | d3bc2c3 | 2018-10-14 11:38:08 +0800 | [diff] [blame] | 151 | set(LWS_WITH_FTS 1) |
Andy Green | aa4143a | 2018-11-12 15:24:42 +0800 | [diff] [blame] | 152 | set(LWS_WITH_THREADPOOL 1) |
| 153 | set(LWS_UNIX_SOCK 1) |
| 154 | set(LWS_WITH_HTTP_PROXY 1) |
| 155 | set(LWS_WITH_DISKCACHE 1) |
| 156 | set(LWS_WITH_LWSAC 1) |
Andy Green | 89eedca | 2018-11-23 11:30:56 +0800 | [diff] [blame] | 157 | set(LWS_WITH_LEJP_CONF 1) |
| 158 | set(LWS_WITH_PLUGINS 1) |
Andy Green | 08b5ad9 | 2018-11-29 08:29:48 +0800 | [diff] [blame] | 159 | set(LWS_ROLE_RAW_PROXY 1) |
Andy Green | eda102e | 2018-12-13 20:05:12 +0800 | [diff] [blame] | 160 | set(LWS_WITH_GENCRYPTO 1) |
| 161 | set(LWS_WITH_JOSE 1) |
Andy Green | 1d9d04f | 2018-01-27 08:01:33 +0800 | [diff] [blame] | 162 | endif() |
| 163 | |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 164 | if (NOT LWS_WITH_NETWORK) |
| 165 | set(LWS_ROLE_H1 0) |
| 166 | set(LWS_ROLE_WS 0) |
| 167 | set(LWS_ROLE_RAW 0) |
| 168 | set(LWS_WITHOUT_EXTENSIONS 1) |
| 169 | set(LWS_WITHOUT_SERVER 1) |
| 170 | set(LWS_WITHOUT_CLIENT 1) |
| 171 | set(LWS_WITH_HTTP2 0) |
| 172 | set(LWS_WITH_SOCKS5 0) |
| 173 | set(LWS_UNIX_SOCK 0) |
| 174 | set(LWS_WITH_HTTP_PROXY 0) |
| 175 | set(LWS_WITH_PLUGINS 0) |
| 176 | set(LWS_WITH_LWSWS 0) |
| 177 | set(LWS_WITH_CGI 0) |
| 178 | set(LWS_ROLE_RAW_PROXY 0) |
| 179 | set(LWS_WITH_PEER_LIMITS 0) |
| 180 | set(LWS_WITH_GENERIC_SESSIONS 0) |
| 181 | set(LWS_WITH_HTTP_STREAM_COMPRESSION 0) |
| 182 | set(LWS_WITH_HTTP_BROTLI 0) |
| 183 | set(LWS_WITH_POLL 0) |
| 184 | endif() |
| 185 | |
Andy Green | 47e10ab | 2018-10-03 14:14:29 +0800 | [diff] [blame] | 186 | # do you care about this? Then send me a patch where it disables it on travis |
| 187 | # but allows it on APPLE |
| 188 | if (APPLE) |
| 189 | set(LWS_ROLE_DBUS 0) |
| 190 | endif() |
| 191 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 192 | if(NOT DEFINED CMAKE_BUILD_TYPE) |
| 193 | set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type") |
| 194 | endif() |
| 195 | |
Andy Green | fd810f1 | 2018-09-04 08:06:46 +0800 | [diff] [blame] | 196 | # microsoft... that's why you can't have nice things |
| 197 | |
| 198 | if (WIN32 OR LWS_WITH_ESP32) |
| 199 | set(LWS_UNIX_SOCK 0) |
| 200 | endif() |
| 201 | |
Andy Green | a5b2248 | 2018-10-14 06:12:27 +0800 | [diff] [blame] | 202 | if (LWS_WITH_ESP32) |
| 203 | set(LWS_WITH_LWSAC 0) |
Andy Green | d3bc2c3 | 2018-10-14 11:38:08 +0800 | [diff] [blame] | 204 | set(LWS_WITH_FTS 0) |
Andy Green | a5b2248 | 2018-10-14 06:12:27 +0800 | [diff] [blame] | 205 | endif() |
| 206 | |
Samuel Martin | a11a282 | 2014-05-02 14:24:58 +0200 | [diff] [blame] | 207 | project(libwebsockets C) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 208 | |
| 209 | set(PACKAGE "libwebsockets") |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 210 | set(CPACK_PACKAGE_NAME "${PACKAGE}") |
Andy Green | 1c08a96 | 2018-05-04 13:27:12 +0800 | [diff] [blame] | 211 | set(CPACK_PACKAGE_VERSION_MAJOR "3") |
Andy Green | 89eedca | 2018-11-23 11:30:56 +0800 | [diff] [blame] | 212 | set(CPACK_PACKAGE_VERSION_MINOR "1") |
Andy Green | 2d245ae | 2018-11-23 11:33:40 +0800 | [diff] [blame] | 213 | set(CPACK_PACKAGE_VERSION_PATCH "99") |
Andy Green | 89eedca | 2018-11-23 11:30:56 +0800 | [diff] [blame] | 214 | set(CPACK_PACKAGE_RELEASE 1) |
| 215 | set(CPACK_GENERATOR "RPM") |
Roger A. Light | e59908e | 2015-12-14 17:25:29 +0000 | [diff] [blame] | 216 | set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 217 | set(CPACK_PACKAGE_VENDOR "andy@warmcat.com") |
Andy Green | 89eedca | 2018-11-23 11:30:56 +0800 | [diff] [blame] | 218 | set(CPACK_PACKAGE_CONTACT "andy@warmcat.com") |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 219 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE} ${PACKAGE_VERSION}") |
Andy Green | 89eedca | 2018-11-23 11:30:56 +0800 | [diff] [blame] | 220 | set(SOVERSION "14") |
Rainer Poisel | d2cef15 | 2016-11-07 21:36:05 +0100 | [diff] [blame] | 221 | if(NOT CPACK_GENERATOR) |
| 222 | if(UNIX) |
| 223 | set(CPACK_GENERATOR "TGZ") |
| 224 | else() |
| 225 | set(CPACK_GENERATOR "ZIP") |
| 226 | endif() |
| 227 | endif() |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 228 | set(CPACK_SOURCE_GENERATOR "TGZ") |
| 229 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") |
| 230 | set(VERSION "${CPACK_PACKAGE_VERSION}") |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 231 | |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 232 | set(LWS_LIBRARY_VERSION ${CPACK_PACKAGE_VERSION}) |
Roger A. Light | e59908e | 2015-12-14 17:25:29 +0000 | [diff] [blame] | 233 | set(LWS_LIBRARY_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR}) |
| 234 | set(LWS_LIBRARY_VERSION_MINOR ${CPACK_PACKAGE_VERSION_MINOR}) |
| 235 | set(LWS_LIBRARY_VERSION_PATCH ${CPACK_PACKAGE_VERSION_PATCH}) |
| 236 | |
Edwin van den Oetelaar | d6bf73c | 2013-02-18 20:20:05 +0800 | [diff] [blame] | 237 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/") |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 238 | |
Andy Green | 89eedca | 2018-11-23 11:30:56 +0800 | [diff] [blame] | 239 | |
Andy Green | 5b479ac | 2013-03-30 10:30:03 +0800 | [diff] [blame] | 240 | message(STATUS "CMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}'") |
| 241 | |
krismattheus | 5366a76 | 2018-02-05 15:33:36 +0100 | [diff] [blame] | 242 | if(WIN32) |
| 243 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/win32port/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/win32port/version.rc @ONLY) |
| 244 | set(RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/win32port/version.rc) |
| 245 | endif() |
| 246 | |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 247 | # Try to find the current Git hash. |
| 248 | find_package(Git) |
| 249 | if(GIT_EXECUTABLE) |
| 250 | execute_process( |
Alexander Couzens | d7b6c04 | 2017-12-10 00:54:06 +0100 | [diff] [blame] | 251 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
Andy Green | 8140c71 | 2018-05-15 12:44:31 +0800 | [diff] [blame] | 252 | COMMAND "${GIT_EXECUTABLE}" describe --tags |
Alexander Couzens | d7b6c04 | 2017-12-10 00:54:06 +0100 | [diff] [blame] | 253 | OUTPUT_VARIABLE GIT_HASH |
| 254 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 255 | ) |
| 256 | set(LWS_BUILD_HASH ${GIT_HASH}) |
| 257 | |
Andy Green | 8140c71 | 2018-05-15 12:44:31 +0800 | [diff] [blame] | 258 | # append the build user and hostname |
Alexander Couzens | d7b6c04 | 2017-12-10 00:54:06 +0100 | [diff] [blame] | 259 | if(NOT LWS_REPRODUCIBLE) |
| 260 | execute_process( |
| 261 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
| 262 | COMMAND "whoami" |
| 263 | OUTPUT_VARIABLE GIT_USER |
| 264 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 265 | ) |
| 266 | execute_process( |
| 267 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
| 268 | COMMAND "hostname" |
| 269 | OUTPUT_VARIABLE GIT_HOST |
| 270 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 271 | ) |
| 272 | string(REGEX REPLACE "([^\\])[\\]([^\\])" "\\1\\\\\\\\\\2" GIT_USER ${GIT_USER}) |
| 273 | set(LWS_BUILD_HASH ${GIT_USER}@${GIT_HOST}-${GIT_HASH}) |
| 274 | endif() |
| 275 | |
| 276 | message("Git commit hash: ${LWS_BUILD_HASH}") |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 277 | endif() |
| 278 | |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 279 | # translate old functionality enables to set up ROLE enables so nothing changes |
Andy Green | aa4143a | 2018-11-12 15:24:42 +0800 | [diff] [blame] | 280 | if (LWS_WITH_HTTP2 AND LWS_WITHOUT_SERVER) |
| 281 | set(LWS_WITH_HTTP2 0) |
| 282 | message("HTTP2 disabled due to LWS_WITHOUT_SERVER") |
| 283 | endif() |
| 284 | |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 285 | if (LWS_WITH_HTTP2) |
| 286 | set(LWS_ROLE_H2 1) |
| 287 | endif() |
| 288 | if (LWS_WITH_CGI) |
| 289 | set(LWS_ROLE_CGI 1) |
| 290 | endif() |
| 291 | |
Andy Green | 27e86e2 | 2018-04-25 08:42:18 +0800 | [diff] [blame] | 292 | if (NOT LWS_ROLE_WS) |
| 293 | set(LWS_WITHOUT_EXTENSIONS 1) |
| 294 | endif() |
| 295 | |
Andy Green | ac6c48d | 2018-04-27 19:16:50 +0800 | [diff] [blame] | 296 | |
Andy Green | d3bc2c3 | 2018-10-14 11:38:08 +0800 | [diff] [blame] | 297 | include_directories(include plugins) |
Andy Green | d1f9f0a | 2018-08-23 09:46:01 +0800 | [diff] [blame] | 298 | |
Andy Green | ac6c48d | 2018-04-27 19:16:50 +0800 | [diff] [blame] | 299 | |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 300 | if (LWS_WITH_LWSWS) |
| 301 | message(STATUS "LWS_WITH_LWSWS --> Enabling LWS_WITH_PLUGINS and LWS_WITH_LIBUV") |
| 302 | set(LWS_WITH_PLUGINS 1) |
| 303 | set(LWS_WITH_LIBUV 1) |
Andy Green | 2f0bc93 | 2016-04-15 12:00:23 +0800 | [diff] [blame] | 304 | set(LWS_WITH_ACCESS_LOG 1) |
Andy Green | 9806140 | 2016-04-15 14:01:29 +0800 | [diff] [blame] | 305 | set(LWS_WITH_SERVER_STATUS 1) |
Andy Green | 5afc567 | 2016-05-10 09:47:10 +0800 | [diff] [blame] | 306 | set(LWS_WITH_LEJP 1) |
Andy Green | 3358c53 | 2016-05-26 21:12:11 +0800 | [diff] [blame] | 307 | set(LWS_WITH_LEJP_CONF 1) |
Andy Green | 98df672 | 2017-09-14 13:14:11 +0800 | [diff] [blame] | 308 | set(LWS_WITH_PEER_LIMITS 1) |
Andy Green | 08b5ad9 | 2018-11-29 08:29:48 +0800 | [diff] [blame] | 309 | set(LWS_ROLE_RAW_PROXY 1) |
| 310 | endif() |
| 311 | |
Andy Green | eda102e | 2018-12-13 20:05:12 +0800 | [diff] [blame] | 312 | # sshd plugin |
| 313 | if (LWS_WITH_PLUGINS) |
| 314 | set(LWS_WITH_GENCRYPTO 1) |
| 315 | endif() |
| 316 | |
Andy Green | 08b5ad9 | 2018-11-29 08:29:48 +0800 | [diff] [blame] | 317 | if (LWS_ROLE_RAW_PROXY) |
| 318 | set (LWS_WITHOUT_CLIENT 0) |
| 319 | set (LWS_WITHOUT_SERVER 0) |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 320 | endif() |
Vijay Khurdiya | e73d446 | 2016-01-15 16:21:51 +0800 | [diff] [blame] | 321 | |
Andy Green | 3ec7c1a | 2017-10-21 06:36:35 +0800 | [diff] [blame] | 322 | if (LWS_WITH_ACME) |
| 323 | set (LWS_WITHOUT_CLIENT 0) |
| 324 | set (LWS_WITHOUT_SERVER 0) |
Andy Green | eda102e | 2018-12-13 20:05:12 +0800 | [diff] [blame] | 325 | set (LWS_WITH_JOSE 1) |
Andy Green | 3ec7c1a | 2017-10-21 06:36:35 +0800 | [diff] [blame] | 326 | endif() |
| 327 | |
Andy Green | eda102e | 2018-12-13 20:05:12 +0800 | [diff] [blame] | 328 | if (LWS_WITH_JOSE) |
Andy Green | 278e520 | 2017-10-18 19:27:38 +0800 | [diff] [blame] | 329 | set(LWS_WITH_LEJP 1) |
Andy Green | eda102e | 2018-12-13 20:05:12 +0800 | [diff] [blame] | 330 | set(LWS_WITH_GENCRYPTO 1) |
Andy Green | 278e520 | 2017-10-18 19:27:38 +0800 | [diff] [blame] | 331 | endif() |
| 332 | |
Andy Green | 0a18354 | 2016-04-09 07:22:40 +0800 | [diff] [blame] | 333 | if (LWS_WITH_PLUGINS AND NOT LWS_WITH_LIBUV) |
| 334 | message(STATUS "LWS_WITH_PLUGINS --> Enabling LWS_WITH_LIBUV") |
| 335 | set(LWS_WITH_LIBUV 1) |
| 336 | endif() |
| 337 | |
Andy Green | 602d884 | 2016-06-07 09:49:59 +0800 | [diff] [blame] | 338 | if (LWS_WITH_SMTP AND NOT LWS_WITH_LIBUV) |
| 339 | message(STATUS "LWS_WITH_SMTP --> Enabling LWS_WITH_LIBUV") |
| 340 | set(LWS_WITH_LIBUV 1) |
| 341 | endif() |
| 342 | |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 343 | if (LWS_WITH_PLUGINS OR LWS_WITH_CGI) |
| 344 | # sshd plugin |
Andy Green | eda102e | 2018-12-13 20:05:12 +0800 | [diff] [blame] | 345 | set(LWS_WITH_GENCRYPTO 1) |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 346 | endif() |
| 347 | |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 348 | if (LWS_WITH_GENERIC_SESSIONS) |
| 349 | set(LWS_WITH_SQLITE3 1) |
| 350 | set(LWS_WITH_SMTP 1) |
| 351 | endif() |
| 352 | |
| 353 | if (LWS_WITH_SMTP AND NOT LWS_WITH_LIBUV) |
| 354 | message(STATUS "LWS_WITH_SMTP --> Enabling LWS_WITH_LIBUV") |
| 355 | set(LWS_WITH_LIBUV 1) |
| 356 | endif() |
| 357 | |
Andy Green | c7c4ae0 | 2017-02-18 17:26:40 +0800 | [diff] [blame] | 358 | if (LWS_WITH_ESP32) |
| 359 | set(LWS_WITH_SHARED OFF) |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 360 | set(LWS_WITH_MBEDTLS ON) |
Andy Green | 00ae909 | 2017-03-16 10:46:31 +0800 | [diff] [blame] | 361 | # set(LWS_WITHOUT_CLIENT ON) |
Andy Green | c7c4ae0 | 2017-02-18 17:26:40 +0800 | [diff] [blame] | 362 | set(LWS_WITHOUT_TESTAPPS ON) |
| 363 | set(LWS_WITHOUT_EXTENSIONS ON) |
| 364 | set(LWS_WITH_PLUGINS OFF) |
| 365 | set(LWS_WITH_RANGES ON) |
| 366 | # this implies no pthreads in the lib |
| 367 | set(LWS_MAX_SMP 1) |
| 368 | set(LWS_HAVE_MALLOC 1) |
| 369 | set(LWS_HAVE_REALLOC 1) |
| 370 | set(LWS_HAVE_GETIFADDRS 1) |
Andy Green | 00ae909 | 2017-03-16 10:46:31 +0800 | [diff] [blame] | 371 | set(LWS_WITH_ZIP_FOPS 1) |
Andy Green | 986bb37 | 2019-02-26 17:18:24 +0800 | [diff] [blame] | 372 | set(LWS_WITH_CUSTOM_HEADERS 0) |
Andy Green | c7c4ae0 | 2017-02-18 17:26:40 +0800 | [diff] [blame] | 373 | endif() |
| 374 | |
Andy Green | 7acf76c | 2016-07-23 14:18:25 +0800 | [diff] [blame] | 375 | |
Andy Green | 8c1f602 | 2016-01-26 20:56:56 +0800 | [diff] [blame] | 376 | if (WIN32) |
Andy Green | 8c1f602 | 2016-01-26 20:56:56 +0800 | [diff] [blame] | 377 | set(LWS_MAX_SMP 1) |
Andy Green | ebed5e7 | 2018-09-02 14:35:37 +0800 | [diff] [blame] | 378 | set(LWS_WITH_THREADPOOL 0) |
Andy Green | 8c1f602 | 2016-01-26 20:56:56 +0800 | [diff] [blame] | 379 | endif() |
| 380 | |
Andy Green | cd0c696 | 2016-03-28 10:12:37 +0800 | [diff] [blame] | 381 | |
| 382 | if (LWS_WITHOUT_SERVER) |
| 383 | set(LWS_WITH_LWSWS OFF) |
| 384 | endif() |
| 385 | |
Andy Green | ac6c48d | 2018-04-27 19:16:50 +0800 | [diff] [blame] | 386 | |
| 387 | # confirm H1 relationships |
| 388 | |
| 389 | if (NOT LWS_ROLE_H1 AND LWS_ROLE_H2) |
| 390 | message(FATAL_ERROR "H2 requires LWS_ROLE_H1") |
| 391 | endif() |
| 392 | |
| 393 | if (NOT LWS_ROLE_H1 AND LWS_ROLE_WS) |
| 394 | message(FATAL_ERROR "WS requires LWS_ROLE_H1") |
| 395 | endif() |
| 396 | |
| 397 | if (NOT LWS_ROLE_H1 AND LWS_ROLE_CGI) |
| 398 | message(FATAL_ERROR "CGI requires LWS_ROLE_H1") |
| 399 | endif() |
| 400 | |
| 401 | # confirm HTTP relationships |
| 402 | |
| 403 | if (NOT LWS_ROLE_H1 AND NOT LWS_ROLE_H2 AND LWS_WITH_HTTP_PROXY) |
| 404 | message(FATAL_ERROR "LWS_WITH_LWSWS requires LWS_ROLE_H1") |
| 405 | endif() |
| 406 | |
| 407 | if (NOT LWS_ROLE_H1 AND NOT LWS_ROLE_H2 AND LWS_WITH_HTTP_PROXY) |
| 408 | message(FATAL_ERROR "LWS_WITH_HTTP_PROXY requires LWS_ROLE_H1") |
| 409 | endif() |
| 410 | |
| 411 | if (NOT LWS_ROLE_H1 AND NOT LWS_ROLE_H2 AND LWS_WITH_RANGES) |
| 412 | message(FATAL_ERROR "LWS_WITH_RANGES requires LWS_ROLE_H1") |
| 413 | endif() |
| 414 | |
| 415 | if (NOT LWS_ROLE_H1 AND NOT LWS_ROLE_H2 AND LWS_WITH_ACCESS_LOG) |
| 416 | message(FATAL_ERROR "LWS_WITH_ACCESS_LOG requires LWS_ROLE_H1") |
| 417 | endif() |
| 418 | |
| 419 | |
Andy Green | 1e5a9ad | 2016-03-20 11:59:53 +0800 | [diff] [blame] | 420 | if (LWS_WITH_HTTP_PROXY AND (LWS_WITHOUT_CLIENT OR LWS_WITHOUT_SERVER)) |
Andy Green | fd810f1 | 2018-09-04 08:06:46 +0800 | [diff] [blame] | 421 | message("You have to enable both client and server for http proxy") |
| 422 | set(LWS_WITH_HTTP_PROXY 0) |
Andy Green | 1e5a9ad | 2016-03-20 11:59:53 +0800 | [diff] [blame] | 423 | endif() |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 424 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 425 | # Allow the user to override installation directories. |
| 426 | set(LWS_INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") |
| 427 | set(LWS_INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables") |
| 428 | set(LWS_INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files") |
| 429 | set(LWS_INSTALL_EXAMPLES_DIR bin CACHE PATH "Installation directory for example files") |
| 430 | |
ABruines | 80a7068 | 2015-08-09 22:56:32 +0200 | [diff] [blame] | 431 | # Allow the user to use the old CyaSSL options/library in stead of wolfSSL |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 432 | if (LWS_WITH_CYASSL AND LWS_WITH_WOLFSSL) |
| 433 | message(FATAL_ERROR "LWS_WITH_CYASSL and LWS_WITH_WOLFSSL are mutually exclusive!") |
ABruines | 80a7068 | 2015-08-09 22:56:32 +0200 | [diff] [blame] | 434 | endif() |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 435 | if (LWS_WITH_CYASSL) |
ABruines | 80a7068 | 2015-08-09 22:56:32 +0200 | [diff] [blame] | 436 | # Copy CyaSSL options to the wolfSSL options |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 437 | set(LWS_WITH_WOLFSSL ${LWS_WITH_CYASSL} CACHE BOOL "Use wolfSSL/CyaSSL instead of OpenSSL" FORCE) |
ABruines | 80a7068 | 2015-08-09 22:56:32 +0200 | [diff] [blame] | 438 | set(LWS_WOLFSSL_LIBRARIES ${LWS_CYASSL_LIBRARIES} CACHE PATH "Path to wolfSSL/CyaSSL libraries" FORCE) |
| 439 | set(LWS_WOLFSSL_INCLUDE_DIRS ${LWS_CYASSL_INCLUDE_DIRS} CACHE PATH "Path to wolfSSL/CyaSSL header files" FORCE) |
| 440 | endif() |
| 441 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 442 | if (NOT (LWS_WITH_STATIC OR LWS_WITH_SHARED)) |
Peter Pentchev | e46f412 | 2015-10-01 12:25:05 +0300 | [diff] [blame] | 443 | message(FATAL_ERROR "Makes no sense to compile with neither static nor shared libraries.") |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 444 | endif() |
| 445 | |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 446 | if (NOT LWS_WITHOUT_EXTENSIONS OR LWS_WITH_ZIP_FOPS) |
| 447 | set(LWS_WITH_ZLIB 1) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 448 | endif() |
| 449 | |
| 450 | set(LWS_ZLIB_LIBRARIES CACHE PATH "Path to the zlib library") |
| 451 | set(LWS_ZLIB_INCLUDE_DIRS CACHE PATH "Path to the zlib include directory") |
| 452 | set(LWS_OPENSSL_LIBRARIES CACHE PATH "Path to the OpenSSL library") |
| 453 | set(LWS_OPENSSL_INCLUDE_DIRS CACHE PATH "Path to the OpenSSL include directory") |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 454 | set(LWS_WOLFSSL_LIBRARIES CACHE PATH "Path to the wolfSSL library") |
| 455 | set(LWS_WOLFSSL_INCLUDE_DIRS CACHE PATH "Path to the wolfSSL include directory") |
Andy Green | c83afc6 | 2017-10-16 12:52:32 +0800 | [diff] [blame] | 456 | set(LWS_LIBEV_LIBRARIES CACHE PATH "Path to the libev library") |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 457 | set(LWS_LIBEV_INCLUDE_DIRS CACHE PATH "Path to the libev include directory") |
Andy Green | 86ed65f | 2016-02-14 09:27:41 +0800 | [diff] [blame] | 458 | set(LWS_LIBUV_LIBRARIES CACHE PATH "Path to the libuv library") |
Andy Green | 02ff145 | 2016-03-31 08:33:47 +0800 | [diff] [blame] | 459 | set(LWS_LIBUV_INCLUDE_DIRS CACHE PATH "Path to the libuv include directory") |
Yuchen Xie | 936bf08 | 2017-02-18 15:51:34 +0800 | [diff] [blame] | 460 | set(LWS_SQLITE3_LIBRARIES CACHE PATH "Path to the sqlite3 library") |
| 461 | set(LWS_SQLITE3_INCLUDE_DIRS CACHE PATH "Path to the sqlite3 include directory") |
Aditya Tirumala | ec50eba | 2017-03-15 19:41:11 +0530 | [diff] [blame] | 462 | set(LWS_LIBEVENT_INCLUDE_DIRS CACHE PATH "Path to the libevent include directory") |
| 463 | set(LWS_LIBEVENT_LIBRARIES CACHE PATH "Path to the libevent library") |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 464 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 465 | |
Andy Green | 9ffb42e | 2015-11-09 04:24:46 +0800 | [diff] [blame] | 466 | if (NOT LWS_WITH_SSL) |
| 467 | set(LWS_WITHOUT_BUILTIN_SHA1 OFF) |
| 468 | endif() |
| 469 | |
Andy Green | edeb8a5 | 2018-11-23 10:52:39 +0800 | [diff] [blame] | 470 | if (LWS_WITH_BORINGSSL) |
| 471 | # boringssl deprecated EVP_PKEY |
| 472 | set (LWS_WITH_GENHASH OFF) |
| 473 | endif() |
| 474 | |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 475 | if (LWS_WITH_SSL AND NOT LWS_WITH_WOLFSSL AND NOT LWS_WITH_MBEDTLS) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 476 | if ("${LWS_OPENSSL_LIBRARIES}" STREQUAL "" OR "${LWS_OPENSSL_INCLUDE_DIRS}" STREQUAL "") |
| 477 | else() |
Andy Green | 3a09c3b | 2017-03-08 11:11:41 +0800 | [diff] [blame] | 478 | if (NOT LWS_WITH_ESP32) |
| 479 | set(OPENSSL_LIBRARIES ${LWS_OPENSSL_LIBRARIES}) |
| 480 | endif() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 481 | set(OPENSSL_INCLUDE_DIRS ${LWS_OPENSSL_INCLUDE_DIRS}) |
| 482 | set(OPENSSL_FOUND 1) |
| 483 | endif() |
| 484 | endif() |
| 485 | |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 486 | if (LWS_WITH_SSL AND LWS_WITH_WOLFSSL) |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 487 | if ("${LWS_WOLFSSL_LIBRARIES}" STREQUAL "" OR "${LWS_WOLFSSL_INCLUDE_DIRS}" STREQUAL "") |
| 488 | if (NOT WOLFSSL_FOUND) |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 489 | if (LWS_WITH_CYASSL) |
| 490 | message(FATAL_ERROR "You must set LWS_CYASSL_LIBRARIES and LWS_CYASSL_INCLUDE_DIRS when LWS_WITH_CYASSL is turned on.") |
ABruines | 80a7068 | 2015-08-09 22:56:32 +0200 | [diff] [blame] | 491 | else() |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 492 | message(FATAL_ERROR "You must set LWS_WOLFSSL_LIBRARIES and LWS_WOLFSSL_INCLUDE_DIRS when LWS_WITH_WOLFSSL is turned on.") |
ABruines | 80a7068 | 2015-08-09 22:56:32 +0200 | [diff] [blame] | 493 | endif() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 494 | endif() |
| 495 | else() |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 496 | set(WOLFSSL_LIBRARIES ${LWS_WOLFSSL_LIBRARIES}) |
| 497 | set(WOLFSSL_INCLUDE_DIRS ${LWS_WOLFSSL_INCLUDE_DIRS}) |
| 498 | set(WOLFSSL_FOUND 1) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 499 | endif() |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 500 | set(USE_WOLFSSL 1) |
kaleb-himes | 65b68bd | 2018-04-28 07:54:09 +0800 | [diff] [blame] | 501 | set(LWS_WITH_TLS 1) |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 502 | if (LWS_WITH_CYASSL) |
ABruines | 80a7068 | 2015-08-09 22:56:32 +0200 | [diff] [blame] | 503 | set(USE_OLD_CYASSL 1) |
| 504 | endif() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 505 | endif() |
| 506 | |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 507 | if (LWS_WITH_SSL AND LWS_WITH_MBEDTLS) |
Andy Green | 6d25763 | 2017-08-28 21:27:55 +0800 | [diff] [blame] | 508 | if ("${LWS_MBEDTLS_LIBRARIES}" STREQUAL "" OR "${LWS_MBEDTLS_INCLUDE_DIRS}" STREQUAL "" AND NOT LWS_WITH_ESP32) |
Andy Green | c0c217b | 2017-08-28 21:00:11 +0800 | [diff] [blame] | 509 | |
| 510 | find_path(LWS_MBEDTLS_INCLUDE_DIRS mbedtls/ssl.h) |
| 511 | |
| 512 | find_library(MBEDTLS_LIBRARY mbedtls) |
| 513 | find_library(MBEDX509_LIBRARY mbedx509) |
| 514 | find_library(MBEDCRYPTO_LIBRARY mbedcrypto) |
| 515 | |
| 516 | set(LWS_MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}" "${MBEDCRYPTO_LIBRARY}") |
| 517 | |
| 518 | include(FindPackageHandleStandardArgs) |
| 519 | find_package_handle_standard_args(MBEDTLS DEFAULT_MSG |
| 520 | LWS_MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY) |
| 521 | |
| 522 | mark_as_advanced(LWS_MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY) |
| 523 | |
| 524 | if ("${LWS_MBEDTLS_LIBRARIES}" STREQUAL "" OR "${LWS_MBEDTLS_INCLUDE_DIRS}" STREQUAL "") |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 525 | message(FATAL_ERROR "You must set LWS_MBEDTLS_LIBRARIES and LWS_MBEDTLS_INCLUDE_DIRS when LWS_WITH_MBEDTLS is turned on.") |
Juraj Vijtiuk | 3aaf38d | 2017-08-28 20:12:32 +0800 | [diff] [blame] | 526 | endif() |
Andy Green | c0c217b | 2017-08-28 21:00:11 +0800 | [diff] [blame] | 527 | endif() |
Andy Green | 6d25763 | 2017-08-28 21:27:55 +0800 | [diff] [blame] | 528 | set(MBEDTLS_LIBRARIES ${LWS_MBEDTLS_LIBRARIES}) |
| 529 | set(MBEDTLS_INCLUDE_DIRS ${LWS_MBEDTLS_INCLUDE_DIRS}) |
| 530 | set(MBEDTLS_FOUND 1) |
Juraj Vijtiuk | 3aaf38d | 2017-08-28 20:12:32 +0800 | [diff] [blame] | 531 | set(USE_MBEDTLS 1) |
| 532 | endif() |
| 533 | |
Andy Green | d588286 | 2018-09-02 14:43:05 +0800 | [diff] [blame] | 534 | if (LWS_WITH_HTTP_STREAM_COMPRESSION) |
| 535 | set(LWS_WITH_ZLIB 1) |
| 536 | endif() |
| 537 | |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 538 | if (LWS_WITH_ZLIB AND NOT LWS_WITH_BUNDLED_ZLIB) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 539 | if ("${LWS_ZLIB_LIBRARIES}" STREQUAL "" OR "${LWS_ZLIB_INCLUDE_DIRS}" STREQUAL "") |
| 540 | else() |
| 541 | set(ZLIB_LIBRARIES ${LWS_ZLIB_LIBRARIES}) |
| 542 | set(ZLIB_INCLUDE_DIRS ${LWS_ZLIB_INCLUDE_DIRS}) |
| 543 | set(ZLIB_FOUND 1) |
| 544 | endif() |
| 545 | endif() |
| 546 | |
| 547 | if (LWS_WITH_LIBEV) |
| 548 | if ("${LWS_LIBEV_LIBRARIES}" STREQUAL "" OR "${LWS_LIBEV_INCLUDE_DIRS}" STREQUAL "") |
| 549 | else() |
| 550 | set(LIBEV_LIBRARIES ${LWS_LIBEV_LIBRARIES}) |
| 551 | set(LIBEV_INCLUDE_DIRS ${LWS_LIBEV_INCLUDE_DIRS}) |
| 552 | set(LIBEV_FOUND 1) |
| 553 | endif() |
| 554 | endif() |
| 555 | |
Andy Green | 86ed65f | 2016-02-14 09:27:41 +0800 | [diff] [blame] | 556 | if (LWS_WITH_LIBUV) |
| 557 | if ("${LWS_LIBUV_LIBRARIES}" STREQUAL "" OR "${LWS_LIBUV_INCLUDE_DIRS}" STREQUAL "") |
| 558 | else() |
| 559 | set(LIBUV_LIBRARIES ${LWS_LIBUV_LIBRARIES}) |
| 560 | set(LIBUV_INCLUDE_DIRS ${LWS_LIBUV_INCLUDE_DIRS}) |
| 561 | set(LIBUV_FOUND 1) |
| 562 | endif() |
| 563 | endif() |
| 564 | |
Aditya Tirumala | ec50eba | 2017-03-15 19:41:11 +0530 | [diff] [blame] | 565 | if (LWS_WITH_LIBEVENT) |
| 566 | if ("${LWS_LIBEVENT_LIBRARIES}" STREQUAL "" OR "${LWS_LIBEVENT_INCLUDE_DIRS}" STREQUAL "") |
| 567 | else() |
| 568 | set(LIBEVENT_LIBRARIES ${LWS_LIBEVENT_LIBRARIES}) |
| 569 | set(LIBEVENT_INCLUDE_DIRS ${LWS_LIBEVENT_INCLUDE_DIRS}) |
| 570 | set(LIBEVENT_FOUND 1) |
| 571 | endif() |
| 572 | endif() |
| 573 | |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 574 | if (LWS_WITH_SQLITE3) |
| 575 | if ("${LWS_SQLITE3_LIBRARIES}" STREQUAL "" OR "${LWS_SQLITE3_INCLUDE_DIRS}" STREQUAL "") |
| 576 | else() |
| 577 | set(SQLITE3_LIBRARIES ${LWS_SQLITE3_LIBRARIES}) |
| 578 | set(SQLITE3_INCLUDE_DIRS ${LWS_SQLITE3_INCLUDE_DIRS}) |
| 579 | set(SQLITE3_FOUND 1) |
| 580 | endif() |
| 581 | endif() |
| 582 | |
Andy Green | 1e5a9ad | 2016-03-20 11:59:53 +0800 | [diff] [blame] | 583 | |
Andy Green | ff2f5f6 | 2018-02-19 10:39:01 +0800 | [diff] [blame] | 584 | if (LWS_WITH_LIBEV AND LWS_WITH_LIBEVENT) |
| 585 | message(FATAL_ERROR "Sorry libev and libevent conflict with each others' namespace, you can only have one or the other") |
| 586 | endif() |
| 587 | |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 588 | # The base dir where the test-apps look for the SSL certs. |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 589 | set(LWS_OPENSSL_CLIENT_CERTS ../share CACHE PATH "Server SSL certificate directory") |
| 590 | if (WIN32) |
| 591 | set(LWS_OPENSSL_CLIENT_CERTS . CACHE PATH "Client SSL certificate directory") |
Joakim Soderberg | 46e4886 | 2014-04-24 14:47:10 +0200 | [diff] [blame] | 592 | |
Leonardo Maccari Rufino | 2ce39fe | 2017-05-30 18:31:06 -0300 | [diff] [blame] | 593 | if (LWS_UNIX_SOCK) |
Yeonjun Lim | 3c6a8c1 | 2016-03-30 22:47:02 -0700 | [diff] [blame] | 594 | set(LWS_UNIX_SOCK OFF) |
Leonardo Maccari Rufino | 2ce39fe | 2017-05-30 18:31:06 -0300 | [diff] [blame] | 595 | message(WARNING "Windows does not support UNIX domain sockets") |
Yeonjun Lim | 3c6a8c1 | 2016-03-30 22:47:02 -0700 | [diff] [blame] | 596 | endif() |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 597 | else() |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 598 | set(LWS_OPENSSL_CLIENT_CERTS /etc/pki/tls/certs/ CACHE PATH "Client SSL certificate directory") |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 599 | endif() |
| 600 | |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 601 | # LWS_OPENSSL_SUPPORT deprecated... use LWS_WITH_TLS |
| 602 | if (LWS_WITH_SSL OR LWS_WITH_MBEDTLS) |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 603 | set(LWS_OPENSSL_SUPPORT 1) |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 604 | set(LWS_WITH_TLS 1) |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 605 | endif() |
| 606 | |
Andy Green | d2ec7ad | 2014-03-15 10:39:29 +0800 | [diff] [blame] | 607 | if (LWS_SSL_CLIENT_USE_OS_CA_CERTS) |
| 608 | set(LWS_SSL_CLIENT_USE_OS_CA_CERTS 1) |
| 609 | endif() |
| 610 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 611 | if (LWS_WITH_LATENCY) |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 612 | set(LWS_LATENCY 1) |
| 613 | endif() |
| 614 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 615 | if (LWS_WITHOUT_DAEMONIZE OR WIN32) |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 616 | set(LWS_NO_DAEMONIZE 1) |
| 617 | endif() |
| 618 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 619 | if (LWS_WITHOUT_SERVER) |
Joakim Soderberg | e9a4211 | 2013-02-06 15:29:59 +0900 | [diff] [blame] | 620 | set(LWS_NO_SERVER 1) |
| 621 | endif() |
| 622 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 623 | if (LWS_WITHOUT_CLIENT) |
Joakim Soderberg | e9a4211 | 2013-02-06 15:29:59 +0900 | [diff] [blame] | 624 | set(LWS_NO_CLIENT 1) |
| 625 | endif() |
| 626 | |
Andrew Canaday | 9769f4f | 2014-03-23 13:25:07 +0800 | [diff] [blame] | 627 | if (LWS_WITH_LIBEV) |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 628 | set(LWS_WITH_LIBEV 1) |
Andrew Canaday | 9769f4f | 2014-03-23 13:25:07 +0800 | [diff] [blame] | 629 | endif() |
| 630 | |
Andy Green | 86ed65f | 2016-02-14 09:27:41 +0800 | [diff] [blame] | 631 | if (LWS_WITH_LIBUV) |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 632 | set(LWS_WITH_LIBUV 1) |
Andy Green | 86ed65f | 2016-02-14 09:27:41 +0800 | [diff] [blame] | 633 | endif() |
| 634 | |
Aditya Tirumala | ec50eba | 2017-03-15 19:41:11 +0530 | [diff] [blame] | 635 | if (LWS_WITH_LIBEVENT) |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 636 | set(LWS_WITH_LIBEVENT 1) |
Aditya Tirumala | ec50eba | 2017-03-15 19:41:11 +0530 | [diff] [blame] | 637 | endif() |
| 638 | |
Andy Green | 055f297 | 2014-03-24 16:09:25 +0800 | [diff] [blame] | 639 | if (LWS_IPV6) |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 640 | set(LWS_WITH_IPV6 1) |
James Devine | 3f13ea2 | 2014-03-24 16:09:25 +0800 | [diff] [blame] | 641 | endif() |
| 642 | |
Yeonjun Lim | 3c6a8c1 | 2016-03-30 22:47:02 -0700 | [diff] [blame] | 643 | if (LWS_UNIX_SOCK) |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 644 | set(LWS_WITH_UNIX_SOCK 1) |
Yeonjun Lim | 3c6a8c1 | 2016-03-30 22:47:02 -0700 | [diff] [blame] | 645 | endif() |
| 646 | |
Andy Green | 2eedea9 | 2014-04-03 14:33:48 +0800 | [diff] [blame] | 647 | if (LWS_WITH_HTTP2) |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 648 | set(LWS_WITH_HTTP2 1) |
Andy Green | 2eedea9 | 2014-04-03 14:33:48 +0800 | [diff] [blame] | 649 | endif() |
| 650 | |
Andy Green | d3a5505 | 2016-01-19 03:34:24 +0800 | [diff] [blame] | 651 | if ("${LWS_MAX_SMP}" STREQUAL "") |
Andy Green | 581b86e | 2017-06-12 13:36:24 +0800 | [diff] [blame] | 652 | set(LWS_MAX_SMP 1) |
Andy Green | d3a5505 | 2016-01-19 03:34:24 +0800 | [diff] [blame] | 653 | endif() |
| 654 | |
Andy Green | 7fe02e3 | 2016-03-29 08:51:42 +0800 | [diff] [blame] | 655 | |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 656 | if (MINGW) |
| 657 | set(LWS_MINGW_SUPPORT 1) |
Stephan Eberle | b820e2c | 2015-10-23 08:10:55 +0200 | [diff] [blame] | 658 | set(CMAKE_C_FLAGS "-D__USE_MINGW_ANSI_STDIO ${CMAKE_C_FLAGS}") |
Ralph Lessmann | 33b40e0 | 2017-12-01 11:36:31 +0800 | [diff] [blame] | 659 | add_definitions(-DWINVER=0x0601 -D_WIN32_WINNT=0x0601) |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 660 | endif() |
| 661 | |
Vijay Khurdiya | e73d446 | 2016-01-15 16:21:51 +0800 | [diff] [blame] | 662 | if (LWS_SSL_SERVER_WITH_ECDH_CERT) |
| 663 | set(LWS_SSL_SERVER_WITH_ECDH_CERT 1) |
| 664 | endif() |
| 665 | |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 666 | include_directories("${PROJECT_BINARY_DIR}") |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 667 | |
Joakim Soderberg | 4f4a38b | 2013-02-06 15:28:07 +0900 | [diff] [blame] | 668 | include(CheckCSourceCompiles) |
| 669 | |
| 670 | # Check for different inline keyword versions. |
| 671 | foreach(KEYWORD "inline" "__inline__" "__inline") |
| 672 | set(CMAKE_REQUIRED_DEFINITIONS "-DKEYWORD=${KEYWORD}") |
| 673 | CHECK_C_SOURCE_COMPILES( |
| 674 | " |
| 675 | #include <stdio.h> |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 676 | static KEYWORD void a() {} |
Joakim Soderberg | 4f4a38b | 2013-02-06 15:28:07 +0900 | [diff] [blame] | 677 | int main(int argc, char **argv) { a(); return 0; } |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 678 | " LWS_HAVE_${KEYWORD}) |
Joakim Soderberg | 4f4a38b | 2013-02-06 15:28:07 +0900 | [diff] [blame] | 679 | endforeach() |
| 680 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 681 | if (NOT LWS_HAVE_inline) |
| 682 | if (LWS_HAVE___inline__) |
Joakim Soderberg | 4f4a38b | 2013-02-06 15:28:07 +0900 | [diff] [blame] | 683 | set(inline __inline__) |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 684 | elseif(LWS_HAVE___inline) |
Joakim Soderberg | 4f4a38b | 2013-02-06 15:28:07 +0900 | [diff] [blame] | 685 | set(inline __inline) |
| 686 | endif() |
| 687 | endif() |
| 688 | |
Peter Pentchev | fb71b79 | 2016-10-02 02:21:03 +0300 | [diff] [blame] | 689 | # Put the libraries and binaries that get built into directories at the |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 690 | # top of the build tree rather than in hard-to-find leaf directories. |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 691 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") |
| 692 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") |
| 693 | SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 694 | |
Andy Green | 0aa382f | 2016-07-06 10:48:41 +0800 | [diff] [blame] | 695 | SET(LWS_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}") |
| 696 | |
thinkski | d34bae1 | 2013-04-16 19:48:05 +0800 | [diff] [blame] | 697 | # Put absolute path of dynamic libraries into the object code. Some |
| 698 | # architectures, notably Mac OS X, need this. |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 699 | SET(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${LWS_INSTALL_LIB_DIR}${LIB_SUFFIX}") |
thinkski | d34bae1 | 2013-04-16 19:48:05 +0800 | [diff] [blame] | 700 | |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 701 | include(CheckFunctionExists) |
Alexander Bruines | ddd9bfa | 2016-04-13 22:17:05 +0200 | [diff] [blame] | 702 | include(CheckSymbolExists) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 703 | include(CheckIncludeFile) |
| 704 | include(CheckIncludeFiles) |
| 705 | include(CheckLibraryExists) |
Patrick Gansterer | 8a59033 | 2014-02-28 00:42:08 +0100 | [diff] [blame] | 706 | include(CheckTypeSize) |
Andy Green | 65f87ef | 2018-04-12 21:37:59 +0800 | [diff] [blame] | 707 | include(CheckCSourceCompiles) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 708 | |
Andy Green | 4c79ee7 | 2015-10-15 11:20:40 +0800 | [diff] [blame] | 709 | if (LWS_WITHOUT_BUILTIN_SHA1) |
| 710 | set(LWS_SHA1_USE_OPENSSL_NAME 1) |
| 711 | endif() |
| 712 | |
Alexander von Gluck IV | 8bea6c1 | 2017-09-24 15:30:42 +0000 | [diff] [blame] | 713 | if (HAIKU) |
| 714 | set(CMAKE_REQUIRED_LIBRARIES network) |
| 715 | endif() |
| 716 | |
Andy Green | 546a280 | 2018-10-09 15:14:12 +0800 | [diff] [blame] | 717 | CHECK_C_SOURCE_COMPILES( |
| 718 | "#include <strings.h> |
| 719 | int main(int argc, char **argv) { char buf[1]; bzero(buf, 1); return 0; } |
| 720 | " LWS_HAVE_BZERO) |
| 721 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 722 | CHECK_FUNCTION_EXISTS(fork LWS_HAVE_FORK) |
| 723 | CHECK_FUNCTION_EXISTS(getenv LWS_HAVE_GETENV) |
| 724 | CHECK_FUNCTION_EXISTS(malloc LWS_HAVE_MALLOC) |
| 725 | CHECK_FUNCTION_EXISTS(memset LWS_HAVE_MEMSET) |
| 726 | CHECK_FUNCTION_EXISTS(realloc LWS_HAVE_REALLOC) |
| 727 | CHECK_FUNCTION_EXISTS(socket LWS_HAVE_SOCKET) |
| 728 | CHECK_FUNCTION_EXISTS(strerror LWS_HAVE_STRERROR) |
| 729 | CHECK_FUNCTION_EXISTS(vfork LWS_HAVE_VFORK) |
Andy Green | 1a13885 | 2016-03-20 11:55:25 +0800 | [diff] [blame] | 730 | CHECK_FUNCTION_EXISTS(execvpe LWS_HAVE_EXECVPE) |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 731 | CHECK_FUNCTION_EXISTS(getifaddrs LWS_HAVE_GETIFADDRS) |
Andy Green | 7d22c29 | 2016-03-04 10:53:51 +0800 | [diff] [blame] | 732 | CHECK_FUNCTION_EXISTS(snprintf LWS_HAVE_SNPRINTF) |
| 733 | CHECK_FUNCTION_EXISTS(_snprintf LWS_HAVE__SNPRINTF) |
| 734 | CHECK_FUNCTION_EXISTS(_vsnprintf LWS_HAVE__VSNPRINTF) |
Andy Green | 12aeba7 | 2016-04-26 07:45:45 +0800 | [diff] [blame] | 735 | CHECK_FUNCTION_EXISTS(getloadavg LWS_HAVE_GETLOADAVG) |
WebsocketUser | 0be9e98 | 2017-06-09 20:20:42 +0800 | [diff] [blame] | 736 | CHECK_FUNCTION_EXISTS(atoll LWS_HAVE_ATOLL) |
| 737 | CHECK_FUNCTION_EXISTS(_atoi64 LWS_HAVE__ATOI64) |
| 738 | CHECK_FUNCTION_EXISTS(_stat32i64 LWS_HAVE__STAT32I64) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 739 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 740 | if (NOT LWS_HAVE_GETIFADDRS) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 741 | if (LWS_WITHOUT_BUILTIN_GETIFADDRS) |
| 742 | message(FATAL_ERROR "No getifaddrs was found on the system. Turn off the LWS_WITHOUT_BUILTIN_GETIFADDRS compile option to use the supplied BSD version.") |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 743 | endif() |
| 744 | set(LWS_BUILTIN_GETIFADDRS 1) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 745 | endif() |
| 746 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 747 | CHECK_INCLUDE_FILE(dlfcn.h LWS_HAVE_DLFCN_H) |
| 748 | CHECK_INCLUDE_FILE(fcntl.h LWS_HAVE_FCNTL_H) |
| 749 | CHECK_INCLUDE_FILE(in6addr.h LWS_HAVE_IN6ADDR_H) |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 750 | CHECK_INCLUDE_FILE(memory.h LWS_HAVE_MEMORY_H) |
| 751 | CHECK_INCLUDE_FILE(netinet/in.h LWS_HAVE_NETINET_IN_H) |
| 752 | CHECK_INCLUDE_FILE(stdint.h LWS_HAVE_STDINT_H) |
| 753 | CHECK_INCLUDE_FILE(stdlib.h LWS_HAVE_STDLIB_H) |
| 754 | CHECK_INCLUDE_FILE(strings.h LWS_HAVE_STRINGS_H) |
| 755 | CHECK_INCLUDE_FILE(string.h LWS_HAVE_STRING_H) |
| 756 | CHECK_INCLUDE_FILE(sys/prctl.h LWS_HAVE_SYS_PRCTL_H) |
| 757 | CHECK_INCLUDE_FILE(sys/socket.h LWS_HAVE_SYS_SOCKET_H) |
Fredrik Skogman | 9de43fc | 2016-09-09 06:48:24 +0800 | [diff] [blame] | 758 | CHECK_INCLUDE_FILE(sys/sockio.h LWS_HAVE_SYS_SOCKIO_H) |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 759 | CHECK_INCLUDE_FILE(sys/stat.h LWS_HAVE_SYS_STAT_H) |
| 760 | CHECK_INCLUDE_FILE(sys/types.h LWS_HAVE_SYS_TYPES_H) |
| 761 | CHECK_INCLUDE_FILE(unistd.h LWS_HAVE_UNISTD_H) |
| 762 | CHECK_INCLUDE_FILE(vfork.h LWS_HAVE_VFORK_H) |
Andy Green | 156363f | 2017-06-07 06:10:02 +0800 | [diff] [blame] | 763 | CHECK_INCLUDE_FILE(sys/capability.h LWS_HAVE_SYS_CAPABILITY_H) |
Andy Green | 1b43ed1 | 2018-01-26 07:22:35 +0800 | [diff] [blame] | 764 | CHECK_INCLUDE_FILE(malloc.h LWS_HAVE_MALLOC_H) |
Andy Green | 3de2e9a | 2018-03-02 09:01:22 +0800 | [diff] [blame] | 765 | CHECK_INCLUDE_FILE(pthread.h LWS_HAVE_PTHREAD_H) |
Andy Green | 156363f | 2017-06-07 06:10:02 +0800 | [diff] [blame] | 766 | |
Andy Green | 31dfc4a | 2018-10-02 10:50:24 +0800 | [diff] [blame] | 767 | CHECK_LIBRARY_EXISTS(cap cap_set_flag "" LWS_HAVE_LIBCAP) |
| 768 | |
| 769 | if (LWS_ROLE_DBUS) |
Andy Green | 31dfc4a | 2018-10-02 10:50:24 +0800 | [diff] [blame] | 770 | |
| 771 | if (NOT LWS_DBUS_LIB) |
| 772 | set(LWS_DBUS_LIB "dbus-1") |
| 773 | endif() |
| 774 | |
| 775 | CHECK_LIBRARY_EXISTS(${LWS_DBUS_LIB} dbus_connection_set_watch_functions "" LWS_HAVE_LIBDBUS) |
Andy Green | 47e10ab | 2018-10-03 14:14:29 +0800 | [diff] [blame] | 776 | if (NOT LWS_HAVE_LIBDBUS) |
| 777 | message(FATAL_ERROR "Install dbus-devel, or libdbus-1-dev etc") |
| 778 | endif() |
Andy Green | 31dfc4a | 2018-10-02 10:50:24 +0800 | [diff] [blame] | 779 | |
| 780 | if (NOT LWS_DBUS_INCLUDE1) |
| 781 | # look in fedora and debian / ubuntu place |
| 782 | if (EXISTS "/usr/include/dbus-1.0") |
| 783 | set(LWS_DBUS_INCLUDE1 "/usr/include/dbus-1.0") |
| 784 | else() |
| 785 | message(FATAL_ERROR "Set LWS_DBUS_INCLUDE1 to /usr/include/dbus-1.0 or wherever the main dbus includes are") |
| 786 | endif() |
| 787 | endif() |
| 788 | |
| 789 | if (NOT LWS_DBUS_INCLUDE2) |
| 790 | # look in fedora... debian / ubuntu has the ARCH in the path... |
| 791 | if (EXISTS "/usr/lib64/dbus-1.0/include") |
| 792 | set(LWS_DBUS_INCLUDE2 "/usr/lib64/dbus-1.0/include") |
| 793 | else() |
| 794 | message(FATAL_ERROR "Set LWS_DBUS_INCLUDE2 to /usr/lib/ARCH-linux-gnu/dbus-1.0/include or wherever dbus-arch-deps.h is on your system") |
| 795 | endif() |
| 796 | endif() |
| 797 | |
| 798 | set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES};${LWS_DBUS_INCLUDE1};${LWS_DBUS_INCLUDE2}) |
| 799 | |
| 800 | CHECK_C_SOURCE_COMPILES("#include <dbus/dbus.h> |
| 801 | int main(void) { |
| 802 | return 0; |
| 803 | }" LWS_DBUS_CHECK_OK) |
| 804 | endif() |
Andy Green | 5f2a815 | 2015-11-02 08:21:08 +0800 | [diff] [blame] | 805 | |
Andy Green | 4cfe81d | 2016-10-05 13:49:46 +0800 | [diff] [blame] | 806 | if (LWS_WITH_LIBUV) |
| 807 | CHECK_INCLUDE_FILE(uv-version.h LWS_HAVE_UV_VERSION_H) |
Dominyk Tiller | d2943ff | 2018-06-24 03:27:44 +0100 | [diff] [blame] | 808 | # libuv changed the location in 1.21.0. Retain both |
| 809 | # checks temporarily to ensure a smooth transition. |
Andy Green | a03dd40 | 2018-08-14 08:00:25 +0800 | [diff] [blame] | 810 | if (NOT LWS_HAVE_UV_VERSION_H) |
Dominyk Tiller | d2943ff | 2018-06-24 03:27:44 +0100 | [diff] [blame] | 811 | CHECK_INCLUDE_FILE(uv/version.h LWS_HAVE_NEW_UV_VERSION_H) |
| 812 | endif() |
Andy Green | 4cfe81d | 2016-10-05 13:49:46 +0800 | [diff] [blame] | 813 | endif() |
| 814 | |
| 815 | |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 816 | if (LWS_WITH_ZLIB AND NOT LWS_WITH_BUNDLED_ZLIB) |
Andy Green | 5f2a815 | 2015-11-02 08:21:08 +0800 | [diff] [blame] | 817 | CHECK_INCLUDE_FILE(zlib.h LWS_HAVE_ZLIB_H) |
| 818 | endif() |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 819 | |
Peter Pentchev | e46f412 | 2015-10-01 12:25:05 +0300 | [diff] [blame] | 820 | # TODO: These can also be tested to see whether they actually work... |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 821 | set(LWS_HAVE_WORKING_FORK LWS_HAVE_FORK) |
| 822 | set(LWS_HAVE_WORKING_VFORK LWS_HAVE_VFORK) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 823 | |
| 824 | CHECK_INCLUDE_FILES("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS) |
| 825 | |
Andy Green | 7262e14 | 2017-07-07 08:32:04 +0800 | [diff] [blame] | 826 | CHECK_C_SOURCE_COMPILES("#include <stdint.h> |
| 827 | int main(void) { |
| 828 | intptr_t test = 1; |
| 829 | return 0; |
| 830 | }" LWS_HAS_INTPTR_T) |
| 831 | |
Andy Green | aa4143a | 2018-11-12 15:24:42 +0800 | [diff] [blame] | 832 | set(CMAKE_REQUIRED_FLAGS "-pthread") |
| 833 | CHECK_C_SOURCE_COMPILES("#define _GNU_SOURCE |
| 834 | #include <pthread.h> |
| 835 | int main(void) { |
| 836 | pthread_t th = 0; |
| 837 | pthread_setname_np(th, NULL); |
| 838 | return 0; |
| 839 | }" LWS_HAS_PTHREAD_SETNAME_NP) |
Patrick Gansterer | 8a59033 | 2014-02-28 00:42:08 +0100 | [diff] [blame] | 840 | |
Andy Green | 6139933 | 2019-01-11 18:19:21 +0800 | [diff] [blame] | 841 | CHECK_C_SOURCE_COMPILES("#include <stddef.h> |
pblemel | 39e19c8 | 2019-01-11 16:48:53 +0800 | [diff] [blame] | 842 | #include <getopt.h> |
| 843 | int main(void) { |
| 844 | void *p = (void *)getopt_long; |
| 845 | return p != NULL; |
| 846 | }" LWS_HAS_GETOPT_LONG) |
| 847 | |
| 848 | |
Patrick Gansterer | 8a59033 | 2014-02-28 00:42:08 +0100 | [diff] [blame] | 849 | if (NOT PID_T_SIZE) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 850 | set(pid_t int) |
Patrick Gansterer | 8a59033 | 2014-02-28 00:42:08 +0100 | [diff] [blame] | 851 | endif() |
| 852 | |
| 853 | if (NOT SIZE_T_SIZE) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 854 | set(size_t "unsigned int") |
| 855 | endif() |
| 856 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 857 | if (NOT LWS_HAVE_MALLOC) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 858 | set(malloc rpl_malloc) |
| 859 | endif() |
| 860 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 861 | if (NOT LWS_HAVE_REALLOC) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 862 | set(realloc rpl_realloc) |
| 863 | endif() |
| 864 | |
Roger A. Light | 7a474b4 | 2015-06-26 11:40:54 +0200 | [diff] [blame] | 865 | |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 866 | if (MSVC) |
| 867 | # Turn off stupid microsoft security warnings. |
| 868 | add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) |
Edwin van den Oetelaar | 15a38a7 | 2013-03-10 06:53:57 +0800 | [diff] [blame] | 869 | endif(MSVC) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 870 | |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 871 | include_directories("${PROJECT_SOURCE_DIR}/lib") |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 872 | |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 873 | # Group headers and sources. |
| 874 | # Some IDEs use this for nicer file structure. |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 875 | set(HDR_PRIVATE |
Andy Green | de064fd | 2018-05-03 10:49:36 +0800 | [diff] [blame] | 876 | lib/core/private.h) |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 877 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 878 | set(HDR_PUBLIC |
Andy Green | d1f9f0a | 2018-08-23 09:46:01 +0800 | [diff] [blame] | 879 | "${PROJECT_SOURCE_DIR}/include/libwebsockets.h" |
Andy Green | 7597ac3 | 2017-10-16 16:59:57 +0800 | [diff] [blame] | 880 | "${PROJECT_BINARY_DIR}/lws_config.h" |
| 881 | "${PROJECT_SOURCE_DIR}/plugins/ssh-base/include/lws-plugin-ssh.h" |
| 882 | ) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 883 | |
| 884 | set(SOURCES |
Andy Green | de064fd | 2018-05-03 10:49:36 +0800 | [diff] [blame] | 885 | lib/core/alloc.c |
Andy Green | 502130d | 2018-05-10 16:13:26 +0800 | [diff] [blame] | 886 | lib/core/context.c |
| 887 | lib/core/libwebsockets.c |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 888 | lib/core/logs.c |
Andy Green | 502130d | 2018-05-10 16:13:26 +0800 | [diff] [blame] | 889 | lib/misc/base64-decode.c |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 890 | lib/core/vfs.c |
Andy Green | 502130d | 2018-05-10 16:13:26 +0800 | [diff] [blame] | 891 | lib/misc/lws-ring.c |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 892 | ) |
| 893 | |
| 894 | if (LWS_WITH_NETWORK) |
| 895 | list(APPEND SOURCES |
| 896 | lib/core-net/dummy-callback.c |
| 897 | lib/core-net/output.c |
| 898 | lib/core-net/close.c |
| 899 | lib/core-net/network.c |
| 900 | lib/core-net/vhost.c |
| 901 | lib/core-net/pollfd.c |
| 902 | lib/core-net/service.c |
| 903 | lib/core-net/stats.c |
| 904 | lib/core-net/wsi.c |
| 905 | lib/core-net/wsi-timeout.c |
| 906 | lib/core-net/adopt.c |
| 907 | lib/roles/pipe/ops-pipe.c |
| 908 | ) |
| 909 | |
| 910 | if (LWS_WITH_STATS) |
| 911 | list(APPEND SOURCES |
| 912 | lib/core-net/stats.c |
| 913 | ) |
| 914 | endif() |
| 915 | endif() |
Andy Green | ebed5e7 | 2018-09-02 14:35:37 +0800 | [diff] [blame] | 916 | |
| 917 | if (LWS_WITH_THREADPOOL AND UNIX AND LWS_HAVE_PTHREAD_H) |
| 918 | list(APPEND SOURCES lib/misc/threadpool/threadpool.c) |
| 919 | endif() |
Andy Green | c83afc6 | 2017-10-16 12:52:32 +0800 | [diff] [blame] | 920 | |
Andy Green | ac6c48d | 2018-04-27 19:16:50 +0800 | [diff] [blame] | 921 | if (LWS_ROLE_H1 OR LWS_ROLE_H2) |
| 922 | list(APPEND SOURCES |
| 923 | lib/roles/http/header.c |
| 924 | lib/roles/http/server/parsers.c) |
Andy Green | d588286 | 2018-09-02 14:43:05 +0800 | [diff] [blame] | 925 | if (LWS_WITH_HTTP_STREAM_COMPRESSION) |
| 926 | list(APPEND SOURCES |
| 927 | lib/roles/http/compression/stream.c |
| 928 | lib/roles/http/compression/deflate/deflate.c) |
| 929 | if (LWS_WITH_HTTP_BROTLI) |
| 930 | list(APPEND SOURCES |
| 931 | lib/roles/http/compression/brotli/brotli.c) |
| 932 | endif() |
| 933 | endif() |
Andy Green | ac6c48d | 2018-04-27 19:16:50 +0800 | [diff] [blame] | 934 | endif() |
| 935 | |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 936 | if (LWS_ROLE_H1) |
Andy Green | c83afc6 | 2017-10-16 12:52:32 +0800 | [diff] [blame] | 937 | list(APPEND SOURCES |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 938 | lib/roles/h1/ops-h1.c) |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 939 | endif() |
| 940 | |
| 941 | if (LWS_ROLE_WS) |
| 942 | list(APPEND SOURCES |
| 943 | lib/roles/ws/ops-ws.c) |
| 944 | if (NOT LWS_WITHOUT_CLIENT) |
| 945 | list(APPEND SOURCES |
| 946 | lib/roles/ws/client-ws.c |
Andy Green | 27e86e2 | 2018-04-25 08:42:18 +0800 | [diff] [blame] | 947 | lib/roles/ws/client-parser-ws.c) |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 948 | endif() |
| 949 | if (NOT LWS_WITHOUT_SERVER) |
| 950 | list(APPEND SOURCES |
| 951 | lib/roles/ws/server-ws.c) |
| 952 | endif() |
| 953 | endif() |
| 954 | |
| 955 | if (LWS_ROLE_RAW) |
| 956 | list(APPEND SOURCES |
Andy Green | 502130d | 2018-05-10 16:13:26 +0800 | [diff] [blame] | 957 | lib/roles/raw-skt/ops-raw-skt.c |
| 958 | lib/roles/raw-file/ops-raw-file.c) |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 959 | endif() |
| 960 | |
Andy Green | 08b5ad9 | 2018-11-29 08:29:48 +0800 | [diff] [blame] | 961 | if (LWS_ROLE_RAW_PROXY) |
| 962 | list(APPEND SOURCES |
| 963 | lib/roles/raw-proxy/ops-raw-proxy.c) |
| 964 | endif() |
| 965 | |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 966 | if (LWS_ROLE_CGI) |
| 967 | list(APPEND SOURCES |
| 968 | lib/roles/cgi/cgi-server.c |
| 969 | lib/roles/cgi/ops-cgi.c) |
Andy Green | c83afc6 | 2017-10-16 12:52:32 +0800 | [diff] [blame] | 970 | endif() |
| 971 | |
Andy Green | 31dfc4a | 2018-10-02 10:50:24 +0800 | [diff] [blame] | 972 | if (LWS_ROLE_DBUS) |
| 973 | list(APPEND SOURCES |
| 974 | lib/roles/dbus/dbus.c) |
| 975 | endif() |
| 976 | |
Andy Green | c83afc6 | 2017-10-16 12:52:32 +0800 | [diff] [blame] | 977 | if (LWS_WITH_ACCESS_LOG) |
| 978 | list(APPEND SOURCES |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 979 | lib/roles/http/server/access-log.c) |
Andy Green | c83afc6 | 2017-10-16 12:52:32 +0800 | [diff] [blame] | 980 | endif() |
| 981 | |
| 982 | if (LWS_WITH_PEER_LIMITS) |
| 983 | list(APPEND SOURCES |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 984 | lib/misc/peer-limits.c) |
Andy Green | c83afc6 | 2017-10-16 12:52:32 +0800 | [diff] [blame] | 985 | endif() |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 986 | |
Andy Green | a5b2248 | 2018-10-14 06:12:27 +0800 | [diff] [blame] | 987 | if (LWS_WITH_LWSAC) |
| 988 | list(APPEND SOURCES |
| 989 | lib/misc/lwsac/lwsac.c |
| 990 | lib/misc/lwsac/cached-file.c) |
| 991 | endif() |
| 992 | |
Andy Green | d3bc2c3 | 2018-10-14 11:38:08 +0800 | [diff] [blame] | 993 | if (LWS_WITH_FTS) |
| 994 | list(APPEND SOURCES |
| 995 | lib/misc/fts/trie.c |
| 996 | lib/misc/fts/trie-fd.c) |
| 997 | endif() |
| 998 | |
Andy Green | aa4143a | 2018-11-12 15:24:42 +0800 | [diff] [blame] | 999 | if (LWS_WITH_DISKCACHE) |
| 1000 | list(APPEND SOURCES |
| 1001 | lib/misc/diskcache.c) |
| 1002 | endif() |
| 1003 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 1004 | if (NOT LWS_WITHOUT_CLIENT) |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 1005 | list(APPEND SOURCES |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 1006 | lib/core-net/connect.c |
| 1007 | lib/core-net/client.c |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 1008 | lib/roles/http/client/client.c |
| 1009 | lib/roles/http/client/client-handshake.c) |
| 1010 | endif() |
| 1011 | |
| 1012 | if (NOT LWS_WITHOUT_SERVER) |
| 1013 | list(APPEND SOURCES |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 1014 | lib/core-net/server.c |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 1015 | lib/roles/listen/ops-listen.c) |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 1016 | endif() |
| 1017 | |
Andy Green | 904a9c0 | 2017-10-13 10:33:02 +0800 | [diff] [blame] | 1018 | if (LWS_WITH_MBEDTLS) |
Juraj Vijtiuk | 41909ea | 2017-08-28 20:22:20 +0800 | [diff] [blame] | 1019 | set(LWS_WITH_SSL ON) |
Andy Green | 89cb55e | 2017-10-18 09:41:44 +0800 | [diff] [blame] | 1020 | |
Andy Green | 89cb55e | 2017-10-18 09:41:44 +0800 | [diff] [blame] | 1021 | include_directories(lib/tls/mbedtls/wrapper/include) |
| 1022 | include_directories(lib/tls/mbedtls/wrapper/include/platform) |
| 1023 | include_directories(lib/tls/mbedtls/wrapper/include/internal) |
| 1024 | include_directories(lib/tls/mbedtls/wrapper/include/openssl) |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 1025 | |
| 1026 | if (LWS_WITH_NETWORK) |
| 1027 | list(APPEND HDR_PRIVATE |
| 1028 | lib/tls/mbedtls/wrapper/include/internal/ssl3.h |
| 1029 | lib/tls/mbedtls/wrapper/include/internal/ssl_cert.h |
| 1030 | lib/tls/mbedtls/wrapper/include/internal/ssl_code.h |
| 1031 | lib/tls/mbedtls/wrapper/include/internal/ssl_dbg.h |
| 1032 | lib/tls/mbedtls/wrapper/include/internal/ssl_lib.h |
| 1033 | lib/tls/mbedtls/wrapper/include/internal/ssl_methods.h |
| 1034 | lib/tls/mbedtls/wrapper/include/internal/ssl_pkey.h |
| 1035 | lib/tls/mbedtls/wrapper/include/internal/ssl_stack.h |
| 1036 | lib/tls/mbedtls/wrapper/include/internal/ssl_types.h |
| 1037 | lib/tls/mbedtls/wrapper/include/internal/ssl_x509.h |
| 1038 | lib/tls/mbedtls/wrapper/include/internal/tls1.h |
| 1039 | lib/tls/mbedtls/wrapper/include/internal/x509_vfy.h) |
| 1040 | |
| 1041 | list(APPEND HDR_PRIVATE |
| 1042 | lib/tls/mbedtls/wrapper/include/openssl/ssl.h) |
| 1043 | |
| 1044 | list(APPEND HDR_PRIVATE |
| 1045 | lib/tls/mbedtls/wrapper/include/platform/ssl_pm.h |
| 1046 | lib/tls/mbedtls/wrapper/include/platform/ssl_port.h) |
| 1047 | |
| 1048 | list(APPEND SOURCES |
| 1049 | lib/tls/mbedtls/wrapper/library/ssl_cert.c |
| 1050 | lib/tls/mbedtls/wrapper/library/ssl_lib.c |
| 1051 | lib/tls/mbedtls/wrapper/library/ssl_methods.c |
| 1052 | lib/tls/mbedtls/wrapper/library/ssl_pkey.c |
| 1053 | lib/tls/mbedtls/wrapper/library/ssl_stack.c |
| 1054 | lib/tls/mbedtls/wrapper/library/ssl_x509.c) |
| 1055 | |
| 1056 | list(APPEND SOURCES |
| 1057 | lib/tls/mbedtls/wrapper/platform/ssl_pm.c |
| 1058 | lib/tls/mbedtls/wrapper/platform/ssl_port.c) |
| 1059 | endif() |
Juraj Vijtiuk | 77a71e9 | 2017-08-28 20:13:58 +0800 | [diff] [blame] | 1060 | endif() |
| 1061 | |
Juraj Vijtiuk | 41909ea | 2017-08-28 20:22:20 +0800 | [diff] [blame] | 1062 | if (LWS_WITH_SSL) |
| 1063 | list(APPEND SOURCES |
Andy Green | c32a22c | 2017-10-19 11:21:27 +0800 | [diff] [blame] | 1064 | lib/tls/tls.c |
| 1065 | ) |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 1066 | if (LWS_WITH_NETWORK) |
| 1067 | list(APPEND SOURCES |
| 1068 | lib/tls/tls-network.c |
| 1069 | ) |
| 1070 | endif() |
Juraj Vijtiuk | 41909ea | 2017-08-28 20:22:20 +0800 | [diff] [blame] | 1071 | |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 1072 | if (LWS_WITH_MBEDTLS) |
| 1073 | list(APPEND SOURCES |
| 1074 | lib/tls/mbedtls/tls.c |
| 1075 | lib/tls/mbedtls/x509.c |
| 1076 | ) |
| 1077 | if (LWS_WITH_NETWORK) |
Andy Green | 89cb55e | 2017-10-18 09:41:44 +0800 | [diff] [blame] | 1078 | list(APPEND SOURCES |
Andy Green | dd3e561 | 2017-10-18 19:14:11 +0800 | [diff] [blame] | 1079 | lib/tls/mbedtls/ssl.c |
Andy Green | c32a22c | 2017-10-19 11:21:27 +0800 | [diff] [blame] | 1080 | ) |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 1081 | endif() |
| 1082 | if (LWS_WITH_GENCRYPTO) |
| 1083 | list(APPEND SOURCES |
| 1084 | lib/tls/mbedtls/lws-genhash.c |
| 1085 | lib/tls/mbedtls/lws-genrsa.c |
| 1086 | lib/tls/mbedtls/lws-genaes.c |
| 1087 | lib/tls/lws-genec-common.c |
| 1088 | lib/tls/mbedtls/lws-genec.c |
| 1089 | lib/tls/mbedtls/lws-gencrypto.c |
| 1090 | ) |
| 1091 | endif() |
| 1092 | else() |
| 1093 | list(APPEND SOURCES |
| 1094 | lib/tls/openssl/tls.c |
| 1095 | lib/tls/openssl/x509.c |
| 1096 | ) |
| 1097 | if (LWS_WITH_NETWORK) |
Andy Green | 89cb55e | 2017-10-18 09:41:44 +0800 | [diff] [blame] | 1098 | list(APPEND SOURCES |
Andy Green | dd3e561 | 2017-10-18 19:14:11 +0800 | [diff] [blame] | 1099 | lib/tls/openssl/ssl.c |
Andy Green | dd3e561 | 2017-10-18 19:14:11 +0800 | [diff] [blame] | 1100 | ) |
Andy Green | 89cb55e | 2017-10-18 09:41:44 +0800 | [diff] [blame] | 1101 | endif() |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 1102 | if (LWS_WITH_GENCRYPTO) |
| 1103 | list(APPEND SOURCES |
| 1104 | lib/tls/openssl/lws-genhash.c |
| 1105 | lib/tls/openssl/lws-genrsa.c |
| 1106 | lib/tls/openssl/lws-genaes.c |
| 1107 | lib/tls/lws-genec-common.c |
| 1108 | lib/tls/openssl/lws-genec.c |
| 1109 | lib/tls/openssl/lws-gencrypto.c |
| 1110 | ) |
| 1111 | endif() |
| 1112 | endif() |
Andy Green | 89cb55e | 2017-10-18 09:41:44 +0800 | [diff] [blame] | 1113 | |
Juraj Vijtiuk | 41909ea | 2017-08-28 20:22:20 +0800 | [diff] [blame] | 1114 | if (NOT LWS_WITHOUT_SERVER) |
| 1115 | list(APPEND SOURCES |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 1116 | lib/tls/tls-server.c) |
Andy Green | 89cb55e | 2017-10-18 09:41:44 +0800 | [diff] [blame] | 1117 | if (LWS_WITH_MBEDTLS) |
| 1118 | list(APPEND SOURCES |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 1119 | lib/tls/mbedtls/mbedtls-server.c) |
Andy Green | 89cb55e | 2017-10-18 09:41:44 +0800 | [diff] [blame] | 1120 | else() |
| 1121 | list(APPEND SOURCES |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 1122 | lib/tls/openssl/openssl-server.c) |
Andy Green | 89cb55e | 2017-10-18 09:41:44 +0800 | [diff] [blame] | 1123 | endif() |
Juraj Vijtiuk | 41909ea | 2017-08-28 20:22:20 +0800 | [diff] [blame] | 1124 | endif() |
| 1125 | if (NOT LWS_WITHOUT_CLIENT) |
| 1126 | list(APPEND SOURCES |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 1127 | lib/tls/tls-client.c) |
Andy Green | 89cb55e | 2017-10-18 09:41:44 +0800 | [diff] [blame] | 1128 | if (LWS_WITH_MBEDTLS) |
| 1129 | list(APPEND SOURCES |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 1130 | lib/tls/mbedtls/mbedtls-client.c) |
Andy Green | 89cb55e | 2017-10-18 09:41:44 +0800 | [diff] [blame] | 1131 | else() |
| 1132 | list(APPEND SOURCES |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 1133 | lib/tls/openssl/openssl-client.c) |
Andy Green | 89cb55e | 2017-10-18 09:41:44 +0800 | [diff] [blame] | 1134 | endif() |
| 1135 | |
Juraj Vijtiuk | 41909ea | 2017-08-28 20:22:20 +0800 | [diff] [blame] | 1136 | endif() |
| 1137 | endif() |
Juraj Vijtiuk | 77a71e9 | 2017-08-28 20:13:58 +0800 | [diff] [blame] | 1138 | |
Andy Green | 4c79ee7 | 2015-10-15 11:20:40 +0800 | [diff] [blame] | 1139 | if (NOT LWS_WITHOUT_BUILTIN_SHA1) |
| 1140 | list(APPEND SOURCES |
Andy Green | c83afc6 | 2017-10-16 12:52:32 +0800 | [diff] [blame] | 1141 | lib/misc/sha-1.c) |
Andy Green | 4c79ee7 | 2015-10-15 11:20:40 +0800 | [diff] [blame] | 1142 | endif() |
| 1143 | |
Andy Green | e4a3e8c | 2018-03-17 06:43:12 +0800 | [diff] [blame] | 1144 | if (LWS_WITH_HTTP2 AND NOT LWS_WITHOUT_SERVER) |
Andy Green | 2eedea9 | 2014-04-03 14:33:48 +0800 | [diff] [blame] | 1145 | list(APPEND SOURCES |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 1146 | lib/roles/h2/http2.c |
| 1147 | lib/roles/h2/hpack.c |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 1148 | lib/roles/h2/ops-h2.c) |
Andy Green | 2eedea9 | 2014-04-03 14:33:48 +0800 | [diff] [blame] | 1149 | endif() |
Andy Green | e40aa9b | 2014-04-02 21:02:54 +0800 | [diff] [blame] | 1150 | # select the active platform files |
| 1151 | |
| 1152 | if (WIN32) |
| 1153 | list(APPEND SOURCES |
Andy Green | df1d60f | 2018-06-16 09:37:07 +0800 | [diff] [blame] | 1154 | lib/plat/windows/windows-fds.c |
| 1155 | lib/plat/windows/windows-file.c |
| 1156 | lib/plat/windows/windows-init.c |
| 1157 | lib/plat/windows/windows-misc.c |
| 1158 | lib/plat/windows/windows-pipe.c |
| 1159 | lib/plat/windows/windows-service.c |
| 1160 | lib/plat/windows/windows-sockets.c |
| 1161 | ) |
Andy Green | e40aa9b | 2014-04-02 21:02:54 +0800 | [diff] [blame] | 1162 | else() |
Andy Green | 0aed7a0 | 2017-02-22 09:50:11 +0800 | [diff] [blame] | 1163 | |
Andy Green | 8487279 | 2017-11-30 12:40:46 +0800 | [diff] [blame] | 1164 | if (LWS_PLAT_OPTEE) |
Andy Green | 5f2a815 | 2015-11-02 08:21:08 +0800 | [diff] [blame] | 1165 | list(APPEND SOURCES |
Andy Green | d995d75 | 2019-01-11 13:13:34 +0800 | [diff] [blame] | 1166 | lib/plat/optee/lws-plat-optee.c |
| 1167 | ) |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 1168 | if (LWS_WITH_NETWORK) |
| 1169 | list(APPEND SOURCES |
| 1170 | lib/plat/optee/network.c |
| 1171 | ) |
| 1172 | endif() |
Andy Green | 5f2a815 | 2015-11-02 08:21:08 +0800 | [diff] [blame] | 1173 | else() |
Andy Green | 8487279 | 2017-11-30 12:40:46 +0800 | [diff] [blame] | 1174 | if (LWS_WITH_ESP32) |
Andy Green | 7acf76c | 2016-07-23 14:18:25 +0800 | [diff] [blame] | 1175 | list(APPEND SOURCES |
Andy Green | df1d60f | 2018-06-16 09:37:07 +0800 | [diff] [blame] | 1176 | lib/plat/esp32/esp32-fds.c |
| 1177 | lib/plat/esp32/esp32-file.c |
| 1178 | lib/plat/esp32/esp32-helpers.c |
| 1179 | lib/plat/esp32/esp32-init.c |
| 1180 | lib/plat/esp32/esp32-misc.c |
| 1181 | lib/plat/esp32/esp32-pipe.c |
| 1182 | lib/plat/esp32/esp32-service.c |
| 1183 | lib/plat/esp32/esp32-sockets.c |
Andy Green | 8487279 | 2017-11-30 12:40:46 +0800 | [diff] [blame] | 1184 | lib/misc/romfs.c) |
Andy Green | 7acf76c | 2016-07-23 14:18:25 +0800 | [diff] [blame] | 1185 | else() |
Andy Green | 8487279 | 2017-11-30 12:40:46 +0800 | [diff] [blame] | 1186 | list(APPEND SOURCES |
Andy Green | df1d60f | 2018-06-16 09:37:07 +0800 | [diff] [blame] | 1187 | lib/plat/unix/unix-caps.c |
Andy Green | df1d60f | 2018-06-16 09:37:07 +0800 | [diff] [blame] | 1188 | lib/plat/unix/unix-file.c |
| 1189 | lib/plat/unix/unix-misc.c |
| 1190 | lib/plat/unix/unix-init.c |
Andy Green | df1d60f | 2018-06-16 09:37:07 +0800 | [diff] [blame] | 1191 | ) |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 1192 | if (LWS_WITH_NETWORK) |
| 1193 | list(APPEND SOURCES |
| 1194 | lib/plat/unix/unix-pipe.c |
| 1195 | lib/plat/unix/unix-service.c |
| 1196 | lib/plat/unix/unix-sockets.c |
| 1197 | lib/plat/unix/unix-fds.c |
| 1198 | ) |
| 1199 | endif() |
Andy Green | df1d60f | 2018-06-16 09:37:07 +0800 | [diff] [blame] | 1200 | |
| 1201 | if (LWS_WITH_PLUGINS AND LWS_WITH_LIBUV) |
| 1202 | list(APPEND SOURCES lib/plat/unix/unix-plugins.c) |
| 1203 | endif() |
Andy Green | 7acf76c | 2016-07-23 14:18:25 +0800 | [diff] [blame] | 1204 | endif() |
Andy Green | 5f2a815 | 2015-11-02 08:21:08 +0800 | [diff] [blame] | 1205 | endif() |
Andy Green | e40aa9b | 2014-04-02 21:02:54 +0800 | [diff] [blame] | 1206 | endif() |
| 1207 | |
Andy Green | ac6c48d | 2018-04-27 19:16:50 +0800 | [diff] [blame] | 1208 | if ((LWS_ROLE_H1 OR LWS_ROLE_H2) AND NOT LWS_WITHOUT_SERVER) |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 1209 | list(APPEND SOURCES |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 1210 | lib/roles/http/server/server.c |
| 1211 | lib/roles/http/server/lws-spa.c) |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 1212 | endif() |
| 1213 | |
Andy Green | ac6c48d | 2018-04-27 19:16:50 +0800 | [diff] [blame] | 1214 | if (LWS_ROLE_WS AND NOT LWS_WITHOUT_EXTENSIONS) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 1215 | list(APPEND HDR_PRIVATE |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 1216 | lib/roles/ws/ext/extension-permessage-deflate.h) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 1217 | list(APPEND SOURCES |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 1218 | lib/roles/ws/ext/extension.c |
| 1219 | lib/roles/ws/ext/extension-permessage-deflate.c) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 1220 | endif() |
| 1221 | |
Andy Green | 1e5a9ad | 2016-03-20 11:59:53 +0800 | [diff] [blame] | 1222 | if (LWS_WITH_HTTP_PROXY) |
| 1223 | list(APPEND SOURCES |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 1224 | lib/roles/http/server/rewrite.c) |
Andy Green | 1e5a9ad | 2016-03-20 11:59:53 +0800 | [diff] [blame] | 1225 | endif() |
| 1226 | |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 1227 | if (LWS_WITH_POLL AND LWS_WITH_NETWORK) |
Andy Green | a717df2 | 2014-04-11 13:14:37 +0800 | [diff] [blame] | 1228 | list(APPEND SOURCES |
Andy Green | d37b383 | 2018-04-29 10:44:36 +0800 | [diff] [blame] | 1229 | lib/event-libs/poll/poll.c) |
Andy Green | 86ed65f | 2016-02-14 09:27:41 +0800 | [diff] [blame] | 1230 | endif() |
| 1231 | |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 1232 | if (LWS_WITH_LIBUV AND LWS_WITH_NETWORK) |
Andy Green | 86ed65f | 2016-02-14 09:27:41 +0800 | [diff] [blame] | 1233 | list(APPEND SOURCES |
Andy Green | 8d213f8 | 2018-04-29 08:34:19 +0800 | [diff] [blame] | 1234 | lib/event-libs/libuv/libuv.c) |
Andy Green | 86ed65f | 2016-02-14 09:27:41 +0800 | [diff] [blame] | 1235 | endif() |
Andy Green | a717df2 | 2014-04-11 13:14:37 +0800 | [diff] [blame] | 1236 | |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 1237 | if (LWS_WITH_LIBEVENT AND LWS_WITH_NETWORK) |
Aditya Tirumala | ec50eba | 2017-03-15 19:41:11 +0530 | [diff] [blame] | 1238 | list(APPEND SOURCES |
Andy Green | 8d213f8 | 2018-04-29 08:34:19 +0800 | [diff] [blame] | 1239 | lib/event-libs/libevent/libevent.c) |
Aditya Tirumala | ec50eba | 2017-03-15 19:41:11 +0530 | [diff] [blame] | 1240 | endif() |
| 1241 | |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 1242 | if (LWS_WITH_LIBEV AND LWS_WITH_NETWORK) |
Andy Green | d37b383 | 2018-04-29 10:44:36 +0800 | [diff] [blame] | 1243 | list(APPEND SOURCES |
| 1244 | lib/event-libs/libev/libev.c) |
| 1245 | endif() |
| 1246 | |
Andy Green | 5afc567 | 2016-05-10 09:47:10 +0800 | [diff] [blame] | 1247 | if (LWS_WITH_LEJP) |
| 1248 | list(APPEND SOURCES |
Andy Green | c83afc6 | 2017-10-16 12:52:32 +0800 | [diff] [blame] | 1249 | lib/misc/lejp.c) |
Andy Green | 5afc567 | 2016-05-10 09:47:10 +0800 | [diff] [blame] | 1250 | endif() |
Andy Green | 043700a | 2019-01-15 06:59:48 +0800 | [diff] [blame] | 1251 | if (LWS_WITH_LEJP_CONF AND LWS_WITH_NETWORK AND NOT LWS_PLAT_OPTEE) |
Andy Green | 3358c53 | 2016-05-26 21:12:11 +0800 | [diff] [blame] | 1252 | list(APPEND SOURCES |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 1253 | "lib/roles/http/server/lejp-conf.c" |
Andy Green | 3358c53 | 2016-05-26 21:12:11 +0800 | [diff] [blame] | 1254 | ) |
| 1255 | endif() |
Andy Green | 5afc567 | 2016-05-10 09:47:10 +0800 | [diff] [blame] | 1256 | |
Andy Green | 602d884 | 2016-06-07 09:49:59 +0800 | [diff] [blame] | 1257 | if (LWS_WITH_SMTP) |
| 1258 | list(APPEND SOURCES |
Andy Green | c83afc6 | 2017-10-16 12:52:32 +0800 | [diff] [blame] | 1259 | lib/misc/smtp.c) |
Andy Green | 602d884 | 2016-06-07 09:49:59 +0800 | [diff] [blame] | 1260 | endif() |
| 1261 | |
Andy Green | ed4acef | 2016-12-12 13:36:25 +0800 | [diff] [blame] | 1262 | if (LWS_WITH_RANGES) |
| 1263 | list(APPEND SOURCES |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 1264 | lib/roles/http/server/ranges.c) |
Andy Green | ed4acef | 2016-12-12 13:36:25 +0800 | [diff] [blame] | 1265 | endif() |
| 1266 | |
Andy Green | 753f1d6 | 2017-03-03 09:19:14 +0800 | [diff] [blame] | 1267 | if (LWS_WITH_ZIP_FOPS) |
Silas Parker | c1b5c8c | 2017-03-09 19:21:40 +0800 | [diff] [blame] | 1268 | if (LWS_WITH_ZLIB) |
| 1269 | list(APPEND SOURCES |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 1270 | lib/roles/http/server/fops-zip.c) |
Silas Parker | c1b5c8c | 2017-03-09 19:21:40 +0800 | [diff] [blame] | 1271 | else() |
| 1272 | message(FATAL_ERROR "Pre-zipped file support (LWS_WITH_ZIP_FOPS) requires ZLIB (LWS_WITH_ZLIB)") |
| 1273 | endif() |
Andy Green | 753f1d6 | 2017-03-03 09:19:14 +0800 | [diff] [blame] | 1274 | endif() |
| 1275 | |
Andy Green | eda102e | 2018-12-13 20:05:12 +0800 | [diff] [blame] | 1276 | if (LWS_WITH_JOSE) |
Andy Green | 278e520 | 2017-10-18 19:27:38 +0800 | [diff] [blame] | 1277 | list(APPEND SOURCES |
Andy Green | 440dacc | 2018-11-27 08:36:08 +0800 | [diff] [blame] | 1278 | lib/jose/jwk/jwk.c |
| 1279 | lib/jose/jws/jose.c |
Andy Green | eda102e | 2018-12-13 20:05:12 +0800 | [diff] [blame] | 1280 | lib/jose/jws/jws.c |
| 1281 | lib/jose/jwe/jwe.c |
Andy Green | 21889b5 | 2018-12-24 07:42:03 +0800 | [diff] [blame] | 1282 | lib/jose/jwe/enc/aescbc.c |
| 1283 | lib/jose/jwe/enc/aesgcm.c |
| 1284 | lib/jose/jwe/enc/aeskw.c |
Andy Green | eda102e | 2018-12-13 20:05:12 +0800 | [diff] [blame] | 1285 | lib/jose/jwe/jwe-rsa-aescbc.c |
Andy Green | eda102e | 2018-12-13 20:05:12 +0800 | [diff] [blame] | 1286 | lib/jose/jwe/jwe-rsa-aesgcm.c |
Andy Green | 21889b5 | 2018-12-24 07:42:03 +0800 | [diff] [blame] | 1287 | lib/jose/jwe/jwe-ecdh-es-aeskw.c |
Andy Green | eda102e | 2018-12-13 20:05:12 +0800 | [diff] [blame] | 1288 | ) |
Andy Green | 440dacc | 2018-11-27 08:36:08 +0800 | [diff] [blame] | 1289 | endif() |
| 1290 | |
Andy Green | eda102e | 2018-12-13 20:05:12 +0800 | [diff] [blame] | 1291 | if (LWS_WITH_JOSE OR LWS_WITH_GENCRYPTO) |
Andy Green | a3dcc95 | 2018-12-05 13:11:03 +0800 | [diff] [blame] | 1292 | list(APPEND SOURCES |
| 1293 | lib/tls/lws-gencrypto-common.c) |
| 1294 | endif() |
| 1295 | |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 1296 | # Add helper files for Windows. |
| 1297 | if (WIN32) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1298 | set(WIN32_HELPERS_PATH win32port/win32helpers) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1299 | include_directories(${WIN32_HELPERS_PATH}) |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 1300 | |
| 1301 | if (WIN32) |
| 1302 | list(APPEND SOURCES |
| 1303 | ${WIN32_HELPERS_PATH}/gettimeofday.c |
| 1304 | ) |
| 1305 | |
| 1306 | list(APPEND HDR_PRIVATE |
| 1307 | ${WIN32_HELPERS_PATH}/gettimeofday.h |
| 1308 | ) |
| 1309 | endif(WIN32) |
| 1310 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1311 | else() |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1312 | # Unix. |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 1313 | if (NOT LWS_WITHOUT_DAEMONIZE) |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 1314 | list(APPEND SOURCES |
Andy Green | 126be3c | 2018-04-11 13:39:42 +0800 | [diff] [blame] | 1315 | lib/misc/daemonize.c) |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 1316 | endif() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1317 | endif() |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 1318 | |
| 1319 | if (UNIX) |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 1320 | if (NOT LWS_HAVE_GETIFADDRS) |
Andy Green | c83afc6 | 2017-10-16 12:52:32 +0800 | [diff] [blame] | 1321 | list(APPEND HDR_PRIVATE lib/misc/getifaddrs.h) |
| 1322 | list(APPEND SOURCES lib/misc/getifaddrs.c) |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 1323 | endif() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1324 | endif() |
Andy Green | da3f6ff | 2013-03-16 12:32:59 +0800 | [diff] [blame] | 1325 | |
Andy Green | b39c22f | 2015-11-29 18:52:37 +0800 | [diff] [blame] | 1326 | if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) |
Steven Lai | ba3c75c | 2015-01-27 19:46:26 +0800 | [diff] [blame] | 1327 | include (CheckCCompilerFlag) |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 1328 | CHECK_C_COMPILER_FLAG(-fvisibility=hidden LWS_HAVE_VISIBILITY) |
| 1329 | if (LWS_HAVE_VISIBILITY) |
Steven Lai | ba3c75c | 2015-01-27 19:46:26 +0800 | [diff] [blame] | 1330 | set(VISIBILITY_FLAG -fvisibility=hidden) |
| 1331 | endif() |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 1332 | if (LWS_WITH_GCOV) |
Andy Green | b50e9fb | 2019-02-28 07:05:12 +0800 | [diff] [blame^] | 1333 | set (GCOV_FLAGS "-fprofile-arcs -ftest-coverage ") |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 1334 | endif() |
Andy Green | 7b227eb | 2018-04-20 10:33:23 +0800 | [diff] [blame] | 1335 | |
Andy Green | cbb8b1d | 2018-11-03 14:47:48 +0800 | [diff] [blame] | 1336 | if (LWS_WITH_ASAN) |
| 1337 | set (ASAN_FLAGS "-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=leak -fsanitize=undefined -fsanitize-address-use-after-scope -fsanitize-undefined-trap-on-error") |
| 1338 | message("Enabling ASAN") |
| 1339 | endif() |
Andy Green | 7b227eb | 2018-04-20 10:33:23 +0800 | [diff] [blame] | 1340 | |
Andy Green | 8487279 | 2017-11-30 12:40:46 +0800 | [diff] [blame] | 1341 | if (UNIX AND NOT LWS_WITH_ESP32) |
Andy Green | cbb8b1d | 2018-11-03 14:47:48 +0800 | [diff] [blame] | 1342 | set(CMAKE_C_FLAGS "-Wall -Wsign-compare -Wignored-qualifiers -Wtype-limits -Wuninitialized -Werror ${VISIBILITY_FLAG} -Wundef ${GCOV_FLAGS} ${CMAKE_C_FLAGS} ${ASAN_FLAGS}" ) |
Andy Green | 53ec6b1 | 2016-10-05 10:15:16 +0800 | [diff] [blame] | 1343 | else() |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 1344 | set(CMAKE_C_FLAGS "-Wall -Wsign-compare -Wignored-qualifiers -Wtype-limits -Wuninitialized -Werror ${VISIBILITY_FLAG} ${GCOV_FLAGS} ${CMAKE_C_FLAGS}" ) |
Andy Green | 53ec6b1 | 2016-10-05 10:15:16 +0800 | [diff] [blame] | 1345 | endif() |
Joakim Soderberg | c2012e4 | 2013-03-23 08:55:02 +0800 | [diff] [blame] | 1346 | endif () |
Andy Green | da3f6ff | 2013-03-16 12:32:59 +0800 | [diff] [blame] | 1347 | |
Andy Green | 043700a | 2019-01-15 06:59:48 +0800 | [diff] [blame] | 1348 | if (LWS_PLAT_OPTEE) |
| 1349 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot ../../../../lib/libutils/isoc/include -I../../../../lib/libutils/isoc/include -I../../../../lib/libutils/ext/include" ) |
| 1350 | endif() |
| 1351 | |
Andy Green | aa3c8cd | 2016-01-25 21:39:07 +0800 | [diff] [blame] | 1352 | if ((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT LWS_WITHOUT_TESTAPPS) |
Andy Green | 3de2e9a | 2018-03-02 09:01:22 +0800 | [diff] [blame] | 1353 | if (UNIX AND LWS_HAVE_PTHREAD_H) |
Andy Green | 09b8a71 | 2015-11-29 19:41:13 +0800 | [diff] [blame] | 1354 | # jeez clang understands -pthread but dies if he sees it at link time! |
| 1355 | # http://stackoverflow.com/questions/2391194/what-is-gs-pthread-equiv-in-clang |
| 1356 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread" ) |
| 1357 | endif() |
| 1358 | endif() |
| 1359 | |
Andy Green | 1700265 | 2015-11-29 19:19:09 +0800 | [diff] [blame] | 1360 | if ((CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) |
Andy Green | f6e6818 | 2018-11-05 10:25:36 +0800 | [diff] [blame] | 1361 | |
Andy Green | 1700265 | 2015-11-29 19:19:09 +0800 | [diff] [blame] | 1362 | # otherwise osx blows a bunch of openssl deprecated api errors |
| 1363 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations" ) |
Andy Green | f6e6818 | 2018-11-05 10:25:36 +0800 | [diff] [blame] | 1364 | if (UNIX AND LWS_HAVE_PTHREAD_H) |
| 1365 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread" ) |
| 1366 | endif() |
Andy Green | 1700265 | 2015-11-29 19:19:09 +0800 | [diff] [blame] | 1367 | endif() |
| 1368 | |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 1369 | source_group("Headers Private" FILES ${HDR_PRIVATE}) |
| 1370 | source_group("Headers Public" FILES ${HDR_PUBLIC}) |
| 1371 | source_group("Sources" FILES ${SOURCES}) |
krismattheus | 5366a76 | 2018-02-05 15:33:36 +0100 | [diff] [blame] | 1372 | source_group("Resources" FILES ${RESOURCES}) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 1373 | |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 1374 | # |
| 1375 | # Create the lib. |
| 1376 | # |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1377 | set(LWS_LIBRARIES) |
Roger A. Light | b6147fd | 2015-05-05 15:02:08 -0500 | [diff] [blame] | 1378 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1379 | if (LWS_WITH_STATIC) |
Brown, Matthew | b0ff623 | 2016-09-27 05:32:40 +0800 | [diff] [blame] | 1380 | if (LWS_STATIC_PIC) |
| 1381 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
| 1382 | endif() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1383 | add_library(websockets STATIC |
| 1384 | ${HDR_PRIVATE} |
| 1385 | ${HDR_PUBLIC} |
| 1386 | ${SOURCES}) |
| 1387 | list(APPEND LWS_LIBRARIES websockets) |
Roger A. Light | b6147fd | 2015-05-05 15:02:08 -0500 | [diff] [blame] | 1388 | |
| 1389 | if (WIN32) |
| 1390 | # Windows uses the same .lib ending for static libraries and shared |
| 1391 | # library linker files, so rename the static library. |
| 1392 | set_target_properties(websockets |
| 1393 | PROPERTIES |
| 1394 | OUTPUT_NAME websockets_static) |
| 1395 | endif() |
Andy Green | 4ca114f | 2017-02-28 07:51:56 +0800 | [diff] [blame] | 1396 | add_custom_command( |
| 1397 | TARGET websockets |
Andy Green | d1f9f0a | 2018-08-23 09:46:01 +0800 | [diff] [blame] | 1398 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/include/libwebsockets.h |
Sergey Kovalevich | 5d1d756 | 2017-05-29 18:48:01 +0300 | [diff] [blame] | 1399 | ${CMAKE_CURRENT_BINARY_DIR}/include/libwebsockets.h |
Andy Green | 4ca114f | 2017-02-28 07:51:56 +0800 | [diff] [blame] | 1400 | ) |
Andy Green | 37d6116 | 2018-11-23 08:54:40 +0800 | [diff] [blame] | 1401 | |
| 1402 | add_custom_command( |
| 1403 | TARGET websockets |
| 1404 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/include/libwebsockets/ |
| 1405 | ${CMAKE_CURRENT_BINARY_DIR}/include/libwebsockets |
| 1406 | ) |
| 1407 | |
Andy Green | 4ca114f | 2017-02-28 07:51:56 +0800 | [diff] [blame] | 1408 | add_custom_command( |
| 1409 | TARGET websockets |
Sergey Kovalevich | 5d1d756 | 2017-05-29 18:48:01 +0300 | [diff] [blame] | 1410 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/lws_config.h |
| 1411 | ${CMAKE_CURRENT_BINARY_DIR}/include/lws_config.h |
Andy Green | 4ca114f | 2017-02-28 07:51:56 +0800 | [diff] [blame] | 1412 | ) |
| 1413 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1414 | endif() |
Roger A. Light | b6147fd | 2015-05-05 15:02:08 -0500 | [diff] [blame] | 1415 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1416 | if (LWS_WITH_SHARED) |
| 1417 | add_library(websockets_shared SHARED |
| 1418 | ${HDR_PRIVATE} |
| 1419 | ${HDR_PUBLIC} |
krismattheus | 5366a76 | 2018-02-05 15:33:36 +0100 | [diff] [blame] | 1420 | ${SOURCES} |
| 1421 | ${RESOURCES}) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1422 | list(APPEND LWS_LIBRARIES websockets_shared) |
Joakim Soderberg | 0848353 | 2013-02-13 09:29:17 +0800 | [diff] [blame] | 1423 | |
Roger A. Light | b6147fd | 2015-05-05 15:02:08 -0500 | [diff] [blame] | 1424 | # We want the shared lib to be named "libwebsockets" |
| 1425 | # not "libwebsocket_shared". |
| 1426 | set_target_properties(websockets_shared |
| 1427 | PROPERTIES |
| 1428 | OUTPUT_NAME websockets) |
| 1429 | |
| 1430 | if (WIN32) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1431 | # Compile as DLL (export function declarations) |
| 1432 | set_property( |
| 1433 | TARGET websockets_shared |
| 1434 | PROPERTY COMPILE_DEFINITIONS |
| 1435 | LWS_DLL |
| 1436 | LWS_INTERNAL) |
| 1437 | endif() |
Roger A. Light | b6147fd | 2015-05-05 15:02:08 -0500 | [diff] [blame] | 1438 | |
| 1439 | if (APPLE) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1440 | set_property(TARGET websockets_shared PROPERTY MACOSX_RPATH YES) |
| 1441 | endif() |
Andy Green | 4ca114f | 2017-02-28 07:51:56 +0800 | [diff] [blame] | 1442 | |
| 1443 | add_custom_command( |
| 1444 | TARGET websockets_shared |
Andy Green | d1f9f0a | 2018-08-23 09:46:01 +0800 | [diff] [blame] | 1445 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/include/libwebsockets.h |
Sergey Kovalevich | 5d1d756 | 2017-05-29 18:48:01 +0300 | [diff] [blame] | 1446 | ${CMAKE_CURRENT_BINARY_DIR}/include/libwebsockets.h |
Andy Green | 4ca114f | 2017-02-28 07:51:56 +0800 | [diff] [blame] | 1447 | ) |
Andy Green | 37d6116 | 2018-11-23 08:54:40 +0800 | [diff] [blame] | 1448 | |
| 1449 | add_custom_command( |
| 1450 | TARGET websockets |
| 1451 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/include/libwebsockets |
| 1452 | ${CMAKE_CURRENT_BINARY_DIR}/include/libwebsockets |
| 1453 | ) |
| 1454 | |
Andy Green | 4ca114f | 2017-02-28 07:51:56 +0800 | [diff] [blame] | 1455 | add_custom_command( |
| 1456 | TARGET websockets_shared |
Sergey Kovalevich | 5d1d756 | 2017-05-29 18:48:01 +0300 | [diff] [blame] | 1457 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/lws_config.h |
| 1458 | ${CMAKE_CURRENT_BINARY_DIR}/include/lws_config.h |
Andy Green | 4ca114f | 2017-02-28 07:51:56 +0800 | [diff] [blame] | 1459 | ) |
| 1460 | |
| 1461 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1462 | endif() |
Joakim Soderberg | f83585f | 2013-02-13 09:29:09 +0800 | [diff] [blame] | 1463 | |
| 1464 | # Set the so version of the lib. |
Andy Green | 19c1a99 | 2013-03-10 06:59:01 +0800 | [diff] [blame] | 1465 | # Equivalent to LDFLAGS=-version-info x:x:x |
Andy Green | b39c22f | 2015-11-29 18:52:37 +0800 | [diff] [blame] | 1466 | if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1467 | foreach(lib ${LWS_LIBRARIES}) |
| 1468 | set_target_properties(${lib} |
Joakim Soderberg | f272cb0 | 2013-02-13 09:29:26 +0800 | [diff] [blame] | 1469 | PROPERTIES |
| 1470 | SOVERSION ${SOVERSION}) |
| 1471 | endforeach() |
Joakim Soderberg | f83585f | 2013-02-13 09:29:09 +0800 | [diff] [blame] | 1472 | endif() |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 1473 | |
Joakim Soderberg | 0848353 | 2013-02-13 09:29:17 +0800 | [diff] [blame] | 1474 | set(LIB_LIST) |
| 1475 | |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 1476 | # |
| 1477 | # Find libraries. |
| 1478 | # |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 1479 | |
| 1480 | # |
Andy Green | d588286 | 2018-09-02 14:43:05 +0800 | [diff] [blame] | 1481 | # ZLIB (needed for deflate extension and if LWS_WITH_HTTP_STREAM_COMPRESSION) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 1482 | # |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1483 | if (LWS_WITH_ZLIB) |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 1484 | if (LWS_WITH_BUNDLED_ZLIB) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1485 | if (WIN32) |
| 1486 | set(WIN32_ZLIB_PATH "win32port/zlib") |
| 1487 | set(ZLIB_SRCS |
| 1488 | ${WIN32_ZLIB_PATH}/adler32.c |
| 1489 | ${WIN32_ZLIB_PATH}/compress.c |
| 1490 | ${WIN32_ZLIB_PATH}/crc32.c |
| 1491 | ${WIN32_ZLIB_PATH}/deflate.c |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1492 | ${WIN32_ZLIB_PATH}/gzlib.c |
| 1493 | ${WIN32_ZLIB_PATH}/gzread.c |
| 1494 | ${WIN32_ZLIB_PATH}/gzwrite.c |
| 1495 | ${WIN32_ZLIB_PATH}/infback.c |
| 1496 | ${WIN32_ZLIB_PATH}/inffast.c |
| 1497 | ${WIN32_ZLIB_PATH}/inflate.c |
| 1498 | ${WIN32_ZLIB_PATH}/inftrees.c |
| 1499 | ${WIN32_ZLIB_PATH}/trees.c |
| 1500 | ${WIN32_ZLIB_PATH}/uncompr.c |
| 1501 | ${WIN32_ZLIB_PATH}/zutil.c) |
| 1502 | add_library(zlib_internal STATIC ${ZLIB_SRCS}) |
| 1503 | set(ZLIB_INCLUDE_DIRS ${WIN32_ZLIB_PATH}) |
| 1504 | get_property(ZLIB_LIBRARIES TARGET zlib_internal PROPERTY LOCATION) |
| 1505 | set(ZLIB_FOUND 1) |
| 1506 | # Make sure zlib_internal is compiled before the libs. |
| 1507 | foreach (lib ${LWS_LIBRARIES}) |
| 1508 | add_dependencies(${lib} zlib_internal) |
| 1509 | endforeach() |
| 1510 | else() |
| 1511 | message(FATAL_ERROR "Don't have bundled zlib for that platform") |
| 1512 | endif() |
| 1513 | elseif (NOT ZLIB_FOUND) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 1514 | find_package(ZLIB REQUIRED) |
| 1515 | endif() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1516 | message("zlib include dirs: ${ZLIB_INCLUDE_DIRS}") |
| 1517 | message("zlib libraries: ${ZLIB_LIBRARIES}") |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 1518 | include_directories(${ZLIB_INCLUDE_DIRS}) |
| 1519 | list(APPEND LIB_LIST ${ZLIB_LIBRARIES}) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1520 | endif() |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 1521 | |
Andy Green | d588286 | 2018-09-02 14:43:05 +0800 | [diff] [blame] | 1522 | if (LWS_WITH_HTTP_BROTLI) |
| 1523 | list(APPEND LIB_LIST brotlienc brotlidec brotlidec) |
| 1524 | endif() |
| 1525 | |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 1526 | # |
| 1527 | # OpenSSL |
| 1528 | # |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 1529 | if (LWS_WITH_SSL) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1530 | message("Compiling with SSL support") |
Andy Green | 1a3f177 | 2016-03-28 19:58:02 +0800 | [diff] [blame] | 1531 | set(chose_ssl 0) |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 1532 | if (LWS_WITH_WOLFSSL) |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 1533 | # Use wolfSSL as OpenSSL replacement. |
Joakim Söderberg | cb4156d | 2013-02-06 15:30:56 +0900 | [diff] [blame] | 1534 | # TODO: Add a find_package command for this also. |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 1535 | message("wolfSSL include dir: ${WOLFSSL_INCLUDE_DIRS}") |
| 1536 | message("wolfSSL libraries: ${WOLFSSL_LIBRARIES}") |
Joakim Söderberg | cb4156d | 2013-02-06 15:30:56 +0900 | [diff] [blame] | 1537 | |
Joakim Soderberg | 7df9908 | 2013-02-07 20:24:19 +0800 | [diff] [blame] | 1538 | # Additional to the root directory we need to include |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 1539 | # the wolfssl/ subdirectory which contains the OpenSSL |
Peter Pentchev | bb085da | 2015-12-03 15:55:11 +0200 | [diff] [blame] | 1540 | # compatibility layer headers. |
Peter Pentchev | e46f412 | 2015-10-01 12:25:05 +0300 | [diff] [blame] | 1541 | |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 1542 | if (LWS_WITH_CYASSL) |
ABruines | 80a7068 | 2015-08-09 22:56:32 +0200 | [diff] [blame] | 1543 | foreach(inc ${WOLFSSL_INCLUDE_DIRS}) |
| 1544 | include_directories("${inc}" "${inc}/cyassl") |
| 1545 | endforeach() |
| 1546 | else() |
| 1547 | foreach(inc ${WOLFSSL_INCLUDE_DIRS}) |
| 1548 | include_directories("${inc}" "${inc}/wolfssl") |
| 1549 | endforeach() |
| 1550 | endif() |
Joakim Soderberg | 7df9908 | 2013-02-07 20:24:19 +0800 | [diff] [blame] | 1551 | |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 1552 | list(APPEND LIB_LIST "${WOLFSSL_LIBRARIES}") |
Andy Green | 1a3f177 | 2016-03-28 19:58:02 +0800 | [diff] [blame] | 1553 | set(chose_ssl 1) |
| 1554 | endif() |
| 1555 | |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 1556 | if (LWS_WITH_MBEDTLS) |
Juraj Vijtiuk | 3aaf38d | 2017-08-28 20:12:32 +0800 | [diff] [blame] | 1557 | message("MBEDTLS include dir: ${MBEDTLS_INCLUDE_DIRS}") |
| 1558 | message("MBEDTLS libraries: ${MBEDTLS_LIBRARIES}") |
| 1559 | |
| 1560 | foreach(inc ${MBEDTLS_INCLUDE_DIRS}) |
| 1561 | include_directories("${inc}" "${inc}/mbedtls") |
| 1562 | endforeach() |
| 1563 | |
| 1564 | list(APPEND LIB_LIST "${MBEDTLS_LIBRARIES}") |
| 1565 | set(chose_ssl 1) |
| 1566 | endif() |
| 1567 | |
Andy Green | 1a3f177 | 2016-03-28 19:58:02 +0800 | [diff] [blame] | 1568 | if (NOT chose_ssl) |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 1569 | if (NOT OPENSSL_FOUND AND NOT LWS_WITH_BORINGSSL) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1570 | # TODO: Add support for STATIC also. |
Andy Green | 3a09c3b | 2017-03-08 11:11:41 +0800 | [diff] [blame] | 1571 | if (NOT LWS_WITH_ESP32) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1572 | find_package(OpenSSL REQUIRED) |
Andy Green | 3a09c3b | 2017-03-08 11:11:41 +0800 | [diff] [blame] | 1573 | endif() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1574 | set(OPENSSL_INCLUDE_DIRS "${OPENSSL_INCLUDE_DIR}") |
| 1575 | endif() |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1576 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1577 | message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIRS}") |
Andy Green | 3a09c3b | 2017-03-08 11:11:41 +0800 | [diff] [blame] | 1578 | if (NOT LWS_WITH_ESP32) |
| 1579 | message("OpenSSL libraries: ${OPENSSL_LIBRARIES}") |
| 1580 | endif() |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 1581 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1582 | include_directories("${OPENSSL_INCLUDE_DIRS}") |
Andy Green | 3a09c3b | 2017-03-08 11:11:41 +0800 | [diff] [blame] | 1583 | if (NOT LWS_WITH_ESP32) |
| 1584 | list(APPEND LIB_LIST ${OPENSSL_LIBRARIES}) |
| 1585 | endif() |
Joakim Soderberg | 9a720bb | 2016-03-12 08:37:36 +0800 | [diff] [blame] | 1586 | |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 1587 | if (NOT LWS_WITH_MBEDTLS) |
Andy Green | c0c217b | 2017-08-28 21:00:11 +0800 | [diff] [blame] | 1588 | # older (0.98) Openssl lacks this |
| 1589 | set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIRS}) |
| 1590 | check_include_file(openssl/ecdh.h LWS_HAVE_OPENSSL_ECDH_H) |
Joakim Soderberg | 9a720bb | 2016-03-12 08:37:36 +0800 | [diff] [blame] | 1591 | |
Andy Green | c0c217b | 2017-08-28 21:00:11 +0800 | [diff] [blame] | 1592 | if (LWS_SSL_SERVER_WITH_ECDH_CERT AND NOT LWS_HAVE_OPENSSL_ECDH_H) |
| 1593 | message(FATAL_ERROR "Missing openssl/ecdh.h, so cannot use LWS_SSL_SERVER_WITH_ECDH_CERT") |
| 1594 | endif() |
Andy Green | 0186490 | 2017-09-10 14:44:12 +0800 | [diff] [blame] | 1595 | else() |
| 1596 | unset(LWS_HAVE_OPENSSL_ECDH_H) |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 1597 | endif(NOT LWS_WITH_MBEDTLS) |
Karl Palsson | d13c147 | 2016-06-06 15:03:09 +0000 | [diff] [blame] | 1598 | endif() |
Joakim Soderberg | 9a720bb | 2016-03-12 08:37:36 +0800 | [diff] [blame] | 1599 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 1600 | endif(LWS_WITH_SSL) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1601 | |
Andrew Canaday | 9769f4f | 2014-03-23 13:25:07 +0800 | [diff] [blame] | 1602 | if (LWS_WITH_LIBEV) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1603 | if (NOT LIBEV_FOUND) |
| 1604 | find_path(LIBEV_INCLUDE_DIRS NAMES ev.h) |
| 1605 | find_library(LIBEV_LIBRARIES NAMES ev) |
| 1606 | if(LIBEV_INCLUDE_DIRS AND LIBEV_LIBRARIES) |
| 1607 | set(LIBEV_FOUND 1) |
| 1608 | endif() |
| 1609 | endif() |
| 1610 | message("libev include dir: ${LIBEV_INCLUDE_DIRS}") |
| 1611 | message("libev libraries: ${LIBEV_LIBRARIES}") |
| 1612 | include_directories("${LIBEV_INCLUDE_DIRS}") |
| 1613 | list(APPEND LIB_LIST ${LIBEV_LIBRARIES}) |
Andrew Canaday | 9769f4f | 2014-03-23 13:25:07 +0800 | [diff] [blame] | 1614 | endif(LWS_WITH_LIBEV) |
| 1615 | |
Andy Green | 86ed65f | 2016-02-14 09:27:41 +0800 | [diff] [blame] | 1616 | if (LWS_WITH_LIBUV) |
| 1617 | if (NOT LIBUV_FOUND) |
| 1618 | find_path(LIBUV_INCLUDE_DIRS NAMES uv.h) |
| 1619 | find_library(LIBUV_LIBRARIES NAMES uv) |
| 1620 | if(LIBUV_INCLUDE_DIRS AND LIBUV_LIBRARIES) |
| 1621 | set(LIBUV_FOUND 1) |
| 1622 | endif() |
| 1623 | endif() |
| 1624 | message("libuv include dir: ${LIBUV_INCLUDE_DIRS}") |
| 1625 | message("libuv libraries: ${LIBUV_LIBRARIES}") |
| 1626 | include_directories("${LIBUV_INCLUDE_DIRS}") |
| 1627 | list(APPEND LIB_LIST ${LIBUV_LIBRARIES}) |
| 1628 | endif() |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 1629 | |
Aditya Tirumala | ec50eba | 2017-03-15 19:41:11 +0530 | [diff] [blame] | 1630 | if (LWS_WITH_LIBEVENT) |
| 1631 | if (NOT LIBEVENT_FOUND) |
| 1632 | find_path(LIBEVENT_INCLUDE_DIRS NAMES event2/event.h) |
| 1633 | find_library(LIBEVENT_LIBRARIES NAMES event) |
| 1634 | if(LIBEVENT_INCLUDE_DIRS AND LIBEVENT_LIBRARIES) |
| 1635 | set(LIBEVENT_FOUND 1) |
| 1636 | endif() |
| 1637 | endif() |
| 1638 | message("libevent include dir: ${LIBEVENT_INCLUDE_DIRS}") |
| 1639 | message("libevent libraries: ${LIBEVENT_LIBRARIES}") |
| 1640 | include_directories("${LIBEVENT_INCLUDE_DIRS}") |
| 1641 | list(APPEND LIB_LIST ${LIBEVENT_LIBRARIES}) |
| 1642 | endif(LWS_WITH_LIBEVENT) |
| 1643 | |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 1644 | if (LWS_WITH_SQLITE3) |
| 1645 | if (NOT SQLITE3_FOUND) |
| 1646 | find_path(SQLITE3_INCLUDE_DIRS NAMES sqlite3.h) |
| 1647 | find_library(SQLITE3_LIBRARIES NAMES sqlite3) |
| 1648 | if(SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES) |
| 1649 | set(SQLITE3_FOUND 1) |
| 1650 | endif() |
| 1651 | endif() |
| 1652 | message("sqlite3 include dir: ${SQLITE3_INCLUDE_DIRS}") |
| 1653 | message("sqlite3 libraries: ${SQLITE3_LIBRARIES}") |
| 1654 | include_directories("${SQLITE3_INCLUDE_DIRS}") |
| 1655 | list(APPEND LIB_LIST ${SQLITE3_LIBRARIES}) |
| 1656 | endif() |
| 1657 | |
| 1658 | |
Andy Green | fd810f1 | 2018-09-04 08:06:46 +0800 | [diff] [blame] | 1659 | if (LWS_WITH_HUBBUB) |
Yuchen Xie | 63477de | 2016-10-10 20:10:34 +0800 | [diff] [blame] | 1660 | find_library(LIBHUBBUB_LIBRARIES NAMES hubbub) |
Andy Green | 1e5a9ad | 2016-03-20 11:59:53 +0800 | [diff] [blame] | 1661 | list(APPEND LIB_LIST ${LIBHUBBUB_LIBRARIES} ) |
| 1662 | endif() |
| 1663 | |
Andy Green | 31dfc4a | 2018-10-02 10:50:24 +0800 | [diff] [blame] | 1664 | if (LWS_ROLE_DBUS) |
| 1665 | message("dbus include dir 1: ${LWS_DBUS_INCLUDE1}") |
| 1666 | message("dbus include dir 2: ${LWS_DBUS_INCLUDE2}") |
| 1667 | include_directories("${LWS_DBUS_INCLUDE1}") |
| 1668 | include_directories("${LWS_DBUS_INCLUDE2}") |
| 1669 | list(APPEND LIB_LIST ${LWS_DBUS_LIB}) |
| 1670 | endif() |
Andy Green | 86ed65f | 2016-02-14 09:27:41 +0800 | [diff] [blame] | 1671 | |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1672 | # |
| 1673 | # Platform specific libs. |
| 1674 | # |
Patrick Gansterer | 5b71aac | 2014-02-28 01:31:39 +0100 | [diff] [blame] | 1675 | if (WINCE) |
| 1676 | list(APPEND LIB_LIST ws2.lib) |
| 1677 | elseif (WIN32) |
Joel Winarske | 238766b | 2017-02-14 11:17:09 -0800 | [diff] [blame] | 1678 | list(APPEND LIB_LIST ws2_32.lib userenv.lib psapi.lib iphlpapi.lib) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 1679 | endif() |
| 1680 | |
Anzey | 08d36db | 2018-01-04 10:37:25 +0800 | [diff] [blame] | 1681 | if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") |
| 1682 | list(APPEND LIB_LIST socket) |
| 1683 | endif() |
| 1684 | |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1685 | if (UNIX) |
Joakim Soderberg | 0848353 | 2013-02-13 09:29:17 +0800 | [diff] [blame] | 1686 | list(APPEND LIB_LIST m) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1687 | endif() |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 1688 | |
Alexander von Gluck IV | 8bea6c1 | 2017-09-24 15:30:42 +0000 | [diff] [blame] | 1689 | if (HAIKU) |
| 1690 | list(APPEND LIB_LIST network) |
| 1691 | endif() |
| 1692 | |
Andy Green | 156363f | 2017-06-07 06:10:02 +0800 | [diff] [blame] | 1693 | if (LWS_HAVE_LIBCAP) |
| 1694 | list(APPEND LIB_LIST cap ) |
| 1695 | endif() |
| 1696 | |
| 1697 | |
| 1698 | |
Joakim Soderberg | f272cb0 | 2013-02-13 09:29:26 +0800 | [diff] [blame] | 1699 | # Setup the linking for all libs. |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1700 | foreach (lib ${LWS_LIBRARIES}) |
Joakim Soderberg | f272cb0 | 2013-02-13 09:29:26 +0800 | [diff] [blame] | 1701 | target_link_libraries(${lib} ${LIB_LIST}) |
| 1702 | endforeach() |
Joakim Soderberg | 0848353 | 2013-02-13 09:29:17 +0800 | [diff] [blame] | 1703 | |
Alexander Bruines | ddd9bfa | 2016-04-13 22:17:05 +0200 | [diff] [blame] | 1704 | set (temp ${CMAKE_REQUIRED_LIBRARIES}) |
| 1705 | set(CMAKE_REQUIRED_LIBRARIES ${LIB_LIST}) |
Andy Green | 37e8ee2 | 2017-11-08 15:53:43 +0800 | [diff] [blame] | 1706 | |
| 1707 | if (LWS_WITH_ZLIB) |
| 1708 | if (LWS_WITH_BUNDLED_ZLIB) |
| 1709 | if (WIN32) |
| 1710 | # it's trying to delete internal zlib entry |
| 1711 | LIST(REMOVE_AT CMAKE_REQUIRED_LIBRARIES 0 ) |
| 1712 | endif() |
| 1713 | endif() |
| 1714 | endif() |
| 1715 | |
Alexander Bruines | ddd9bfa | 2016-04-13 22:17:05 +0200 | [diff] [blame] | 1716 | CHECK_FUNCTION_EXISTS(SSL_CTX_set1_param LWS_HAVE_SSL_CTX_set1_param) |
Andy Green | 3ff720f | 2017-06-20 11:46:49 +0800 | [diff] [blame] | 1717 | CHECK_FUNCTION_EXISTS(SSL_set_info_callback LWS_HAVE_SSL_SET_INFO_CALLBACK) |
Andy Green | e7bf0aa | 2016-06-28 19:50:40 +0800 | [diff] [blame] | 1718 | CHECK_FUNCTION_EXISTS(X509_VERIFY_PARAM_set1_host LWS_HAVE_X509_VERIFY_PARAM_set1_host) |
Andy Green | 7597ac3 | 2017-10-16 16:59:57 +0800 | [diff] [blame] | 1719 | CHECK_FUNCTION_EXISTS(RSA_set0_key LWS_HAVE_RSA_SET0_KEY) |
Andy Green | 00ffebf | 2017-10-26 09:54:25 +0800 | [diff] [blame] | 1720 | CHECK_FUNCTION_EXISTS(X509_get_key_usage LWS_HAVE_X509_get_key_usage) |
| 1721 | CHECK_FUNCTION_EXISTS(SSL_CTX_get0_certificate LWS_HAVE_SSL_CTX_get0_certificate) |
Andy Green | b45956f | 2018-03-27 06:29:49 +0800 | [diff] [blame] | 1722 | CHECK_FUNCTION_EXISTS(SSL_get0_alpn_selected LWS_HAVE_SSL_get0_alpn_selected) |
| 1723 | CHECK_FUNCTION_EXISTS(SSL_set_alpn_protos LWS_HAVE_SSL_set_alpn_protos) |
Andy Green | 93d4e18 | 2018-10-27 08:05:21 +0800 | [diff] [blame] | 1724 | CHECK_FUNCTION_EXISTS(SSL_CTX_set_ciphersuites LWS_HAVE_SSL_CTX_set_ciphersuites) |
Andy Green | 89cb55e | 2017-10-18 09:41:44 +0800 | [diff] [blame] | 1725 | if (LWS_WITH_SSL AND NOT LWS_WITH_MBEDTLS) |
| 1726 | CHECK_SYMBOL_EXISTS(SSL_CTX_get_extra_chain_certs_only openssl/ssl.h LWS_HAVE_SSL_EXTRA_CHAIN_CERTS) |
Andy Green | a3dcc95 | 2018-12-05 13:11:03 +0800 | [diff] [blame] | 1727 | CHECK_FUNCTION_EXISTS(EVP_MD_CTX_free LWS_HAVE_EVP_MD_CTX_free) |
Andy Green | eda102e | 2018-12-13 20:05:12 +0800 | [diff] [blame] | 1728 | CHECK_FUNCTION_EXISTS(ECDSA_SIG_set0 LWS_HAVE_ECDSA_SIG_set0) |
| 1729 | CHECK_FUNCTION_EXISTS(BN_bn2binpad LWS_HAVE_BN_bn2binpad) |
| 1730 | CHECK_FUNCTION_EXISTS(EVP_aes_128_wrap LWS_HAVE_EVP_aes_128_wrap) |
Andy Green | 89cb55e | 2017-10-18 09:41:44 +0800 | [diff] [blame] | 1731 | endif() |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 1732 | if (LWS_WITH_MBEDTLS) |
Andy Green | 8a74348 | 2017-04-07 11:29:57 +0800 | [diff] [blame] | 1733 | set(LWS_HAVE_TLS_CLIENT_METHOD 1) |
Andy Green | 37b994c | 2017-09-09 08:31:49 +0800 | [diff] [blame] | 1734 | if (NOT LWS_WITH_ESP32) |
| 1735 | # not supported in esp-idf openssl wrapper yet, but is in our version |
| 1736 | set(LWS_HAVE_X509_VERIFY_PARAM_set1_host 1) |
| 1737 | endif() |
Andy Green | ad9c99a | 2019-01-11 13:14:32 +0800 | [diff] [blame] | 1738 | |
| 1739 | CHECK_FUNCTION_EXISTS(mbedtls_ssl_conf_alpn_protocols LWS_HAVE_mbedtls_ssl_conf_alpn_protocols) |
| 1740 | CHECK_FUNCTION_EXISTS(mbedtls_ssl_get_alpn_protocol LWS_HAVE_mbedtls_ssl_get_alpn_protocol) |
| 1741 | CHECK_FUNCTION_EXISTS(mbedtls_ssl_conf_sni LWS_HAVE_mbedtls_ssl_conf_sni) |
| 1742 | CHECK_FUNCTION_EXISTS(mbedtls_ssl_set_hs_ca_chain LWS_HAVE_mbedtls_ssl_set_hs_ca_chain) |
| 1743 | CHECK_FUNCTION_EXISTS(mbedtls_ssl_set_hs_own_cert LWS_HAVE_mbedtls_ssl_set_hs_own_cert) |
| 1744 | CHECK_FUNCTION_EXISTS(mbedtls_ssl_set_hs_authmode LWS_HAVE_mbedtls_ssl_set_hs_authmode) |
| 1745 | CHECK_FUNCTION_EXISTS(mbedtls_net_init LWS_HAVE_mbedtls_net_init) |
| 1746 | |
Andy Green | 8a74348 | 2017-04-07 11:29:57 +0800 | [diff] [blame] | 1747 | else() |
Martin Milata | d7d8c08 | 2017-04-06 15:46:37 +0200 | [diff] [blame] | 1748 | CHECK_FUNCTION_EXISTS(TLS_client_method LWS_HAVE_TLS_CLIENT_METHOD) |
| 1749 | CHECK_FUNCTION_EXISTS(TLSv1_2_client_method LWS_HAVE_TLSV1_2_CLIENT_METHOD) |
Andy Green | 8a74348 | 2017-04-07 11:29:57 +0800 | [diff] [blame] | 1750 | endif() |
Andy Green | 65f87ef | 2018-04-12 21:37:59 +0800 | [diff] [blame] | 1751 | |
| 1752 | # ideally we want to use pipe2() |
| 1753 | |
| 1754 | CHECK_C_SOURCE_COMPILES("#define _GNU_SOURCE\n#include <unistd.h>\nint main(void) {int fd[2];\n return pipe2(fd, 0);\n}\n" LWS_HAVE_PIPE2) |
| 1755 | |
Andy Green | a939087 | 2018-04-18 18:45:27 +0800 | [diff] [blame] | 1756 | # tcp keepalive needs this on linux to work practically... but it only exists |
| 1757 | # after kernel 2.6.37 |
| 1758 | |
Silas Parker | 3c3c49f | 2018-05-15 08:04:48 +0800 | [diff] [blame] | 1759 | CHECK_C_SOURCE_COMPILES("#include <netinet/tcp.h>\nint main(void) { return TCP_USER_TIMEOUT; }\n" LWS_HAVE_TCP_USER_TIMEOUT) |
Andy Green | a939087 | 2018-04-18 18:45:27 +0800 | [diff] [blame] | 1760 | |
Alexander Bruines | ddd9bfa | 2016-04-13 22:17:05 +0200 | [diff] [blame] | 1761 | set(CMAKE_REQUIRED_LIBRARIES ${temp}) |
| 1762 | # Generate the lws_config.h that includes all the public compilation settings. |
| 1763 | configure_file( |
Andy Green | 4f267c5 | 2017-09-22 09:46:58 +0800 | [diff] [blame] | 1764 | "${PROJECT_SOURCE_DIR}/cmake/lws_config.h.in" |
Alexander Bruines | ddd9bfa | 2016-04-13 22:17:05 +0200 | [diff] [blame] | 1765 | "${PROJECT_BINARY_DIR}/lws_config.h") |
| 1766 | |
| 1767 | # Generate the lws_config.h that includes all the private compilation settings. |
| 1768 | configure_file( |
Andy Green | 4f267c5 | 2017-09-22 09:46:58 +0800 | [diff] [blame] | 1769 | "${PROJECT_SOURCE_DIR}/cmake/lws_config_private.h.in" |
Alexander Bruines | ddd9bfa | 2016-04-13 22:17:05 +0200 | [diff] [blame] | 1770 | "${PROJECT_BINARY_DIR}/lws_config_private.h") |
| 1771 | |
Andy Green | 3a09c3b | 2017-03-08 11:11:41 +0800 | [diff] [blame] | 1772 | # Generate self-signed SSL certs for the test-server. |
| 1773 | |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 1774 | if (LWS_WITH_SSL AND NOT LWS_WITH_WOLFSSL) |
Andy Green | 3a09c3b | 2017-03-08 11:11:41 +0800 | [diff] [blame] | 1775 | message("Searching for OpenSSL executable and dlls") |
| 1776 | find_package(OpenSSLbins) |
| 1777 | message("OpenSSL executable: ${OPENSSL_EXECUTABLE}") |
| 1778 | if (OPENSSL_EXECUTABLE MATCHES "^$") |
| 1779 | set(OPENSSL_EXECUTABLE openssl) |
| 1780 | endif() |
| 1781 | if (NOT OPENSSL_EXECUTABLE) |
| 1782 | set(OPENSSL_EXECUTABLE openssl) |
| 1783 | endif() |
| 1784 | |
| 1785 | endif() |
| 1786 | |
| 1787 | set(GENCERTS 0) |
| 1788 | |
Adam Wolk | 2befafc | 2017-11-25 20:15:29 +0100 | [diff] [blame] | 1789 | if (LWS_WITH_SSL AND OPENSSL_EXECUTABLE AND NOT LWS_WITHOUT_TEST_SERVER AND NOT LWS_WITHOUT_SERVER AND NOT LWS_WITHOUT_TESTAPPS) |
Andy Green | 3a09c3b | 2017-03-08 11:11:41 +0800 | [diff] [blame] | 1790 | set(GENCERTS 1) |
| 1791 | endif() |
| 1792 | if (LWS_WITH_ESP32) |
| 1793 | set(GENCERTS 1) |
| 1794 | endif() |
| 1795 | message(" GENCERTS = ${GENCERTS}") |
| 1796 | if (GENCERTS) |
| 1797 | message("Generating SSL Certificates for the test-server...") |
| 1798 | |
| 1799 | set(TEST_SERVER_SSL_KEY "${PROJECT_BINARY_DIR}/libwebsockets-test-server.key.pem") |
| 1800 | set(TEST_SERVER_SSL_CERT "${PROJECT_BINARY_DIR}/libwebsockets-test-server.pem") |
| 1801 | |
| 1802 | if (WIN32) |
| 1803 | if (MINGW) |
| 1804 | message("cmd = \"${OPENSSL_EXECUTABLE}\" req -new -newkey rsa:1024 -days 10000 -nodes -x509 -subj \"/C=GB/ST=Erewhon/L=All around/O=libwebsockets-test/CN=localhost\" -keyout \"${TEST_SERVER_SSL_KEY}\" -out \"${TEST_SERVER_SSL_CERT}\"") |
| 1805 | execute_process( |
| 1806 | COMMAND "${OPENSSL_EXECUTABLE}" req -new -newkey rsa:1024 -days 10000 -nodes -x509 -subj "/C=GB/ST=Erewhon/L=All around/O=libwebsockets-test/CN=localhost" -keyout "${TEST_SERVER_SSL_KEY}" -out "${TEST_SERVER_SSL_CERT}" |
| 1807 | RESULT_VARIABLE OPENSSL_RETURN_CODE) |
| 1808 | else() |
| 1809 | file(WRITE "${PROJECT_BINARY_DIR}/openssl_input.txt" |
| 1810 | "GB\n" |
| 1811 | "Erewhon\n" |
| 1812 | "All around\n" |
| 1813 | "libwebsockets-test\n" |
| 1814 | "localhost\n" |
| 1815 | "none@invalid.org\n\n" |
| 1816 | ) |
| 1817 | |
| 1818 | # The "type" command is a bit picky with paths. |
| 1819 | file(TO_NATIVE_PATH "${PROJECT_BINARY_DIR}/openssl_input.txt" OPENSSL_INPUT_WIN_PATH) |
| 1820 | message("OPENSSL_INPUT_WIN_PATH = ${OPENSSL_INPUT_WIN_PATH}") |
| 1821 | message("cmd = \"${OPENSSL_EXECUTABLE}\" req -new -newkey rsa:1024 -days 10000 -nodes -x509 -keyout \"${TEST_SERVER_SSL_KEY}\" -out \"${TEST_SERVER_SSL_CERT}\"") |
| 1822 | |
| 1823 | execute_process( |
| 1824 | COMMAND cmd /c type "${OPENSSL_INPUT_WIN_PATH}" |
| 1825 | COMMAND "${OPENSSL_EXECUTABLE}" req -new -newkey rsa:1024 -days 10000 -nodes -x509 -keyout "${TEST_SERVER_SSL_KEY}" -out "${TEST_SERVER_SSL_CERT}" |
| 1826 | RESULT_VARIABLE OPENSSL_RETURN_CODE |
| 1827 | OUTPUT_QUIET ERROR_QUIET) |
| 1828 | |
| 1829 | message("\n") |
| 1830 | endif() |
| 1831 | |
| 1832 | if (OPENSSL_RETURN_CODE) |
| 1833 | message(WARNING "!!! Failed to generate SSL certificate for Test Server using cmd.exe !!!:\nOpenSSL return code = ${OPENSSL_RETURN_CODE}") |
| 1834 | else() |
| 1835 | message("SUCCSESFULLY generated SSL certificate") |
| 1836 | endif() |
| 1837 | else() |
| 1838 | # Unix. |
| 1839 | execute_process( |
| 1840 | COMMAND printf "GB\\nErewhon\\nAll around\\nlibwebsockets-test\\n\\nlocalhost\\nnone@invalid.org\\n" |
| 1841 | COMMAND "${OPENSSL_EXECUTABLE}" |
| 1842 | req -new -newkey rsa:1024 -days 10000 -nodes -x509 -keyout "${TEST_SERVER_SSL_KEY}" -out "${TEST_SERVER_SSL_CERT}" |
| 1843 | RESULT_VARIABLE OPENSSL_RETURN_CODE |
Andy Green | 54236bd | 2017-05-11 15:02:01 +0800 | [diff] [blame] | 1844 | # OUTPUT_QUIET ERROR_QUIET |
| 1845 | ) |
Andy Green | 3a09c3b | 2017-03-08 11:11:41 +0800 | [diff] [blame] | 1846 | |
| 1847 | if (OPENSSL_RETURN_CODE) |
| 1848 | message(WARNING "!!! Failed to generate SSL certificate for Test Server!!!:\nOpenSSL return code = ${OPENSSL_RETURN_CODE}") |
| 1849 | else() |
| 1850 | message("SUCCESSFULLY generated SSL certificate") |
| 1851 | endif() |
| 1852 | endif() |
| 1853 | |
| 1854 | list(APPEND TEST_SERVER_DATA |
| 1855 | "${TEST_SERVER_SSL_KEY}" |
| 1856 | "${TEST_SERVER_SSL_CERT}") |
| 1857 | endif() |
| 1858 | |
| 1859 | |
Alexander Bruines | ddd9bfa | 2016-04-13 22:17:05 +0200 | [diff] [blame] | 1860 | |
| 1861 | |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1862 | # |
| 1863 | # Test applications |
| 1864 | # |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 1865 | set(TEST_APP_LIST) |
Andy Green | ac6c48d | 2018-04-27 19:16:50 +0800 | [diff] [blame] | 1866 | if ((LWS_ROLE_H1 OR LWS_ROLE_H2) AND NOT LWS_WITHOUT_TESTAPPS) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1867 | # |
| 1868 | # Helper function for adding a test app. |
| 1869 | # |
Andy Green | 0ad1a6e | 2016-02-20 14:05:55 +0800 | [diff] [blame] | 1870 | macro(create_test_app TEST_NAME MAIN_SRC S2 S3 S4 S5 S6) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1871 | |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1872 | set(TEST_SRCS ${MAIN_SRC}) |
| 1873 | set(TEST_HDR) |
Andy Green | eb15ea0 | 2015-11-19 13:55:47 +0800 | [diff] [blame] | 1874 | if ("${S2}" STREQUAL "") |
| 1875 | else() |
| 1876 | list(APPEND TEST_SRCS ${S2}) |
| 1877 | endif() |
| 1878 | if ("${S3}" STREQUAL "") |
| 1879 | else() |
| 1880 | list(APPEND TEST_SRCS ${S3}) |
| 1881 | endif() |
| 1882 | if ("${S4}" STREQUAL "") |
| 1883 | else() |
| 1884 | list(APPEND TEST_SRCS ${S4}) |
| 1885 | endif() |
Andy Green | 6711266 | 2016-01-11 11:34:01 +0800 | [diff] [blame] | 1886 | if ("${S5}" STREQUAL "") |
| 1887 | else() |
| 1888 | list(APPEND TEST_SRCS ${S5}) |
| 1889 | endif() |
Andy Green | 0ad1a6e | 2016-02-20 14:05:55 +0800 | [diff] [blame] | 1890 | if ("${S6}" STREQUAL "") |
| 1891 | else() |
| 1892 | list(APPEND TEST_SRCS ${S6}) |
| 1893 | endif() |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1894 | if (WIN32) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1895 | list(APPEND TEST_SRCS |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1896 | ${WIN32_HELPERS_PATH}/getopt.c |
| 1897 | ${WIN32_HELPERS_PATH}/getopt_long.c |
| 1898 | ${WIN32_HELPERS_PATH}/gettimeofday.c |
Patrick Gansterer | 73882e4 | 2014-03-29 08:25:58 +0100 | [diff] [blame] | 1899 | ) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1900 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1901 | list(APPEND TEST_HDR |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1902 | ${WIN32_HELPERS_PATH}/getopt.h |
| 1903 | ${WIN32_HELPERS_PATH}/gettimeofday.h |
Patrick Gansterer | 73882e4 | 2014-03-29 08:25:58 +0100 | [diff] [blame] | 1904 | ) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1905 | endif(WIN32) |
| 1906 | |
Joakim Soderberg | 0848353 | 2013-02-13 09:29:17 +0800 | [diff] [blame] | 1907 | source_group("Headers Private" FILES ${TEST_HDR}) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1908 | source_group("Sources" FILES ${TEST_SRCS}) |
| 1909 | add_executable(${TEST_NAME} ${TEST_SRCS} ${TEST_HDR}) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1910 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 1911 | if (LWS_LINK_TESTAPPS_DYNAMIC) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1912 | if (NOT LWS_WITH_SHARED) |
Peter Pentchev | e46f412 | 2015-10-01 12:25:05 +0300 | [diff] [blame] | 1913 | message(FATAL_ERROR "Build of the shared library is disabled. LWS_LINK_TESTAPPS_DYNAMIC must be combined with LWS_WITH_SHARED.") |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1914 | endif() |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 1915 | target_link_libraries(${TEST_NAME} websockets_shared) |
| 1916 | add_dependencies(${TEST_NAME} websockets_shared) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1917 | else() |
| 1918 | if (NOT LWS_WITH_STATIC) |
Peter Pentchev | e46f412 | 2015-10-01 12:25:05 +0300 | [diff] [blame] | 1919 | message(FATAL_ERROR "Build of the static library is disabled. Disabled LWS_LINK_TESTAPPS_DYNAMIC must be combined with LWS_WITH_STATIC.") |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1920 | endif() |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 1921 | target_link_libraries(${TEST_NAME} websockets) |
| 1922 | add_dependencies(${TEST_NAME} websockets) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1923 | endif() |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 1924 | |
Andy Green | d588286 | 2018-09-02 14:43:05 +0800 | [diff] [blame] | 1925 | if (LWS_WITH_HTTP_STREAM_COMPRESSION) |
| 1926 | target_link_libraries(${TEST_NAME} z) |
| 1927 | endif() |
| 1928 | |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 1929 | # Set test app specific defines. |
| 1930 | set_property(TARGET ${TEST_NAME} |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1931 | PROPERTY COMPILE_DEFINITIONS |
Andy Green | 63b3b95 | 2013-03-09 12:51:43 +0800 | [diff] [blame] | 1932 | INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/share" |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 1933 | ) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 1934 | |
| 1935 | # Prefix the binary names with libwebsockets. |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1936 | set_target_properties(${TEST_NAME} |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 1937 | PROPERTIES |
| 1938 | OUTPUT_NAME libwebsockets-${TEST_NAME}) |
| 1939 | |
| 1940 | # Add to the list of tests. |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 1941 | list(APPEND TEST_APP_LIST ${TEST_NAME}) |
Joakim Soderberg | 11a8cda | 2013-02-22 09:28:06 +0800 | [diff] [blame] | 1942 | endmacro() |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1943 | |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 1944 | if (UNIX AND LWS_WITH_PLUGINS) |
| 1945 | set(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}") |
Anzey | 08d36db | 2018-01-04 10:37:25 +0800 | [diff] [blame] | 1946 | if(NOT((${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") OR (${CMAKE_SYSTEM_NAME} MATCHES "QNX"))) |
Bablooos | fded366 | 2016-11-29 20:45:37 +0800 | [diff] [blame] | 1947 | target_link_libraries(websockets dl) |
| 1948 | endif() |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 1949 | endif() |
Andy Green | 1a3f177 | 2016-03-28 19:58:02 +0800 | [diff] [blame] | 1950 | |
Andy Green | f497562 | 2018-04-30 19:17:32 +0800 | [diff] [blame] | 1951 | if (LWS_WITH_LIBEV) |
| 1952 | # libev generates a big mess of warnings with gcc, maintainer claims gcc to blame |
| 1953 | set_source_files_properties( lib/event-libs/libev/libev.c PROPERTIES COMPILE_FLAGS "-Wno-error" ) |
| 1954 | endif() |
Andy Green | 3a09c3b | 2017-03-08 11:11:41 +0800 | [diff] [blame] | 1955 | |
| 1956 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 1957 | if (NOT LWS_WITHOUT_SERVER) |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 1958 | # |
| 1959 | # test-server |
| 1960 | # |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 1961 | if (NOT LWS_WITHOUT_TEST_SERVER) |
Andy Green | 4f267c5 | 2017-09-22 09:46:58 +0800 | [diff] [blame] | 1962 | create_test_app(test-server "test-apps/test-server.c" |
Andy Green | d05b408 | 2018-04-28 14:11:39 +0800 | [diff] [blame] | 1963 | "" |
| 1964 | "" |
Andy Green | 5939d3a | 2017-06-28 11:16:48 +0800 | [diff] [blame] | 1965 | "" |
| 1966 | "" |
| 1967 | "") |
Andy Green | 7597ac3 | 2017-10-16 16:59:57 +0800 | [diff] [blame] | 1968 | |
| 1969 | if (LWS_WITH_CGI) |
| 1970 | create_test_app(test-sshd "test-apps/test-sshd.c" |
| 1971 | "" |
| 1972 | "" |
| 1973 | "" |
| 1974 | "" |
| 1975 | "") |
| 1976 | target_include_directories(test-sshd PRIVATE "${PROJECT_SOURCE_DIR}/plugins/ssh-base/include") |
| 1977 | |
| 1978 | endif() |
| 1979 | |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 1980 | endif() |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 1981 | |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 1982 | # |
| 1983 | # test-server-extpoll |
| 1984 | # |
Andy Green | f497562 | 2018-04-30 19:17:32 +0800 | [diff] [blame] | 1985 | if (NOT LWS_WITHOUT_TEST_SERVER_EXTPOLL AND NOT WIN32) |
Andy Green | d05b408 | 2018-04-28 14:11:39 +0800 | [diff] [blame] | 1986 | create_test_app(test-server-extpoll |
| 1987 | "test-apps/test-server.c" |
| 1988 | "" |
| 1989 | "" |
Andy Green | 5939d3a | 2017-06-28 11:16:48 +0800 | [diff] [blame] | 1990 | "" |
| 1991 | "" |
| 1992 | "") |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 1993 | # Set defines for this executable only. |
| 1994 | set_property( |
| 1995 | TARGET test-server-extpoll |
| 1996 | PROPERTY COMPILE_DEFINITIONS |
| 1997 | EXTERNAL_POLL |
Andy Green | 63b3b95 | 2013-03-09 12:51:43 +0800 | [diff] [blame] | 1998 | INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/share" |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 1999 | ) |
Joakim Soderberg | f272cb0 | 2013-02-13 09:29:26 +0800 | [diff] [blame] | 2000 | |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 2001 | # We need to link against winsock code. |
| 2002 | if (WIN32) |
| 2003 | target_link_libraries(test-server-extpoll ws2_32.lib) |
Edwin van den Oetelaar | 15a38a7 | 2013-03-10 06:53:57 +0800 | [diff] [blame] | 2004 | endif(WIN32) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 2005 | endif() |
| 2006 | |
Andy Green | 5a90bb3 | 2017-10-25 15:52:28 +0800 | [diff] [blame] | 2007 | if (LWS_WITH_LEJP) |
| 2008 | create_test_app( |
| 2009 | test-lejp |
| 2010 | "test-apps/test-lejp.c" |
| 2011 | "" |
| 2012 | "" |
| 2013 | "" |
| 2014 | "" |
| 2015 | "") |
| 2016 | endif() |
| 2017 | |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 2018 | # Data files for running the test server. |
Andy Green | 350af23 | 2017-12-20 10:42:39 +0800 | [diff] [blame] | 2019 | list(APPEND TEST_SERVER_DATA |
Andy Green | 4f267c5 | 2017-09-22 09:46:58 +0800 | [diff] [blame] | 2020 | "${PROJECT_SOURCE_DIR}/test-apps/favicon.ico" |
| 2021 | "${PROJECT_SOURCE_DIR}/test-apps/leaf.jpg" |
| 2022 | "${PROJECT_SOURCE_DIR}/test-apps/candide.zip" |
Andy Green | edeb8a5 | 2018-11-23 10:52:39 +0800 | [diff] [blame] | 2023 | "${PROJECT_SOURCE_DIR}/test-apps/libwebsockets.org-logo.svg" |
Andy Green | 904a9c0 | 2017-10-13 10:33:02 +0800 | [diff] [blame] | 2024 | "${PROJECT_SOURCE_DIR}/test-apps/http2.png" |
Andy Green | a416178 | 2018-03-22 07:44:02 +0800 | [diff] [blame] | 2025 | "${PROJECT_SOURCE_DIR}/test-apps/wss-over-h2.png" |
Andy Green | 4f267c5 | 2017-09-22 09:46:58 +0800 | [diff] [blame] | 2026 | "${PROJECT_SOURCE_DIR}/test-apps/lws-common.js" |
Andy Green | 97f3e66 | 2018-08-25 07:22:36 +0800 | [diff] [blame] | 2027 | "${PROJECT_SOURCE_DIR}/test-apps/test.html" |
| 2028 | "${PROJECT_SOURCE_DIR}/test-apps/test.css" |
| 2029 | "${PROJECT_SOURCE_DIR}/test-apps/test.js") |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 2030 | |
Joakim Soderberg | 6596e4b | 2014-02-18 13:38:14 +0100 | [diff] [blame] | 2031 | add_custom_command(TARGET test-server |
| 2032 | POST_BUILD |
Joakim Soderberg | 1632c9a | 2014-11-26 01:22:50 +0800 | [diff] [blame] | 2033 | COMMAND "${CMAKE_COMMAND}" -E make_directory "$<TARGET_FILE_DIR:test-server>/../share/libwebsockets-test-server") |
Joakim Soderberg | 6596e4b | 2014-02-18 13:38:14 +0100 | [diff] [blame] | 2034 | |
Joakim Soderberg | c7ed2be | 2013-02-22 09:28:17 +0800 | [diff] [blame] | 2035 | # Copy the file needed to run the server so that the test apps can |
| 2036 | # reach them from their default output location |
| 2037 | foreach (TEST_FILE ${TEST_SERVER_DATA}) |
Joakim Soderberg | 6596e4b | 2014-02-18 13:38:14 +0100 | [diff] [blame] | 2038 | if (EXISTS ${TEST_FILE}) |
| 2039 | add_custom_command(TARGET test-server |
| 2040 | POST_BUILD |
Joakim Soderberg | 1632c9a | 2014-11-26 01:22:50 +0800 | [diff] [blame] | 2041 | COMMAND "${CMAKE_COMMAND}" -E copy "${TEST_FILE}" "$<TARGET_FILE_DIR:test-server>/../share/libwebsockets-test-server" VERBATIM) |
Joakim Soderberg | 6596e4b | 2014-02-18 13:38:14 +0100 | [diff] [blame] | 2042 | endif() |
Joakim Soderberg | c7ed2be | 2013-02-22 09:28:17 +0800 | [diff] [blame] | 2043 | endforeach() |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2044 | endif(NOT LWS_WITHOUT_SERVER) |
Joakim Söderberg | 68e8d73 | 2013-02-06 15:27:39 +0900 | [diff] [blame] | 2045 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2046 | if (NOT LWS_WITHOUT_CLIENT) |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 2047 | # |
| 2048 | # test-client |
| 2049 | # |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2050 | if (NOT LWS_WITHOUT_TEST_CLIENT) |
Andy Green | 4f267c5 | 2017-09-22 09:46:58 +0800 | [diff] [blame] | 2051 | create_test_app(test-client "test-apps/test-client.c" "" "" "" "" "") |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 2052 | endif() |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 2053 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2054 | endif(NOT LWS_WITHOUT_CLIENT) |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 2055 | |
| 2056 | |
| 2057 | if (LWS_WITH_PLUGINS AND LWS_WITH_SHARED) |
Andy Green | 7597ac3 | 2017-10-16 16:59:57 +0800 | [diff] [blame] | 2058 | macro(create_plugin PLUGIN_NAME PLUGIN_INCLUDE MAIN_SRC S2 S3) |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 2059 | |
| 2060 | set(PLUGIN_SRCS ${MAIN_SRC}) |
| 2061 | |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 2062 | if ("${S2}" STREQUAL "") |
| 2063 | else() |
| 2064 | list(APPEND PLUGIN_SRCS ${S2}) |
| 2065 | endif() |
| 2066 | if ("${S3}" STREQUAL "") |
| 2067 | else() |
| 2068 | list(APPEND PLUGIN_SRCS ${S3}) |
| 2069 | endif() |
| 2070 | |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 2071 | if (WIN32) |
Andy Green | d6be677 | 2016-05-14 06:49:29 +0800 | [diff] [blame] | 2072 | list(APPEND PLUGIN_SRCS |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 2073 | ${WIN32_HELPERS_PATH}/getopt.c |
| 2074 | ${WIN32_HELPERS_PATH}/getopt_long.c |
| 2075 | ${WIN32_HELPERS_PATH}/gettimeofday.c |
| 2076 | ) |
| 2077 | |
| 2078 | list(APPEND PLUGIN_HDR |
| 2079 | ${WIN32_HELPERS_PATH}/getopt.h |
| 2080 | ${WIN32_HELPERS_PATH}/gettimeofday.h |
| 2081 | ) |
| 2082 | endif(WIN32) |
| 2083 | |
| 2084 | source_group("Headers Private" FILES ${PLUGIN_HDR}) |
| 2085 | source_group("Sources" FILES ${PLUGIN_SRCS}) |
| 2086 | add_library(${PLUGIN_NAME} SHARED ${PLUGIN_SRCS} ${PLUGIN_HDR}) |
| 2087 | |
Denis Osvald | 8d21c35 | 2016-04-06 18:07:37 +0200 | [diff] [blame] | 2088 | target_link_libraries(${PLUGIN_NAME} websockets_shared) |
| 2089 | add_dependencies(${PLUGIN_NAME} websockets_shared) |
Andy Green | 7597ac3 | 2017-10-16 16:59:57 +0800 | [diff] [blame] | 2090 | include_directories(${PLUGIN_INCLUDE}) |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 2091 | |
| 2092 | # Set test app specific defines. |
| 2093 | set_property(TARGET ${PLUGIN_NAME} |
| 2094 | PROPERTY COMPILE_DEFINITIONS |
| 2095 | INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/plugins" |
| 2096 | ) |
| 2097 | |
Andy Green | a03dd40 | 2018-08-14 08:00:25 +0800 | [diff] [blame] | 2098 | SET_TARGET_PROPERTIES(${PLUGIN_NAME} |
| 2099 | PROPERTIES COMPILE_FLAGS ${CMAKE_C_FLAGS}) |
| 2100 | |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 2101 | # set_target_properties(${PLUGIN_NAME} |
| 2102 | # PROPERTIES |
| 2103 | # OUTPUT_NAME ${PLUGIN_NAME}) |
| 2104 | |
| 2105 | list(APPEND PLUGINS_LIST ${PLUGIN_NAME}) |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 2106 | |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 2107 | endmacro() |
| 2108 | |
Andy Green | 27e86e2 | 2018-04-25 08:42:18 +0800 | [diff] [blame] | 2109 | if (LWS_ROLE_WS) |
Andy Green | 7597ac3 | 2017-10-16 16:59:57 +0800 | [diff] [blame] | 2110 | create_plugin(protocol_dumb_increment "" |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 2111 | "plugins/protocol_dumb_increment.c" "" "") |
Andy Green | 7597ac3 | 2017-10-16 16:59:57 +0800 | [diff] [blame] | 2112 | create_plugin(protocol_lws_mirror "" |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 2113 | "plugins/protocol_lws_mirror.c" "" "") |
Andy Green | 7597ac3 | 2017-10-16 16:59:57 +0800 | [diff] [blame] | 2114 | create_plugin(protocol_lws_status "" |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 2115 | "plugins/protocol_lws_status.c" "" "") |
Andy Green | 7597ac3 | 2017-10-16 16:59:57 +0800 | [diff] [blame] | 2116 | create_plugin(protocol_lws_table_dirlisting "" |
Andy Green | 722cc4a | 2016-06-26 06:29:20 +0800 | [diff] [blame] | 2117 | "plugins/generic-table/protocol_table_dirlisting.c" "" "") |
Andy Green | be8d791 | 2017-02-27 12:55:56 +0800 | [diff] [blame] | 2118 | if (NOT WIN32) |
Andy Green | 7597ac3 | 2017-10-16 16:59:57 +0800 | [diff] [blame] | 2119 | create_plugin(protocol_lws_raw_test "" |
Andy Green | be8d791 | 2017-02-27 12:55:56 +0800 | [diff] [blame] | 2120 | "plugins/protocol_lws_raw_test.c" "" "") |
Andy Green | 4e2eef3 | 2018-11-28 07:25:16 +0800 | [diff] [blame] | 2121 | |
| 2122 | create_plugin(protocol_deaddrop "" |
| 2123 | "plugins/deaddrop/protocol_lws_deaddrop.c" "" "") |
| 2124 | |
Andy Green | be8d791 | 2017-02-27 12:55:56 +0800 | [diff] [blame] | 2125 | endif() |
Andy Green | 722cc4a | 2016-06-26 06:29:20 +0800 | [diff] [blame] | 2126 | |
Andy Green | 9806140 | 2016-04-15 14:01:29 +0800 | [diff] [blame] | 2127 | if (LWS_WITH_SERVER_STATUS) |
Andy Green | 7597ac3 | 2017-10-16 16:59:57 +0800 | [diff] [blame] | 2128 | create_plugin(protocol_lws_server_status "" |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 2129 | "plugins/protocol_lws_server_status.c" "" "") |
Andy Green | 9806140 | 2016-04-15 14:01:29 +0800 | [diff] [blame] | 2130 | endif() |
Andy Green | 2700d1c | 2016-05-12 19:45:04 +0800 | [diff] [blame] | 2131 | |
| 2132 | if (NOT LWS_WITHOUT_CLIENT) |
Andy Green | 7597ac3 | 2017-10-16 16:59:57 +0800 | [diff] [blame] | 2133 | create_plugin(protocol_client_loopback_test "" |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 2134 | "plugins/protocol_client_loopback_test.c" "" "") |
Andy Green | 27e86e2 | 2018-04-25 08:42:18 +0800 | [diff] [blame] | 2135 | endif() |
| 2136 | |
| 2137 | endif() |
| 2138 | |
| 2139 | create_plugin(protocol_post_demo "" |
| 2140 | "plugins/protocol_post_demo.c" "" "") |
| 2141 | |
Andy Green | 08b5ad9 | 2018-11-29 08:29:48 +0800 | [diff] [blame] | 2142 | if (LWS_ROLE_RAW_PROXY) |
| 2143 | create_plugin(protocol_lws_raw_proxy "" |
| 2144 | "plugins/raw-proxy/protocol_lws_raw_proxy.c" "" "") |
| 2145 | endif() |
| 2146 | |
Andy Green | d3bc2c3 | 2018-10-14 11:38:08 +0800 | [diff] [blame] | 2147 | if (LWS_WITH_FTS) |
| 2148 | create_plugin(protocol_fulltext_demo "" |
| 2149 | "plugins/protocol_fulltext_demo.c" "" "") |
| 2150 | endif() |
| 2151 | |
| 2152 | |
Andy Green | 27e86e2 | 2018-04-25 08:42:18 +0800 | [diff] [blame] | 2153 | if (LWS_WITH_SSL) |
| 2154 | create_plugin(protocol_lws_ssh_base "plugins/ssh-base/include" |
| 2155 | "plugins/ssh-base/sshd.c;plugins/ssh-base/telnet.c;plugins/ssh-base/kex-25519.c" "plugins/ssh-base/crypto/chacha.c;plugins/ssh-base/crypto/ed25519.c;plugins/ssh-base/crypto/fe25519.c;plugins/ssh-base/crypto/ge25519.c;plugins/ssh-base/crypto/poly1305.c;plugins/ssh-base/crypto/sc25519.c;plugins/ssh-base/crypto/smult_curve25519_ref.c" "") |
| 2156 | create_plugin(protocol_lws_sshd_demo "plugins/ssh-base/include" "plugins/protocol_lws_sshd_demo.c" "" "") |
| 2157 | |
| 2158 | include_directories("${PROJECT_SOURCE_DIR}/plugins/ssh-base/include") |
| 2159 | endif() |
| 2160 | |
| 2161 | |
Andy Green | 2700d1c | 2016-05-12 19:45:04 +0800 | [diff] [blame] | 2162 | |
Andy Green | 3ec7c1a | 2017-10-21 06:36:35 +0800 | [diff] [blame] | 2163 | if (LWS_WITH_ACME) |
| 2164 | create_plugin(protocol_lws_acme_client "" |
| 2165 | "plugins/acme-client/protocol_lws_acme_client.c" "" "") |
| 2166 | endif() |
| 2167 | |
Andy Green | 27e86e2 | 2018-04-25 08:42:18 +0800 | [diff] [blame] | 2168 | if (LWS_WITH_GENERIC_SESSIONS AND LWS_ROLE_WS) |
Andy Green | 7597ac3 | 2017-10-16 16:59:57 +0800 | [diff] [blame] | 2169 | create_plugin(protocol_generic_sessions "" |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 2170 | "plugins/generic-sessions/protocol_generic_sessions.c" |
| 2171 | "plugins/generic-sessions/utils.c" |
| 2172 | "plugins/generic-sessions/handlers.c") |
| 2173 | |
| 2174 | if (WIN32) |
| 2175 | target_link_libraries(protocol_generic_sessions ${LWS_SQLITE3_LIBRARIES}) |
| 2176 | else() |
| 2177 | target_link_libraries(protocol_generic_sessions sqlite3 ) |
| 2178 | endif(WIN32) |
Andy Green | 4e75ae3 | 2016-06-15 12:24:38 +0800 | [diff] [blame] | 2179 | |
Andy Green | 7597ac3 | 2017-10-16 16:59:57 +0800 | [diff] [blame] | 2180 | create_plugin(protocol_lws_messageboard "" |
Andy Green | 4e75ae3 | 2016-06-15 12:24:38 +0800 | [diff] [blame] | 2181 | "plugins/generic-sessions/protocol_lws_messageboard.c" "" "") |
| 2182 | if (WIN32) |
| 2183 | target_link_libraries(protocol_lws_messageboard ${LWS_SQLITE3_LIBRARIES}) |
| 2184 | else() |
| 2185 | target_link_libraries(protocol_lws_messageboard sqlite3 ) |
| 2186 | endif(WIN32) |
| 2187 | |
Andy Green | ae68860 | 2018-04-27 11:19:09 +0800 | [diff] [blame] | 2188 | endif(LWS_WITH_GENERIC_SESSIONS AND LWS_ROLE_WS) |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 2189 | |
| 2190 | |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 2191 | endif(LWS_WITH_PLUGINS AND LWS_WITH_SHARED) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 2192 | |
| 2193 | # |
| 2194 | # Copy OpenSSL dlls to the output directory on Windows. |
| 2195 | # (Otherwise we'll get an error when trying to run) |
| 2196 | # |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 2197 | if (WIN32 AND LWS_WITH_SSL AND NOT LWS_WITH_WOLFSSL) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 2198 | if(OPENSSL_BIN_FOUND) |
Joakim Soderberg | 20aedc8 | 2013-02-22 09:28:11 +0800 | [diff] [blame] | 2199 | message("OpenSSL dlls found:") |
| 2200 | message(" Libeay: ${LIBEAY_BIN}") |
| 2201 | message(" SSLeay: ${SSLEAY_BIN}") |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 2202 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 2203 | foreach(TARGET_BIN ${TEST_APP_LIST}) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 2204 | add_custom_command(TARGET ${TARGET_BIN} |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 2205 | POST_BUILD |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 2206 | COMMAND "${CMAKE_COMMAND}" -E copy "${LIBEAY_BIN}" "$<TARGET_FILE_DIR:${TARGET_BIN}>" VERBATIM) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 2207 | add_custom_command(TARGET ${TARGET_BIN} |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 2208 | POST_BUILD |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 2209 | COMMAND "${CMAKE_COMMAND}" -E copy "${SSLEAY_BIN}" "$<TARGET_FILE_DIR:${TARGET_BIN}>" VERBATIM) |
Andy Green | 41d1326 | 2017-10-26 07:24:45 +0800 | [diff] [blame] | 2210 | |
| 2211 | # |
| 2212 | # Win32: if we are using libuv, also need to copy it in the output dir |
| 2213 | # |
| 2214 | if (WIN32 AND LWS_WITH_LIBUV) |
| 2215 | STRING(REPLACE ".lib" ".dll" LIBUV_BIN ${LIBUV_LIBRARIES}) |
| 2216 | add_custom_command(TARGET ${TARGET_BIN} |
| 2217 | POST_BUILD |
| 2218 | COMMAND "${CMAKE_COMMAND}" -E copy "${LIBUV_BIN}" "$<TARGET_FILE_DIR:${TARGET_BIN}>" VERBATIM) |
| 2219 | endif() |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 2220 | endforeach() |
| 2221 | endif() |
| 2222 | endif() |
Andy Green | f497562 | 2018-04-30 19:17:32 +0800 | [diff] [blame] | 2223 | endif((LWS_ROLE_H1 OR LWS_ROLE_H2) AND NOT LWS_WITHOUT_TESTAPPS) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 2224 | |
Andy Green | cd0c696 | 2016-03-28 10:12:37 +0800 | [diff] [blame] | 2225 | if (LWS_WITH_LWSWS) |
| 2226 | list(APPEND LWSWS_SRCS |
| 2227 | "lwsws/main.c" |
Andy Green | cd0c696 | 2016-03-28 10:12:37 +0800 | [diff] [blame] | 2228 | ) |
| 2229 | |
| 2230 | if (WIN32) |
| 2231 | list(APPEND LWSWS_SRCS |
| 2232 | ${WIN32_HELPERS_PATH}/getopt.c |
| 2233 | ${WIN32_HELPERS_PATH}/getopt_long.c |
| 2234 | ${WIN32_HELPERS_PATH}/gettimeofday.c |
| 2235 | ) |
| 2236 | |
| 2237 | list(APPEND LWSWS_HDR |
| 2238 | ${WIN32_HELPERS_PATH}/getopt.h |
| 2239 | ${WIN32_HELPERS_PATH}/gettimeofday.h |
| 2240 | ) |
| 2241 | endif(WIN32) |
| 2242 | |
| 2243 | source_group("Headers Private" FILES ${LWSWS_HDR}) |
| 2244 | source_group("Sources" FILES ${LWSWS_SRCS}) |
| 2245 | add_executable("lwsws" ${LWSWS_SRCS} ${LWSWS_HDR}) |
| 2246 | |
Andy Green | fd12fc2 | 2016-04-07 03:10:54 +0800 | [diff] [blame] | 2247 | target_link_libraries("lwsws" websockets_shared) |
| 2248 | add_dependencies("lwsws" websockets_shared) |
Andy Green | cd0c696 | 2016-03-28 10:12:37 +0800 | [diff] [blame] | 2249 | |
| 2250 | # Set test app specific defines. |
| 2251 | set_property(TARGET "lwsws" |
| 2252 | PROPERTY COMPILE_DEFINITIONS |
| 2253 | INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/share" |
| 2254 | ) |
Andy Green | cd0c696 | 2016-03-28 10:12:37 +0800 | [diff] [blame] | 2255 | endif (LWS_WITH_LWSWS) |
| 2256 | |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 2257 | if (UNIX) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 2258 | |
| 2259 | # Generate and install pkgconfig. |
| 2260 | # (This is not indented, because the tabs will be part of the output) |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 2261 | file(WRITE "${PROJECT_BINARY_DIR}/libwebsockets.pc" |
Andy Green | 0f3e413 | 2014-02-27 07:28:45 +0800 | [diff] [blame] | 2262 | "prefix=\"${CMAKE_INSTALL_PREFIX}\" |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 2263 | exec_prefix=\${prefix} |
Andy Green | 975423c | 2013-02-26 11:58:45 +0800 | [diff] [blame] | 2264 | libdir=\${exec_prefix}/lib${LIB_SUFFIX} |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 2265 | includedir=\${prefix}/include |
| 2266 | |
| 2267 | Name: libwebsockets |
| 2268 | Description: Websockets server and client library |
Roger A. Light | e59908e | 2015-12-14 17:25:29 +0000 | [diff] [blame] | 2269 | Version: ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH} |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 2270 | |
| 2271 | Libs: -L\${libdir} -lwebsockets |
| 2272 | Cflags: -I\${includedir}" |
| 2273 | ) |
| 2274 | |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 2275 | install(FILES "${PROJECT_BINARY_DIR}/libwebsockets.pc" |
Andy Green | c8c1662 | 2013-03-10 08:10:19 +0800 | [diff] [blame] | 2276 | DESTINATION lib${LIB_SUFFIX}/pkgconfig) |
Andy Green | 1725332 | 2017-06-19 12:29:48 +0800 | [diff] [blame] | 2277 | |
| 2278 | file(WRITE "${PROJECT_BINARY_DIR}/libwebsockets_static.pc" |
| 2279 | "prefix=\"${CMAKE_INSTALL_PREFIX}\" |
| 2280 | exec_prefix=\${prefix} |
| 2281 | libdir=\${exec_prefix}/lib${LIB_SUFFIX} |
| 2282 | includedir=\${prefix}/include |
| 2283 | |
| 2284 | Name: libwebsockets_static |
| 2285 | Description: Websockets server and client static library |
| 2286 | Version: ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH} |
| 2287 | |
| 2288 | Libs: -L\${libdir} -lwebsockets_static |
| 2289 | Libs.private: |
| 2290 | Cflags: -I\${includedir}" |
| 2291 | ) |
| 2292 | |
| 2293 | install(FILES "${PROJECT_BINARY_DIR}/libwebsockets_static.pc" |
| 2294 | DESTINATION lib${LIB_SUFFIX}/pkgconfig) |
| 2295 | |
| 2296 | |
Edwin van den Oetelaar | 15a38a7 | 2013-03-10 06:53:57 +0800 | [diff] [blame] | 2297 | endif(UNIX) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 2298 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2299 | # |
| 2300 | # Installation preparations. |
| 2301 | # |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 2302 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2303 | if(WIN32 AND NOT CYGWIN) |
| 2304 | set(DEF_INSTALL_CMAKE_DIR cmake) |
| 2305 | else() |
Andrew Cooks | cdcf5fc | 2016-01-17 13:54:13 +0800 | [diff] [blame] | 2306 | set(DEF_INSTALL_CMAKE_DIR lib${LIB_SUFFIX}/cmake/libwebsockets) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2307 | endif() |
| 2308 | |
| 2309 | set(LWS_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files") |
| 2310 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2311 | # Export targets (This is used for other CMake projects to easily find the libraries and include files). |
Alexey Reznichenko | 9384613 | 2017-11-20 12:41:29 +0100 | [diff] [blame] | 2312 | if (LWS_WITH_EXPORT_LWSTARGETS) |
| 2313 | export(TARGETS ${LWS_LIBRARIES} |
| 2314 | FILE "${PROJECT_BINARY_DIR}/LibwebsocketsTargets.cmake") |
| 2315 | endif() |
| 2316 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2317 | export(PACKAGE libwebsockets) |
| 2318 | |
| 2319 | # Generate the config file for the build-tree. |
| 2320 | set(LWS__INCLUDE_DIRS |
| 2321 | "${PROJECT_SOURCE_DIR}/lib" |
| 2322 | "${PROJECT_BINARY_DIR}") |
| 2323 | set(LIBWEBSOCKETS_INCLUDE_DIRS ${LWS__INCLUDE_DIRS} CACHE PATH "Libwebsockets include directories") |
| 2324 | configure_file(${PROJECT_SOURCE_DIR}/cmake/LibwebsocketsConfig.cmake.in |
| 2325 | ${PROJECT_BINARY_DIR}/LibwebsocketsConfig.cmake |
| 2326 | @ONLY) |
| 2327 | |
| 2328 | # Generate the config file for the installation tree. |
Patrick Gansterer | e04ec35 | 2014-02-28 16:29:28 +0100 | [diff] [blame] | 2329 | get_filename_component(LWS_ABSOLUTE_INSTALL_CMAKE_DIR ${LWS_INSTALL_CMAKE_DIR} ABSOLUTE) |
| 2330 | get_filename_component(LWS_ABSOLUTE_INSTALL_INCLUDE_DIR ${LWS_INSTALL_INCLUDE_DIR} ABSOLUTE) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2331 | file(RELATIVE_PATH |
| 2332 | REL_INCLUDE_DIR |
Patrick Gansterer | e04ec35 | 2014-02-28 16:29:28 +0100 | [diff] [blame] | 2333 | "${LWS_ABSOLUTE_INSTALL_CMAKE_DIR}" |
| 2334 | "${LWS_ABSOLUTE_INSTALL_INCLUDE_DIR}") # Calculate the relative directory from the cmake dir. |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2335 | |
| 2336 | # Note the EVENT_CMAKE_DIR is defined in JanssonConfig.cmake.in, |
| 2337 | # we escape it here so it's evaluated when it is included instead |
| 2338 | # so that the include dirs are given relative to where the |
| 2339 | # config file is located. |
| 2340 | set(LWS__INCLUDE_DIRS |
| 2341 | "\${LWS_CMAKE_DIR}/${REL_INCLUDE_DIR}") |
| 2342 | configure_file(${PROJECT_SOURCE_DIR}/cmake/LibwebsocketsConfig.cmake.in |
| 2343 | ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/LibwebsocketsConfig.cmake |
| 2344 | @ONLY) |
| 2345 | |
| 2346 | # Generate version info for both build-tree and install-tree. |
| 2347 | configure_file(${PROJECT_SOURCE_DIR}/cmake/LibwebsocketsConfigVersion.cmake.in |
| 2348 | ${PROJECT_BINARY_DIR}/LibwebsocketsConfigVersion.cmake |
| 2349 | @ONLY) |
| 2350 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 2351 | set_target_properties(${LWS_LIBRARIES} |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2352 | PROPERTIES PUBLIC_HEADER "${HDR_PUBLIC}") |
| 2353 | |
| 2354 | # |
| 2355 | # Installation. |
| 2356 | # |
| 2357 | |
Andy Green | d1f9f0a | 2018-08-23 09:46:01 +0800 | [diff] [blame] | 2358 | install(DIRECTORY include/libwebsockets |
| 2359 | DESTINATION "${LWS_INSTALL_INCLUDE_DIR}" COMPONENT dev_headers) |
| 2360 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2361 | # Install libs and headers. |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 2362 | install(TARGETS ${LWS_LIBRARIES} |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2363 | EXPORT LibwebsocketsTargets |
| 2364 | LIBRARY DESTINATION "${LWS_INSTALL_LIB_DIR}${LIB_SUFFIX}" COMPONENT libraries |
| 2365 | ARCHIVE DESTINATION "${LWS_INSTALL_LIB_DIR}${LIB_SUFFIX}" COMPONENT libraries |
| 2366 | RUNTIME DESTINATION "${LWS_INSTALL_BIN_DIR}" COMPONENT libraries # Windows DLLs |
| 2367 | PUBLIC_HEADER DESTINATION "${LWS_INSTALL_INCLUDE_DIR}" COMPONENT dev) |
Andy Green | d1f9f0a | 2018-08-23 09:46:01 +0800 | [diff] [blame] | 2368 | |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 2369 | set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2370 | set(CPACK_COMPONENT_DEV_DISPLAY_NAME "Development files") |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 2371 | |
| 2372 | # Install test apps. |
Andy Green | 12a9592 | 2017-06-28 09:50:54 +0800 | [diff] [blame] | 2373 | if (NOT LWS_WITHOUT_TESTAPPS) |
| 2374 | install(TARGETS ${TEST_APP_LIST} |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2375 | RUNTIME DESTINATION ${LWS_INSTALL_EXAMPLES_DIR} |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 2376 | COMPONENT examples) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2377 | set(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Example files") |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 2378 | endif() |
| 2379 | |
Andy Green | cd0c696 | 2016-03-28 10:12:37 +0800 | [diff] [blame] | 2380 | # lwsws |
| 2381 | if (LWS_WITH_LWSWS) |
| 2382 | install(TARGETS lwsws |
| 2383 | RUNTIME DESTINATION "${LWS_INSTALL_BIN_DIR}" COMPONENT lwsws ) |
| 2384 | endif() |
| 2385 | |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 2386 | # Programs shared files used by the test-server. |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2387 | if (NOT LWS_WITHOUT_TESTAPPS AND NOT LWS_WITHOUT_SERVER) |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 2388 | install(FILES ${TEST_SERVER_DATA} |
| 2389 | DESTINATION share/libwebsockets-test-server |
Andy Green | ee94621 | 2016-12-03 15:13:15 +0800 | [diff] [blame] | 2390 | COMPONENT examples) |
| 2391 | |
Andy Green | 4f267c5 | 2017-09-22 09:46:58 +0800 | [diff] [blame] | 2392 | install(FILES "${PROJECT_SOURCE_DIR}/test-apps/private/index.html" |
Andy Green | ee94621 | 2016-12-03 15:13:15 +0800 | [diff] [blame] | 2393 | DESTINATION share/libwebsockets-test-server/private |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 2394 | COMPONENT examples) |
Andy Green | 6a8099b | 2016-02-21 21:25:48 +0800 | [diff] [blame] | 2395 | if (LWS_WITH_CGI) |
Andy Green | 4f267c5 | 2017-09-22 09:46:58 +0800 | [diff] [blame] | 2396 | set(CGI_TEST_SCRIPT "${PROJECT_SOURCE_DIR}/test-apps/lws-cgi-test.sh") |
Andy Green | 6a8099b | 2016-02-21 21:25:48 +0800 | [diff] [blame] | 2397 | install(FILES ${CGI_TEST_SCRIPT} |
| 2398 | PERMISSIONS OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE OWNER_READ GROUP_READ WORLD_READ |
| 2399 | DESTINATION share/libwebsockets-test-server |
| 2400 | COMPONENT examples) |
| 2401 | endif() |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 2402 | endif() |
| 2403 | |
Adam Wolk | 2befafc | 2017-11-25 20:15:29 +0100 | [diff] [blame] | 2404 | |
| 2405 | if (NOT LWS_WITHOUT_TEST_SERVER AND NOT LWS_WITHOUT_SERVER AND NOT LWS_WITHOUT_TESTAPPS) |
| 2406 | install(FILES test-apps/lws-ssh-test-keys;test-apps/lws-ssh-test-keys.pub |
| 2407 | DESTINATION share/libwebsockets-test-server |
| 2408 | COMPONENT examples) |
| 2409 | endif() |
Andy Green | 7597ac3 | 2017-10-16 16:59:57 +0800 | [diff] [blame] | 2410 | |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 2411 | # plugins |
| 2412 | |
| 2413 | if (LWS_WITH_PLUGINS) |
| 2414 | install(TARGETS ${PLUGINS_LIST} |
Denis Osvald | 8d21c35 | 2016-04-06 18:07:37 +0200 | [diff] [blame] | 2415 | PERMISSIONS OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE OWNER_READ GROUP_READ WORLD_READ |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 2416 | DESTINATION share/libwebsockets-test-server/plugins |
| 2417 | COMPONENT plugins) |
Andy Green | 4e2eef3 | 2018-11-28 07:25:16 +0800 | [diff] [blame] | 2418 | |
| 2419 | if (NOT WIN32) |
| 2420 | install(FILES plugins/deaddrop/assets/index.html;plugins/deaddrop/assets/deaddrop.js;plugins/deaddrop/assets/deaddrop.css;plugins/deaddrop/assets/drop.svg |
| 2421 | DESTINATION share/libwebsockets-test-server/deaddrop |
| 2422 | COMPONENT plugins) |
| 2423 | endif() |
| 2424 | |
| 2425 | |
Andy Green | 9806140 | 2016-04-15 14:01:29 +0800 | [diff] [blame] | 2426 | if (LWS_WITH_SERVER_STATUS) |
Andy Green | 97f3e66 | 2018-08-25 07:22:36 +0800 | [diff] [blame] | 2427 | install(FILES plugins/server-status.html;plugins/server-status.js;plugins/server-status.css;plugins/lwsws-logo.png |
Andy Green | 9806140 | 2016-04-15 14:01:29 +0800 | [diff] [blame] | 2428 | DESTINATION share/libwebsockets-test-server/server-status |
| 2429 | COMPONENT examples) |
| 2430 | endif() |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 2431 | if (LWS_WITH_GENERIC_SESSIONS) |
| 2432 | install(FILES |
| 2433 | plugins/generic-sessions/assets/lwsgs-logo.png |
| 2434 | plugins/generic-sessions/assets/seats.jpg |
| 2435 | plugins/generic-sessions/assets/failed-login.html |
| 2436 | plugins/generic-sessions/assets/lwsgs.js |
Andy Green | 35473ca | 2018-08-29 07:15:34 +0800 | [diff] [blame] | 2437 | plugins/generic-sessions/assets/lwsgs.css |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 2438 | plugins/generic-sessions/assets/post-register-fail.html |
| 2439 | plugins/generic-sessions/assets/post-register-ok.html |
| 2440 | plugins/generic-sessions/assets/post-verify-ok.html |
| 2441 | plugins/generic-sessions/assets/post-verify-fail.html |
| 2442 | plugins/generic-sessions/assets/sent-forgot-ok.html |
| 2443 | plugins/generic-sessions/assets/sent-forgot-fail.html |
| 2444 | plugins/generic-sessions/assets/post-forgot-ok.html |
| 2445 | plugins/generic-sessions/assets/post-forgot-fail.html |
| 2446 | plugins/generic-sessions/assets/index.html |
| 2447 | DESTINATION share/libwebsockets-test-server/generic-sessions |
| 2448 | COMPONENT examples) |
| 2449 | install(FILES plugins/generic-sessions/assets/successful-login.html |
| 2450 | DESTINATION share/libwebsockets-test-server/generic-sessions/needauth |
| 2451 | COMPONENT examples) |
| 2452 | install(FILES plugins/generic-sessions/assets/admin-login.html |
| 2453 | DESTINATION share/libwebsockets-test-server/generic-sessions/needadmin |
| 2454 | COMPONENT examples) |
| 2455 | endif() |
| 2456 | |
Andy Green | 722cc4a | 2016-06-26 06:29:20 +0800 | [diff] [blame] | 2457 | install(FILES |
| 2458 | plugins/generic-table/assets/lwsgt.js |
| 2459 | plugins/generic-table/assets/index.html |
| 2460 | DESTINATION share/libwebsockets-test-server/generic-table |
| 2461 | COMPONENT examples) |
| 2462 | |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 2463 | endif() |
| 2464 | |
Charles Prevot | 90a0dd6 | 2015-12-08 10:26:57 +0800 | [diff] [blame] | 2465 | # Install the LibwebsocketsConfig.cmake and LibwebsocketsConfigVersion.cmake |
| 2466 | install(FILES |
| 2467 | "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/LibwebsocketsConfig.cmake" |
| 2468 | "${PROJECT_BINARY_DIR}/LibwebsocketsConfigVersion.cmake" |
| 2469 | DESTINATION "${LWS_INSTALL_CMAKE_DIR}" COMPONENT dev) |
| 2470 | |
Andy Green | f632e44 | 2016-03-29 18:27:32 +0800 | [diff] [blame] | 2471 | # Install exports for the install-tree. |
Alexey Reznichenko | 9384613 | 2017-11-20 12:41:29 +0100 | [diff] [blame] | 2472 | if (LWS_WITH_EXPORT_LWSTARGETS) |
| 2473 | install(EXPORT LibwebsocketsTargets |
| 2474 | DESTINATION "${LWS_INSTALL_CMAKE_DIR}" COMPONENT dev) |
| 2475 | endif() |
Andy Green | f632e44 | 2016-03-29 18:27:32 +0800 | [diff] [blame] | 2476 | |
Andy Green | 2aab3f9 | 2013-03-10 08:11:48 +0800 | [diff] [blame] | 2477 | # build subdir is not part of sources |
Steffen Vogel | 40cd5c4 | 2018-05-26 09:19:54 +0800 | [diff] [blame] | 2478 | set(CPACK_SOURCE_IGNORE_FILES $(CPACK_SOURCE_IGNORE_FILES) "/.git/" "/build/" "\\\\.tgz$" "\\\\.tar\\\\.gz$") |
Andy Green | 2aab3f9 | 2013-03-10 08:11:48 +0800 | [diff] [blame] | 2479 | |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 2480 | # Most people are more used to "make dist" compared to "make package_source" |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 2481 | add_custom_target(dist COMMAND "${CMAKE_MAKE_PROGRAM}" package_source) |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 2482 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2483 | include(UseRPMTools) |
| 2484 | if (RPMTools_FOUND) |
Andy Green | 4f267c5 | 2017-09-22 09:46:58 +0800 | [diff] [blame] | 2485 | RPMTools_ADD_RPM_TARGETS(libwebsockets scripts/libwebsockets.spec) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2486 | endif() |
| 2487 | |
| 2488 | message("---------------------------------------------------------------------") |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 2489 | message(" Settings: (For more help do cmake -LH <srcpath>)") |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2490 | message("---------------------------------------------------------------------") |
Stephan Eberle | b820e2c | 2015-10-23 08:10:55 +0200 | [diff] [blame] | 2491 | message(" LWS_WITH_STATIC = ${LWS_WITH_STATIC}") |
| 2492 | message(" LWS_WITH_SHARED = ${LWS_WITH_SHARED}") |
| 2493 | message(" LWS_WITH_SSL = ${LWS_WITH_SSL} (SSL Support)") |
Andy Green | d2ec7ad | 2014-03-15 10:39:29 +0800 | [diff] [blame] | 2494 | message(" LWS_SSL_CLIENT_USE_OS_CA_CERTS = ${LWS_SSL_CLIENT_USE_OS_CA_CERTS}") |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 2495 | message(" LWS_WITH_WOLFSSL = ${LWS_WITH_WOLFSSL} (wolfSSL/CyaSSL replacement for OpenSSL)") |
| 2496 | if (LWS_WITH_WOLFSSL) |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 2497 | message(" LWS_WOLFSSL_LIBRARIES = ${LWS_WOLFSSL_LIBRARIES}") |
| 2498 | message(" LWS_WOLFSSL_INCLUDE_DIRS = ${LWS_WOLFSSL_INCLUDE_DIRS}") |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2499 | endif() |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 2500 | message(" LWS_WITH_MBEDTLS = ${LWS_WITH_MBEDTLS} (mbedTLS replacement for OpenSSL)") |
Andy Green | 4c79ee7 | 2015-10-15 11:20:40 +0800 | [diff] [blame] | 2501 | message(" LWS_WITHOUT_BUILTIN_SHA1 = ${LWS_WITHOUT_BUILTIN_SHA1}") |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2502 | message(" LWS_WITHOUT_BUILTIN_GETIFADDRS = ${LWS_WITHOUT_BUILTIN_GETIFADDRS}") |
| 2503 | message(" LWS_WITHOUT_CLIENT = ${LWS_WITHOUT_CLIENT}") |
| 2504 | message(" LWS_WITHOUT_SERVER = ${LWS_WITHOUT_SERVER}") |
| 2505 | message(" LWS_LINK_TESTAPPS_DYNAMIC = ${LWS_LINK_TESTAPPS_DYNAMIC}") |
| 2506 | message(" LWS_WITHOUT_TESTAPPS = ${LWS_WITHOUT_TESTAPPS}") |
| 2507 | message(" LWS_WITHOUT_TEST_SERVER = ${LWS_WITHOUT_TEST_SERVER}") |
| 2508 | message(" LWS_WITHOUT_TEST_SERVER_EXTPOLL = ${LWS_WITHOUT_TEST_SERVER_EXTPOLL}") |
| 2509 | message(" LWS_WITHOUT_TEST_PING = ${LWS_WITHOUT_TEST_PING}") |
| 2510 | message(" LWS_WITHOUT_TEST_CLIENT = ${LWS_WITHOUT_TEST_CLIENT}") |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2511 | message(" LWS_WITHOUT_EXTENSIONS = ${LWS_WITHOUT_EXTENSIONS}") |
| 2512 | message(" LWS_WITH_LATENCY = ${LWS_WITH_LATENCY}") |
| 2513 | message(" LWS_WITHOUT_DAEMONIZE = ${LWS_WITHOUT_DAEMONIZE}") |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 2514 | message(" LWS_WITH_LIBEV = ${LWS_WITH_LIBEV}") |
| 2515 | message(" LWS_WITH_LIBUV = ${LWS_WITH_LIBUV}") |
| 2516 | message(" LWS_WITH_LIBEVENT = ${LWS_WITH_LIBEVENT}") |
Andy Green | 2eedea9 | 2014-04-03 14:33:48 +0800 | [diff] [blame] | 2517 | message(" LWS_IPV6 = ${LWS_IPV6}") |
Yeonjun Lim | 3c6a8c1 | 2016-03-30 22:47:02 -0700 | [diff] [blame] | 2518 | message(" LWS_UNIX_SOCK = ${LWS_UNIX_SOCK}") |
Andy Green | 2eedea9 | 2014-04-03 14:33:48 +0800 | [diff] [blame] | 2519 | message(" LWS_WITH_HTTP2 = ${LWS_WITH_HTTP2}") |
Vijay Khurdiya | e73d446 | 2016-01-15 16:21:51 +0800 | [diff] [blame] | 2520 | message(" LWS_SSL_SERVER_WITH_ECDH_CERT = ${LWS_SSL_SERVER_WITH_ECDH_CERT}") |
Andy Green | d3a5505 | 2016-01-19 03:34:24 +0800 | [diff] [blame] | 2521 | message(" LWS_MAX_SMP = ${LWS_MAX_SMP}") |
Andy Green | 3de2e9a | 2018-03-02 09:01:22 +0800 | [diff] [blame] | 2522 | message(" LWS_HAVE_PTHREAD_H = ${LWS_HAVE_PTHREAD_H}") |
Andy Green | 6a8099b | 2016-02-21 21:25:48 +0800 | [diff] [blame] | 2523 | message(" LWS_WITH_CGI = ${LWS_WITH_CGI}") |
Joakim Soderberg | 9a720bb | 2016-03-12 08:37:36 +0800 | [diff] [blame] | 2524 | message(" LWS_HAVE_OPENSSL_ECDH_H = ${LWS_HAVE_OPENSSL_ECDH_H}") |
Alexander Bruines | ddd9bfa | 2016-04-13 22:17:05 +0200 | [diff] [blame] | 2525 | message(" LWS_HAVE_SSL_CTX_set1_param = ${LWS_HAVE_SSL_CTX_set1_param}") |
Andy Green | 7597ac3 | 2017-10-16 16:59:57 +0800 | [diff] [blame] | 2526 | message(" LWS_HAVE_RSA_SET0_KEY = ${LWS_HAVE_RSA_SET0_KEY}") |
Andy Green | 1e5a9ad | 2016-03-20 11:59:53 +0800 | [diff] [blame] | 2527 | message(" LWS_WITH_HTTP_PROXY = ${LWS_WITH_HTTP_PROXY}") |
| 2528 | message(" LIBHUBBUB_LIBRARIES = ${LIBHUBBUB_LIBRARIES}") |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 2529 | message(" PLUGINS = ${PLUGINS_LIST}") |
Andy Green | 2f0bc93 | 2016-04-15 12:00:23 +0800 | [diff] [blame] | 2530 | message(" LWS_WITH_ACCESS_LOG = ${LWS_WITH_ACCESS_LOG}") |
Andy Green | 9806140 | 2016-04-15 14:01:29 +0800 | [diff] [blame] | 2531 | message(" LWS_WITH_SERVER_STATUS = ${LWS_WITH_SERVER_STATUS}") |
Andy Green | 5afc567 | 2016-05-10 09:47:10 +0800 | [diff] [blame] | 2532 | message(" LWS_WITH_LEJP = ${LWS_WITH_LEJP}") |
Andy Green | 3358c53 | 2016-05-26 21:12:11 +0800 | [diff] [blame] | 2533 | message(" LWS_WITH_LEJP_CONF = ${LWS_WITH_LEJP_CONF}") |
Andy Green | 602d884 | 2016-06-07 09:49:59 +0800 | [diff] [blame] | 2534 | message(" LWS_WITH_SMTP = ${LWS_WITH_SMTP}") |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 2535 | message(" LWS_WITH_GENERIC_SESSIONS = ${LWS_WITH_GENERIC_SESSIONS}") |
Brown, Matthew | b0ff623 | 2016-09-27 05:32:40 +0800 | [diff] [blame] | 2536 | message(" LWS_STATIC_PIC = ${LWS_STATIC_PIC}") |
Andy Green | ed4acef | 2016-12-12 13:36:25 +0800 | [diff] [blame] | 2537 | message(" LWS_WITH_RANGES = ${LWS_WITH_RANGES}") |
Andy Green | 51c96d8 | 2017-01-17 07:01:02 +0800 | [diff] [blame] | 2538 | message(" LWS_PLAT_OPTEE = ${LWS_PLAT_OPTEE}") |
Andy Green | c7c4ae0 | 2017-02-18 17:26:40 +0800 | [diff] [blame] | 2539 | message(" LWS_WITH_ESP32 = ${LWS_WITH_ESP32}") |
Andy Green | 753f1d6 | 2017-03-03 09:19:14 +0800 | [diff] [blame] | 2540 | message(" LWS_WITH_ZIP_FOPS = ${LWS_WITH_ZIP_FOPS}") |
Andy Green | c35661c | 2017-03-21 11:34:49 +0800 | [diff] [blame] | 2541 | message(" LWS_AVOID_SIGPIPE_IGN = ${LWS_AVOID_SIGPIPE_IGN}") |
Andy Green | a7def3c | 2017-05-07 10:02:03 +0800 | [diff] [blame] | 2542 | message(" LWS_WITH_STATS = ${LWS_WITH_STATS}") |
Andy Ning | ed92b6d | 2017-05-05 11:38:34 -0400 | [diff] [blame] | 2543 | message(" LWS_WITH_SOCKS5 = ${LWS_WITH_SOCKS5}") |
Andy Green | 156363f | 2017-06-07 06:10:02 +0800 | [diff] [blame] | 2544 | message(" LWS_HAVE_SYS_CAPABILITY_H = ${LWS_HAVE_SYS_CAPABILITY_H}") |
| 2545 | message(" LWS_HAVE_LIBCAP = ${LWS_HAVE_LIBCAP}") |
Andy Green | 98df672 | 2017-09-14 13:14:11 +0800 | [diff] [blame] | 2546 | message(" LWS_WITH_PEER_LIMITS = ${LWS_WITH_PEER_LIMITS}") |
WebsocketUser | 0be9e98 | 2017-06-09 20:20:42 +0800 | [diff] [blame] | 2547 | message(" LWS_HAVE_ATOLL = ${LWS_HAVE_ATOLL}") |
| 2548 | message(" LWS_HAVE__ATOI64 = ${LWS_HAVE__ATOI64}") |
| 2549 | message(" LWS_HAVE_STAT32I64 = ${LWS_HAVE_STAT32I64}") |
Andy Green | 7262e14 | 2017-07-07 08:32:04 +0800 | [diff] [blame] | 2550 | message(" LWS_HAS_INTPTR_T = ${LWS_HAS_INTPTR_T}") |
Alexey Reznichenko | 9384613 | 2017-11-20 12:41:29 +0100 | [diff] [blame] | 2551 | message(" LWS_WITH_EXPORT_LWSTARGETS = ${LWS_WITH_EXPORT_LWSTARGETS}") |
Andy Green | c55fd27 | 2016-06-08 10:07:02 +0800 | [diff] [blame] | 2552 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 2553 | message("---------------------------------------------------------------------") |
| 2554 | |
| 2555 | # These will be available to parent projects including libwebsockets using add_subdirectory() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 2556 | set(LIBWEBSOCKETS_LIBRARIES ${LWS_LIBRARIES} CACHE STRING "Libwebsocket libraries") |
| 2557 | if (LWS_WITH_STATIC) |
Sergey Kovalevich | 989ff82 | 2017-05-29 21:44:01 +0300 | [diff] [blame] | 2558 | set(LIBWEBSOCKETS_LIBRARIES_STATIC websockets CACHE STRING "Libwebsocket static library") |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 2559 | endif() |
| 2560 | if (LWS_WITH_SHARED) |
| 2561 | set(LIBWEBSOCKETS_LIBRARIES_SHARED websockets_shared CACHE STRING "Libwebsocket shared library") |
| 2562 | endif() |
Tomas Cejka | efda177 | 2013-04-11 08:13:13 +0800 | [diff] [blame] | 2563 | |
Andy Green | e4a3e8c | 2018-03-17 06:43:12 +0800 | [diff] [blame] | 2564 | if (LWS_WITH_MINIMAL_EXAMPLES) |
| 2565 | MACRO(SUBDIRLIST result curdir) |
| 2566 | FILE(GLOB children RELATIVE ${curdir} ${curdir}/*) |
| 2567 | SET(dirlist "") |
| 2568 | |
| 2569 | FOREACH(child ${children}) |
| 2570 | IF(IS_DIRECTORY ${curdir}/${child}) |
| 2571 | LIST(APPEND dirlist ${child}) |
| 2572 | ENDIF() |
| 2573 | ENDFOREACH() |
| 2574 | |
| 2575 | SET(${result} ${dirlist}) |
| 2576 | ENDMACRO() |
| 2577 | |
| 2578 | SUBDIRLIST(SUBDIRS "${PROJECT_SOURCE_DIR}/minimal-examples") |
| 2579 | FOREACH(subdir ${SUBDIRS}) |
| 2580 | |
| 2581 | SUBDIRLIST(SUBDIRS2 "${PROJECT_SOURCE_DIR}/minimal-examples/${subdir}") |
| 2582 | FOREACH(subdir2 ${SUBDIRS2}) |
| 2583 | if (EXISTS "${PROJECT_SOURCE_DIR}/minimal-examples/${subdir}/${subdir2}/CMakeLists.txt") |
| 2584 | message("Processing ${PROJECT_SOURCE_DIR}/minimal-examples/${subdir}/${subdir2}") |
| 2585 | add_subdirectory("${PROJECT_SOURCE_DIR}/minimal-examples/${subdir}/${subdir2}") |
| 2586 | endif() |
| 2587 | ENDFOREACH() |
| 2588 | ENDFOREACH() |
| 2589 | ENDIF() |
| 2590 | |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 2591 | # This must always be last! |
| 2592 | include(CPack) |