Hiroaki Sakon | c00675c | 2014-09-22 22:39:59 +0900 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.8) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 2 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 3 | if(NOT DEFINED CMAKE_BUILD_TYPE) |
| 4 | set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type") |
| 5 | endif() |
| 6 | |
Samuel Martin | a11a282 | 2014-05-02 14:24:58 +0200 | [diff] [blame] | 7 | project(libwebsockets C) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 8 | |
| 9 | set(PACKAGE "libwebsockets") |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 10 | set(CPACK_PACKAGE_NAME "${PACKAGE}") |
| 11 | set(CPACK_PACKAGE_VERSION_MAJOR "1") |
Andy Green | 16fb013 | 2015-03-28 11:35:40 +0800 | [diff] [blame] | 12 | set(CPACK_PACKAGE_VERSION_MINOR "4") |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 13 | set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}") |
| 14 | set(CPACK_PACKAGE_VENDOR "andy@warmcat.com") |
| 15 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE} ${PACKAGE_VERSION}") |
Roger Light | b863954 | 2015-02-17 10:06:58 +0000 | [diff] [blame] | 16 | set(SOVERSION "5") |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 17 | set(CPACK_SOURCE_GENERATOR "TGZ") |
| 18 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") |
| 19 | set(VERSION "${CPACK_PACKAGE_VERSION}") |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 20 | |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 21 | set(LWS_LIBRARY_VERSION ${CPACK_PACKAGE_VERSION}) |
Edwin van den Oetelaar | d6bf73c | 2013-02-18 20:20:05 +0800 | [diff] [blame] | 22 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/") |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 23 | |
Andy Green | 5b479ac | 2013-03-30 10:30:03 +0800 | [diff] [blame] | 24 | message(STATUS "CMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}'") |
| 25 | |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 26 | # Try to find the current Git hash. |
| 27 | find_package(Git) |
| 28 | if(GIT_EXECUTABLE) |
| 29 | execute_process( |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 30 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 31 | COMMAND "${GIT_EXECUTABLE}" log -n 1 --pretty=%h |
| 32 | OUTPUT_VARIABLE GIT_HASH |
| 33 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 34 | ) |
| 35 | |
| 36 | set(LWS_BUILD_HASH ${GIT_HASH}) |
| 37 | message("Git commit hash: ${LWS_BUILD_HASH}") |
| 38 | endif() |
| 39 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 40 | set(LWS_USE_BUNDLED_ZLIB_DEFAULT OFF) |
| 41 | if(WIN32) |
| 42 | set(LWS_USE_BUNDLED_ZLIB_DEFAULT ON) |
| 43 | endif() |
| 44 | |
| 45 | option(LWS_WITH_STATIC "Build the static version of the library" ON) |
| 46 | option(LWS_WITH_SHARED "Build the shared version of the library" ON) |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 47 | option(LWS_WITH_SSL "Include SSL support (default OpenSSL, wolfSSL if LWS_USE_WOLFSSL is set)" ON) |
ABruines | 80a7068 | 2015-08-09 22:56:32 +0200 | [diff] [blame] | 48 | option(LWS_USE_CYASSL "Use CyaSSL replacement for OpenSSL. When settings this, you also need to specify LWS_CYASSL_LIBRARIES and LWS_CYASSL_INCLUDE_DIRS" OFF) |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 49 | option(LWS_USE_WOLFSSL "Use wolfSSL replacement for OpenSSL. When settings this, you also need to specify LWS_WOLFSSL_LIBRARIES and LWS_WOLFSSL_INCLUDE_DIRS" OFF) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 50 | option(LWS_WITH_ZLIB "Include zlib support (required for extensions)" ON) |
| 51 | option(LWS_WITH_LIBEV "Compile with support for libev" OFF) |
| 52 | option(LWS_USE_BUNDLED_ZLIB "Use bundled zlib version (Windows only)" ${LWS_USE_BUNDLED_ZLIB_DEFAULT}) |
Andy Green | d2ec7ad | 2014-03-15 10:39:29 +0800 | [diff] [blame] | 53 | option(LWS_SSL_CLIENT_USE_OS_CA_CERTS "SSL support should make use of OS installed CA root certs" ON) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 54 | option(LWS_WITHOUT_BUILTIN_GETIFADDRS "Don't use BSD getifaddrs implementation from libwebsockets if it is missing (this will result in a compilation error) ... Default is your libc provides it. On some systems such as uclibc it doesn't exist." OFF) |
| 55 | option(LWS_WITHOUT_CLIENT "Don't build the client part of the library" OFF) |
| 56 | option(LWS_WITHOUT_SERVER "Don't build the server part of the library" OFF) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 57 | option(LWS_LINK_TESTAPPS_DYNAMIC "Link the test apps to the shared version of the library. Default is to link statically" OFF) |
| 58 | option(LWS_WITHOUT_TESTAPPS "Don't build the libwebsocket-test-apps" OFF) |
| 59 | option(LWS_WITHOUT_TEST_SERVER "Don't build the test server" OFF) |
| 60 | option(LWS_WITHOUT_TEST_SERVER_EXTPOLL "Don't build the test server version that uses external poll" OFF) |
| 61 | option(LWS_WITHOUT_TEST_PING "Don't build the ping test application" OFF) |
| 62 | option(LWS_WITHOUT_TEST_CLIENT "Don't build the client test application" OFF) |
| 63 | option(LWS_WITHOUT_TEST_FRAGGLE "Don't build the ping test application" OFF) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 64 | option(LWS_WITHOUT_EXTENSIONS "Don't compile with extensions" OFF) |
| 65 | option(LWS_WITH_LATENCY "Build latency measuring code into the library" OFF) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 66 | option(LWS_WITHOUT_DAEMONIZE "Don't build the daemonization api" ON) |
Quinlan Pfiffer | 363420d | 2015-01-26 11:24:03 +0800 | [diff] [blame] | 67 | option(LWS_IPV6 "Compile with support for ipv6" OFF) |
Andy Green | 2eedea9 | 2014-04-03 14:33:48 +0800 | [diff] [blame] | 68 | option(LWS_WITH_HTTP2 "Compile with support for http2" OFF) |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 69 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 70 | # Allow the user to override installation directories. |
| 71 | set(LWS_INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") |
| 72 | set(LWS_INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables") |
| 73 | set(LWS_INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files") |
| 74 | set(LWS_INSTALL_EXAMPLES_DIR bin CACHE PATH "Installation directory for example files") |
| 75 | |
ABruines | 80a7068 | 2015-08-09 22:56:32 +0200 | [diff] [blame] | 76 | # Allow the user to use the old CyaSSL options/library in stead of wolfSSL |
| 77 | if (LWS_USE_CYASSL AND LWS_USE_WOLFSSL) |
| 78 | message(FATAL_ERROR "LWS_USE_CYASSL and LWS_USE_WOLFSSL are mutually exclusive!") |
| 79 | endif() |
| 80 | if (LWS_USE_CYASSL) |
| 81 | # Copy CyaSSL options to the wolfSSL options |
| 82 | set(LWS_USE_WOLFSSL ${LWS_USE_CYASSL} CACHE BOOL "Use wolfSSL/CyaSSL instead of OpenSSL" FORCE) |
| 83 | set(LWS_WOLFSSL_LIBRARIES ${LWS_CYASSL_LIBRARIES} CACHE PATH "Path to wolfSSL/CyaSSL libraries" FORCE) |
| 84 | set(LWS_WOLFSSL_INCLUDE_DIRS ${LWS_CYASSL_INCLUDE_DIRS} CACHE PATH "Path to wolfSSL/CyaSSL header files" FORCE) |
| 85 | endif() |
| 86 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 87 | if (LWS_WITHOUT_CLIENT AND LWS_WITHOUT_SERVER) |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 88 | message(FATAL_ERROR "Makes no sense to compile without both client or server.") |
| 89 | endif() |
| 90 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 91 | if (NOT (LWS_WITH_STATIC OR LWS_WITH_SHARED)) |
| 92 | message(FATAL_ERROR "Makes no sense to compile without both static or shared libraries.") |
| 93 | endif() |
| 94 | |
| 95 | if (NOT LWS_WITHOUT_EXTENSIONS) |
| 96 | if (NOT LWS_WITH_ZLIB) |
| 97 | message(FATAL_ERROR "zlib is required for extensions.") |
| 98 | endif() |
| 99 | endif() |
| 100 | |
| 101 | set(LWS_ZLIB_LIBRARIES CACHE PATH "Path to the zlib library") |
| 102 | set(LWS_ZLIB_INCLUDE_DIRS CACHE PATH "Path to the zlib include directory") |
| 103 | set(LWS_OPENSSL_LIBRARIES CACHE PATH "Path to the OpenSSL library") |
| 104 | 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] | 105 | set(LWS_WOLFSSL_LIBRARIES CACHE PATH "Path to the wolfSSL library") |
| 106 | set(LWS_WOLFSSL_INCLUDE_DIRS CACHE PATH "Path to the wolfSSL include directory") |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 107 | set(LWS_LIBEV_LIBRARIES CACHE PATH "Path to the libev library") |
| 108 | set(LWS_LIBEV_INCLUDE_DIRS CACHE PATH "Path to the libev include directory") |
| 109 | |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 110 | if (LWS_WITH_SSL AND NOT LWS_USE_WOLFSSL) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 111 | if ("${LWS_OPENSSL_LIBRARIES}" STREQUAL "" OR "${LWS_OPENSSL_INCLUDE_DIRS}" STREQUAL "") |
| 112 | else() |
| 113 | set(OPENSSL_LIBRARIES ${LWS_OPENSSL_LIBRARIES}) |
| 114 | set(OPENSSL_INCLUDE_DIRS ${LWS_OPENSSL_INCLUDE_DIRS}) |
| 115 | set(OPENSSL_FOUND 1) |
| 116 | endif() |
| 117 | endif() |
| 118 | |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 119 | if (LWS_WITH_SSL AND LWS_USE_WOLFSSL) |
| 120 | if ("${LWS_WOLFSSL_LIBRARIES}" STREQUAL "" OR "${LWS_WOLFSSL_INCLUDE_DIRS}" STREQUAL "") |
| 121 | if (NOT WOLFSSL_FOUND) |
ABruines | 80a7068 | 2015-08-09 22:56:32 +0200 | [diff] [blame] | 122 | if (LWS_USE_CYASSL) |
| 123 | message(FATAL_ERROR "You must set LWS_CYASSL_LIBRARIES and LWS_CYASSL_INCLUDE_DIRS when LWS_USE_CYASSL is turned on.") |
| 124 | else() |
| 125 | message(FATAL_ERROR "You must set LWS_WOLFSSL_LIBRARIES and LWS_WOLFSSL_INCLUDE_DIRS when LWS_USE_WOLFSSL is turned on.") |
| 126 | endif() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 127 | endif() |
| 128 | else() |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 129 | set(WOLFSSL_LIBRARIES ${LWS_WOLFSSL_LIBRARIES}) |
| 130 | set(WOLFSSL_INCLUDE_DIRS ${LWS_WOLFSSL_INCLUDE_DIRS}) |
| 131 | set(WOLFSSL_FOUND 1) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 132 | endif() |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 133 | set(USE_WOLFSSL 1) |
ABruines | 80a7068 | 2015-08-09 22:56:32 +0200 | [diff] [blame] | 134 | if (LWS_USE_CYASSL) |
| 135 | set(USE_OLD_CYASSL 1) |
| 136 | endif() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 137 | endif() |
| 138 | |
| 139 | if (LWS_WITH_ZLIB AND NOT LWS_USE_BUNDLED_ZLIB) |
| 140 | if ("${LWS_ZLIB_LIBRARIES}" STREQUAL "" OR "${LWS_ZLIB_INCLUDE_DIRS}" STREQUAL "") |
| 141 | else() |
| 142 | set(ZLIB_LIBRARIES ${LWS_ZLIB_LIBRARIES}) |
| 143 | set(ZLIB_INCLUDE_DIRS ${LWS_ZLIB_INCLUDE_DIRS}) |
| 144 | set(ZLIB_FOUND 1) |
| 145 | endif() |
| 146 | endif() |
| 147 | |
| 148 | if (LWS_WITH_LIBEV) |
| 149 | if ("${LWS_LIBEV_LIBRARIES}" STREQUAL "" OR "${LWS_LIBEV_INCLUDE_DIRS}" STREQUAL "") |
| 150 | else() |
| 151 | set(LIBEV_LIBRARIES ${LWS_LIBEV_LIBRARIES}) |
| 152 | set(LIBEV_INCLUDE_DIRS ${LWS_LIBEV_INCLUDE_DIRS}) |
| 153 | set(LIBEV_FOUND 1) |
| 154 | endif() |
| 155 | endif() |
| 156 | |
| 157 | # FIXME: This must be runtime-only option. |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 158 | # The base dir where the test-apps look for the SSL certs. |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 159 | set(LWS_OPENSSL_CLIENT_CERTS ../share CACHE PATH "Server SSL certificate directory") |
| 160 | if (WIN32) |
| 161 | set(LWS_OPENSSL_CLIENT_CERTS . CACHE PATH "Client SSL certificate directory") |
Joakim Soderberg | 46e4886 | 2014-04-24 14:47:10 +0200 | [diff] [blame] | 162 | |
| 163 | if (LWS_IPV6) |
| 164 | set(LWS_IPV6 OFF) |
| 165 | message(WARNING "IPv6 does currently not work on Windows!") |
| 166 | endif() |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 167 | else() |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 168 | 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] | 169 | endif() |
| 170 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 171 | if (LWS_WITHOUT_EXTENSIONS) |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 172 | set(LWS_NO_EXTENSIONS 1) |
| 173 | endif() |
| 174 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 175 | if (LWS_WITH_SSL) |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 176 | set(LWS_OPENSSL_SUPPORT 1) |
| 177 | endif() |
| 178 | |
Andy Green | d2ec7ad | 2014-03-15 10:39:29 +0800 | [diff] [blame] | 179 | if (LWS_SSL_CLIENT_USE_OS_CA_CERTS) |
| 180 | set(LWS_SSL_CLIENT_USE_OS_CA_CERTS 1) |
| 181 | endif() |
| 182 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 183 | if (LWS_WITH_LATENCY) |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 184 | set(LWS_LATENCY 1) |
| 185 | endif() |
| 186 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 187 | if (LWS_WITHOUT_DAEMONIZE OR WIN32) |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 188 | set(LWS_NO_DAEMONIZE 1) |
| 189 | endif() |
| 190 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 191 | if (LWS_WITHOUT_SERVER) |
Joakim Soderberg | e9a4211 | 2013-02-06 15:29:59 +0900 | [diff] [blame] | 192 | set(LWS_NO_SERVER 1) |
| 193 | endif() |
| 194 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 195 | if (LWS_WITHOUT_CLIENT) |
Joakim Soderberg | e9a4211 | 2013-02-06 15:29:59 +0900 | [diff] [blame] | 196 | set(LWS_NO_CLIENT 1) |
| 197 | endif() |
| 198 | |
Andrew Canaday | 9769f4f | 2014-03-23 13:25:07 +0800 | [diff] [blame] | 199 | if (LWS_WITH_LIBEV) |
| 200 | set(LWS_USE_LIBEV 1) |
Andrew Canaday | 9769f4f | 2014-03-23 13:25:07 +0800 | [diff] [blame] | 201 | endif() |
| 202 | |
Andy Green | 055f297 | 2014-03-24 16:09:25 +0800 | [diff] [blame] | 203 | if (LWS_IPV6) |
| 204 | set(LWS_USE_IPV6 1) |
James Devine | 3f13ea2 | 2014-03-24 16:09:25 +0800 | [diff] [blame] | 205 | endif() |
| 206 | |
Andy Green | 2eedea9 | 2014-04-03 14:33:48 +0800 | [diff] [blame] | 207 | if (LWS_WITH_HTTP2) |
| 208 | set(LWS_USE_HTTP2 1) |
| 209 | endif() |
| 210 | |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 211 | if (MINGW) |
| 212 | set(LWS_MINGW_SUPPORT 1) |
| 213 | endif() |
| 214 | |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 215 | include_directories("${PROJECT_BINARY_DIR}") |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 216 | |
Joakim Soderberg | 4f4a38b | 2013-02-06 15:28:07 +0900 | [diff] [blame] | 217 | include(CheckCSourceCompiles) |
| 218 | |
| 219 | # Check for different inline keyword versions. |
| 220 | foreach(KEYWORD "inline" "__inline__" "__inline") |
| 221 | set(CMAKE_REQUIRED_DEFINITIONS "-DKEYWORD=${KEYWORD}") |
| 222 | CHECK_C_SOURCE_COMPILES( |
| 223 | " |
| 224 | #include <stdio.h> |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 225 | static KEYWORD void a() {} |
Joakim Soderberg | 4f4a38b | 2013-02-06 15:28:07 +0900 | [diff] [blame] | 226 | 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] | 227 | " LWS_HAVE_${KEYWORD}) |
Joakim Soderberg | 4f4a38b | 2013-02-06 15:28:07 +0900 | [diff] [blame] | 228 | endforeach() |
| 229 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 230 | if (NOT LWS_HAVE_inline) |
| 231 | if (LWS_HAVE___inline__) |
Joakim Soderberg | 4f4a38b | 2013-02-06 15:28:07 +0900 | [diff] [blame] | 232 | set(inline __inline__) |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 233 | elseif(LWS_HAVE___inline) |
Joakim Soderberg | 4f4a38b | 2013-02-06 15:28:07 +0900 | [diff] [blame] | 234 | set(inline __inline) |
| 235 | endif() |
| 236 | endif() |
| 237 | |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 238 | # Put the libaries and binaries that get built into directories at the |
| 239 | # 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] | 240 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") |
| 241 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") |
| 242 | SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 243 | |
thinkski | d34bae1 | 2013-04-16 19:48:05 +0800 | [diff] [blame] | 244 | # Put absolute path of dynamic libraries into the object code. Some |
| 245 | # architectures, notably Mac OS X, need this. |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 246 | 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] | 247 | |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 248 | include(CheckFunctionExists) |
| 249 | include(CheckIncludeFile) |
| 250 | include(CheckIncludeFiles) |
| 251 | include(CheckLibraryExists) |
Patrick Gansterer | 8a59033 | 2014-02-28 00:42:08 +0100 | [diff] [blame] | 252 | include(CheckTypeSize) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 253 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 254 | CHECK_FUNCTION_EXISTS(bzero LWS_HAVE_BZERO) |
| 255 | CHECK_FUNCTION_EXISTS(fork LWS_HAVE_FORK) |
| 256 | CHECK_FUNCTION_EXISTS(getenv LWS_HAVE_GETENV) |
| 257 | CHECK_FUNCTION_EXISTS(malloc LWS_HAVE_MALLOC) |
| 258 | CHECK_FUNCTION_EXISTS(memset LWS_HAVE_MEMSET) |
| 259 | CHECK_FUNCTION_EXISTS(realloc LWS_HAVE_REALLOC) |
| 260 | CHECK_FUNCTION_EXISTS(socket LWS_HAVE_SOCKET) |
| 261 | CHECK_FUNCTION_EXISTS(strerror LWS_HAVE_STRERROR) |
| 262 | CHECK_FUNCTION_EXISTS(vfork LWS_HAVE_VFORK) |
| 263 | CHECK_FUNCTION_EXISTS(getifaddrs LWS_HAVE_GETIFADDRS) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 264 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 265 | if (NOT LWS_HAVE_GETIFADDRS) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 266 | if (LWS_WITHOUT_BUILTIN_GETIFADDRS) |
| 267 | 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] | 268 | endif() |
| 269 | set(LWS_BUILTIN_GETIFADDRS 1) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 270 | endif() |
| 271 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 272 | CHECK_INCLUDE_FILE(dlfcn.h LWS_HAVE_DLFCN_H) |
| 273 | CHECK_INCLUDE_FILE(fcntl.h LWS_HAVE_FCNTL_H) |
| 274 | CHECK_INCLUDE_FILE(in6addr.h LWS_HAVE_IN6ADDR_H) |
| 275 | CHECK_INCLUDE_FILE(inttypes.h LWS_HAVE_INTTYPES_H) |
| 276 | CHECK_INCLUDE_FILE(memory.h LWS_HAVE_MEMORY_H) |
| 277 | CHECK_INCLUDE_FILE(netinet/in.h LWS_HAVE_NETINET_IN_H) |
| 278 | CHECK_INCLUDE_FILE(stdint.h LWS_HAVE_STDINT_H) |
| 279 | CHECK_INCLUDE_FILE(stdlib.h LWS_HAVE_STDLIB_H) |
| 280 | CHECK_INCLUDE_FILE(strings.h LWS_HAVE_STRINGS_H) |
| 281 | CHECK_INCLUDE_FILE(string.h LWS_HAVE_STRING_H) |
| 282 | CHECK_INCLUDE_FILE(sys/prctl.h LWS_HAVE_SYS_PRCTL_H) |
| 283 | CHECK_INCLUDE_FILE(sys/socket.h LWS_HAVE_SYS_SOCKET_H) |
| 284 | CHECK_INCLUDE_FILE(sys/stat.h LWS_HAVE_SYS_STAT_H) |
| 285 | CHECK_INCLUDE_FILE(sys/types.h LWS_HAVE_SYS_TYPES_H) |
| 286 | CHECK_INCLUDE_FILE(unistd.h LWS_HAVE_UNISTD_H) |
| 287 | CHECK_INCLUDE_FILE(vfork.h LWS_HAVE_VFORK_H) |
| 288 | CHECK_INCLUDE_FILE(zlib.h LWS_HAVE_ZLIB_H) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 289 | |
| 290 | # TODO: These can be tested if they actually work also... |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 291 | set(LWS_HAVE_WORKING_FORK LWS_HAVE_FORK) |
| 292 | set(LWS_HAVE_WORKING_VFORK LWS_HAVE_VFORK) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 293 | |
| 294 | CHECK_INCLUDE_FILES("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS) |
| 295 | |
Patrick Gansterer | 8a59033 | 2014-02-28 00:42:08 +0100 | [diff] [blame] | 296 | CHECK_TYPE_SIZE(pid_t PID_T_SIZE) |
| 297 | CHECK_TYPE_SIZE(size_t SIZE_T_SIZE) |
| 298 | |
| 299 | if (NOT PID_T_SIZE) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 300 | set(pid_t int) |
Patrick Gansterer | 8a59033 | 2014-02-28 00:42:08 +0100 | [diff] [blame] | 301 | endif() |
| 302 | |
| 303 | if (NOT SIZE_T_SIZE) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 304 | set(size_t "unsigned int") |
| 305 | endif() |
| 306 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 307 | if (NOT LWS_HAVE_MALLOC) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 308 | set(malloc rpl_malloc) |
| 309 | endif() |
| 310 | |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 311 | if (NOT LWS_HAVE_REALLOC) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 312 | set(realloc rpl_realloc) |
| 313 | endif() |
| 314 | |
Roger A. Light | 7a474b4 | 2015-06-26 11:40:54 +0200 | [diff] [blame] | 315 | # Generate the lws_config.h that includes all the public compilation settings. |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 316 | configure_file( |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 317 | "${PROJECT_SOURCE_DIR}/lws_config.h.in" |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 318 | "${PROJECT_BINARY_DIR}/lws_config.h") |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 319 | |
Roger A. Light | 7a474b4 | 2015-06-26 11:40:54 +0200 | [diff] [blame] | 320 | # Generate the lws_config.h that includes all the private compilation settings. |
| 321 | configure_file( |
| 322 | "${PROJECT_SOURCE_DIR}/lws_config_private.h.in" |
| 323 | "${PROJECT_BINARY_DIR}/lws_config_private.h") |
| 324 | |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 325 | if (MSVC) |
| 326 | # Turn off stupid microsoft security warnings. |
| 327 | 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] | 328 | endif(MSVC) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 329 | |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 330 | include_directories("${PROJECT_SOURCE_DIR}/lib") |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 331 | |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 332 | # Group headers and sources. |
| 333 | # Some IDEs use this for nicer file structure. |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 334 | set(HDR_PRIVATE |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 335 | lib/private-libwebsockets.h) |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 336 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 337 | set(HDR_PUBLIC |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 338 | "${PROJECT_SOURCE_DIR}/lib/libwebsockets.h" |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 339 | "${PROJECT_BINARY_DIR}/lws_config.h") |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 340 | |
| 341 | set(SOURCES |
| 342 | lib/base64-decode.c |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 343 | lib/handshake.c |
| 344 | lib/libwebsockets.c |
Andy Green | d474135 | 2014-04-03 07:36:41 +0800 | [diff] [blame] | 345 | lib/service.c |
Andy Green | 34f3dd2 | 2014-04-03 07:42:50 +0800 | [diff] [blame] | 346 | lib/pollfd.c |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 347 | lib/output.c |
| 348 | lib/parsers.c |
Andy Green | 3d67f51 | 2014-04-03 07:29:50 +0800 | [diff] [blame] | 349 | lib/context.c |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 350 | lib/sha-1.c |
Alejandro Mery | cdc9717 | 2014-12-04 23:15:27 +0100 | [diff] [blame] | 351 | lib/alloc.c |
wonder-mice | dd32c24 | 2015-04-23 05:37:46 +0800 | [diff] [blame] | 352 | lib/header.c) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 353 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 354 | if (NOT LWS_WITHOUT_CLIENT) |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 355 | list(APPEND SOURCES |
| 356 | lib/client.c |
| 357 | lib/client-handshake.c |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 358 | lib/client-parser.c) |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 359 | endif() |
| 360 | |
Andy Green | c57037a | 2014-04-03 10:17:00 +0800 | [diff] [blame] | 361 | if (LWS_WITH_SSL) |
| 362 | list(APPEND SOURCES |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 363 | lib/ssl.c) |
Andy Green | c57037a | 2014-04-03 10:17:00 +0800 | [diff] [blame] | 364 | endif() |
| 365 | |
Andy Green | 2eedea9 | 2014-04-03 14:33:48 +0800 | [diff] [blame] | 366 | if (LWS_WITH_HTTP2) |
| 367 | list(APPEND SOURCES |
Andy Green | 024eb6c | 2014-10-08 12:00:53 +0800 | [diff] [blame] | 368 | lib/http2.c |
Andy Green | 2add634 | 2014-10-12 08:38:16 +0800 | [diff] [blame] | 369 | lib/hpack.c |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 370 | lib/ssl-http2.c) |
Andy Green | 2eedea9 | 2014-04-03 14:33:48 +0800 | [diff] [blame] | 371 | endif() |
Andy Green | e40aa9b | 2014-04-02 21:02:54 +0800 | [diff] [blame] | 372 | # select the active platform files |
| 373 | |
| 374 | if (WIN32) |
| 375 | list(APPEND SOURCES |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 376 | lib/lws-plat-win.c) |
Andy Green | e40aa9b | 2014-04-02 21:02:54 +0800 | [diff] [blame] | 377 | else() |
| 378 | list(APPEND SOURCES |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 379 | lib/lws-plat-unix.c) |
Andy Green | e40aa9b | 2014-04-02 21:02:54 +0800 | [diff] [blame] | 380 | endif() |
| 381 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 382 | if (NOT LWS_WITHOUT_SERVER) |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 383 | list(APPEND SOURCES |
| 384 | lib/server.c |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 385 | lib/server-handshake.c) |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 386 | endif() |
| 387 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 388 | if (NOT LWS_WITHOUT_EXTENSIONS) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 389 | list(APPEND HDR_PRIVATE |
| 390 | lib/extension-deflate-frame.h |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 391 | lib/extension-deflate-stream.h) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 392 | list(APPEND SOURCES |
| 393 | lib/extension.c |
| 394 | lib/extension-deflate-frame.c |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 395 | lib/extension-deflate-stream.c) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 396 | endif() |
| 397 | |
Andy Green | a717df2 | 2014-04-11 13:14:37 +0800 | [diff] [blame] | 398 | if (LWS_WITH_LIBEV) |
| 399 | list(APPEND SOURCES |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 400 | lib/libev.c) |
Andy Green | a717df2 | 2014-04-11 13:14:37 +0800 | [diff] [blame] | 401 | endif(LWS_WITH_LIBEV) |
| 402 | |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 403 | # Add helper files for Windows. |
| 404 | if (WIN32) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 405 | set(WIN32_HELPERS_PATH win32port/win32helpers) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 406 | include_directories(${WIN32_HELPERS_PATH}) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 407 | else() |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 408 | # Unix. |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 409 | if (NOT LWS_WITHOUT_DAEMONIZE) |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 410 | list(APPEND SOURCES |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 411 | lib/daemonize.c) |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 412 | endif() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 413 | endif() |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 414 | |
| 415 | if (UNIX) |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 416 | if (NOT LWS_HAVE_GETIFADDRS) |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 417 | list(APPEND HDR_PRIVATE lib/getifaddrs.h) |
| 418 | list(APPEND SOURCES lib/getifaddrs.c) |
| 419 | endif() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 420 | endif() |
Andy Green | da3f6ff | 2013-03-16 12:32:59 +0800 | [diff] [blame] | 421 | |
Joakim Soderberg | c2012e4 | 2013-03-23 08:55:02 +0800 | [diff] [blame] | 422 | if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) |
Steven Lai | ba3c75c | 2015-01-27 19:46:26 +0800 | [diff] [blame] | 423 | include (CheckCCompilerFlag) |
=?UTF-8?q?Joakim=20S=C3=B6derberg?= | cefab31 | 2015-06-24 16:46:02 +0200 | [diff] [blame] | 424 | CHECK_C_COMPILER_FLAG(-fvisibility=hidden LWS_HAVE_VISIBILITY) |
| 425 | if (LWS_HAVE_VISIBILITY) |
Steven Lai | ba3c75c | 2015-01-27 19:46:26 +0800 | [diff] [blame] | 426 | set(VISIBILITY_FLAG -fvisibility=hidden) |
| 427 | endif() |
pmcdona | 0a0a7eb | 2013-12-18 10:17:25 +0800 | [diff] [blame] | 428 | if (UNIX) |
Bruce Perens | e38b850 | 2015-10-15 08:46:29 +0800 | [diff] [blame^] | 429 | set(CMAKE_C_FLAGS "-Wall -Werror ${VISIBILITY_FLAG} ${CMAKE_C_FLAGS}" ) |
pmcdona | 0a0a7eb | 2013-12-18 10:17:25 +0800 | [diff] [blame] | 430 | else(UNIX) |
Bruce Perens | e38b850 | 2015-10-15 08:46:29 +0800 | [diff] [blame^] | 431 | set(CMAKE_C_FLAGS "-Wall ${VISIBILITY_FLAG} ${CMAKE_C_FLAGS}" ) |
pmcdona | 0a0a7eb | 2013-12-18 10:17:25 +0800 | [diff] [blame] | 432 | endif(UNIX) |
Joakim Soderberg | c2012e4 | 2013-03-23 08:55:02 +0800 | [diff] [blame] | 433 | endif () |
Andy Green | da3f6ff | 2013-03-16 12:32:59 +0800 | [diff] [blame] | 434 | |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 435 | source_group("Headers Private" FILES ${HDR_PRIVATE}) |
| 436 | source_group("Headers Public" FILES ${HDR_PUBLIC}) |
| 437 | source_group("Sources" FILES ${SOURCES}) |
| 438 | |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 439 | # |
| 440 | # Create the lib. |
| 441 | # |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 442 | set(LWS_LIBRARIES) |
Roger A. Light | b6147fd | 2015-05-05 15:02:08 -0500 | [diff] [blame] | 443 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 444 | if (LWS_WITH_STATIC) |
| 445 | add_library(websockets STATIC |
| 446 | ${HDR_PRIVATE} |
| 447 | ${HDR_PUBLIC} |
| 448 | ${SOURCES}) |
| 449 | list(APPEND LWS_LIBRARIES websockets) |
Roger A. Light | b6147fd | 2015-05-05 15:02:08 -0500 | [diff] [blame] | 450 | |
| 451 | if (WIN32) |
| 452 | # Windows uses the same .lib ending for static libraries and shared |
| 453 | # library linker files, so rename the static library. |
| 454 | set_target_properties(websockets |
| 455 | PROPERTIES |
| 456 | OUTPUT_NAME websockets_static) |
| 457 | endif() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 458 | endif() |
Roger A. Light | b6147fd | 2015-05-05 15:02:08 -0500 | [diff] [blame] | 459 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 460 | if (LWS_WITH_SHARED) |
| 461 | add_library(websockets_shared SHARED |
| 462 | ${HDR_PRIVATE} |
| 463 | ${HDR_PUBLIC} |
| 464 | ${SOURCES}) |
| 465 | list(APPEND LWS_LIBRARIES websockets_shared) |
Joakim Soderberg | 0848353 | 2013-02-13 09:29:17 +0800 | [diff] [blame] | 466 | |
Roger A. Light | b6147fd | 2015-05-05 15:02:08 -0500 | [diff] [blame] | 467 | # We want the shared lib to be named "libwebsockets" |
| 468 | # not "libwebsocket_shared". |
| 469 | set_target_properties(websockets_shared |
| 470 | PROPERTIES |
| 471 | OUTPUT_NAME websockets) |
| 472 | |
| 473 | if (WIN32) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 474 | # Compile as DLL (export function declarations) |
| 475 | set_property( |
| 476 | TARGET websockets_shared |
| 477 | PROPERTY COMPILE_DEFINITIONS |
| 478 | LWS_DLL |
| 479 | LWS_INTERNAL) |
| 480 | endif() |
Roger A. Light | b6147fd | 2015-05-05 15:02:08 -0500 | [diff] [blame] | 481 | |
| 482 | if (APPLE) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 483 | set_property(TARGET websockets_shared PROPERTY MACOSX_RPATH YES) |
| 484 | endif() |
| 485 | endif() |
Joakim Soderberg | f83585f | 2013-02-13 09:29:09 +0800 | [diff] [blame] | 486 | |
Roger A. Light | b6147fd | 2015-05-05 15:02:08 -0500 | [diff] [blame] | 487 | |
Joakim Soderberg | f83585f | 2013-02-13 09:29:09 +0800 | [diff] [blame] | 488 | # Set the so version of the lib. |
Andy Green | 19c1a99 | 2013-03-10 06:59:01 +0800 | [diff] [blame] | 489 | # Equivalent to LDFLAGS=-version-info x:x:x |
Joakim Soderberg | f83585f | 2013-02-13 09:29:09 +0800 | [diff] [blame] | 490 | if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 491 | foreach(lib ${LWS_LIBRARIES}) |
| 492 | set_target_properties(${lib} |
Joakim Soderberg | f272cb0 | 2013-02-13 09:29:26 +0800 | [diff] [blame] | 493 | PROPERTIES |
| 494 | SOVERSION ${SOVERSION}) |
| 495 | endforeach() |
Joakim Soderberg | f83585f | 2013-02-13 09:29:09 +0800 | [diff] [blame] | 496 | endif() |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 497 | |
Joakim Soderberg | 0848353 | 2013-02-13 09:29:17 +0800 | [diff] [blame] | 498 | set(LIB_LIST) |
| 499 | |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 500 | # |
| 501 | # Find libraries. |
| 502 | # |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 503 | |
| 504 | # |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 505 | # ZLIB (Only needed for deflate extensions). |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 506 | # |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 507 | if (LWS_WITH_ZLIB) |
| 508 | if (LWS_USE_BUNDLED_ZLIB) |
| 509 | if (WIN32) |
| 510 | set(WIN32_ZLIB_PATH "win32port/zlib") |
| 511 | set(ZLIB_SRCS |
| 512 | ${WIN32_ZLIB_PATH}/adler32.c |
| 513 | ${WIN32_ZLIB_PATH}/compress.c |
| 514 | ${WIN32_ZLIB_PATH}/crc32.c |
| 515 | ${WIN32_ZLIB_PATH}/deflate.c |
| 516 | ${WIN32_ZLIB_PATH}/gzclose.c |
| 517 | ${WIN32_ZLIB_PATH}/gzio.c |
| 518 | ${WIN32_ZLIB_PATH}/gzlib.c |
| 519 | ${WIN32_ZLIB_PATH}/gzread.c |
| 520 | ${WIN32_ZLIB_PATH}/gzwrite.c |
| 521 | ${WIN32_ZLIB_PATH}/infback.c |
| 522 | ${WIN32_ZLIB_PATH}/inffast.c |
| 523 | ${WIN32_ZLIB_PATH}/inflate.c |
| 524 | ${WIN32_ZLIB_PATH}/inftrees.c |
| 525 | ${WIN32_ZLIB_PATH}/trees.c |
| 526 | ${WIN32_ZLIB_PATH}/uncompr.c |
| 527 | ${WIN32_ZLIB_PATH}/zutil.c) |
| 528 | add_library(zlib_internal STATIC ${ZLIB_SRCS}) |
| 529 | set(ZLIB_INCLUDE_DIRS ${WIN32_ZLIB_PATH}) |
| 530 | get_property(ZLIB_LIBRARIES TARGET zlib_internal PROPERTY LOCATION) |
| 531 | set(ZLIB_FOUND 1) |
| 532 | # Make sure zlib_internal is compiled before the libs. |
| 533 | foreach (lib ${LWS_LIBRARIES}) |
| 534 | add_dependencies(${lib} zlib_internal) |
| 535 | endforeach() |
| 536 | else() |
| 537 | message(FATAL_ERROR "Don't have bundled zlib for that platform") |
| 538 | endif() |
| 539 | elseif (NOT ZLIB_FOUND) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 540 | find_package(ZLIB REQUIRED) |
| 541 | endif() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 542 | message("zlib include dirs: ${ZLIB_INCLUDE_DIRS}") |
| 543 | message("zlib libraries: ${ZLIB_LIBRARIES}") |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 544 | include_directories(${ZLIB_INCLUDE_DIRS}) |
| 545 | list(APPEND LIB_LIST ${ZLIB_LIBRARIES}) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 546 | endif() |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 547 | |
| 548 | # |
| 549 | # OpenSSL |
| 550 | # |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 551 | if (LWS_WITH_SSL) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 552 | message("Compiling with SSL support") |
| 553 | |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 554 | if (LWS_USE_WOLFSSL) |
| 555 | # Use wolfSSL as OpenSSL replacement. |
Joakim Söderberg | cb4156d | 2013-02-06 15:30:56 +0900 | [diff] [blame] | 556 | # TODO: Add a find_package command for this also. |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 557 | message("wolfSSL include dir: ${WOLFSSL_INCLUDE_DIRS}") |
| 558 | message("wolfSSL libraries: ${WOLFSSL_LIBRARIES}") |
Joakim Söderberg | cb4156d | 2013-02-06 15:30:56 +0900 | [diff] [blame] | 559 | |
Joakim Soderberg | 7df9908 | 2013-02-07 20:24:19 +0800 | [diff] [blame] | 560 | # Additional to the root directory we need to include |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 561 | # the wolfssl/ subdirectory which contains the OpenSSL |
Joakim Soderberg | 7df9908 | 2013-02-07 20:24:19 +0800 | [diff] [blame] | 562 | # compatability layer headers. |
ABruines | 80a7068 | 2015-08-09 22:56:32 +0200 | [diff] [blame] | 563 | if (LWS_USE_CYASSL) |
| 564 | foreach(inc ${WOLFSSL_INCLUDE_DIRS}) |
| 565 | include_directories("${inc}" "${inc}/cyassl") |
| 566 | endforeach() |
| 567 | else() |
| 568 | foreach(inc ${WOLFSSL_INCLUDE_DIRS}) |
| 569 | include_directories("${inc}" "${inc}/wolfssl") |
| 570 | endforeach() |
| 571 | endif() |
Joakim Soderberg | 7df9908 | 2013-02-07 20:24:19 +0800 | [diff] [blame] | 572 | |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 573 | list(APPEND LIB_LIST "${WOLFSSL_LIBRARIES}") |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 574 | else() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 575 | if (NOT OPENSSL_FOUND) |
| 576 | # TODO: Add support for STATIC also. |
| 577 | find_package(OpenSSL REQUIRED) |
| 578 | set(OPENSSL_INCLUDE_DIRS "${OPENSSL_INCLUDE_DIR}") |
| 579 | endif() |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 580 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 581 | message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIRS}") |
Joakim Söderberg | cb4156d | 2013-02-06 15:30:56 +0900 | [diff] [blame] | 582 | message("OpenSSL libraries: ${OPENSSL_LIBRARIES}") |
Joakim Soderberg | add3926 | 2013-02-06 15:25:26 +0900 | [diff] [blame] | 583 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 584 | include_directories("${OPENSSL_INCLUDE_DIRS}") |
Joakim Soderberg | d2f5b19 | 2014-04-07 11:28:08 +0200 | [diff] [blame] | 585 | list(APPEND LIB_LIST ${OPENSSL_LIBRARIES}) |
Joakim Söderberg | cb4156d | 2013-02-06 15:30:56 +0900 | [diff] [blame] | 586 | endif() |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 587 | endif(LWS_WITH_SSL) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 588 | |
Andrew Canaday | 9769f4f | 2014-03-23 13:25:07 +0800 | [diff] [blame] | 589 | if (LWS_WITH_LIBEV) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 590 | if (NOT LIBEV_FOUND) |
| 591 | find_path(LIBEV_INCLUDE_DIRS NAMES ev.h) |
| 592 | find_library(LIBEV_LIBRARIES NAMES ev) |
| 593 | if(LIBEV_INCLUDE_DIRS AND LIBEV_LIBRARIES) |
| 594 | set(LIBEV_FOUND 1) |
| 595 | endif() |
| 596 | endif() |
| 597 | message("libev include dir: ${LIBEV_INCLUDE_DIRS}") |
| 598 | message("libev libraries: ${LIBEV_LIBRARIES}") |
| 599 | include_directories("${LIBEV_INCLUDE_DIRS}") |
| 600 | list(APPEND LIB_LIST ${LIBEV_LIBRARIES}) |
Andrew Canaday | 9769f4f | 2014-03-23 13:25:07 +0800 | [diff] [blame] | 601 | endif(LWS_WITH_LIBEV) |
| 602 | |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 603 | # |
| 604 | # Platform specific libs. |
| 605 | # |
Patrick Gansterer | 5b71aac | 2014-02-28 01:31:39 +0100 | [diff] [blame] | 606 | if (WINCE) |
| 607 | list(APPEND LIB_LIST ws2.lib) |
| 608 | elseif (WIN32) |
Joakim Soderberg | 0848353 | 2013-02-13 09:29:17 +0800 | [diff] [blame] | 609 | list(APPEND LIB_LIST ws2_32.lib) |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 610 | endif() |
| 611 | |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 612 | if (UNIX) |
Joakim Soderberg | 0848353 | 2013-02-13 09:29:17 +0800 | [diff] [blame] | 613 | list(APPEND LIB_LIST m) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 614 | endif() |
Joakim Soderberg | 08e434e | 2013-02-01 14:52:53 +0100 | [diff] [blame] | 615 | |
Joakim Soderberg | f272cb0 | 2013-02-13 09:29:26 +0800 | [diff] [blame] | 616 | # Setup the linking for all libs. |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 617 | foreach (lib ${LWS_LIBRARIES}) |
Joakim Soderberg | f272cb0 | 2013-02-13 09:29:26 +0800 | [diff] [blame] | 618 | target_link_libraries(${lib} ${LIB_LIST}) |
| 619 | endforeach() |
Joakim Soderberg | 0848353 | 2013-02-13 09:29:17 +0800 | [diff] [blame] | 620 | |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 621 | # |
| 622 | # Test applications |
| 623 | # |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 624 | set(TEST_APP_LIST) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 625 | if (NOT LWS_WITHOUT_TESTAPPS) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 626 | # |
| 627 | # Helper function for adding a test app. |
| 628 | # |
Patrick Gansterer | 73882e4 | 2014-03-29 08:25:58 +0100 | [diff] [blame] | 629 | macro(create_test_app TEST_NAME MAIN_SRC) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 630 | |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 631 | set(TEST_SRCS ${MAIN_SRC}) |
| 632 | set(TEST_HDR) |
| 633 | |
| 634 | if (WIN32) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 635 | list(APPEND TEST_SRCS |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 636 | ${WIN32_HELPERS_PATH}/getopt.c |
| 637 | ${WIN32_HELPERS_PATH}/getopt_long.c |
| 638 | ${WIN32_HELPERS_PATH}/gettimeofday.c |
Patrick Gansterer | 73882e4 | 2014-03-29 08:25:58 +0100 | [diff] [blame] | 639 | ) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 640 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 641 | list(APPEND TEST_HDR |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 642 | ${WIN32_HELPERS_PATH}/getopt.h |
| 643 | ${WIN32_HELPERS_PATH}/gettimeofday.h |
Patrick Gansterer | 73882e4 | 2014-03-29 08:25:58 +0100 | [diff] [blame] | 644 | ) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 645 | endif(WIN32) |
| 646 | |
Joakim Soderberg | 0848353 | 2013-02-13 09:29:17 +0800 | [diff] [blame] | 647 | source_group("Headers Private" FILES ${TEST_HDR}) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 648 | source_group("Sources" FILES ${TEST_SRCS}) |
| 649 | add_executable(${TEST_NAME} ${TEST_SRCS} ${TEST_HDR}) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 650 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 651 | if (LWS_LINK_TESTAPPS_DYNAMIC) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 652 | if (NOT LWS_WITH_SHARED) |
| 653 | message(FATAL_ERROR "Build of shared library is disabled. LWS_LINK_TESTAPPS_DYNAMIC must be combined with LWS_WITH_SHARED.") |
| 654 | endif() |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 655 | target_link_libraries(${TEST_NAME} websockets_shared) |
| 656 | add_dependencies(${TEST_NAME} websockets_shared) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 657 | else() |
| 658 | if (NOT LWS_WITH_STATIC) |
| 659 | message(FATAL_ERROR "Build of static library is disabled. Disabled LWS_LINK_TESTAPPS_DYNAMIC must be combined with LWS_WITH_STATIC.") |
| 660 | endif() |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 661 | target_link_libraries(${TEST_NAME} websockets) |
| 662 | add_dependencies(${TEST_NAME} websockets) |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 663 | endif() |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 664 | |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 665 | # Set test app specific defines. |
| 666 | set_property(TARGET ${TEST_NAME} |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 667 | PROPERTY COMPILE_DEFINITIONS |
Andy Green | 63b3b95 | 2013-03-09 12:51:43 +0800 | [diff] [blame] | 668 | INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/share" |
Joakim Soderberg | d2edfec | 2013-02-06 15:27:27 +0900 | [diff] [blame] | 669 | ) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 670 | |
| 671 | # Prefix the binary names with libwebsockets. |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 672 | set_target_properties(${TEST_NAME} |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 673 | PROPERTIES |
| 674 | OUTPUT_NAME libwebsockets-${TEST_NAME}) |
| 675 | |
| 676 | # Add to the list of tests. |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 677 | list(APPEND TEST_APP_LIST ${TEST_NAME}) |
Joakim Soderberg | 11a8cda | 2013-02-22 09:28:06 +0800 | [diff] [blame] | 678 | endmacro() |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 679 | |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 680 | if (LWS_WITH_SSL AND NOT LWS_USE_WOLFSSL) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 681 | message("Searching for OpenSSL executable and dlls") |
| 682 | find_package(OpenSSLbins) |
| 683 | message("OpenSSL executable: ${OPENSSL_EXECUTABLE}") |
| 684 | endif() |
| 685 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 686 | if (NOT LWS_WITHOUT_SERVER) |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 687 | # |
| 688 | # test-server |
| 689 | # |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 690 | if (NOT LWS_WITHOUT_TEST_SERVER) |
Patrick Gansterer | 73882e4 | 2014-03-29 08:25:58 +0100 | [diff] [blame] | 691 | create_test_app(test-server "test-server/test-server.c") |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 692 | endif() |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 693 | |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 694 | # |
| 695 | # test-server-extpoll |
| 696 | # |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 697 | if (NOT LWS_WITHOUT_TEST_SERVER_EXTPOLL) |
Patrick Gansterer | 73882e4 | 2014-03-29 08:25:58 +0100 | [diff] [blame] | 698 | create_test_app(test-server-extpoll "test-server/test-server.c") |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 699 | # Set defines for this executable only. |
| 700 | set_property( |
| 701 | TARGET test-server-extpoll |
| 702 | PROPERTY COMPILE_DEFINITIONS |
| 703 | EXTERNAL_POLL |
Andy Green | 63b3b95 | 2013-03-09 12:51:43 +0800 | [diff] [blame] | 704 | INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/share" |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 705 | ) |
Joakim Soderberg | f272cb0 | 2013-02-13 09:29:26 +0800 | [diff] [blame] | 706 | |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 707 | # We need to link against winsock code. |
| 708 | if (WIN32) |
| 709 | target_link_libraries(test-server-extpoll ws2_32.lib) |
Edwin van den Oetelaar | 15a38a7 | 2013-03-10 06:53:57 +0800 | [diff] [blame] | 710 | endif(WIN32) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 711 | endif() |
| 712 | |
| 713 | # Data files for running the test server. |
| 714 | set(TEST_SERVER_DATA |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 715 | "${PROJECT_SOURCE_DIR}/test-server/favicon.ico" |
| 716 | "${PROJECT_SOURCE_DIR}/test-server/leaf.jpg" |
| 717 | "${PROJECT_SOURCE_DIR}/test-server/libwebsockets.org-logo.png" |
| 718 | "${PROJECT_SOURCE_DIR}/test-server/test.html") |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 719 | |
| 720 | # Generate self-signed SSL certs for the test-server. |
Joakim Soderberg | 6596e4b | 2014-02-18 13:38:14 +0100 | [diff] [blame] | 721 | if (LWS_WITH_SSL AND OPENSSL_EXECUTABLE AND NOT LWS_WITHOUT_TEST_SERVER) |
Joakim Soderberg | 20aedc8 | 2013-02-22 09:28:11 +0800 | [diff] [blame] | 722 | message("Generating SSL Certificates for the test-server...") |
| 723 | |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 724 | set(TEST_SERVER_SSL_KEY "${PROJECT_BINARY_DIR}/libwebsockets-test-server.key.pem") |
| 725 | set(TEST_SERVER_SSL_CERT "${PROJECT_BINARY_DIR}/libwebsockets-test-server.pem") |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 726 | |
| 727 | if (WIN32) |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 728 | file(WRITE "${PROJECT_BINARY_DIR}/openssl_input.txt" |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 729 | "GB\n" |
| 730 | "Erewhon\n" |
| 731 | "All around\n" |
| 732 | "libwebsockets-test\n" |
| 733 | "localhost\n" |
Joakim Soderberg | 20aedc8 | 2013-02-22 09:28:11 +0800 | [diff] [blame] | 734 | "none@invalid.org\n\n" |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 735 | ) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 736 | |
Joakim Soderberg | 20aedc8 | 2013-02-22 09:28:11 +0800 | [diff] [blame] | 737 | # The "type" command is a bit picky with paths. |
| 738 | file(TO_NATIVE_PATH "${PROJECT_BINARY_DIR}/openssl_input.txt" OPENSSL_INPUT_WIN_PATH) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 739 | message("OPENSSL_INPUT_WIN_PATH = ${OPENSSL_INPUT_WIN_PATH}") |
| 740 | message("cmd = \"${OPENSSL_EXECUTABLE}\" req -new -newkey rsa:1024 -days 10000 -nodes -x509 -keyout \"${TEST_SERVER_SSL_KEY}\" -out \"${TEST_SERVER_SSL_CERT}\"") |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 741 | |
| 742 | execute_process( |
Joakim Soderberg | 20aedc8 | 2013-02-22 09:28:11 +0800 | [diff] [blame] | 743 | COMMAND cmd /c type "${OPENSSL_INPUT_WIN_PATH}" |
| 744 | COMMAND "${OPENSSL_EXECUTABLE}" req -new -newkey rsa:1024 -days 10000 -nodes -x509 -keyout "${TEST_SERVER_SSL_KEY}" -out "${TEST_SERVER_SSL_CERT}" |
wonder-mice | 67e246f | 2015-04-22 13:17:53 -0700 | [diff] [blame] | 745 | RESULT_VARIABLE OPENSSL_RETURN_CODE |
| 746 | OUTPUT_QUIET ERROR_QUIET) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 747 | |
Joakim Soderberg | c7ed2be | 2013-02-22 09:28:17 +0800 | [diff] [blame] | 748 | message("\n") |
| 749 | |
Joakim Soderberg | 20aedc8 | 2013-02-22 09:28:11 +0800 | [diff] [blame] | 750 | if (OPENSSL_RETURN_CODE) |
Joakim Soderberg | 6596e4b | 2014-02-18 13:38:14 +0100 | [diff] [blame] | 751 | message(WARNING "!!! Failed to generate SSL certificate for Test Server using cmd.exe !!!:\nOpenSSL return code = ${OPENSSL_RETURN_CODE}") |
| 752 | else() |
| 753 | message("SUCCSESFULLY generated SSL certificate") |
Joakim Soderberg | 20aedc8 | 2013-02-22 09:28:11 +0800 | [diff] [blame] | 754 | endif() |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 755 | else() |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 756 | # Unix. |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 757 | execute_process( |
| 758 | COMMAND printf "GB\\nErewhon\\nAll around\\nlibwebsockets-test\\n\\nlocalhost\\nnone@invalid.org\\n" |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 759 | COMMAND "${OPENSSL_EXECUTABLE}" |
| 760 | req -new -newkey rsa:1024 -days 10000 -nodes -x509 -keyout "${TEST_SERVER_SSL_KEY}" -out "${TEST_SERVER_SSL_CERT}" |
wonder-mice | 67e246f | 2015-04-22 13:17:53 -0700 | [diff] [blame] | 761 | RESULT_VARIABLE OPENSSL_RETURN_CODE |
| 762 | OUTPUT_QUIET ERROR_QUIET) |
Joakim Soderberg | 6596e4b | 2014-02-18 13:38:14 +0100 | [diff] [blame] | 763 | |
| 764 | if (OPENSSL_RETURN_CODE) |
| 765 | message(WARNING "!!! Failed to generate SSL certificate for Test Server!!!:\nOpenSSL return code = ${OPENSSL_RETURN_CODE}") |
| 766 | else() |
| 767 | message("SUCCSESFULLY generated SSL certificate") |
| 768 | endif() |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 769 | endif() |
| 770 | |
| 771 | list(APPEND TEST_SERVER_DATA |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 772 | "${TEST_SERVER_SSL_KEY}" |
| 773 | "${TEST_SERVER_SSL_CERT}") |
Joakim Soderberg | f272cb0 | 2013-02-13 09:29:26 +0800 | [diff] [blame] | 774 | endif() |
Joakim Soderberg | c7ed2be | 2013-02-22 09:28:17 +0800 | [diff] [blame] | 775 | |
Joakim Soderberg | 6596e4b | 2014-02-18 13:38:14 +0100 | [diff] [blame] | 776 | add_custom_command(TARGET test-server |
| 777 | POST_BUILD |
Joakim Soderberg | 1632c9a | 2014-11-26 01:22:50 +0800 | [diff] [blame] | 778 | 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] | 779 | |
Joakim Soderberg | c7ed2be | 2013-02-22 09:28:17 +0800 | [diff] [blame] | 780 | # Copy the file needed to run the server so that the test apps can |
| 781 | # reach them from their default output location |
| 782 | foreach (TEST_FILE ${TEST_SERVER_DATA}) |
Joakim Soderberg | 6596e4b | 2014-02-18 13:38:14 +0100 | [diff] [blame] | 783 | if (EXISTS ${TEST_FILE}) |
| 784 | add_custom_command(TARGET test-server |
| 785 | POST_BUILD |
Joakim Soderberg | 1632c9a | 2014-11-26 01:22:50 +0800 | [diff] [blame] | 786 | 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] | 787 | endif() |
Joakim Soderberg | c7ed2be | 2013-02-22 09:28:17 +0800 | [diff] [blame] | 788 | endforeach() |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 789 | endif(NOT LWS_WITHOUT_SERVER) |
Joakim Söderberg | 68e8d73 | 2013-02-06 15:27:39 +0900 | [diff] [blame] | 790 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 791 | if (NOT LWS_WITHOUT_CLIENT) |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 792 | # |
| 793 | # test-client |
| 794 | # |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 795 | if (NOT LWS_WITHOUT_TEST_CLIENT) |
Patrick Gansterer | 73882e4 | 2014-03-29 08:25:58 +0100 | [diff] [blame] | 796 | create_test_app(test-client "test-server/test-client.c") |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 797 | endif() |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 798 | |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 799 | # |
| 800 | # test-fraggle |
| 801 | # |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 802 | if (NOT LWS_WITHOUT_TEST_FRAGGLE) |
Patrick Gansterer | 73882e4 | 2014-03-29 08:25:58 +0100 | [diff] [blame] | 803 | create_test_app(test-fraggle "test-server/test-fraggle.c") |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 804 | endif() |
| 805 | |
| 806 | # |
| 807 | # test-ping |
| 808 | # |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 809 | if (NOT LWS_WITHOUT_TEST_PING) |
Patrick Gansterer | 73882e4 | 2014-03-29 08:25:58 +0100 | [diff] [blame] | 810 | create_test_app(test-ping "test-server/test-ping.c") |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 811 | endif() |
Andy Green | 27696f2 | 2013-03-10 08:09:25 +0800 | [diff] [blame] | 812 | # |
| 813 | # test-echo |
| 814 | # |
| 815 | if (NOT WITHOUT_TEST_ECHO) |
Patrick Gansterer | 73882e4 | 2014-03-29 08:25:58 +0100 | [diff] [blame] | 816 | create_test_app(test-echo "test-server/test-echo.c") |
Andy Green | 27696f2 | 2013-03-10 08:09:25 +0800 | [diff] [blame] | 817 | endif() |
| 818 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 819 | endif(NOT LWS_WITHOUT_CLIENT) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 820 | |
| 821 | # |
| 822 | # Copy OpenSSL dlls to the output directory on Windows. |
| 823 | # (Otherwise we'll get an error when trying to run) |
| 824 | # |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 825 | if (WIN32 AND LWS_WITH_SSL AND NOT LWS_USE_WOLFSSL) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 826 | if(OPENSSL_BIN_FOUND) |
Joakim Soderberg | 20aedc8 | 2013-02-22 09:28:11 +0800 | [diff] [blame] | 827 | message("OpenSSL dlls found:") |
| 828 | message(" Libeay: ${LIBEAY_BIN}") |
| 829 | message(" SSLeay: ${SSLEAY_BIN}") |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 830 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 831 | foreach(TARGET_BIN ${TEST_APP_LIST}) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 832 | add_custom_command(TARGET ${TARGET_BIN} |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 833 | POST_BUILD |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 834 | 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] | 835 | add_custom_command(TARGET ${TARGET_BIN} |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 836 | POST_BUILD |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 837 | COMMAND "${CMAKE_COMMAND}" -E copy "${SSLEAY_BIN}" "$<TARGET_FILE_DIR:${TARGET_BIN}>" VERBATIM) |
Joakim Soderberg | 4c53123 | 2013-02-06 15:26:58 +0900 | [diff] [blame] | 838 | endforeach() |
| 839 | endif() |
| 840 | endif() |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 841 | endif(NOT LWS_WITHOUT_TESTAPPS) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 842 | |
| 843 | if (UNIX) |
| 844 | # Generate documentation. |
| 845 | # TODO: Fix this on Windows. |
| 846 | message("Generating API documentation") |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 847 | file(GLOB C_FILES "${PROJECT_SOURCE_DIR}/lib/*.c") |
| 848 | execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${PROJECT_BINARY_DIR}/doc/") |
Joakim Söderberg | 455e451 | 2013-02-19 10:14:54 +0800 | [diff] [blame] | 849 | |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 850 | execute_process( |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 851 | COMMAND "${PROJECT_SOURCE_DIR}/scripts/kernel-doc" -html ${C_FILES} ${HDR_PUBLIC} |
| 852 | OUTPUT_FILE "${PROJECT_BINARY_DIR}/doc/libwebsockets-api-doc.html" |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 853 | ERROR_QUIET) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 854 | |
| 855 | execute_process( |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 856 | COMMAND "${PROJECT_SOURCE_DIR}/scripts/kernel-doc" -text ${C_FILES} ${HDR_PUBLIC} |
| 857 | OUTPUT_FILE "${PROJECT_BINARY_DIR}/doc/libwebsockets-api-doc.txt" |
Joakim Soderberg | 7eadd58 | 2013-02-22 09:28:04 +0800 | [diff] [blame] | 858 | ERROR_QUIET) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 859 | |
| 860 | # Generate and install pkgconfig. |
| 861 | # (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] | 862 | file(WRITE "${PROJECT_BINARY_DIR}/libwebsockets.pc" |
Andy Green | 0f3e413 | 2014-02-27 07:28:45 +0800 | [diff] [blame] | 863 | "prefix=\"${CMAKE_INSTALL_PREFIX}\" |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 864 | exec_prefix=\${prefix} |
Andy Green | 975423c | 2013-02-26 11:58:45 +0800 | [diff] [blame] | 865 | libdir=\${exec_prefix}/lib${LIB_SUFFIX} |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 866 | includedir=\${prefix}/include |
| 867 | |
| 868 | Name: libwebsockets |
| 869 | Description: Websockets server and client library |
Andy Green | e919af8 | 2014-02-15 14:45:14 +0800 | [diff] [blame] | 870 | Version: ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR} |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 871 | |
| 872 | Libs: -L\${libdir} -lwebsockets |
| 873 | Cflags: -I\${includedir}" |
| 874 | ) |
| 875 | |
Markus Elfring | 299244f | 2013-10-26 20:03:43 +0800 | [diff] [blame] | 876 | install(FILES "${PROJECT_BINARY_DIR}/libwebsockets.pc" |
Andy Green | c8c1662 | 2013-03-10 08:10:19 +0800 | [diff] [blame] | 877 | DESTINATION lib${LIB_SUFFIX}/pkgconfig) |
Edwin van den Oetelaar | 15a38a7 | 2013-03-10 06:53:57 +0800 | [diff] [blame] | 878 | endif(UNIX) |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 879 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 880 | # |
| 881 | # Installation preparations. |
| 882 | # |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 883 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 884 | if(WIN32 AND NOT CYGWIN) |
| 885 | set(DEF_INSTALL_CMAKE_DIR cmake) |
| 886 | else() |
| 887 | set(DEF_INSTALL_CMAKE_DIR lib/cmake/libwebsockets) |
| 888 | endif() |
| 889 | |
| 890 | set(LWS_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files") |
| 891 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 892 | # Export targets (This is used for other CMake projects to easily find the libraries and include files). |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 893 | export(TARGETS ${LWS_LIBRARIES} |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 894 | FILE "${PROJECT_BINARY_DIR}/LibwebsocketsTargets.cmake") |
| 895 | export(PACKAGE libwebsockets) |
| 896 | |
| 897 | # Generate the config file for the build-tree. |
| 898 | set(LWS__INCLUDE_DIRS |
| 899 | "${PROJECT_SOURCE_DIR}/lib" |
| 900 | "${PROJECT_BINARY_DIR}") |
| 901 | set(LIBWEBSOCKETS_INCLUDE_DIRS ${LWS__INCLUDE_DIRS} CACHE PATH "Libwebsockets include directories") |
| 902 | configure_file(${PROJECT_SOURCE_DIR}/cmake/LibwebsocketsConfig.cmake.in |
| 903 | ${PROJECT_BINARY_DIR}/LibwebsocketsConfig.cmake |
| 904 | @ONLY) |
| 905 | |
| 906 | # Generate the config file for the installation tree. |
Patrick Gansterer | e04ec35 | 2014-02-28 16:29:28 +0100 | [diff] [blame] | 907 | get_filename_component(LWS_ABSOLUTE_INSTALL_CMAKE_DIR ${LWS_INSTALL_CMAKE_DIR} ABSOLUTE) |
| 908 | 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] | 909 | file(RELATIVE_PATH |
| 910 | REL_INCLUDE_DIR |
Patrick Gansterer | e04ec35 | 2014-02-28 16:29:28 +0100 | [diff] [blame] | 911 | "${LWS_ABSOLUTE_INSTALL_CMAKE_DIR}" |
| 912 | "${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] | 913 | |
| 914 | # Note the EVENT_CMAKE_DIR is defined in JanssonConfig.cmake.in, |
| 915 | # we escape it here so it's evaluated when it is included instead |
| 916 | # so that the include dirs are given relative to where the |
| 917 | # config file is located. |
| 918 | set(LWS__INCLUDE_DIRS |
| 919 | "\${LWS_CMAKE_DIR}/${REL_INCLUDE_DIR}") |
| 920 | configure_file(${PROJECT_SOURCE_DIR}/cmake/LibwebsocketsConfig.cmake.in |
| 921 | ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/LibwebsocketsConfig.cmake |
| 922 | @ONLY) |
| 923 | |
| 924 | # Generate version info for both build-tree and install-tree. |
| 925 | configure_file(${PROJECT_SOURCE_DIR}/cmake/LibwebsocketsConfigVersion.cmake.in |
| 926 | ${PROJECT_BINARY_DIR}/LibwebsocketsConfigVersion.cmake |
| 927 | @ONLY) |
| 928 | |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 929 | set_target_properties(${LWS_LIBRARIES} |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 930 | PROPERTIES PUBLIC_HEADER "${HDR_PUBLIC}") |
| 931 | |
| 932 | # |
| 933 | # Installation. |
| 934 | # |
| 935 | |
| 936 | # Install libs and headers. |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 937 | install(TARGETS ${LWS_LIBRARIES} |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 938 | EXPORT LibwebsocketsTargets |
| 939 | LIBRARY DESTINATION "${LWS_INSTALL_LIB_DIR}${LIB_SUFFIX}" COMPONENT libraries |
| 940 | ARCHIVE DESTINATION "${LWS_INSTALL_LIB_DIR}${LIB_SUFFIX}" COMPONENT libraries |
| 941 | RUNTIME DESTINATION "${LWS_INSTALL_BIN_DIR}" COMPONENT libraries # Windows DLLs |
| 942 | PUBLIC_HEADER DESTINATION "${LWS_INSTALL_INCLUDE_DIR}" COMPONENT dev) |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 943 | set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 944 | set(CPACK_COMPONENT_DEV_DISPLAY_NAME "Development files") |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 945 | |
| 946 | # Install test apps. |
Andy Green | 7f54e76 | 2014-02-21 18:48:05 +0800 | [diff] [blame] | 947 | if (NOT LWS_WITHOUT_TESTAPPS AND NOT LWS_WITHOUT_CLIENT) |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 948 | install(TARGETS test-client ${TEST_APP_LIST} |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 949 | RUNTIME DESTINATION ${LWS_INSTALL_EXAMPLES_DIR} |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 950 | COMPONENT examples) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 951 | set(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Example files") |
Joakim Söderberg | 6ac9709 | 2013-02-19 10:14:37 +0800 | [diff] [blame] | 952 | endif() |
| 953 | |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 954 | # Programs shared files used by the test-server. |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 955 | if (NOT LWS_WITHOUT_TESTAPPS AND NOT LWS_WITHOUT_SERVER) |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 956 | install(FILES ${TEST_SERVER_DATA} |
| 957 | DESTINATION share/libwebsockets-test-server |
| 958 | COMPONENT examples) |
| 959 | endif() |
| 960 | |
Andy Green | 2aab3f9 | 2013-03-10 08:11:48 +0800 | [diff] [blame] | 961 | # build subdir is not part of sources |
| 962 | set(CPACK_SOURCE_IGNORE_FILES $(CPACK_SOURCE_IGNORE_FILES) ".git" "build" "tgz" "tar.gz") |
| 963 | |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 964 | # 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] | 965 | add_custom_target(dist COMMAND "${CMAKE_MAKE_PROGRAM}" package_source) |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 966 | |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 967 | include(UseRPMTools) |
| 968 | if (RPMTools_FOUND) |
Tomas Cejka | efda177 | 2013-04-11 08:13:13 +0800 | [diff] [blame] | 969 | RPMTools_ADD_RPM_TARGETS(libwebsockets libwebsockets.spec) |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 970 | endif() |
| 971 | |
| 972 | message("---------------------------------------------------------------------") |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 973 | message(" Settings: (For more help do cmake -LH <srcpath>)") |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 974 | message("---------------------------------------------------------------------") |
| 975 | message(" LWS_WITH_SSL = ${LWS_WITH_SSL} (SSL Support)") |
Andy Green | d2ec7ad | 2014-03-15 10:39:29 +0800 | [diff] [blame] | 976 | message(" LWS_SSL_CLIENT_USE_OS_CA_CERTS = ${LWS_SSL_CLIENT_USE_OS_CA_CERTS}") |
ABruines | 80a7068 | 2015-08-09 22:56:32 +0200 | [diff] [blame] | 977 | message(" LWS_USE_WOLFSSL = ${LWS_USE_WOLFSSL} (wolfSSL/CyaSSL replacement for OpenSSL)") |
Alexander Bruines | c3bcb89 | 2015-08-08 18:54:49 +0200 | [diff] [blame] | 978 | if (LWS_USE_WOLFSSL) |
| 979 | message(" LWS_WOLFSSL_LIBRARIES = ${LWS_WOLFSSL_LIBRARIES}") |
| 980 | message(" LWS_WOLFSSL_INCLUDE_DIRS = ${LWS_WOLFSSL_INCLUDE_DIRS}") |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 981 | endif() |
| 982 | message(" LWS_WITHOUT_BUILTIN_GETIFADDRS = ${LWS_WITHOUT_BUILTIN_GETIFADDRS}") |
| 983 | message(" LWS_WITHOUT_CLIENT = ${LWS_WITHOUT_CLIENT}") |
| 984 | message(" LWS_WITHOUT_SERVER = ${LWS_WITHOUT_SERVER}") |
| 985 | message(" LWS_LINK_TESTAPPS_DYNAMIC = ${LWS_LINK_TESTAPPS_DYNAMIC}") |
| 986 | message(" LWS_WITHOUT_TESTAPPS = ${LWS_WITHOUT_TESTAPPS}") |
| 987 | message(" LWS_WITHOUT_TEST_SERVER = ${LWS_WITHOUT_TEST_SERVER}") |
| 988 | message(" LWS_WITHOUT_TEST_SERVER_EXTPOLL = ${LWS_WITHOUT_TEST_SERVER_EXTPOLL}") |
| 989 | message(" LWS_WITHOUT_TEST_PING = ${LWS_WITHOUT_TEST_PING}") |
| 990 | message(" LWS_WITHOUT_TEST_CLIENT = ${LWS_WITHOUT_TEST_CLIENT}") |
| 991 | message(" LWS_WITHOUT_TEST_FRAGGLE = ${LWS_WITHOUT_TEST_FRAGGLE}") |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 992 | message(" LWS_WITHOUT_EXTENSIONS = ${LWS_WITHOUT_EXTENSIONS}") |
| 993 | message(" LWS_WITH_LATENCY = ${LWS_WITH_LATENCY}") |
| 994 | message(" LWS_WITHOUT_DAEMONIZE = ${LWS_WITHOUT_DAEMONIZE}") |
Andrew Canaday | 9769f4f | 2014-03-23 13:25:07 +0800 | [diff] [blame] | 995 | message(" LWS_USE_LIBEV = ${LWS_USE_LIBEV}") |
Andy Green | 2eedea9 | 2014-04-03 14:33:48 +0800 | [diff] [blame] | 996 | message(" LWS_IPV6 = ${LWS_IPV6}") |
| 997 | message(" LWS_WITH_HTTP2 = ${LWS_WITH_HTTP2}") |
Joakim Soderberg | 6744555 | 2014-02-15 13:48:56 +0800 | [diff] [blame] | 998 | message("---------------------------------------------------------------------") |
| 999 | |
| 1000 | # These will be available to parent projects including libwebsockets using add_subdirectory() |
wonder-mice | f1b1254 | 2015-04-22 10:52:13 -0700 | [diff] [blame] | 1001 | set(LIBWEBSOCKETS_LIBRARIES ${LWS_LIBRARIES} CACHE STRING "Libwebsocket libraries") |
| 1002 | if (LWS_WITH_STATIC) |
| 1003 | set(LIBWEBSOCKETS_LIBRARIES_STATIC websocket CACHE STRING "Libwebsocket static library") |
| 1004 | endif() |
| 1005 | if (LWS_WITH_SHARED) |
| 1006 | set(LIBWEBSOCKETS_LIBRARIES_SHARED websockets_shared CACHE STRING "Libwebsocket shared library") |
| 1007 | endif() |
Tomas Cejka | efda177 | 2013-04-11 08:13:13 +0800 | [diff] [blame] | 1008 | |
Joakim Soderberg | b37827b | 2013-02-22 09:28:08 +0800 | [diff] [blame] | 1009 | # This must always be last! |
| 1010 | include(CPack) |