Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 1 | # |
| 2 | # libwebsockets - small server side websockets and web server implementation |
| 3 | # |
| 4 | # Copyright (C) 2010 - 2020 Andy Green <andy@warmcat.com> |
| 5 | # |
| 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | # of this software and associated documentation files (the "Software"), to |
| 8 | # deal in the Software without restriction, including without limitation the |
| 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | # sell copies of the Software, and to permit persons to whom the Software is |
| 11 | # furnished to do so, subject to the following conditions: |
| 12 | # |
| 13 | # The above copyright notice and this permission notice shall be included in |
| 14 | # all copies or substantial portions of the Software. |
| 15 | # |
| 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 22 | # IN THE SOFTWARE. |
| 23 | # |
| 24 | |
Andy Green | 90496da | 2020-09-28 07:34:55 +0100 | [diff] [blame] | 25 | cmake_minimum_required(VERSION 2.8.12) |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 26 | include(CheckFunctionExists) |
| 27 | include(CheckSymbolExists) |
| 28 | include(CheckIncludeFile) |
| 29 | include(CheckIncludeFiles) |
| 30 | include(CheckLibraryExists) |
| 31 | include(CheckTypeSize) |
| 32 | include(CheckCSourceCompiles) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 33 | |
Andy Green | 425da07 | 2020-06-03 17:14:03 +0100 | [diff] [blame] | 34 | if (POLICY CMP0048) |
Valentin B | aa0e94c | 2020-04-21 01:33:33 +0200 | [diff] [blame] | 35 | cmake_policy(SET CMP0048 NEW) |
| 36 | endif() |
| 37 | |
Andy Green | 425da07 | 2020-06-03 17:14:03 +0100 | [diff] [blame] | 38 | #if (POLICY CMP0024) |
| 39 | # cmake_policy(SET CMP0024 NEW) |
| 40 | #endif() |
| 41 | |
| 42 | if (POLICY CMP0075) |
| 43 | cmake_policy(SET CMP0075 NEW) |
| 44 | endif() |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 45 | |
Andy Green | 46ee071 | 2017-11-10 08:56:44 +0800 | [diff] [blame] | 46 | # General Advice |
| 47 | # |
| 48 | # For selecting between DEBUG / RELEASE, use -DCMAKE_BUILD_TYPE=DEBUG or =RELEASE |
| 49 | # debug builds include source level debug info and extra logging |
| 50 | |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 51 | set(LWS_WITH_BUNDLED_ZLIB_DEFAULT OFF) |
| 52 | if(WIN32) |
| 53 | set(LWS_WITH_BUNDLED_ZLIB_DEFAULT ON) |
| 54 | endif() |
Andy Green | 16a9071 | 2018-04-27 15:20:56 +0800 | [diff] [blame] | 55 | |
Andy Green | 27e86e2 | 2018-04-25 08:42:18 +0800 | [diff] [blame] | 56 | set(LWS_ROLE_RAW 1) |
Andy Green | d37b383 | 2018-04-29 10:44:36 +0800 | [diff] [blame] | 57 | set(LWS_WITH_POLL 1) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 58 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 59 | if (ESP_PLATFORM) |
Andy Green | cabe021 | 2020-05-14 21:28:48 +0100 | [diff] [blame] | 60 | set(LWS_ESP_PLATFORM 1) |
Andy Green | 60b995b | 2020-12-06 17:29:36 +0000 | [diff] [blame] | 61 | #set(CMAKE_TOOLCHAIN_FILE contrib/cross-esp32.cmake) |
Andy Green | cabe021 | 2020-05-14 21:28:48 +0100 | [diff] [blame] | 62 | set(LWIP_PROVIDE_ERRNO 1) |
| 63 | endif() |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 64 | |
Andy Green | 4683ae2 | 2020-01-20 18:13:53 +0000 | [diff] [blame] | 65 | # it's at this point any toolchain file is brought in |
Andy Green | 962e9ee | 2020-09-28 10:13:39 +0100 | [diff] [blame] | 66 | project(libwebsockets C CXX) |
Andy Green | cb0ea63 | 2020-05-01 05:45:18 +0100 | [diff] [blame] | 67 | include(CTest) |
Andy Green | 4683ae2 | 2020-01-20 18:13:53 +0000 | [diff] [blame] | 68 | |
Andy Green | 60b995b | 2020-12-06 17:29:36 +0000 | [diff] [blame] | 69 | if (ESP_PLATFORM) |
| 70 | include_directories( |
Andy Green | d4dd7cb | 2021-08-26 12:31:06 +0100 | [diff] [blame] | 71 | $ENV{IDF_PATH}/components/esp_hw_support/include/soc/ |
| 72 | $ENV{IDF_PATH}/components/freertos/include/ |
| 73 | $ENV{IDF_PATH}/components/xtensa/${CONFIG_IDF_TARGET}/include/ |
| 74 | $ENV{IDF_PATH}/components/freertos/include/esp_additions |
| 75 | $ENV{IDF_PATH}/components/hal/include |
| 76 | $ENV{IDF_PATH}/components/soc/${CONFIG_IDF_TARGET}/include/ |
| 77 | $ENV{IDF_PATH}/components/soc/include/ |
| 78 | $ENV{IDF_PATH}/components/esp_hw_support/include |
| 79 | $ENV{IDF_PATH}/components/hal/${CONFIG_IDF_TARGET}/include/ |
| 80 | ) |
| 81 | |
| 82 | if (CONFIG_IDF_TARGET_ARCH_RISCV) |
| 83 | include_directories( |
| 84 | $ENV{IDF_PATH}/components/freertos/port/riscv/include |
| 85 | $ENV{IDF_PATH}/components/riscv/include) |
| 86 | else() |
| 87 | include_directories( |
| 88 | $ENV{IDF_PATH}/components/freertos/port/xtensa/include |
| 89 | $ENV{IDF_PATH}/components/xtensa/include) |
| 90 | endif() |
| 91 | |
Andy Green | 60b995b | 2020-12-06 17:29:36 +0000 | [diff] [blame] | 92 | endif() |
| 93 | |
| 94 | |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 95 | # |
Andy Green | 1d9d04f | 2018-01-27 08:01:33 +0800 | [diff] [blame] | 96 | # Select features recommended for PC distro packaging |
| 97 | # |
| 98 | option(LWS_WITH_DISTRO_RECOMMENDED "Enable features recommended for distro packaging" OFF) |
Andy Green | aa4143a | 2018-11-12 15:24:42 +0800 | [diff] [blame] | 99 | option(LWS_FOR_GITOHASHI "Enable features recommended for use with gitohashi" OFF) |
Andy Green | 1d9d04f | 2018-01-27 08:01:33 +0800 | [diff] [blame] | 100 | |
| 101 | # |
Jakov Smolic | c9c152b | 2020-05-26 16:35:16 +0200 | [diff] [blame] | 102 | # Compiler features |
| 103 | # |
| 104 | option(DISABLE_WERROR "Avoid treating compiler warnings as fatal errors" OFF) |
| 105 | |
| 106 | # |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 107 | # Major individual features |
| 108 | # |
Andy Green | 84a5754 | 2019-01-13 06:58:21 +0800 | [diff] [blame] | 109 | option(LWS_WITH_NETWORK "Compile with network-related code" ON) |
Andy Green | 16a9071 | 2018-04-27 15:20:56 +0800 | [diff] [blame] | 110 | 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] | 111 | option(LWS_ROLE_WS "Compile with support for websockets" ON) |
Sakthi Kannan | 9d099ba | 2020-02-25 13:28:25 +0000 | [diff] [blame] | 112 | option(LWS_ROLE_MQTT "Build with support for MQTT client" OFF) |
Andy Green | 31dfc4a | 2018-10-02 10:50:24 +0800 | [diff] [blame] | 113 | option(LWS_ROLE_DBUS "Compile with support for DBUS" OFF) |
Andy Green | 08b5ad9 | 2018-11-29 08:29:48 +0800 | [diff] [blame] | 114 | option(LWS_ROLE_RAW_PROXY "Raw packet proxy" OFF) |
Andy Green | ed04a26 | 2020-02-28 15:50:15 +0000 | [diff] [blame] | 115 | option(LWS_ROLE_RAW_FILE "Compile with support for raw files" ON) |
Andy Green | aa4143a | 2018-11-12 15:24:42 +0800 | [diff] [blame] | 116 | option(LWS_WITH_HTTP2 "Compile with server support for HTTP/2" ON) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 117 | option(LWS_WITH_LWSWS "Libwebsockets Webserver" OFF) |
| 118 | option(LWS_WITH_CGI "Include CGI (spawn process with network-connected stdin/out/err) APIs" OFF) |
| 119 | option(LWS_IPV6 "Compile with support for ipv6" OFF) |
Andy Green | 911898a | 2020-05-24 13:57:21 +0100 | [diff] [blame] | 120 | option(LWS_UNIX_SOCK "Compile with support for UNIX domain socket if OS supports it" ON) |
Andy Green | 1d05f42 | 2020-08-30 07:39:27 +0100 | [diff] [blame] | 121 | option(LWS_WITH_PLUGINS "Support plugins for protocols and extensions (implies LWS_WITH_PLUGINS_API)" OFF) |
Andy Green | 0e6df74 | 2021-01-31 05:50:12 +0000 | [diff] [blame] | 122 | option(LWS_WITH_PLUGINS_BUILTIN "Build the plugin protocols directly into lws library" OFF) |
Jorge E. Moreira | 4d0db3e | 2021-12-23 11:10:24 -0800 | [diff] [blame] | 123 | option(LWS_WITH_HTTP_PROXY "Support for active HTTP proxying" ON) |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 124 | option(LWS_WITH_ZIP_FOPS "Support serving pre-zipped files" OFF) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 125 | option(LWS_WITH_SOCKS5 "Allow use of SOCKS5 proxy on client connections" OFF) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 126 | option(LWS_WITH_PEER_LIMITS "Track peers and restrict resources a single peer can allocate" OFF) |
| 127 | option(LWS_WITH_ACCESS_LOG "Support generating Apache-compatible access logs" OFF) |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 128 | option(LWS_WITH_RANGES "Support http ranges (RFC7233)" OFF) |
Andy Green | aa4143a | 2018-11-12 15:24:42 +0800 | [diff] [blame] | 129 | 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] | 130 | option(LWS_WITH_HTTP_STREAM_COMPRESSION "Support HTTP stream compression" OFF) |
| 131 | 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] | 132 | 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] | 133 | option(LWS_WITH_HUBBUB "Enable libhubbub rewriting support" OFF) |
Andy Green | 7a84ca4 | 2019-10-14 16:46:48 +0100 | [diff] [blame] | 134 | option(LWS_WITH_ALSA "Enable alsa audio example" OFF) |
Andy Green | af2f1f9 | 2020-02-07 11:39:32 +0000 | [diff] [blame] | 135 | option(LWS_WITH_GTK "Enable gtk example" OFF) |
Andy Green | aa4143a | 2018-11-12 15:24:42 +0800 | [diff] [blame] | 136 | option(LWS_WITH_FTS "Full Text Search support" OFF) |
Andy Green | 94f1c7b | 2019-09-22 07:25:58 -0700 | [diff] [blame] | 137 | option(LWS_WITH_SYS_ASYNC_DNS "Nonblocking internal IPv4 + IPv6 DNS resolver" OFF) |
| 138 | option(LWS_WITH_SYS_NTPCLIENT "Build in tiny ntpclient good for tls date validation and run via lws_system" OFF) |
Andy Green | d0fa39a | 2019-09-27 14:32:59 -0700 | [diff] [blame] | 139 | option(LWS_WITH_SYS_DHCP_CLIENT "Build in tiny DHCP client" OFF) |
Andy Green | bb1a8d3 | 2020-02-28 09:29:25 +0000 | [diff] [blame] | 140 | option(LWS_WITH_HTTP_BASIC_AUTH "Support Basic Auth" ON) |
Andy Green | 9a1f184 | 2020-02-28 10:31:04 +0000 | [diff] [blame] | 141 | option(LWS_WITH_HTTP_UNCOMMON_HEADERS "Include less common http header support" ON) |
Andy Green | 30f3606 | 2020-06-23 13:19:30 +0100 | [diff] [blame] | 142 | option(LWS_WITH_SYS_STATE "lws_system state support" ON) |
Andy Green | 8eca7e1 | 2020-06-24 20:15:46 +0100 | [diff] [blame] | 143 | option(LWS_WITH_SYS_SMD "Lws System Message Distribution" ON) |
Andy Green | 3fe08ce | 2021-02-17 10:31:22 +0000 | [diff] [blame] | 144 | option(LWS_WITH_SYS_FAULT_INJECTION "Enable fault injection support" OFF) |
Andy Green | 3f4623b | 2021-01-06 15:08:22 +0000 | [diff] [blame] | 145 | option(LWS_WITH_SYS_METRICS "Lws Metrics API" OFF) |
Andy Green | bb1a8d3 | 2020-02-28 09:29:25 +0000 | [diff] [blame] | 146 | |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 147 | # |
Andy Green | 28ce32a | 2020-02-29 12:37:24 +0000 | [diff] [blame] | 148 | # Secure Streams |
| 149 | # |
| 150 | option(LWS_WITH_SECURE_STREAMS "Secure Streams protocol-agnostic API" OFF) |
Andy Green | 962e9ee | 2020-09-28 10:13:39 +0100 | [diff] [blame] | 151 | option(LWS_WITH_SECURE_STREAMS_CPP "Secure Streams C++ classes" OFF) |
Andy Green | 28ce32a | 2020-02-29 12:37:24 +0000 | [diff] [blame] | 152 | option(LWS_WITH_SECURE_STREAMS_PROXY_API "Secure Streams support to work across processes" OFF) |
| 153 | option(LWS_WITH_SECURE_STREAMS_SYS_AUTH_API_AMAZON_COM "Auth support for api.amazon.com" OFF) |
Andy Green | 4cc7f4e | 2020-03-26 06:48:34 +0000 | [diff] [blame] | 154 | option(LWS_WITH_SECURE_STREAMS_STATIC_POLICY_ONLY "Secure Streams Policy is hardcoded only" OFF) |
Jed Lu | c82910d | 2020-12-29 16:42:25 -0800 | [diff] [blame] | 155 | option(LWS_WITH_SECURE_STREAMS_AUTH_SIGV4 "Secure Streams Auth support for AWS Sigv4" OFF) |
Jed Lu | 2abf411 | 2021-06-10 00:08:37 -0700 | [diff] [blame] | 156 | option(LWS_WITH_SECURE_STREAMS_BUFFER_DUMP "Secure Streams protocol buffer dump" OFF) |
| 157 | option(LWS_WITH_SS_DIRECT_PROTOCOL_STR "Secure Streams directly set/get metadata w/o policy" OFF) |
Andy Green | 28ce32a | 2020-02-29 12:37:24 +0000 | [diff] [blame] | 158 | |
| 159 | # |
Andy Green | cb0ea63 | 2020-05-01 05:45:18 +0100 | [diff] [blame] | 160 | # CTest options |
| 161 | # |
| 162 | # |
| 163 | # If you build with LWS_WITH_MINIMAL_EXAMPLES, you can use CTest / make test to run |
| 164 | # examples that can give a pass/fail response. By default it runs tests both against |
| 165 | # a local server peer and warmcat.com, if your CI wants to do the tests but does not |
| 166 | # have internet routing, then you can still run a subset of tests with CTest / make |
| 167 | # test that only does local tests by disabling this option. |
| 168 | # |
| 169 | option(LWS_CTEST_INTERNET_AVAILABLE "CTest will performs tests that need the Internet" ON) |
| 170 | |
| 171 | # |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 172 | # TLS library options... all except mbedTLS are basically OpenSSL variants. |
| 173 | # |
| 174 | option(LWS_WITH_SSL "Include SSL support (defaults to OpenSSL or similar, mbedTLS if LWS_WITH_MBEDTLS is set)" ON) |
| 175 | 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) |
| 176 | option(LWS_WITH_BORINGSSL "Use BoringSSL replacement for OpenSSL" OFF) |
| 177 | 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) |
| 178 | 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) |
| 179 | option(LWS_SSL_CLIENT_USE_OS_CA_CERTS "SSL support should make use of the OS-installed CA root certs" ON) |
Andy Green | fd24392 | 2021-01-23 20:56:01 +0000 | [diff] [blame] | 180 | option(LWS_TLS_LOG_PLAINTEXT_RX "For debugging log the received plaintext as soon as decrypted" OFF) |
| 181 | option(LWS_TLS_LOG_PLAINTEXT_TX "For debugging log the transmitted plaintext just before encryption" OFF) |
Catalin | d5753b6 | 2021-03-25 08:37:36 +0000 | [diff] [blame] | 182 | option(LWS_WITH_TLS_SESSIONS "Enable persistent, resumable TLS sessions" ON) |
Andy Green | 2f9bb7a | 2021-05-21 14:32:21 +0100 | [diff] [blame] | 183 | option(LWS_WITH_TLS_JIT_TRUST "Enable dynamically computing which trusted TLS CA is needed to be instantiated" OFF) |
Andy Green | fd24392 | 2021-01-23 20:56:01 +0000 | [diff] [blame] | 184 | |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 185 | # |
| 186 | # Event library options (may select multiple, or none for default poll() |
| 187 | # |
| 188 | option(LWS_WITH_LIBEV "Compile with support for libev" OFF) |
| 189 | option(LWS_WITH_LIBUV "Compile with support for libuv" OFF) |
| 190 | option(LWS_WITH_LIBEVENT "Compile with support for libevent" OFF) |
Andy Green | af2f1f9 | 2020-02-07 11:39:32 +0000 | [diff] [blame] | 191 | option(LWS_WITH_GLIB "Compile with support for glib event loop" OFF) |
Christian Fuchs | b961e5f | 2021-01-06 14:15:53 +0100 | [diff] [blame] | 192 | option(LWS_WITH_SDEVENT "Compile with support for sd-event loop" OFF) |
Andy Green | 0f42f0d | 2021-03-15 19:33:37 +0000 | [diff] [blame] | 193 | option(LWS_WITH_ULOOP "Compile with support for uloop" OFF) |
Andy Green | af2f1f9 | 2020-02-07 11:39:32 +0000 | [diff] [blame] | 194 | |
Andy Green | c6c7ab2 | 2020-08-27 15:37:14 +0100 | [diff] [blame] | 195 | if (UNIX) |
| 196 | # since v4.1, on unix platforms default is build any event libs as runtime plugins |
| 197 | option(LWS_WITH_EVLIB_PLUGINS "Compile event lib support into runtime-selected plugins" ON) |
| 198 | else() |
| 199 | # otherwise default to linking the event lib(s) to libwebsockets.so |
| 200 | option(LWS_WITH_EVLIB_PLUGINS "Compile event lib support into runtime-selected plugins" OFF) |
| 201 | endif() |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 202 | # |
Andy Green | 15ce46d | 2020-06-10 19:17:08 +0100 | [diff] [blame] | 203 | # LWS Drivers |
| 204 | # |
| 205 | |
| 206 | option(LWS_WITH_DRIVERS "With generic drivers for gpio, i2c, display etc" OFF) |
| 207 | |
| 208 | # |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 209 | # Static / Dynamic build options |
| 210 | # |
| 211 | option(LWS_WITH_STATIC "Build the static version of the library" ON) |
| 212 | option(LWS_WITH_SHARED "Build the shared version of the library" ON) |
| 213 | option(LWS_LINK_TESTAPPS_DYNAMIC "Link the test apps to the shared version of the library. Default is to link statically" OFF) |
| 214 | option(LWS_STATIC_PIC "Build the static version of the library with position-independent code" OFF) |
Andy Green | 132833a | 2021-09-08 11:07:18 +0100 | [diff] [blame] | 215 | option(LWS_SUPPRESS_DEPRECATED_API_WARNINGS "Turn off complaints about, eg, openssl 3 deprecated api usage" ON) |
Andy Green | 8e5f849 | 2021-02-14 06:05:16 +0000 | [diff] [blame] | 216 | |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 217 | # |
| 218 | # Specific platforms |
| 219 | # |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 220 | option(LWS_WITH_ESP32 "Build for ESP32" OFF) |
| 221 | option(LWS_PLAT_OPTEE "Build for OPTEE" OFF) |
Andy Green | 0fa5563 | 2019-08-18 10:35:43 +0100 | [diff] [blame] | 222 | option(LWS_PLAT_FREERTOS "Build for FreeRTOS" OFF) |
Andy Green | c591e1a | 2019-09-19 06:54:53 +0100 | [diff] [blame] | 223 | option(LWS_PLAT_ANDROID "Android flavour of unix platform" OFF) |
Andy Green | 0fa5563 | 2019-08-18 10:35:43 +0100 | [diff] [blame] | 224 | |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 225 | # |
| 226 | # Client / Server / Test Apps build control |
| 227 | # |
| 228 | option(LWS_WITHOUT_CLIENT "Don't build the client part of the library" OFF) |
| 229 | option(LWS_WITHOUT_SERVER "Don't build the server part of the library" OFF) |
| 230 | option(LWS_WITHOUT_TESTAPPS "Don't build the libwebsocket-test-apps" OFF) |
| 231 | option(LWS_WITHOUT_TEST_SERVER "Don't build the test server" OFF) |
| 232 | option(LWS_WITHOUT_TEST_SERVER_EXTPOLL "Don't build the test server version that uses external poll" OFF) |
| 233 | 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] | 234 | 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] | 235 | # |
| 236 | # Extensions (permessage-deflate) |
| 237 | # |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 238 | option(LWS_WITHOUT_EXTENSIONS "Don't compile with extensions" ON) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 239 | # |
| 240 | # Helpers + misc |
| 241 | # |
| 242 | 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) |
| 243 | option(LWS_FALLBACK_GETHOSTBYNAME "Also try to do dns resolution using gethostbyname if getaddrinfo fails" OFF) |
| 244 | option(LWS_WITHOUT_BUILTIN_SHA1 "Don't build the lws sha-1 (eg, because openssl will provide it" OFF) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 245 | option(LWS_WITHOUT_DAEMONIZE "Don't build the daemonization api" ON) |
| 246 | 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] | 247 | option(LWS_WITH_LEJP "With the Lightweight JSON Parser" ON) |
Andy Green | dcaa001 | 2021-06-30 04:58:25 +0100 | [diff] [blame] | 248 | option(LWS_WITH_CBOR "With the Lightweight LECP CBOR Parser" OFF) |
| 249 | option(LWS_WITH_CBOR_FLOAT "Build floating point types if building CBOR LECP" ON) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 250 | option(LWS_WITH_SQLITE3 "Require SQLITE3 support" OFF) |
Andy Green | c099e7b | 2019-08-17 20:46:53 +0100 | [diff] [blame] | 251 | option(LWS_WITH_STRUCT_JSON "Generic struct serialization to and from JSON" OFF) |
Andy Green | 38fb0e3 | 2019-03-30 22:14:15 +0800 | [diff] [blame] | 252 | option(LWS_WITH_STRUCT_SQLITE3 "Generic struct serialization to and from SQLITE3" OFF) |
Andy Green | 0bfd391 | 2020-01-02 08:32:23 +0000 | [diff] [blame] | 253 | # broken atm |
| 254 | #option(LWS_WITH_SMTP "Provide SMTP support" OFF) |
Andy Green | d7294a7 | 2020-04-08 10:51:50 +0100 | [diff] [blame] | 255 | if (LWS_WITH_ESP32) |
Andy Green | 119aa5c | 2019-03-14 08:24:40 +0800 | [diff] [blame] | 256 | option(LWS_WITH_DIR "Directory scanning api support" OFF) |
Andy Green | 579ed35 | 2019-03-14 21:22:17 +0800 | [diff] [blame] | 257 | option(LWS_WITH_LEJP_CONF "With LEJP configuration parser as used by lwsws" OFF) |
Andy Green | 119aa5c | 2019-03-14 08:24:40 +0800 | [diff] [blame] | 258 | else() |
| 259 | option(LWS_WITH_DIR "Directory scanning api support" ON) |
Andy Green | 579ed35 | 2019-03-14 21:22:17 +0800 | [diff] [blame] | 260 | option(LWS_WITH_LEJP_CONF "With LEJP configuration parser as used by lwsws" ON) |
Andy Green | 119aa5c | 2019-03-14 08:24:40 +0800 | [diff] [blame] | 261 | endif() |
Andy Green | d9f793a | 2020-04-22 06:32:15 +0100 | [diff] [blame] | 262 | option(LWS_WITH_NO_LOGS "Disable all logging other than _err and _user from being compiled in" OFF) |
| 263 | set(LWS_LOGGING_BITFIELD_SET 0 CACHE STRING "Bitfield describing which log levels to force included into the build") |
| 264 | set(LWS_LOGGING_BITFIELD_CLEAR 0 CACHE STRING "Bitfield describing which log levels to force removed from the build") |
Andy Green | 9a1f184 | 2020-02-28 10:31:04 +0000 | [diff] [blame] | 265 | option(LWS_LOGS_TIMESTAMP "Timestamp at start of logs" ON) |
Andy Green | 0d588b2 | 2021-02-01 10:45:23 +0000 | [diff] [blame] | 266 | option(LWS_LOG_TAG_LIFECYCLE "Log tagged object lifecycle as NOTICE" ON) |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 267 | option(LWS_AVOID_SIGPIPE_IGN "Android 7+ reportedly needs this" OFF) |
Andy Green | 4db2ff8 | 2021-07-13 05:18:04 +0100 | [diff] [blame] | 268 | option(LWS_WITH_JOSE "JOSE JSON Web Signature / Encryption / Keys (RFC7515/6/) API" OFF) |
| 269 | option(LWS_WITH_COSE "COSE CBOR Signature / Encryption / Keys (RFC8152) API" OFF) |
Andy Green | eda102e | 2018-12-13 20:05:12 +0800 | [diff] [blame] | 270 | 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] | 271 | option(LWS_WITH_SELFTESTS "Selftests run at context creation" OFF) |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 272 | option(LWS_WITH_GCOV "Build with gcc gcov coverage instrumentation" OFF) |
Alexey Reznichenko | 9384613 | 2017-11-20 12:41:29 +0100 | [diff] [blame] | 273 | 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] | 274 | 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] | 275 | 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] | 276 | option(LWS_WITH_LWSAC "lwsac Chunk Allocation api" ON) |
Andy Green | 986bb37 | 2019-02-26 17:18:24 +0800 | [diff] [blame] | 277 | option(LWS_WITH_CUSTOM_HEADERS "Store and allow querying custom HTTP headers (H1 only)" ON) |
Andy Green | b25079c | 2021-05-26 09:13:03 +0100 | [diff] [blame] | 278 | option(LWS_WITH_DISKCACHE "Hashed cache directory with lazy LRU deletion to size limit (unrelated to lws_cache_ttl)" OFF) |
Andy Green | cbb8b1d | 2018-11-03 14:47:48 +0800 | [diff] [blame] | 279 | option(LWS_WITH_ASAN "Build with gcc runtime sanitizer options enabled (needs libasan)" OFF) |
Jackson Ming Hu | 78e1a8f | 2019-07-01 14:54:05 +0100 | [diff] [blame] | 280 | option(LWS_WITH_LEJP_CONF "With LEJP configuration parser as used by lwsws" OFF) |
Andy Green | d727c89 | 2019-07-03 19:46:23 +0100 | [diff] [blame] | 281 | option(LWS_WITH_ZLIB "Include zlib support (required for extensions)" OFF) |
| 282 | option(LWS_WITH_BUNDLED_ZLIB "Use bundled zlib version (Windows only)" ${LWS_WITH_BUNDLED_ZLIB_DEFAULT}) |
| 283 | option(LWS_WITH_MINIZ "Use miniz instead of zlib" OFF) |
Andy Green | c75654c | 2020-09-29 09:29:18 +0100 | [diff] [blame] | 284 | option(LWS_WITH_SEQUENCER "lws_seq_t support" OFF) |
Andy Green | d302198 | 2019-08-10 09:33:07 +0100 | [diff] [blame] | 285 | option(LWS_WITH_EXTERNAL_POLL "Support external POLL integration using callback messages (not recommended)" OFF) |
Andy Green | f00194c | 2019-08-11 06:47:19 +0100 | [diff] [blame] | 286 | option(LWS_WITH_LWS_DSH "Support lws_dsh_t Disordered Shared Heap" OFF) |
Andy Green | f8afcd0 | 2019-08-17 21:20:55 +0100 | [diff] [blame] | 287 | option(LWS_CLIENT_HTTP_PROXYING "Support external http proxies for client connections" ON) |
Andy Green | ae69bfb | 2019-08-18 06:29:34 +0100 | [diff] [blame] | 288 | option(LWS_WITH_FILE_OPS "Support file operations vfs" ON) |
Andy Green | f4b38f1 | 2019-09-30 09:42:38 -0700 | [diff] [blame] | 289 | option(LWS_WITH_UDP "Platform supports UDP" ON) |
Andy Green | 8a7e0ed | 2020-02-12 10:12:39 +0000 | [diff] [blame] | 290 | option(LWS_WITH_SPAWN "Spawn subprocesses with piped stdin/out/stderr" OFF) |
Andy Green | 1da0096 | 2020-02-15 10:09:50 +0000 | [diff] [blame] | 291 | option(LWS_WITH_FSMOUNT "Overlayfs and fallback mounting apis" OFF) |
Andy Green | e038332 | 2020-03-27 18:35:23 +0000 | [diff] [blame] | 292 | option(LWS_WITH_FANALYZER "Enable gcc -fanalyzer if compiler supports" OFF) |
Andy Green | 99e778a | 2020-04-23 15:12:17 +0100 | [diff] [blame] | 293 | option(LWS_HTTP_HEADERS_ALL "Override header reduction optimization and include all like older lws versions" OFF) |
Andy Green | 30761e7 | 2020-07-15 10:25:18 +0100 | [diff] [blame] | 294 | option(LWS_WITH_SUL_DEBUGGING "Enable zombie lws_sul checking on object deletion" OFF) |
Andy Green | 1d05f42 | 2020-08-30 07:39:27 +0100 | [diff] [blame] | 295 | option(LWS_WITH_PLUGINS_API "Build generic lws_plugins apis (see LWS_WITH_PLUGINS to also build protocol plugins)" OFF) |
Andy Green | 06509e2 | 2021-03-15 05:20:15 +0000 | [diff] [blame] | 296 | option(LWS_WITH_CONMON "Collect introspectable connection latency stats on individual client connections" ON) |
Andy Green | 3502845 | 2021-04-20 14:58:20 +0100 | [diff] [blame] | 297 | option(LWS_WITHOUT_EVENTFD "Force using pipe instead of eventfd" OFF) |
Yichen Gu | b31c5d6 | 2021-07-05 16:41:41 +0800 | [diff] [blame] | 298 | if (UNIX OR WIN32) |
| 299 | option(LWS_WITH_CACHE_NSCOOKIEJAR "Build file-backed lws-cache-ttl that uses netscape cookie jar format (linux-only)" ON) |
| 300 | else() |
| 301 | option(LWS_WITH_CACHE_NSCOOKIEJAR "Build file-backed lws-cache-ttl that uses netscape cookie jar format (linux-only)" OFF) |
| 302 | endif() |
Andy Green | f4b38f1 | 2019-09-30 09:42:38 -0700 | [diff] [blame] | 303 | |
Andy Green | 643a001 | 2020-10-04 07:28:41 +0100 | [diff] [blame] | 304 | if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") |
| 305 | option(LWS_WITH_NETLINK "Monitor Netlink for Routing Table changes" ON) |
| 306 | else() |
| 307 | set(LWS_WITH_NETLINK 0) |
| 308 | endif() |
| 309 | |
Andy Green | c00ece3 | 2021-03-08 10:52:06 +0000 | [diff] [blame] | 310 | if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") |
| 311 | # its openssl has md5 deprecated |
| 312 | set(LWS_SUPPRESS_DEPRECATED_API_WARNINGS 1) |
| 313 | endif() |
| 314 | |
Andy Green | 643a001 | 2020-10-04 07:28:41 +0100 | [diff] [blame] | 315 | |
Andy Green | d727c89 | 2019-07-03 19:46:23 +0100 | [diff] [blame] | 316 | # |
| 317 | # to use miniz, enable both LWS_WITH_ZLIB and LWS_WITH_MINIZ |
Andy Green | 97cd393 | 2017-10-21 09:03:42 +0800 | [diff] [blame] | 318 | # |
| 319 | # End of user settings |
| 320 | # |
| 321 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 322 | # sets of sub-options implied by other options |
| 323 | # |
Andy Green | 625bade | 2020-07-20 07:28:28 +0100 | [diff] [blame] | 324 | set(LIB_LIST "") |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 325 | set(LIB_LIST_AT_END) |
| 326 | set(LWS_LIBRARIES) |
| 327 | set(LWS_OPENSSL_SUPPORT 0) |
| 328 | include(CMakeLists-implied-options.txt) |
huangkaicheng | 974b65a | 2020-04-23 06:17:22 +0100 | [diff] [blame] | 329 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 330 | # |
| 331 | # Structural helpers for cmake in subdirs |
| 332 | # |
Jackson Ming Hu | 6b348a5 | 2019-07-01 14:48:43 +0100 | [diff] [blame] | 333 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 334 | macro(add_subdir_include_directories arg1) |
| 335 | add_subdirectory(${arg1}) |
| 336 | include_directories(${_CMAKE_INC_LIST}) |
| 337 | endmacro() |
Andy Green | 0fa5563 | 2019-08-18 10:35:43 +0100 | [diff] [blame] | 338 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 339 | macro(exports_to_parent_scope) |
| 340 | set(SOURCES ${SOURCES} PARENT_SCOPE) |
Andy Green | 2a77277 | 2020-06-07 07:53:36 +0100 | [diff] [blame] | 341 | if (LIB_LIST) |
| 342 | set(LIB_LIST ${LIB_LIST} PARENT_SCOPE) |
| 343 | endif() |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 344 | get_property(_CURR DIRECTORY PROPERTY INCLUDE_DIRECTORIES) |
| 345 | set(_CMAKE_INC_LIST ${_CURR} PARENT_SCOPE) |
Andy Green | 2a77277 | 2020-06-07 07:53:36 +0100 | [diff] [blame] | 346 | if (LWS_LIB_BUILD_INC_PATHS) |
| 347 | set(LWS_LIB_BUILD_INC_PATHS ${LWS_LIB_BUILD_INC_PATHS} PARENT_SCOPE) |
| 348 | endif() |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 349 | endmacro() |
Andy Green | f4b38f1 | 2019-09-30 09:42:38 -0700 | [diff] [blame] | 350 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 351 | macro(export_to_parent_intermediate) |
| 352 | set(SOURCES ${SOURCES} PARENT_SCOPE) |
Andy Green | 2a77277 | 2020-06-07 07:53:36 +0100 | [diff] [blame] | 353 | if (LIB_LIST) |
| 354 | set(LIB_LIST ${LIB_LIST} PARENT_SCOPE) |
| 355 | endif() |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 356 | set(_CMAKE_INC_LIST ${_CMAKE_INC_LIST} PARENT_SCOPE) |
Andy Green | 2a77277 | 2020-06-07 07:53:36 +0100 | [diff] [blame] | 357 | if (LWS_LIB_BUILD_INC_PATHS) |
| 358 | set(LWS_LIB_BUILD_INC_PATHS ${LWS_LIB_BUILD_INC_PATHS} PARENT_SCOPE) |
| 359 | endif() |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 360 | endmacro() |
Jackson Ming Hu | 78e1a8f | 2019-07-01 14:54:05 +0100 | [diff] [blame] | 361 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 362 | # |
| 363 | # Try to find the current Git hash |
| 364 | # |
Andy Green | 1d9d04f | 2018-01-27 08:01:33 +0800 | [diff] [blame] | 365 | |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 366 | find_package(Git) |
| 367 | if(GIT_EXECUTABLE) |
| 368 | execute_process( |
Alexander Couzens | d7b6c04 | 2017-12-10 00:54:06 +0100 | [diff] [blame] | 369 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
Andy Green | 5e99b9f | 2020-04-06 13:22:01 +0100 | [diff] [blame] | 370 | COMMAND "${GIT_EXECUTABLE}" describe --tags --always |
Alexander Couzens | d7b6c04 | 2017-12-10 00:54:06 +0100 | [diff] [blame] | 371 | OUTPUT_VARIABLE GIT_HASH |
| 372 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 373 | ) |
| 374 | set(LWS_BUILD_HASH ${GIT_HASH}) |
| 375 | |
Andy Green | 8140c71 | 2018-05-15 12:44:31 +0800 | [diff] [blame] | 376 | # append the build user and hostname |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 377 | if (NOT LWS_REPRODUCIBLE) |
Alexander Couzens | d7b6c04 | 2017-12-10 00:54:06 +0100 | [diff] [blame] | 378 | execute_process( |
| 379 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
| 380 | COMMAND "whoami" |
| 381 | OUTPUT_VARIABLE GIT_USER |
| 382 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 383 | ) |
| 384 | execute_process( |
| 385 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
| 386 | COMMAND "hostname" |
| 387 | OUTPUT_VARIABLE GIT_HOST |
| 388 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 389 | ) |
| 390 | string(REGEX REPLACE "([^\\])[\\]([^\\])" "\\1\\\\\\\\\\2" GIT_USER ${GIT_USER}) |
| 391 | set(LWS_BUILD_HASH ${GIT_USER}@${GIT_HOST}-${GIT_HASH}) |
| 392 | endif() |
| 393 | |
| 394 | message("Git commit hash: ${LWS_BUILD_HASH}") |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 395 | endif() |
| 396 | |
Andreas Weigel | 02f0d75 | 2021-04-20 08:30:18 -0400 | [diff] [blame] | 397 | if ("${LWS_BUILD_HASH}" STREQUAL "") |
| 398 | set(LWS_BUILD_HASH "unknown") |
| 399 | endif() |
| 400 | |
Andy Green | cb0ea63 | 2020-05-01 05:45:18 +0100 | [diff] [blame] | 401 | set(PACKAGE "libwebsockets") |
| 402 | set(CPACK_RPM_PACKAGE_LICENSE "MIT") |
| 403 | set(CPACK_PACKAGE_NAME "${PACKAGE}") |
| 404 | set(CPACK_PACKAGE_VERSION_MAJOR "4") |
Andy Green | a5aae04 | 2021-10-04 13:36:44 +0100 | [diff] [blame] | 405 | set(CPACK_PACKAGE_VERSION_MINOR "3") |
| 406 | set(CPACK_PACKAGE_VERSION_PATCH_NUMBER "0") |
Andy Green | 9f5bc01 | 2020-05-29 08:24:07 +0100 | [diff] [blame] | 407 | |
| 408 | set(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH_NUMBER}-${LWS_BUILD_HASH}") |
Andy Green | cb0ea63 | 2020-05-01 05:45:18 +0100 | [diff] [blame] | 409 | set(CPACK_PACKAGE_RELEASE 1) |
| 410 | |
| 411 | set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") |
| 412 | set(CPACK_PACKAGE_VENDOR "andy@warmcat.com") |
| 413 | set(CPACK_PACKAGE_CONTACT "andy@warmcat.com") |
Andy Green | cabe021 | 2020-05-14 21:28:48 +0100 | [diff] [blame] | 414 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE} ${CPACK_PACKAGE_VERSION}") |
Andy Green | a5aae04 | 2021-10-04 13:36:44 +0100 | [diff] [blame] | 415 | set(SOVERSION "19") |
Andy Green | cb0ea63 | 2020-05-01 05:45:18 +0100 | [diff] [blame] | 416 | if(NOT CPACK_GENERATOR) |
| 417 | if(UNIX) |
| 418 | set(CPACK_GENERATOR "TGZ") |
| 419 | else() |
| 420 | set(CPACK_GENERATOR "ZIP") |
| 421 | endif() |
| 422 | endif() |
| 423 | set(CPACK_SOURCE_GENERATOR "TGZ") |
| 424 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") |
| 425 | set(VERSION "${CPACK_PACKAGE_VERSION}") |
| 426 | |
| 427 | set(CPACK_RPM_PACKAGE_RELEASE_DIST ON) |
| 428 | set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") |
Andy Green | c6c7ab2 | 2020-08-27 15:37:14 +0100 | [diff] [blame] | 429 | # below makes path length problems in CI |
| 430 | set(CPACK_RPM_DEBUGINFO_PACKAGE OFF) |
Andy Green | cb0ea63 | 2020-05-01 05:45:18 +0100 | [diff] [blame] | 431 | # below makes some kind of chimera rpm with binaries and sources |
| 432 | set(CPACK_RPM_PACKAGE_SOURCES OFF) |
| 433 | set(CPACK_RPM_INSTALL_WITH_EXEC ON) |
Andy Green | c6c7ab2 | 2020-08-27 15:37:14 +0100 | [diff] [blame] | 434 | set(CPACK_RPM_COMPONENT_INSTALL ON) |
Andy Green | cb0ea63 | 2020-05-01 05:45:18 +0100 | [diff] [blame] | 435 | |
| 436 | set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") |
| 437 | set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) |
| 438 | set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) |
| 439 | set(CPACK_DEBIAN_PACKAGE_SOURCE ON) |
Andy Green | c6c7ab2 | 2020-08-27 15:37:14 +0100 | [diff] [blame] | 440 | set(CPACK_DEBIAN_COMPONENT_INSTALL ON) |
| 441 | |
Andy Green | cb0ea63 | 2020-05-01 05:45:18 +0100 | [diff] [blame] | 442 | |
| 443 | set(LWS_LIBRARY_VERSION ${CPACK_PACKAGE_VERSION}) |
| 444 | set(LWS_LIBRARY_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR}) |
| 445 | set(LWS_LIBRARY_VERSION_MINOR ${CPACK_PACKAGE_VERSION_MINOR}) |
Andy Green | 9f5bc01 | 2020-05-29 08:24:07 +0100 | [diff] [blame] | 446 | set(LWS_LIBRARY_VERSION_PATCH ${CPACK_PACKAGE_VERSION_PATCH_NUMBER}) |
| 447 | set(LWS_LIBRARY_VERSION_PATCH_ELABORATED ${CPACK_PACKAGE_VERSION_PATCH}) |
Andy Green | cb0ea63 | 2020-05-01 05:45:18 +0100 | [diff] [blame] | 448 | |
Andy Green | cabe021 | 2020-05-14 21:28:48 +0100 | [diff] [blame] | 449 | if (NOT CMAKE_MODULE_PATH) |
| 450 | set(CMAKE_MODULE_PATH "") |
| 451 | endif() |
Andy Green | cb0ea63 | 2020-05-01 05:45:18 +0100 | [diff] [blame] | 452 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/") |
| 453 | |
| 454 | |
Andy Green | cabe021 | 2020-05-14 21:28:48 +0100 | [diff] [blame] | 455 | if (CMAKE_TOOLCHAIN_FILE) |
| 456 | message(STATUS "CMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}'") |
| 457 | endif() |
| 458 | |
| 459 | if (NOT LIB_SUFFIX) |
| 460 | set(LIB_SUFFIX "") |
| 461 | endif() |
Andy Green | cb0ea63 | 2020-05-01 05:45:18 +0100 | [diff] [blame] | 462 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 463 | if (WIN32) |
Andy Green | cb0ea63 | 2020-05-01 05:45:18 +0100 | [diff] [blame] | 464 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/win32port/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/win32port/version.rc @ONLY) |
| 465 | set(RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/win32port/version.rc) |
| 466 | endif() |
| 467 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 468 | include_directories(include) |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 469 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 470 | # Allow the user to override installation directories. |
| 471 | set(LWS_INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") |
| 472 | set(LWS_INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables") |
| 473 | set(LWS_INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files") |
| 474 | set(LWS_INSTALL_EXAMPLES_DIR bin CACHE PATH "Installation directory for example files") |
| 475 | |
Andy Green | d727c89 | 2019-07-03 19:46:23 +0100 | [diff] [blame] | 476 | # if you gave LWS_WITH_MINIZ, point to MINIZ here if not found |
| 477 | # automatically |
| 478 | |
| 479 | set(LWS_ZLIB_LIBRARIES CACHE PATH "Path to the zlib/miniz library") |
| 480 | set(LWS_ZLIB_INCLUDE_DIRS CACHE PATH "Path to the zlib/miniz include directory") |
Yuchen Xie | 936bf08 | 2017-02-18 15:51:34 +0800 | [diff] [blame] | 481 | set(LWS_SQLITE3_LIBRARIES CACHE PATH "Path to the sqlite3 library") |
| 482 | set(LWS_SQLITE3_INCLUDE_DIRS CACHE PATH "Path to the sqlite3 include directory") |
Andy Green | 1da0096 | 2020-02-15 10:09:50 +0000 | [diff] [blame] | 483 | set(LWS_LIBMOUNT_INCLUDE_DIRS CACHE PATH "Path to the libmount include directory") |
| 484 | set(LWS_LIBMOUNT_LIBRARIES CACHE PATH "Path to the libmount library") |
Andy Green | d3308df | 2020-04-07 14:05:21 +0100 | [diff] [blame] | 485 | # on unix, these are in the toolchain. On win32 you have to put them somewhere |
| 486 | # yourself and point to them here |
| 487 | set(LWS_EXT_PTHREAD_INCLUDE_DIR CACHE PATH "Path to an external pthreads include directory") |
| 488 | set(LWS_EXT_PTHREAD_LIBRARIES CACHE PATH "Path to an external pthreads library") |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 489 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 490 | |
Andy Green | d588286 | 2018-09-02 14:43:05 +0800 | [diff] [blame] | 491 | if (LWS_WITH_HTTP_STREAM_COMPRESSION) |
| 492 | set(LWS_WITH_ZLIB 1) |
| 493 | endif() |
| 494 | |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 495 | if (LWS_WITH_ZLIB AND NOT LWS_WITH_BUNDLED_ZLIB) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 496 | if ("${LWS_ZLIB_LIBRARIES}" STREQUAL "" OR "${LWS_ZLIB_INCLUDE_DIRS}" STREQUAL "") |
| 497 | else() |
| 498 | set(ZLIB_LIBRARIES ${LWS_ZLIB_LIBRARIES}) |
| 499 | set(ZLIB_INCLUDE_DIRS ${LWS_ZLIB_INCLUDE_DIRS}) |
| 500 | set(ZLIB_FOUND 1) |
| 501 | endif() |
| 502 | endif() |
| 503 | |
Andy Green | af2f1f9 | 2020-02-07 11:39:32 +0000 | [diff] [blame] | 504 | |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 505 | if (LWS_WITH_SQLITE3) |
| 506 | if ("${LWS_SQLITE3_LIBRARIES}" STREQUAL "" OR "${LWS_SQLITE3_INCLUDE_DIRS}" STREQUAL "") |
| 507 | else() |
| 508 | set(SQLITE3_LIBRARIES ${LWS_SQLITE3_LIBRARIES}) |
| 509 | set(SQLITE3_INCLUDE_DIRS ${LWS_SQLITE3_INCLUDE_DIRS}) |
| 510 | set(SQLITE3_FOUND 1) |
| 511 | endif() |
| 512 | endif() |
| 513 | |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 514 | include_directories("${PROJECT_BINARY_DIR}") |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 515 | |
Joakim Soderberg | 4f4a38b | 2013-02-06 15:28:07 +0900 | [diff] [blame] | 516 | # Check for different inline keyword versions. |
| 517 | foreach(KEYWORD "inline" "__inline__" "__inline") |
| 518 | set(CMAKE_REQUIRED_DEFINITIONS "-DKEYWORD=${KEYWORD}") |
| 519 | CHECK_C_SOURCE_COMPILES( |
| 520 | " |
| 521 | #include <stdio.h> |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 522 | static KEYWORD void a() {} |
Joakim Soderberg | 4f4a38b | 2013-02-06 15:28:07 +0900 | [diff] [blame] | 523 | 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] | 524 | " LWS_HAVE_${KEYWORD}) |
Joakim Soderberg | 4f4a38b | 2013-02-06 15:28:07 +0900 | [diff] [blame] | 525 | endforeach() |
| 526 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 527 | if (NOT LWS_HAVE_inline) |
| 528 | if (LWS_HAVE___inline__) |
Joakim Soderberg | 4f4a38b | 2013-02-06 15:28:07 +0900 | [diff] [blame] | 529 | set(inline __inline__) |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 530 | elseif(LWS_HAVE___inline) |
Joakim Soderberg | 4f4a38b | 2013-02-06 15:28:07 +0900 | [diff] [blame] | 531 | set(inline __inline) |
| 532 | endif() |
| 533 | endif() |
| 534 | |
Peter Pentchev | fb71b79 | 2016-10-02 02:21:03 +0300 | [diff] [blame] | 535 | # Put the libraries and binaries that get built into directories at the |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 536 | # 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] | 537 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") |
| 538 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") |
| 539 | SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 540 | |
Andy Green | 0aa382f | 2016-07-06 10:48:41 +0800 | [diff] [blame] | 541 | SET(LWS_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}") |
| 542 | |
thinkski | d34bae1 | 2013-04-16 19:48:05 +0800 | [diff] [blame] | 543 | # Put absolute path of dynamic libraries into the object code. Some |
| 544 | # architectures, notably Mac OS X, need this. |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 545 | 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] | 546 | |
Andy Green | 4c79ee7 | 2015-10-15 11:20:40 +0800 | [diff] [blame] | 547 | if (LWS_WITHOUT_BUILTIN_SHA1) |
| 548 | set(LWS_SHA1_USE_OPENSSL_NAME 1) |
| 549 | endif() |
| 550 | |
Andy Green | 546a280 | 2018-10-09 15:14:12 +0800 | [diff] [blame] | 551 | CHECK_C_SOURCE_COMPILES( |
Andy Green | 4c3146c | 2019-03-16 08:10:47 +0800 | [diff] [blame] | 552 | "#include <malloc.h> |
| 553 | int main(int argc, char **argv) { return malloc_trim(0); } |
| 554 | " LWS_HAVE_MALLOC_TRIM) |
| 555 | CHECK_C_SOURCE_COMPILES( |
| 556 | "#include <malloc.h> |
| 557 | int main(int argc, char **argv) { return (int)malloc_usable_size((void *)0); } |
| 558 | " LWS_HAVE_MALLOC_USABLE_SIZE) |
Andy Green | 546a280 | 2018-10-09 15:14:12 +0800 | [diff] [blame] | 559 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 560 | CHECK_FUNCTION_EXISTS(fork LWS_HAVE_FORK) |
| 561 | CHECK_FUNCTION_EXISTS(getenv LWS_HAVE_GETENV) |
| 562 | CHECK_FUNCTION_EXISTS(malloc LWS_HAVE_MALLOC) |
| 563 | CHECK_FUNCTION_EXISTS(memset LWS_HAVE_MEMSET) |
| 564 | CHECK_FUNCTION_EXISTS(realloc LWS_HAVE_REALLOC) |
| 565 | CHECK_FUNCTION_EXISTS(socket LWS_HAVE_SOCKET) |
| 566 | CHECK_FUNCTION_EXISTS(strerror LWS_HAVE_STRERROR) |
| 567 | CHECK_FUNCTION_EXISTS(vfork LWS_HAVE_VFORK) |
Andy Green | 1a13885 | 2016-03-20 11:55:25 +0800 | [diff] [blame] | 568 | CHECK_FUNCTION_EXISTS(execvpe LWS_HAVE_EXECVPE) |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 569 | CHECK_FUNCTION_EXISTS(getifaddrs LWS_HAVE_GETIFADDRS) |
Andy Green | 7d22c29 | 2016-03-04 10:53:51 +0800 | [diff] [blame] | 570 | CHECK_FUNCTION_EXISTS(snprintf LWS_HAVE_SNPRINTF) |
| 571 | CHECK_FUNCTION_EXISTS(_snprintf LWS_HAVE__SNPRINTF) |
| 572 | CHECK_FUNCTION_EXISTS(_vsnprintf LWS_HAVE__VSNPRINTF) |
Andy Green | 12aeba7 | 2016-04-26 07:45:45 +0800 | [diff] [blame] | 573 | CHECK_FUNCTION_EXISTS(getloadavg LWS_HAVE_GETLOADAVG) |
WebsocketUser | 0be9e98 | 2017-06-09 20:20:42 +0800 | [diff] [blame] | 574 | CHECK_FUNCTION_EXISTS(atoll LWS_HAVE_ATOLL) |
| 575 | CHECK_FUNCTION_EXISTS(_atoi64 LWS_HAVE__ATOI64) |
| 576 | CHECK_FUNCTION_EXISTS(_stat32i64 LWS_HAVE__STAT32I64) |
Andy Green | 3c12fd7 | 2019-08-08 20:05:03 +0100 | [diff] [blame] | 577 | CHECK_FUNCTION_EXISTS(clock_gettime LWS_HAVE_CLOCK_GETTIME) |
Pavel Otchertsov | 932527a | 2021-03-25 09:57:49 +0300 | [diff] [blame] | 578 | CHECK_FUNCTION_EXISTS(localtime_r LWS_HAVE_LOCALTIME_R) |
Pavel Otchertsov | f84b90b | 2021-03-25 10:51:01 +0300 | [diff] [blame] | 579 | CHECK_FUNCTION_EXISTS(gmtime_r LWS_HAVE_GMTIME_R) |
Pavel Otchertsov | b5ed383 | 2021-03-25 10:33:05 +0300 | [diff] [blame] | 580 | CHECK_FUNCTION_EXISTS(ctime_r LWS_HAVE_CTIME_R) |
Andy Green | b9ee27f | 2021-03-24 06:11:03 +0000 | [diff] [blame] | 581 | CHECK_FUNCTION_EXISTS(getgrgid_r LWS_HAVE_GETGRGID_R) |
| 582 | CHECK_FUNCTION_EXISTS(getgrnam_r LWS_HAVE_GETGRNAM_R) |
| 583 | CHECK_FUNCTION_EXISTS(getpwuid_r LWS_HAVE_GETPWUID_R) |
| 584 | CHECK_FUNCTION_EXISTS(getpwnam_r LWS_HAVE_GETPWNAM_R) |
Andy Green | a7e4724 | 2021-08-01 08:55:34 +0100 | [diff] [blame] | 585 | CHECK_FUNCTION_EXISTS(timegm LWS_HAVE_TIMEGM) |
Andy Green | eb5a41e | 2020-04-13 19:28:33 +0100 | [diff] [blame] | 586 | |
caobug | cc4fd2c | 2021-05-30 23:27:43 +0800 | [diff] [blame] | 587 | if(CMAKE_SYSTEM_NAME MATCHES "Darwin") |
| 588 | if(CMAKE_OSX_DEPLOYMENT_TARGET LESS "10.12") |
| 589 | message("No clock_gettime found on macOS ${CMAKE_OSX_DEPLOYMENT_TARGET}. Disabling LWS_HAVE_CLOCK_GETTIME.") |
| 590 | set(LWS_HAVE_CLOCK_GETTIME 0) |
| 591 | endif() |
| 592 | endif() |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 593 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 594 | if (NOT LWS_HAVE_GETIFADDRS) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 595 | if (LWS_WITHOUT_BUILTIN_GETIFADDRS) |
| 596 | 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] | 597 | endif() |
| 598 | set(LWS_BUILTIN_GETIFADDRS 1) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 599 | endif() |
| 600 | |
Andy Green | d3308df | 2020-04-07 14:05:21 +0100 | [diff] [blame] | 601 | if (LWS_EXT_PTHREAD_INCLUDE_DIR) |
| 602 | set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES};${LWS_EXT_PTHREAD_INCLUDE_DIR}) |
| 603 | include_directories(${LWS_EXT_PTHREAD_INCLUDE_DIR}) |
| 604 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 605 | list(APPEND LIB_LIST_AT_END ${LWS_EXT_PTHREAD_LIBRARIES}) |
Andy Green | d3308df | 2020-04-07 14:05:21 +0100 | [diff] [blame] | 606 | set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} " -DHAVE_STRUCT_TIMESPEC=1") |
| 607 | endif() |
| 608 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 609 | # |
| 610 | # add libs here that need to be at the end of the link order |
| 611 | # |
| 612 | |
| 613 | if (LWS_EXT_PTHREAD_INCLUDE_DIR) |
| 614 | list(APPEND LIB_LIST_AT_END ${LWS_EXT_PTHREAD_LIBRARIES}) |
| 615 | endif() |
| 616 | |
| 617 | if (LWS_WITH_ZLIB AND NOT LWS_WITH_BUNDLED_ZLIB) |
| 618 | list(APPEND LIB_LIST_AT_END "${ZLIB_LIBRARIES}") |
| 619 | endif() |
| 620 | |
Andy Green | 8b82560 | 2020-12-06 19:16:48 +0000 | [diff] [blame] | 621 | if (LWS_WITH_PLUGINS_API AND UNIX AND CMAKE_DL_LIBS AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "QNX")) |
| 622 | list(APPEND LIB_LIST_AT_END ${CMAKE_DL_LIBS}) |
Andy Green | 16e8fc2 | 2020-08-31 09:19:40 +0100 | [diff] [blame] | 623 | endif() |
| 624 | |
| 625 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 626 | 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] | 627 | CHECK_INCLUDE_FILE(memory.h LWS_HAVE_MEMORY_H) |
| 628 | CHECK_INCLUDE_FILE(netinet/in.h LWS_HAVE_NETINET_IN_H) |
| 629 | CHECK_INCLUDE_FILE(stdint.h LWS_HAVE_STDINT_H) |
| 630 | CHECK_INCLUDE_FILE(stdlib.h LWS_HAVE_STDLIB_H) |
| 631 | CHECK_INCLUDE_FILE(strings.h LWS_HAVE_STRINGS_H) |
| 632 | CHECK_INCLUDE_FILE(string.h LWS_HAVE_STRING_H) |
| 633 | CHECK_INCLUDE_FILE(sys/prctl.h LWS_HAVE_SYS_PRCTL_H) |
| 634 | CHECK_INCLUDE_FILE(sys/socket.h LWS_HAVE_SYS_SOCKET_H) |
Fredrik Skogman | 9de43fc | 2016-09-09 06:48:24 +0800 | [diff] [blame] | 635 | 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] | 636 | CHECK_INCLUDE_FILE(sys/stat.h LWS_HAVE_SYS_STAT_H) |
| 637 | CHECK_INCLUDE_FILE(sys/types.h LWS_HAVE_SYS_TYPES_H) |
| 638 | CHECK_INCLUDE_FILE(unistd.h LWS_HAVE_UNISTD_H) |
| 639 | CHECK_INCLUDE_FILE(vfork.h LWS_HAVE_VFORK_H) |
Andy Green | 156363f | 2017-06-07 06:10:02 +0800 | [diff] [blame] | 640 | CHECK_INCLUDE_FILE(sys/capability.h LWS_HAVE_SYS_CAPABILITY_H) |
Andy Green | 1b43ed1 | 2018-01-26 07:22:35 +0800 | [diff] [blame] | 641 | CHECK_INCLUDE_FILE(malloc.h LWS_HAVE_MALLOC_H) |
Andy Green | 3de2e9a | 2018-03-02 09:01:22 +0800 | [diff] [blame] | 642 | CHECK_INCLUDE_FILE(pthread.h LWS_HAVE_PTHREAD_H) |
hjfbswb | 119fddb | 2019-07-31 16:31:22 +0800 | [diff] [blame] | 643 | CHECK_INCLUDE_FILE(inttypes.h LWS_HAVE_INTTYPES_H) |
Pino Toscano | c623ebf | 2020-11-01 11:24:31 +0100 | [diff] [blame] | 644 | CHECK_INCLUDE_FILE(sys/resource.h LWS_HAVE_SYS_RESOURCE_H) |
Andy Green | 156363f | 2017-06-07 06:10:02 +0800 | [diff] [blame] | 645 | |
Andy Green | 16cbbe2 | 2020-06-03 09:29:28 +0100 | [diff] [blame] | 646 | if (WIN32 OR MSVC) |
| 647 | CHECK_C_SOURCE_COMPILES("#include <winsock2.h> |
| 648 | #include <afunix.h> |
| 649 | int main() { return 0; }" LWS_HAVE_WIN32_AFUNIX_H) |
| 650 | |
| 651 | if (LWS_UNIX_SOCK AND NOT LWS_HAVE_WIN32_AFUNIX_H) |
Orgad Shaneh | aa149e4 | 2020-09-17 14:30:23 +0300 | [diff] [blame] | 652 | message("No afunix.h found. Disabling LWS_UNIX_SOCK.") |
| 653 | set(LWS_WITH_UNIX_SOCK OFF) |
Andy Green | 16cbbe2 | 2020-06-03 09:29:28 +0100 | [diff] [blame] | 654 | endif() |
| 655 | endif() |
| 656 | |
Andy Green | 31dfc4a | 2018-10-02 10:50:24 +0800 | [diff] [blame] | 657 | CHECK_LIBRARY_EXISTS(cap cap_set_flag "" LWS_HAVE_LIBCAP) |
| 658 | |
Andy Green | 4cfe81d | 2016-10-05 13:49:46 +0800 | [diff] [blame] | 659 | |
Andy Green | fc995df | 2017-09-28 11:29:03 +0800 | [diff] [blame] | 660 | if (LWS_WITH_ZLIB AND NOT LWS_WITH_BUNDLED_ZLIB) |
Andy Green | d727c89 | 2019-07-03 19:46:23 +0100 | [diff] [blame] | 661 | if (LWS_WITH_MINIZ) |
| 662 | CHECK_INCLUDE_FILE(miniz.h LWS_HAVE_ZLIB_H) |
| 663 | else() |
| 664 | CHECK_INCLUDE_FILE(zlib.h LWS_HAVE_ZLIB_H) |
| 665 | endif() |
Andy Green | 5f2a815 | 2015-11-02 08:21:08 +0800 | [diff] [blame] | 666 | endif() |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 667 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 668 | CHECK_INCLUDE_FILES("stdlib.h;stdarg.h;string.h" STDC_HEADERS) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 669 | |
Andy Green | cabe021 | 2020-05-14 21:28:48 +0100 | [diff] [blame] | 670 | if (NOT CMAKE_REQUIRED_FLAGS) |
| 671 | set(CMAKE_REQUIRED_FLAGS "") |
| 672 | endif() |
| 673 | if (NOT CMAKE_REQUIRED_INCLUDES) |
| 674 | set(CMAKE_REQUIRED_INCLUDES "") |
| 675 | endif() |
| 676 | if (NOT CMAKE_REQUIRED_LIBRARIES) |
| 677 | set(CMAKE_REQUIRED_LIBRARIES "") |
| 678 | endif() |
| 679 | |
Andy Green | 7262e14 | 2017-07-07 08:32:04 +0800 | [diff] [blame] | 680 | CHECK_C_SOURCE_COMPILES("#include <stdint.h> |
| 681 | int main(void) { |
| 682 | intptr_t test = 1; |
| 683 | return 0; |
| 684 | }" LWS_HAS_INTPTR_T) |
| 685 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 686 | if ((CMAKE_C_COMPILER_ID MATCHES "Clang") OR |
| 687 | (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) |
| 688 | set(COMPILER_IS_CLANG ON) |
| 689 | endif() |
Andy Green | 4b3801a | 2020-01-24 13:55:21 +0000 | [diff] [blame] | 690 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 691 | if (LWS_HAVE_PTHREAD_H AND NOT LWS_PLAT_FREERTOS) |
Pavel Otchertsov | ebe4454 | 2021-03-25 11:09:13 +0300 | [diff] [blame] | 692 | CHECK_C_SOURCE_COMPILES(" |
| 693 | #ifndef _GNU_SOURCE |
| 694 | #define _GNU_SOURCE |
| 695 | #endif |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 696 | #include <pthread.h> |
| 697 | int main(void) { |
Mykola Stryebkov | 0d06d4b | 2021-04-04 18:50:05 +0100 | [diff] [blame] | 698 | #ifdef __PTW32_H |
| 699 | pthread_t th = {0,0}; |
| 700 | #else |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 701 | pthread_t th = 0; |
Mykola Stryebkov | 0d06d4b | 2021-04-04 18:50:05 +0100 | [diff] [blame] | 702 | #endif |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 703 | pthread_setname_np(th, NULL); |
| 704 | return 0; |
| 705 | }" LWS_HAS_PTHREAD_SETNAME_NP) |
| 706 | endif() |
Patrick Gansterer | 8a59033 | 2014-02-28 00:42:08 +0100 | [diff] [blame] | 707 | |
Andy Green | 6139933 | 2019-01-11 18:19:21 +0800 | [diff] [blame] | 708 | CHECK_C_SOURCE_COMPILES("#include <stddef.h> |
Fabrice Fontaine | 6e35da9 | 2020-01-03 14:02:06 +0000 | [diff] [blame] | 709 | #include <getopt.h> |
| 710 | int main(void) { |
pblemel | 39e19c8 | 2019-01-11 16:48:53 +0800 | [diff] [blame] | 711 | void *p = (void *)getopt_long; |
| 712 | return p != NULL; |
| 713 | }" LWS_HAS_GETOPT_LONG) |
| 714 | |
owent | dddc68e | 2020-10-09 17:48:39 +0800 | [diff] [blame] | 715 | CHECK_C_SOURCE_COMPILES("#include <linux/rtnetlink.h> |
| 716 | int main(void) { |
| 717 | int test = RTA_PREF; |
| 718 | return 0; |
| 719 | }" LWS_HAVE_RTA_PREF) |
pblemel | 39e19c8 | 2019-01-11 16:48:53 +0800 | [diff] [blame] | 720 | |
Andy Green | c9731c5 | 2020-12-12 06:21:40 +0000 | [diff] [blame] | 721 | CHECK_C_SOURCE_COMPILES("#include <sys/types.h> |
| 722 | int main(void) { |
| 723 | suseconds_t x = 0; |
| 724 | return (int)x; |
| 725 | }" LWS_HAVE_SUSECONDS_T) |
| 726 | |
Patrick Gansterer | 8a59033 | 2014-02-28 00:42:08 +0100 | [diff] [blame] | 727 | if (NOT PID_T_SIZE) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 728 | set(pid_t int) |
Patrick Gansterer | 8a59033 | 2014-02-28 00:42:08 +0100 | [diff] [blame] | 729 | endif() |
| 730 | |
| 731 | if (NOT SIZE_T_SIZE) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 732 | set(size_t "unsigned int") |
| 733 | endif() |
| 734 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 735 | if (NOT LWS_HAVE_MALLOC) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 736 | set(malloc rpl_malloc) |
| 737 | endif() |
| 738 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 739 | if (NOT LWS_HAVE_REALLOC) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 740 | set(realloc rpl_realloc) |
| 741 | endif() |
| 742 | |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 743 | |
Andy Green | da3f6ff | 2013-03-16 12:32:59 +0800 | [diff] [blame] | 744 | |
Jens Alfke | d7ddd49 | 2019-06-20 16:16:03 -0700 | [diff] [blame] | 745 | |
| 746 | if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG) |
Steven Lai | ba3c75c | 2015-01-27 19:46:26 +0800 | [diff] [blame] | 747 | include (CheckCCompilerFlag) |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 748 | CHECK_C_COMPILER_FLAG(-fvisibility=hidden LWS_HAVE_VISIBILITY) |
Andy Green | e038332 | 2020-03-27 18:35:23 +0000 | [diff] [blame] | 749 | if (LWS_WITH_FANALYZER) |
| 750 | CHECK_C_COMPILER_FLAG(-fanalyzer LWS_HAVE_FANALYZER) |
| 751 | endif() |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 752 | if (LWS_HAVE_VISIBILITY) |
Steven Lai | ba3c75c | 2015-01-27 19:46:26 +0800 | [diff] [blame] | 753 | set(VISIBILITY_FLAG -fvisibility=hidden) |
| 754 | endif() |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 755 | if (LWS_WITH_GCOV) |
Andy Green | b50e9fb | 2019-02-28 07:05:12 +0800 | [diff] [blame] | 756 | set (GCOV_FLAGS "-fprofile-arcs -ftest-coverage ") |
Andy Green | cabe021 | 2020-05-14 21:28:48 +0100 | [diff] [blame] | 757 | else() |
| 758 | set(GCOV_FLAGS "") |
Andy Green | 5b74d71 | 2017-11-14 11:25:54 +0800 | [diff] [blame] | 759 | endif() |
Andy Green | 7b227eb | 2018-04-20 10:33:23 +0800 | [diff] [blame] | 760 | |
Andy Green | cbb8b1d | 2018-11-03 14:47:48 +0800 | [diff] [blame] | 761 | if (LWS_WITH_ASAN) |
Jens Alfke | d7ddd49 | 2019-06-20 16:16:03 -0700 | [diff] [blame] | 762 | set (ASAN_FLAGS "-fsanitize=address -fsanitize=undefined -fsanitize-address-use-after-scope -fsanitize-undefined-trap-on-error") |
| 763 | if (NOT COMPILER_IS_CLANG) |
| 764 | set (ASAN_FLAGS "${ASAN_FLAGS} -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=leak") |
| 765 | endif() |
Andy Green | cbb8b1d | 2018-11-03 14:47:48 +0800 | [diff] [blame] | 766 | message("Enabling ASAN") |
Andy Green | cabe021 | 2020-05-14 21:28:48 +0100 | [diff] [blame] | 767 | else() |
| 768 | set(ASAN_FLAGS "") |
Andy Green | cbb8b1d | 2018-11-03 14:47:48 +0800 | [diff] [blame] | 769 | endif() |
Andy Green | 7b227eb | 2018-04-20 10:33:23 +0800 | [diff] [blame] | 770 | |
Andy Green | 8a0ab2d | 2019-05-15 07:27:18 +0100 | [diff] [blame] | 771 | check_c_compiler_flag("-Wignored-qualifiers" LWS_GCC_HAS_IGNORED_QUALIFIERS) |
| 772 | check_c_compiler_flag("-Wtype-limits" LWS_GCC_HAS_TYPE_LIMITS) |
Andy Green | 8e5f849 | 2021-02-14 06:05:16 +0000 | [diff] [blame] | 773 | check_c_compiler_flag("-Wno-deprecated-declarations" LWS_GCC_HAS_NO_DEPRECATED_DECLARATIONS) |
Andy Green | 8a0ab2d | 2019-05-15 07:27:18 +0100 | [diff] [blame] | 774 | |
| 775 | if (LWS_GCC_HAS_IGNORED_QUALIFIERS) |
| 776 | set(CMAKE_C_FLAGS "-Wignored-qualifiers ${CMAKE_C_FLAGS}" ) |
| 777 | endif() |
| 778 | |
| 779 | if (LWS_GCC_HAS_TYPE_LIMITS) |
| 780 | set(CMAKE_C_FLAGS "-Wtype-limits ${CMAKE_C_FLAGS}" ) |
| 781 | endif() |
| 782 | |
Andy Green | e038332 | 2020-03-27 18:35:23 +0000 | [diff] [blame] | 783 | if (LWS_WITH_FANALYZER AND LWS_HAVE_FANALYZER) |
| 784 | set(CMAKE_C_FLAGS "-fanalyzer ${CMAKE_C_FLAGS}" ) |
| 785 | endif() |
| 786 | |
Orgad Shaneh | 3ef3362 | 2020-09-15 15:00:09 +0300 | [diff] [blame] | 787 | if (CMAKE_COMPILER_IS_CLANG OR CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4) |
Orgad Shaneh | 0938607 | 2020-08-30 09:28:35 +0300 | [diff] [blame] | 788 | set(CMAKE_C_FLAGS "-Wuninitialized ${CMAKE_C_FLAGS}") |
| 789 | endif() |
Andy Green | da3f6ff | 2013-03-16 12:32:59 +0800 | [diff] [blame] | 790 | |
Orgad Shaneh | 0938607 | 2020-08-30 09:28:35 +0300 | [diff] [blame] | 791 | # always warn all and generate debug info |
| 792 | if (UNIX AND NOT LWS_PLAT_FREERTOS) |
Andy Green | fabe78d | 2021-06-28 11:51:44 +0100 | [diff] [blame] | 793 | set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wconversion -Wsign-compare -Wstrict-aliasing ${VISIBILITY_FLAG} -Wundef ${GCOV_FLAGS} ${CMAKE_C_FLAGS} ${ASAN_FLAGS}" ) |
Orgad Shaneh | 0938607 | 2020-08-30 09:28:35 +0300 | [diff] [blame] | 794 | else() |
Andy Green | bdc3a11 | 2020-09-29 16:58:05 +0100 | [diff] [blame] | 795 | set(CMAKE_C_FLAGS "-Wall -Wsign-compare ${VISIBILITY_FLAG} ${GCOV_FLAGS} ${CMAKE_C_FLAGS}" ) |
Orgad Shaneh | 0938607 | 2020-08-30 09:28:35 +0300 | [diff] [blame] | 796 | endif() |
| 797 | |
| 798 | if ("${DISABLE_WERROR}" STREQUAL "OFF") |
| 799 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") |
| 800 | endif() |
Andy Green | 8e5f849 | 2021-02-14 06:05:16 +0000 | [diff] [blame] | 801 | |
| 802 | if (LWS_SUPPRESS_DEPRECATED_API_WARNINGS) |
| 803 | set(CMAKE_C_FLAGS "-Wno-deprecated ${CMAKE_C_FLAGS}") |
| 804 | if (LWS_GCC_HAS_NO_DEPRECATED_DECLARATIONS) |
| 805 | set(CMAKE_C_FLAGS "-Wno-deprecated-declarations ${CMAKE_C_FLAGS}") |
| 806 | endif() |
| 807 | endif() |
Orgad Shaneh | 0938607 | 2020-08-30 09:28:35 +0300 | [diff] [blame] | 808 | endif () |
Andy Green | 043700a | 2019-01-15 06:59:48 +0800 | [diff] [blame] | 809 | |
Andy Green | aa3c8cd | 2016-01-25 21:39:07 +0800 | [diff] [blame] | 810 | if ((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT LWS_WITHOUT_TESTAPPS) |
SCRockz | ad7b17f | 2020-09-03 08:20:16 +0100 | [diff] [blame] | 811 | if (UNIX AND LWS_HAVE_PTHREAD_H AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "QNX")) |
Andy Green | 09b8a71 | 2015-11-29 19:41:13 +0800 | [diff] [blame] | 812 | # jeez clang understands -pthread but dies if he sees it at link time! |
| 813 | # http://stackoverflow.com/questions/2391194/what-is-gs-pthread-equiv-in-clang |
| 814 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread" ) |
Andy Green | 962e9ee | 2020-09-28 10:13:39 +0100 | [diff] [blame] | 815 | list(APPEND LIB_LIST_AT_END -lpthread) |
Andy Green | 09b8a71 | 2015-11-29 19:41:13 +0800 | [diff] [blame] | 816 | endif() |
| 817 | endif() |
| 818 | |
Jens Alfke | d7ddd49 | 2019-06-20 16:16:03 -0700 | [diff] [blame] | 819 | if (COMPILER_IS_CLANG) |
Andy Green | f6e6818 | 2018-11-05 10:25:36 +0800 | [diff] [blame] | 820 | |
Andy Green | 1700265 | 2015-11-29 19:19:09 +0800 | [diff] [blame] | 821 | # otherwise osx blows a bunch of openssl deprecated api errors |
| 822 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations" ) |
Andy Green | f6e6818 | 2018-11-05 10:25:36 +0800 | [diff] [blame] | 823 | if (UNIX AND LWS_HAVE_PTHREAD_H) |
Andy Green | 4b3801a | 2020-01-24 13:55:21 +0000 | [diff] [blame] | 824 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -Wno-error=unused-command-line-argument" ) |
Andy Green | f6e6818 | 2018-11-05 10:25:36 +0800 | [diff] [blame] | 825 | endif() |
Andy Green | 1700265 | 2015-11-29 19:19:09 +0800 | [diff] [blame] | 826 | endif() |
| 827 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 828 | if (WINCE) |
| 829 | list(APPEND LIB_LIST_AT_END ws2.lib) |
| 830 | elseif (WIN32) |
Andy Green | 77062d1 | 2020-08-05 12:01:14 +0100 | [diff] [blame] | 831 | list(APPEND LIB_LIST_AT_END ws2_32.lib userenv.lib psapi.lib iphlpapi.lib crypt32.lib) |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 832 | endif() |
| 833 | |
| 834 | if (MSVC) |
| 835 | # Turn off pointless microsoft security warnings. |
| 836 | add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) |
| 837 | # Fail the build if any warnings |
| 838 | add_compile_options(/W3 /WX) |
Felipe Gasper | b53a09f | 2021-10-13 01:47:40 -0400 | [diff] [blame] | 839 | # Unbreak MSVC broken preprocessor __VA_ARGS__ behaviour |
| 840 | add_compile_options(/Zc:preprocessor /experimental:preprocessor /wd5105) |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 841 | endif(MSVC) |
| 842 | |
| 843 | if (MINGW) |
| 844 | set(LWS_MINGW_SUPPORT 1) |
| 845 | set(CMAKE_C_FLAGS "-D__USE_MINGW_ANSI_STDIO ${CMAKE_C_FLAGS}") |
| 846 | add_definitions(-DWINVER=0x0601 -D_WIN32_WINNT=0x0601) |
| 847 | endif() |
| 848 | |
Andy Green | 2a77277 | 2020-06-07 07:53:36 +0100 | [diff] [blame] | 849 | if (HDR_PRIVATE) |
| 850 | source_group("Headers Private" FILES ${HDR_PRIVATE}) |
| 851 | endif() |
| 852 | if (HDR_PUBLIC) |
| 853 | source_group("Headers Public" FILES ${HDR_PUBLIC}) |
| 854 | endif() |
| 855 | if (SOURCES) |
| 856 | source_group("Sources" FILES ${SOURCES}) |
| 857 | endif() |
Andy Green | cabe021 | 2020-05-14 21:28:48 +0100 | [diff] [blame] | 858 | if (RESOURCES) |
| 859 | source_group("Resources" FILES ${RESOURCES}) |
| 860 | endif() |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 861 | |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 862 | |
| 863 | # |
Andy Green | d588286 | 2018-09-02 14:43:05 +0800 | [diff] [blame] | 864 | # ZLIB (needed for deflate extension and if LWS_WITH_HTTP_STREAM_COMPRESSION) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 865 | # |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 866 | if (LWS_WITH_ZLIB) |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 867 | if (NOT ZLIB_FOUND) |
Andy Green | d727c89 | 2019-07-03 19:46:23 +0100 | [diff] [blame] | 868 | if (LWS_WITH_MINIZ) |
| 869 | find_package(Miniz REQUIRED) |
Orefkov Aleksander | c226da3 | 2021-10-12 10:13:18 +0300 | [diff] [blame] | 870 | set(ZLIB_INCLUDE_DIRS ${MINIZ_INCLUDE_DIR}) |
Andy Green | d727c89 | 2019-07-03 19:46:23 +0100 | [diff] [blame] | 871 | set(ZLIB_LIBRARIES ${MINIZ_LIBRARIES}) |
| 872 | else() |
| 873 | find_package(ZLIB REQUIRED) |
| 874 | endif() |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 875 | endif() |
Andy Green | d727c89 | 2019-07-03 19:46:23 +0100 | [diff] [blame] | 876 | message("zlib/miniz include dirs: ${ZLIB_INCLUDE_DIRS}") |
| 877 | message("zlib/miniz libraries: ${ZLIB_LIBRARIES}") |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 878 | include_directories(${ZLIB_INCLUDE_DIRS}) |
Andy Green | 2cb705f | 2020-02-06 06:51:19 +0000 | [diff] [blame] | 879 | # done later at end of link list |
| 880 | # list(APPEND LIB_LIST ${ZLIB_LIBRARIES}) |
Arenoros | 8a765d7 | 2020-05-28 21:55:08 +0300 | [diff] [blame] | 881 | set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ZLIB_LIBRARIES}) |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 882 | list(APPEND LIB_LIST_AT_END ${ZLIB_LIBRARIES}) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 883 | endif() |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 884 | |
Andy Green | af2f1f9 | 2020-02-07 11:39:32 +0000 | [diff] [blame] | 885 | |
Andy Green | 1da0096 | 2020-02-15 10:09:50 +0000 | [diff] [blame] | 886 | if (LWS_WITH_FSMOUNT AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") |
Andy Green | 425da07 | 2020-06-03 17:14:03 +0100 | [diff] [blame] | 887 | if (NOT LWS_LIBMOUNT_INCLUDE_DIRS STREQUAL "") |
| 888 | include_directories(${LWS_LIBMOUNT_INCLUDE_DIRS}) |
| 889 | message("libmount include dir: ${LWS_LIBMOUNT_INCLUDE_DIRS}") |
| 890 | endif() |
| 891 | if (NOT LWS_LIBMOUNT_LIBRARIES STREQUAL "") |
| 892 | message("libmount libraries: ${LWS_LIBMOUNT_LIBRARIES}") |
| 893 | list(APPEND LIB_LIST ${LWS_LIBMOUNT_LIBRARIES}) |
| 894 | else() |
| 895 | list(APPEND LIB_LIST mount) |
| 896 | endif() |
Andy Green | 1da0096 | 2020-02-15 10:09:50 +0000 | [diff] [blame] | 897 | endif() |
Andy Green | af2f1f9 | 2020-02-07 11:39:32 +0000 | [diff] [blame] | 898 | |
| 899 | |
Andy Green | 7a2fc44 | 2016-05-19 15:28:31 +0800 | [diff] [blame] | 900 | if (LWS_WITH_SQLITE3) |
| 901 | if (NOT SQLITE3_FOUND) |
| 902 | find_path(SQLITE3_INCLUDE_DIRS NAMES sqlite3.h) |
| 903 | find_library(SQLITE3_LIBRARIES NAMES sqlite3) |
| 904 | if(SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES) |
| 905 | set(SQLITE3_FOUND 1) |
| 906 | endif() |
| 907 | endif() |
| 908 | message("sqlite3 include dir: ${SQLITE3_INCLUDE_DIRS}") |
| 909 | message("sqlite3 libraries: ${SQLITE3_LIBRARIES}") |
| 910 | include_directories("${SQLITE3_INCLUDE_DIRS}") |
| 911 | list(APPEND LIB_LIST ${SQLITE3_LIBRARIES}) |
| 912 | endif() |
| 913 | |
| 914 | |
Andy Green | fd810f1 | 2018-09-04 08:06:46 +0800 | [diff] [blame] | 915 | if (LWS_WITH_HUBBUB) |
Yuchen Xie | 63477de | 2016-10-10 20:10:34 +0800 | [diff] [blame] | 916 | find_library(LIBHUBBUB_LIBRARIES NAMES hubbub) |
Andy Green | 1e5a9ad | 2016-03-20 11:59:53 +0800 | [diff] [blame] | 917 | list(APPEND LIB_LIST ${LIBHUBBUB_LIBRARIES} ) |
| 918 | endif() |
| 919 | |
Laszlo Boszormenyi (GCS) | 355be53 | 2020-07-19 16:29:07 +0200 | [diff] [blame] | 920 | if (LWS_HAVE_LIBCAP) |
| 921 | find_library(LIBCAP_LIBRARIES NAMES cap) |
| 922 | list(APPEND LIB_LIST ${LIBCAP_LIBRARIES} ) |
| 923 | endif() |
| 924 | |
Andy Green | 0e6df74 | 2021-01-31 05:50:12 +0000 | [diff] [blame] | 925 | if (LWS_WITH_PLUGINS_BUILTIN) |
| 926 | add_subdirectory(plugins) |
| 927 | endif() |
| 928 | |
Andy Green | 425da07 | 2020-06-03 17:14:03 +0100 | [diff] [blame] | 929 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 930 | # |
| 931 | # Append the "at end" pieces to the lib list |
| 932 | # |
| 933 | list(APPEND LIB_LIST ${LIB_LIST_AT_END}) |
Andy Green | 86ed65f | 2016-02-14 09:27:41 +0800 | [diff] [blame] | 934 | |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 935 | # |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 936 | # Second-level CMakeLists |
Andy Green | 2cb705f | 2020-02-06 06:51:19 +0000 | [diff] [blame] | 937 | # |
| 938 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 939 | include_directories("${PROJECT_SOURCE_DIR}/lib") |
Andy Green | 1725332 | 2017-06-19 12:29:48 +0800 | [diff] [blame] | 940 | |
Andy Green | 0e6df74 | 2021-01-31 05:50:12 +0000 | [diff] [blame] | 941 | add_subdirectory(lib) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 942 | |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 943 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 944 | if(WIN32 AND NOT CYGWIN) |
| 945 | set(DEF_INSTALL_CMAKE_DIR cmake) |
| 946 | else() |
Andrew Cooks | cdcf5fc | 2016-01-17 13:54:13 +0800 | [diff] [blame] | 947 | set(DEF_INSTALL_CMAKE_DIR lib${LIB_SUFFIX}/cmake/libwebsockets) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 948 | endif() |
Andy Green | 43f9af2 | 2020-11-25 10:58:09 +0000 | [diff] [blame] | 949 | |
| 950 | configure_file(${PROJECT_SOURCE_DIR}/cmake/LwsCheckRequirements.cmake |
| 951 | ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/LwsCheckRequirements.cmake |
| 952 | @ONLY) |
| 953 | |
| 954 | configure_file(${PROJECT_SOURCE_DIR}/cmake/LwsCheckRequirements.cmake |
| 955 | ${PROJECT_BINARY_DIR}/LwsCheckRequirements.cmake |
| 956 | @ONLY) |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 957 | |
| 958 | # Generate version info for both build-tree and install-tree. |
| 959 | configure_file(${PROJECT_SOURCE_DIR}/cmake/libwebsockets-config-version.cmake.in |
| 960 | ${PROJECT_BINARY_DIR}/libwebsockets-config-version.cmake |
| 961 | @ONLY) |
| 962 | |
| 963 | # Generate the config file for the build-tree. |
| 964 | set(LWS__INCLUDE_DIRS |
| 965 | "${PROJECT_SOURCE_DIR}/lib" |
| 966 | "${PROJECT_BINARY_DIR}") |
| 967 | set(LIBWEBSOCKETS_INCLUDE_DIRS ${LWS__INCLUDE_DIRS} CACHE PATH "Libwebsockets include directories") |
| 968 | configure_file(${PROJECT_SOURCE_DIR}/cmake/libwebsockets-config.cmake.in |
| 969 | ${PROJECT_BINARY_DIR}/libwebsockets-config.cmake |
| 970 | @ONLY) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 971 | set(LWS_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files") |
| 972 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 973 | # 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] | 974 | if (LWS_WITH_EXPORT_LWSTARGETS) |
| 975 | export(TARGETS ${LWS_LIBRARIES} |
| 976 | FILE "${PROJECT_BINARY_DIR}/LibwebsocketsTargets.cmake") |
| 977 | endif() |
| 978 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 979 | |
| 980 | |
| 981 | set(libwebsockets_DIR ${PROJECT_BINARY_DIR}) |
| 982 | set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") |
| 983 | message("DIR ${libwebsockets_DIR} CMP ${CMAKE_MODULE_PATH}") |
| 984 | |
| 985 | if (LWS_WITH_MINIMAL_EXAMPLES) |
| 986 | add_subdirectory(minimal-examples) |
| 987 | endif() |
| 988 | |
| 989 | if (NOT LWS_WITHOUT_TESTAPPS) |
| 990 | add_subdirectory(test-apps) |
| 991 | endif() |
| 992 | |
Andy Green | 0e6df74 | 2021-01-31 05:50:12 +0000 | [diff] [blame] | 993 | if (NOT LWS_WITH_PLUGINS_BUILTIN) |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 994 | add_subdirectory(plugins) |
Andy Green | 0e6df74 | 2021-01-31 05:50:12 +0000 | [diff] [blame] | 995 | endif() |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 996 | add_subdirectory(lwsws) |
| 997 | |
| 998 | # Generate the lws_config.h that includes all the public compilation settings. |
| 999 | configure_file( |
| 1000 | "${PROJECT_SOURCE_DIR}/cmake/lws_config.h.in" |
| 1001 | "${PROJECT_BINARY_DIR}/lws_config.h") |
| 1002 | |
| 1003 | add_custom_command( |
| 1004 | OUTPUT ${PROJECT_BINARY_DIR}/include/lws_config.h |
| 1005 | ${PROJECT_BINARY_DIR}/include/libwebsockets |
| 1006 | ${PROJECT_BINARY_DIR}/include/libwebsockets.h |
| 1007 | COMMENT "Creating build include dir" |
| 1008 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/include/libwebsockets.h |
| 1009 | ${CMAKE_CURRENT_BINARY_DIR}/include/libwebsockets.h |
| 1010 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/include/libwebsockets/ |
| 1011 | ${CMAKE_CURRENT_BINARY_DIR}/include/libwebsockets |
| 1012 | COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/lws_config.h |
| 1013 | ${CMAKE_CURRENT_BINARY_DIR}/include/lws_config.h |
| 1014 | MAIN_DEPENDENCY ${PROJECT_BINARY_DIR}/lws_config.h |
| 1015 | ) |
| 1016 | |
| 1017 | add_custom_target(GENHDR DEPENDS ${PROJECT_BINARY_DIR}/include/lws_config.h) |
| 1018 | |
| 1019 | file(GLOB HDR_PUBLIC1 RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} include/libwebsockets/*.h) |
| 1020 | file(GLOB HDR_PUBLIC2 RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} include/libwebsockets.h) |
| 1021 | file(GLOB HDR_PUBLIC3 RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/include/lws_config.h) |
| 1022 | list(APPEND HDR_PUBLIC ${HDR_PUBLIC1} ${HDR_PUBLIC2} ${HDR_PUBLIC3}) |
| 1023 | |
| 1024 | set_source_files_properties(${HDR_PUBLIC} PROPERTIES GENERATED 1) |
| 1025 | |
| 1026 | if (LWS_WITH_STATIC) |
| 1027 | add_dependencies(websockets GENHDR) |
| 1028 | endif() |
| 1029 | if (LWS_WITH_SHARED) |
| 1030 | add_dependencies(websockets_shared GENHDR) |
| 1031 | endif() |
| 1032 | |
| 1033 | |
| 1034 | |
| 1035 | # |
| 1036 | # |
| 1037 | # Installation preparations. |
| 1038 | # |
| 1039 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 1040 | export(PACKAGE libwebsockets) |
| 1041 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 1042 | install(DIRECTORY include/libwebsockets |
Andy Green | c6c7ab2 | 2020-08-27 15:37:14 +0100 | [diff] [blame] | 1043 | DESTINATION "${LWS_INSTALL_INCLUDE_DIR}" COMPONENT dev) |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 1044 | install(FILES ${PROJECT_BINARY_DIR}/include/libwebsockets.h ${PROJECT_BINARY_DIR}/include/lws_config.h |
Andy Green | c6c7ab2 | 2020-08-27 15:37:14 +0100 | [diff] [blame] | 1045 | DESTINATION "${LWS_INSTALL_INCLUDE_DIR}" COMPONENT dev) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 1046 | |
| 1047 | # Generate the config file for the installation tree. |
Patrick Gansterer | e04ec35 | 2014-02-28 16:29:28 +0100 | [diff] [blame] | 1048 | get_filename_component(LWS_ABSOLUTE_INSTALL_CMAKE_DIR ${LWS_INSTALL_CMAKE_DIR} ABSOLUTE) |
| 1049 | 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] | 1050 | file(RELATIVE_PATH |
| 1051 | REL_INCLUDE_DIR |
Patrick Gansterer | e04ec35 | 2014-02-28 16:29:28 +0100 | [diff] [blame] | 1052 | "${LWS_ABSOLUTE_INSTALL_CMAKE_DIR}" |
| 1053 | "${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] | 1054 | |
Rogonov Stepan | 31435c9 | 2020-12-24 16:18:46 +0300 | [diff] [blame] | 1055 | if (DEFINED REL_INCLUDE_DIR) |
| 1056 | set(LWS__INCLUDE_DIRS "\${LWS_CMAKE_DIR}/${REL_INCLUDE_DIR}") |
| 1057 | endif() |
Andy Green | b912958 | 2021-10-28 07:17:52 +0100 | [diff] [blame] | 1058 | if (DEFINED OPENSSL_INCLUDE_DIRS) |
| 1059 | set(LWS__INCLUDE_DIRS "${LWS__INCLUDE_DIRS};${OPENSSL_INCLUDE_DIRS}") |
| 1060 | endif() |
Rogonov Stepan | 31435c9 | 2020-12-24 16:18:46 +0300 | [diff] [blame] | 1061 | |
| 1062 | configure_file(${PROJECT_SOURCE_DIR}/cmake/libwebsockets-config.cmake.in |
| 1063 | ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/libwebsockets-config.cmake |
| 1064 | @ONLY) |
| 1065 | |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 1066 | set_target_properties(${LWS_LIBRARIES} |
| 1067 | PROPERTIES PUBLIC_HEADER "${HDR_PUBLIC}") |
Andy Green | 0207705 | 2016-04-06 16:15:40 +0800 | [diff] [blame] | 1068 | |
Charles Prevot | 90a0dd6 | 2015-12-08 10:26:57 +0800 | [diff] [blame] | 1069 | # Install the LibwebsocketsConfig.cmake and LibwebsocketsConfigVersion.cmake |
| 1070 | install(FILES |
Andy Green | b3131fd | 2020-05-22 16:47:40 +0100 | [diff] [blame] | 1071 | "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/libwebsockets-config.cmake" |
| 1072 | "${PROJECT_BINARY_DIR}/libwebsockets-config-version.cmake" |
Andy Green | 43f9af2 | 2020-11-25 10:58:09 +0000 | [diff] [blame] | 1073 | "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/LwsCheckRequirements.cmake" |
Charles Prevot | 90a0dd6 | 2015-12-08 10:26:57 +0800 | [diff] [blame] | 1074 | DESTINATION "${LWS_INSTALL_CMAKE_DIR}" COMPONENT dev) |
| 1075 | |
Andy Green | f632e44 | 2016-03-29 18:27:32 +0800 | [diff] [blame] | 1076 | # Install exports for the install-tree. |
Alexey Reznichenko | 9384613 | 2017-11-20 12:41:29 +0100 | [diff] [blame] | 1077 | if (LWS_WITH_EXPORT_LWSTARGETS) |
| 1078 | install(EXPORT LibwebsocketsTargets |
| 1079 | DESTINATION "${LWS_INSTALL_CMAKE_DIR}" COMPONENT dev) |
| 1080 | endif() |
Andy Green | f632e44 | 2016-03-29 18:27:32 +0800 | [diff] [blame] | 1081 | |
Andy Green | 2aab3f9 | 2013-03-10 08:11:48 +0800 | [diff] [blame] | 1082 | # build subdir is not part of sources |
Steffen Vogel | 40cd5c4 | 2018-05-26 09:19:54 +0800 | [diff] [blame] | 1083 | 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] | 1084 | |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 1085 | # 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] | 1086 | add_custom_target(dist COMMAND "${CMAKE_MAKE_PROGRAM}" package_source) |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 1087 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 1088 | |
Andy Green | e4a3e8c | 2018-03-17 06:43:12 +0800 | [diff] [blame] | 1089 | |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 1090 | # This must always be last! |
| 1091 | include(CPack) |