1include(CheckCSourceCompiles) 2include(CheckIncludeFiles) 3include(CheckFunctionExists) 4include(CheckSymbolExists) 5include(CheckVariableExists) 6include(CheckTypeSize) 7include(CheckLibraryExists) 8include(CMakeDetermineCCompiler) 9include(FindThreads) 10include(FindPkgConfig) 11 12include(LighttpdMacros) 13 14add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES) 15 16# default to ON 17set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Default value for ``POSITION_INDEPENDENT_CODE`` of targets.") 18 19option(WITH_XATTR "with xattr-support for the stat-cache [default: off]") 20option(WITH_MYSQL "with mysql-support for mod_vhostdb_mysql [default: off]") 21option(WITH_PGSQL "with postgres-support for mod_vhostdb_pgsql [default: off]") 22option(WITH_DBI "with dbi-support for mod_vhostdb_dbi [default: off]") 23option(WITH_GNUTLS "with GnuTLS-support [default: off]") 24option(WITH_MBEDTLS "with mbedTLS-support [default: off]") 25option(WITH_NSS "with NSS-crypto-support [default: off]") 26option(WITH_OPENSSL "with openssl-support [default: off]") 27option(WITH_WOLFSSL "with wolfSSL-support [default: off]") 28option(WITH_NETTLE "with Nettle-support [default: off]") 29option(WITH_PCRE "with regex support [default: on]" ON) 30option(WITH_WEBDAV_PROPS "with property-support for mod_webdav [default: off]") 31option(WITH_WEBDAV_LOCKS "locks in webdav [default: off]") 32option(WITH_BROTLI "with brotli-support for mod_deflate [default: off]") 33option(WITH_BZIP "with bzip2-support for mod_deflate [default: off]") 34option(WITH_ZLIB "with deflate-support for mod_deflate [default: on]" ON) 35option(WITH_KRB5 "with Kerberos5-support for mod_auth [default: off]") 36option(WITH_LDAP "with LDAP-support for mod_auth mod_vhostdb_ldap [default: off]") 37option(WITH_PAM "with PAM-support for mod_auth [default: off]") 38option(WITH_LUA "with lua 5.1 for mod_magnet [default: off]") 39# option(WITH_VALGRIND "with internal support for valgrind [default: off]") 40option(WITH_FAM "fam/gamin for reducing number of stat() calls [default: off]") 41option(WITH_GDBM "gdbm storage for mod_trigger_b4_dl [default: off]") 42option(WITH_MEMCACHED "memcached storage for mod_trigger_b4_dl [default: off]") 43option(WITH_LIBEV "libev support for fdevent handlers [default: off]") 44option(WITH_LIBUNWIND "with libunwind to print backtraces in asserts [default: off]") 45option(WITH_GEOIP "with GeoIP-support mod_geoip [default: off]") 46option(WITH_MAXMINDDB "with MaxMind GeoIP2-support mod_maxminddb [default: off]") 47option(WITH_SASL "with SASL-support for mod_authn_sasl [default: off]") 48option(WITH_XXHASH "with system-provided xxhash [default: off]") 49 50if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") 51 option(BUILD_EXTRA_WARNINGS "extra warnings") 52 53 if(BUILD_EXTRA_WARNINGS) 54 set(WARN_CFLAGS "-g -g2 -Wall -Wmissing-declarations -Wcast-align -Wsign-compare -Wnested-externs -Wpointer-arith -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security") 55 set(WARN_LDFLAGS "-Wl,--as-needed") 56 # -Werror -Wbad-function-cast -Wmissing-prototypes 57 endif() 58endif() 59 60option(BUILD_STATIC "build a static lighttpd with all modules added") 61 62if(BUILD_STATIC) 63 set(LIGHTTPD_STATIC 1) 64elseif(APPLE) 65 set(CMAKE_SHARED_MODULE_PREFIX "") 66else() 67 set(CMAKE_SHARED_LIBRARY_PREFIX "") 68endif() 69 70if(WITH_LIBEV) 71 find_package(LibEV REQUIRED) 72 set(HAVE_LIBEV 1) 73endif() 74 75if(WITH_LIBUNWIND) 76 pkg_check_modules(LIBUNWIND REQUIRED libunwind) 77 set(HAVE_LIBUNWIND 1) 78endif() 79 80if(WITH_WEBDAV_PROPS) 81 set(WITH_XML 1) 82 set(WITH_SQLITE3 1) 83endif() 84 85if(WITH_WEBDAV_LOCKS) 86 set(WITH_UUID 1) 87endif() 88 89check_include_files(sys/devpoll.h HAVE_SYS_DEVPOLL_H) 90check_include_files(sys/epoll.h HAVE_SYS_EPOLL_H) 91set(CMAKE_REQUIRED_FLAGS "-include sys/types.h") 92check_include_files(sys/event.h HAVE_SYS_EVENT_H) 93set(CMAKE_REQUIRED_FLAGS) 94check_include_files(sys/mman.h HAVE_SYS_MMAN_H) 95check_include_files(sys/loadavg.h HAVE_SYS_LOADAVG_H) 96check_include_files(sys/poll.h HAVE_SYS_POLL_H) 97check_include_files(sys/port.h HAVE_SYS_PORT_H) 98check_include_files(sys/prctl.h HAVE_SYS_PRCTL_H) 99check_include_files(sys/resource.h HAVE_SYS_RESOURCE_H) 100check_include_files(sys/sendfile.h HAVE_SYS_SENDFILE_H) 101check_include_files(sys/select.h HAVE_SYS_SELECT_H) 102check_include_files(sys/types.h HAVE_SYS_TYPES_H) 103check_include_files(sys/uio.h HAVE_SYS_UIO_H) 104check_include_files(sys/un.h HAVE_SYS_UN_H) 105check_include_files(sys/wait.h HAVE_SYS_WAIT_H) 106check_include_files(sys/time.h HAVE_SYS_TIME_H) 107check_include_files(unistd.h HAVE_UNISTD_H) 108check_include_files(pthread.h HAVE_PTHREAD_H) 109check_include_files(getopt.h HAVE_GETOPT_H) 110check_include_files(inttypes.h HAVE_INTTYPES_H) 111check_include_files(poll.h HAVE_POLL_H) 112check_include_files(pwd.h HAVE_PWD_H) 113check_include_files(stddef.h HAVE_STDDEF_H) 114check_include_files(stdint.h HAVE_STDINT_H) 115check_include_files(strings.h HAVE_STRINGS_H) 116check_include_files(syslog.h HAVE_SYSLOG_H) 117 118# check for fastcgi lib, for the tests only 119check_include_files(fastcgi.h HAVE_FASTCGI_H) 120check_include_files(fastcgi/fastcgi.h HAVE_FASTCGI_FASTCGI_H) 121 122# will be needed for auth 123check_include_files(crypt.h HAVE_CRYPT_H) 124# check if we need libcrypt for crypt_r() 125check_library_exists(crypt crypt_r "" HAVE_LIBCRYPT_CRYPT_R) 126if(HAVE_LIBCRYPT_CRYPT_R) 127 set(HAVE_CRYPT_R 1) 128 set(HAVE_LIBCRYPT 1) 129else() 130 check_library_exists(crypt crypt "" HAVE_LIBCRYPT) 131endif() 132check_function_exists(crypt_r HAVE_CRYPT_R) 133check_function_exists(crypt HAVE_CRYPT) 134 135check_include_files(sys/inotify.h HAVE_SYS_INOTIFY_H) 136if(HAVE_SYS_INOTIFY_H) 137 check_function_exists(inotify_init HAVE_INOTIFY_INIT) 138endif() 139 140set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h) 141check_type_size(socklen_t HAVE_SOCKLEN_T) 142set(CMAKE_EXTRA_INCLUDE_FILES) 143 144check_include_files(sys/random.h HAVE_SYS_RANDOM_H) 145set(CMAKE_EXTRA_INCLUDE_FILES sys/random.h) 146check_function_exists(getentropy HAVE_GETENTROPY) 147set(CMAKE_EXTRA_INCLUDE_FILES) 148 149check_include_files(linux/random.h HAVE_LINUX_RANDOM_H) 150set(CMAKE_EXTRA_INCLUDE_FILES linux/random.h) 151check_function_exists(getrandom HAVE_GETRANDOM) 152set(CMAKE_EXTRA_INCLUDE_FILES) 153 154check_type_size(long SIZEOF_LONG) 155check_type_size(off_t SIZEOF_OFF_T) 156 157check_function_exists(arc4random_buf HAVE_ARC4RANDOM_BUF) 158check_function_exists(chroot HAVE_CHROOT) 159check_function_exists(copy_file_range HAVE_COPY_FILE_RANGE) 160check_function_exists(epoll_ctl HAVE_EPOLL_CTL) 161check_function_exists(fork HAVE_FORK) 162check_function_exists(getloadavg HAVE_GETLOADAVG) 163check_function_exists(getrlimit HAVE_GETRLIMIT) 164check_function_exists(getuid HAVE_GETUID) 165check_function_exists(gmtime_r HAVE_GMTIME_R) 166check_function_exists(inet_ntop HAVE_INET_NTOP) 167check_function_exists(jrand48 HAVE_JRAND48) 168check_function_exists(kqueue HAVE_KQUEUE) 169check_function_exists(localtime_r HAVE_LOCALTIME_R) 170check_function_exists(lstat HAVE_LSTAT) 171check_function_exists(madvise HAVE_MADVISE) 172check_function_exists(memcpy HAVE_MEMCPY) 173check_function_exists(memset HAVE_MEMSET) 174check_function_exists(mmap HAVE_MMAP) 175check_function_exists(pathconf HAVE_PATHCONF) 176check_function_exists(pipe2 HAVE_PIPE2) 177check_function_exists(poll HAVE_POLL) 178check_function_exists(port_create HAVE_PORT_CREATE) 179check_function_exists(prctl HAVE_PRCTL) 180check_function_exists(pread HAVE_PREAD) 181check_function_exists(posix_fadvise HAVE_POSIX_FADVISE) 182check_function_exists(select HAVE_SELECT) 183check_function_exists(sendfile HAVE_SENDFILE) 184check_function_exists(send_file HAVE_SEND_FILE) 185check_function_exists(sendfile64 HAVE_SENDFILE64) 186check_function_exists(sendfilev HAVE_SENDFILEV) 187check_function_exists(sigaction HAVE_SIGACTION) 188check_function_exists(signal HAVE_SIGNAL) 189check_function_exists(sigtimedwait HAVE_SIGTIMEDWAIT) 190check_function_exists(srandom HAVE_SRANDOM) 191check_function_exists(strptime HAVE_STRPTIME) 192check_function_exists(syslog HAVE_SYSLOG) 193check_function_exists(writev HAVE_WRITEV) 194check_function_exists(inet_aton HAVE_INET_ATON) 195check_function_exists(issetugid HAVE_ISSETUGID) 196check_function_exists(inet_pton HAVE_INET_PTON) 197check_function_exists(memset_s HAVE_MEMSET_S) 198check_function_exists(explicit_bzero HAVE_EXPLICIT_BZERO) 199check_function_exists(explicit_memset HAVE_EXPLICIT_MEMSET) 200check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME) 201if (NOT HAVE_CLOCK_GETTIME) 202 check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME) 203endif() 204check_library_exists(elftc elftc_copyfile "libelftc.h" HAVE_ELFTC_COPYFILE) 205check_c_source_compiles(" 206 #include <sys/types.h> 207 #include <sys/socket.h> 208 #include <netinet/in.h> 209 210 int main() { 211 struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0; 212 return 0; 213 }" HAVE_IPV6) 214check_c_source_compiles(" 215 __attribute__((weak)) void __dummy(void *x) { } 216 int main() { 217 void *x; 218 __dummy(x); 219 } 220 " HAVE_WEAK_SYMBOLS) 221check_c_source_compiles(" 222 #include <time.h> 223 int main(void) { 224 struct tm t; 225 t.tm_gmtoff = 0; 226 return 0; 227 } 228 " HAVE_STRUCT_TM_GMTOFF) 229 230## refactor me 231macro(XCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags) 232# reset the variables at the beginning 233 set(${_include_DIR}) 234 set(${_link_DIR}) 235 set(${_link_FLAGS}) 236 set(${_cflags}) 237 238 find_program(${_package}CONFIG_EXECUTABLE NAMES ${_package} PATHS /usr/local/bin ) 239 240 # if pkg-config has been found 241 if(${_package}CONFIG_EXECUTABLE) 242 set(XCONFIG_EXECUTABLE "${${_package}CONFIG_EXECUTABLE}") 243 message(STATUS "found ${_package}: ${XCONFIG_EXECUTABLE}") 244 245 exec_program(${XCONFIG_EXECUTABLE} ARGS --libs OUTPUT_VARIABLE __link_FLAGS) 246 string(REPLACE "\n" "" ${_link_FLAGS} ${__link_FLAGS}) 247 exec_program(${XCONFIG_EXECUTABLE} ARGS --cflags OUTPUT_VARIABLE __cflags) 248 string(REPLACE "\n" "" ${_cflags} ${__cflags}) 249 else() 250 message(STATUS "found ${_package}: no") 251 endif() 252endmacro(XCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags) 253 254if(WITH_XATTR) 255 check_include_files("sys/types.h;sys/xattr.h" HAVE_SYS_XATTR_H) 256 check_function_exists(getxattr HAVE_XATTR) 257 check_include_files("sys/types.h;attr/attributes.h" HAVE_ATTR_ATTRIBUTES_H) 258 if(HAVE_ATTR_ATTRIBUTES_H) 259 check_library_exists(attr attr_get "" HAVE_XATTR) 260 endif() 261else() 262 unset(HAVE_ATTR_ATTRIBUTES_H) 263 unset(HAVE_XATTR) 264endif() 265 266if(WITH_MYSQL) 267 xconfig(mysql_config MYSQL_INCDIR MYSQL_LIBDIR MYSQL_LDFLAGS MYSQL_CFLAGS) 268 269 set(CMAKE_REQUIRED_INCLUDES /usr/include/mysql) 270 check_include_files(mysql.h HAVE_MYSQL_H) 271 set(CMAKE_REQUIRED_INCLUDES) 272 if(HAVE_MYSQL_H) 273 check_library_exists(mysqlclient mysql_real_connect "" HAVE_MYSQL) 274 endif() 275else() 276 unset(HAVE_MYSQL_H) 277 unset(HAVE_MYSQL) 278endif() 279 280if(WITH_PGSQL) 281 xconfig(pg_config PGSQL_INCDIR PGSQL_LIBDIR PGSQL_LDFLAGS PGSQL_CFLAGS) 282 283 check_include_files(libpq-fe.h HAVE_PGSQL_H) 284 if(HAVE_PGSQL_H) 285 check_library_exists(pq PQsetdbLogin "" HAVE_PGSQL) 286 endif() 287else() 288 unset(HAVE_PGSQL_H) 289 unset(HAVE_PGSQL) 290endif() 291 292if(WITH_DBI) 293 check_include_files(dbi/dbi.h HAVE_DBI_H) 294 if(HAVE_DBI_H) 295 check_library_exists(dbi dbi_conn_connect "" HAVE_DBI) 296 endif() 297else() 298 unset(HAVE_DBI_H) 299 unset(HAVE_DBI) 300endif() 301 302set(CRYPTO_LIBRARY "") 303 304if(WITH_OPENSSL) 305 if(APPLE) 306 set(CMAKE_REQUIRED_INCLUDES /opt/local/include) 307 endif() 308 check_include_files(openssl/ssl.h HAVE_OPENSSL_SSL_H) 309 if(APPLE) 310 set(CMAKE_REQUIRED_INCLUDES) 311 endif() 312 if(HAVE_OPENSSL_SSL_H) 313 check_library_exists(crypto BIO_f_base64 "" HAVE_LIBCRYPTO) 314 if(HAVE_LIBCRYPTO) 315 set(CRYPTO_LIBRARY crypto) 316 check_library_exists(ssl SSL_new "" HAVE_LIBSSL) 317 set(HAVE_OPENSSL 1) 318 endif() 319 endif() 320else() 321 unset(HAVE_OPENSSL_SSL_H) 322 unset(HAVE_LIBSSL) 323endif() 324 325if(WITH_WOLFSSL) 326 pkg_check_modules(WOLFSSL QUIET wolfssl) 327 if(NOT ${WITH_WOLFSSL} EQUAL "") 328 find_path(WOLFSSL_INCLUDE_DIR wolfssl/ssl.h ${WITH_WOLFSSL}/include) 329 elseif(WOLFSSL_FOUND) 330 set(WOLFSSL_INCLUDE_DIR ${WOLFSSL_INCLUDE_DIRS}) 331 elseif(APPLE) 332 find_path(WOLFSSL_INCLUDE_DIR wolfssl/ssl.h /opt/local/include) 333 else() 334 find_path(WOLFSSL_INCLUDE_DIR wolfssl/ssl.h /usr/local/include) 335 endif() 336 337 if(NOT ${WITH_WOLFSSL} EQUAL "") 338 find_library(WOLFSSL_LIBRARY 339 NAMES wolfssl 340 PATHS ${WITH_WOLFSSL}/lib 341 ) 342 elseif(WOLFSSL_FOUND) 343 set(WOLFSSL_LIBRARY ${WOLFSSL_LIBRARY_DIRS}) 344 else() 345 find_library(WOLFSSL_LIBRARY 346 NAMES wolfssl 347 PATHS /usr/local/lib /opt/local/lib /usr/lib 348 ) 349 endif() 350 351 if(WOLFSSL_INCLUDE_DIR AND WOLFSSL_LIBRARY) 352 set(CMAKE_REQUIRED_INCLUDES ${WOLFSSL_INCLUDE_DIR}) 353 check_include_files(wolfssl/ssl.h HAVE_WOLFSSL_SSL_H) 354 355 check_c_source_compiles(" 356 #include <wolfssl/options.h> 357 #if !defined(HAVE_LIGHTY) && !defined(OPENSSL_EXTRA) 358 #error HAVE_LIGHTY macro not defined 359 #endif 360 int main() { return 0; } 361 " CHECK_HAVE_LIGHTY) 362 if (NOT CHECK_HAVE_LIGHTY) 363 message(FATAL_ERROR "wolfssl must be built with ./configure --enable-lighty") 364 endif() 365 unset(CHECK_HAVE_LIGHTY) 366 367 set(CMAKE_REQUIRED_LIBRARIES ${WOLFSSL_LIBRARY}) 368 check_library_exists(${WOLFSSL_LIBRARY} wolfSSL_Init "" HAVE_LIBCRYPTO) 369 if(HAVE_LIBCRYPTO) 370 set(CRYPTO_LIBRARY ${WOLFSSL_LIBRARY}) 371 add_definitions(-DHAVE_WOLFSSL_SSL_H) 372 set(HAVE_WOLFSSL 1) 373 endif() 374 set(CMAKE_REQUIRED_INCLUDES) 375 set(CMAKE_REQUIRED_LIBRARIES) 376 include_directories(${WOLFSSL_INCLUDE_DIR} ${WOLFSSL_INCLUDE_DIR}/wolfssl) 377 endif() 378 unset(WOLFSSL_LIBRARY) 379 unset(WOLFSSL_INCLUDE_DIR) 380else() 381 unset(HAVE_WOLFSSL_SSL_H) 382endif() 383 384if(WITH_MBEDTLS) 385 check_include_files(mbedtls/ssl.h HAVE_MBEDTLS_SSL_H) 386 if(HAVE_MBEDTLS_SSL_H) 387 check_library_exists(mbedcrypto mbedtls_base64_encode "" HAVE_LIBMBEDCRYPTO) 388 if(HAVE_LIBMEDTLSCRYPTO) 389 check_library_exists(mbedtls mbedtls_cipher_info_from_type "" HAVE_LIBMBEDTLS) 390 if(HAVE_LIBMBEDTLS) 391 check_library_exists(mbedx509 mbedtls_x509_get_name "" HAVE_LIBMBEDX509) 392 endif() 393 endif() 394 endif() 395else() 396 unset(HAVE_MBEDTLS_SSL_H) 397 unset(HAVE_LIBMBEDCRYPTO) 398 unset(HAVE_LIBMBEDTLS) 399 unset(HAVE_LIBMEDX509) 400endif() 401 402if(WITH_NSS) 403 check_include_files(nss/nss.h HAVE_NSS_NSS_H) 404 check_include_files(nss3/nss.h HAVE_NSS3_NSS_H) 405 if(HAVE_NSS3_NSS_H OR HAVE_NSS_NSS_H) 406 check_library_exists(ssl3 NSSSSL_GetVersion "" HAVE_LIBSSL3) 407 if(HAVE_LIBSSL3) 408 check_library_exists(smime3 NSSSMIME_GetVersion "" HAVE_LIBSMIME3) 409 if(HAVE_LIBSMIME3) 410 check_library_exists(nss3 NSS_GetVersion "" HAVE_LIBNSS3) 411 if(HAVE_LIBNSS3) 412 check_library_exists(nssutil3 NSSUTIL_GetVersion "" HAVE_LIBNSSUTIL3) 413 endif() 414 endif() 415 endif() 416 endif() 417else() 418 unset(HAVE_NSS_NSS_H) 419 unset(HAVE_NSS3_NSS_H) 420 unset(HAVE_LIBSSL3) 421 unset(HAVE_LIBSMIME3) 422 unset(HAVE_LIBNSS3) 423 unset(HAVE_LIBNSSUTIL3) 424endif() 425 426if(WITH_NETTLE) 427 if(APPLE) 428 set(CMAKE_REQUIRED_INCLUDES /opt/local/include) 429 endif() 430 check_include_files(nettle/nettle-types.h HAVE_NETTLE_NETTLE_TYPES_H) 431 if(APPLE) 432 set(CMAKE_REQUIRED_INCLUDES) 433 endif() 434 if(HAVE_NETTLE_NETTLE_TYPES_H) 435 check_library_exists(nettle nettle_md5_init "" HAVE_LIBCRYPTO) 436 if(HAVE_LIBCRYPTO) 437 set(CRYPTO_LIBRARY nettle) 438 endif() 439 endif() 440else() 441 unset(HAVE_NETTLE_NETTLE_TYPES_H) 442endif() 443 444if(WITH_GNUTLS) 445 pkg_check_modules(LIBGNUTLS REQUIRED gnutls) 446 set(HAVE_LIBGNUTLS 1) 447 add_definitions(-DHAVE_GNUTLS_CRYPTO_H) 448 if(NOT WITH_OPENSSL AND NOT WITH_WOLFSSL AND NOT WITH_MBEDTLS AND NOT WITH_NETTLE) 449 set(CRYPTO_LIBRARY gnutls) 450 endif() 451endif() 452 453if(WITH_PCRE) 454 ## if we have pcre-config, use it 455 xconfig(pcre-config PCRE_INCDIR PCRE_LIBDIR PCRE_LDFLAGS PCRE_CFLAGS) 456 if(PCRE_LDFLAGS OR PCRE_CFLAGS) 457 message(STATUS "found pcre at: LDFLAGS: ${PCRE_LDFLAGS} CFLAGS: ${PCRE_CFLAGS}") 458 459 if(NOT PCRE_CFLAGS STREQUAL "\n") 460 ## if it is empty we'll get newline returned 461 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PCRE_CFLAGS}") 462 endif() 463 464 set(HAVE_PCRE_H 1) 465 set(HAVE_LIBPCRE 1) 466 else() 467 if(NOT WIN32) 468 check_include_files(pcre.h HAVE_PCRE_H) 469 check_library_exists(pcre pcre_exec "" HAVE_LIBPCRE) 470 set(PCRE_LDFLAGS -lpcre) 471 else() 472 find_path(PCRE_INCLUDE_DIR pcre.h 473 /usr/local/include 474 /usr/include 475 ) 476 477 set(PCRE_NAMES pcre) 478 find_library(PCRE_LIBRARY 479 NAMES ${PCRE_NAMES} 480 PATHS /usr/lib /usr/local/lib 481 ) 482 483 if(PCRE_INCLUDE_DIR AND PCRE_LIBRARY) 484 set(CMAKE_REQUIRED_INCLUDES ${PCRE_INCLUDE_DIR}) 485 set(CMAKE_REQUIRED_LIBRARIES ${PCRE_LIBRARY}) 486 check_include_files(pcre.h HAVE_PCRE_H) 487 check_library_exists(pcre pcre_exec "" HAVE_LIBPCRE) 488 set(CMAKE_REQUIRED_INCLUDES) 489 set(CMAKE_REQUIRED_LIBRARIES) 490 include_directories(${PCRE_INCLUDE_DIR}) 491 endif() 492 endif() 493 endif() 494 495 if(NOT HAVE_PCRE_H) 496 message(FATAL_ERROR "pcre.h couldn't be found") 497 endif() 498 if(NOT HAVE_LIBPCRE) 499 message(FATAL_ERROR "libpcre couldn't be found") 500 endif() 501else() 502 unset(HAVE_PCRE_H) 503 unset(HAVE_LIBPCRE) 504endif() 505 506if(WITH_SASL) 507 check_include_files(sasl/sasl.h HAVE_SASL_SASL_H) 508 if(HAVE_SASL_SASL_H) 509 check_library_exists(sasl2 sasl_server_init "" HAVE_SASL) 510 endif() 511else() 512 unset(HAVE_SASL_SASL_H) 513 unset(HAVE_SASL) 514endif() 515 516 517if(WITH_XML) 518 xconfig(xml2-config XML2_INCDIR XML2_LIBDIR XML2_LDFLAGS XML2_CFLAGS) 519 if(XML2_LDFLAGS OR XML2_CFLAGS) 520 message(STATUS "found xml2 at: LDFLAGS: ${XML2_LDFLAGS} CFLAGS: ${XML2_CFLAGS}") 521 522 ## if it is empty we'll get newline returned 523 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${XML2_CFLAGS}") 524 525 check_include_files(libxml/tree.h HAVE_LIBXML_H) 526 527 set(CMAKE_REQUIRED_FLAGS ${XML2_LDFLAGS}) 528 check_library_exists(xml2 xmlParseChunk "" HAVE_LIBXML) 529 set(CMAKE_REQUIRED_FLAGS) 530 else() 531 check_include_files(libxml.h HAVE_LIBXML_H) 532 check_library_exists(xml2 xmlParseChunk "" HAVE_LIBXML) 533 endif() 534 535 if(NOT HAVE_LIBXML_H) 536 message(FATAL_ERROR "libxml/tree.h couldn't be found") 537 endif() 538 if(NOT HAVE_LIBXML) 539 message(FATAL_ERROR "libxml2 couldn't be found") 540 endif() 541else() 542 unset(HAVE_LIBXML_H) 543 unset(HAVE_LIBXML) 544endif() 545 546if(WITH_SQLITE3) 547 check_include_files(sqlite3.h HAVE_SQLITE3_H) 548 check_library_exists(sqlite3 sqlite3_reset "" HAVE_SQLITE3) 549else() 550 unset(HAVE_SQLITE3_H) 551 unset(HAVE_SQLITE3) 552endif() 553 554if(WITH_UUID) 555 check_include_files(uuid/uuid.h HAVE_UUID_UUID_H) 556 check_library_exists(uuid uuid_generate "" NEED_LIBUUID) 557 if(NOT NEED_LIBUUID) 558 check_function_exists(uuid_generate HAVE_LIBUUID) 559 else() 560 set(HAVE_LIBUUID 1) 561 endif() 562else() 563 unset(HAVE_UUID_UUID_H) 564 unset(NEED_LIBUUID) 565 unset(HAVE_LIBUUID) 566endif() 567 568if(WITH_XXHASH) 569 check_include_files(xxhash.h HAVE_XXHASH_H) 570 check_library_exists(xxhash XXH_versionNumber "" HAVE_XXHASH) 571else() 572 unset(HAVE_XXHASH_H) 573 unset(HAVE_XXHASH) 574endif() 575 576if(WITH_ZLIB) 577 if(NOT WIN32) 578 check_include_files(zlib.h HAVE_ZLIB_H) 579 check_library_exists(z deflate "" HAVE_LIBZ) 580 set(ZLIB_LIBRARY z) 581 else() 582 find_path(ZLIB_INCLUDE_DIR zlib.h 583 /usr/local/include 584 /usr/include 585 ) 586 587 set(ZLIB_NAMES z zlib zdll) 588 find_library(ZLIB_LIBRARY 589 NAMES ${ZLIB_NAMES} 590 PATHS /usr/lib /usr/local/lib 591 ) 592 593 if(ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY) 594 set(CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIR}) 595 set(CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARY}) 596 get_filename_component(ZLIB_NAME ${ZLIB_LIBRARY} NAME) 597 check_include_files(zlib.h HAVE_ZLIB_H) 598 check_library_exists(${ZLIB_NAME} deflate "" HAVE_LIBZ) 599 set(CMAKE_REQUIRED_INCLUDES) 600 set(CMAKE_REQUIRED_LIBRARIES) 601 include_directories(${ZLIB_INCLUDE_DIR}) 602 endif() 603 endif() 604else() 605 unset(HAVE_ZLIB_H) 606 unset(HAVE_LIBZ) 607 unset(ZLIB_INCLUDE_DIR) 608 unset(ZLIB_LIBRARY) 609endif() 610 611if(WITH_BZIP) 612 check_include_files(bzlib.h HAVE_BZLIB_H) 613 check_library_exists(bz2 BZ2_bzCompress "" HAVE_LIBBZ2) 614else() 615 unset(HAVE_BZLIB_H) 616 unset(HAVE_LIBBZ2) 617endif() 618 619if(WITH_BROTLI) 620 pkg_check_modules(LIBBROTLI REQUIRED libbrotlienc) 621 set(HAVE_BROTLI 1) 622 add_definitions(-DHAVE_BROTLI_ENCODE_H -DHAVE_BROTLI) 623else() 624 unset(HAVE_BROTLI) 625endif() 626 627if(WITH_LDAP) 628 check_include_files(ldap.h HAVE_LDAP_H) 629 check_library_exists(ldap ldap_bind "" HAVE_LIBLDAP) 630 check_include_files(lber.h HAVE_LBER_H) 631 check_library_exists(lber ber_printf "" HAVE_LIBLBER) 632else() 633 unset(HAVE_LDAP_H) 634 unset(HAVE_LIBLDAP) 635 unset(HAVE_LBER_H) 636 unset(HAVE_LIBLBER) 637endif() 638 639if(WITH_PAM) 640 check_include_files(security/pam_appl.h HAVE_SECURITY_PAM_APPL_H) 641 check_library_exists(pam pam_start "" HAVE_PAM) 642else() 643 unset(HAVE_SECURITY_PAM_APPL_H) 644 unset(HAVE_PAM) 645endif() 646 647if(WITH_LUA) 648 pkg_search_module(LUA REQUIRED lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1 lua) 649 message(STATUS "found lua at: INCDIR: ${LUA_INCLUDE_DIRS} LIBDIR: ${LUA_LIBRARY_DIRS} LDFLAGS: ${LUA_LDFLAGS} CFLAGS: ${LUA_CFLAGS}") 650 set(HAVE_LIBLUA 1 "Have liblua") 651 set(HAVE_LUA_H 1 "Have liblua header") 652else() 653 unset(HAVE_LIBLUA) 654 unset(HAVE_LUA_H) 655endif() 656 657if(WITH_FAM) 658 check_include_files(fam.h HAVE_FAM_H) 659 check_library_exists(fam FAMOpen2 "" HAVE_LIBFAM) 660 if(HAVE_LIBFAM) 661 set(CMAKE_REQUIRED_LIBRARIES fam) 662 check_function_exists(FAMNoExists HAVE_FAMNOEXISTS) 663 endif() 664else() 665 unset(HAVE_FAM_H) 666 unset(HAVE_LIBFAM) 667 unset(HAVE_FAMNOEXISTS) 668endif() 669 670if(WITH_GDBM) 671 check_include_files(gdbm.h HAVE_GDBM_H) 672 check_library_exists(gdbm gdbm_open "" HAVE_GDBM) 673else() 674 unset(HAVE_GDBM_H) 675 unset(HAVE_GDBM) 676endif() 677 678if(WITH_MEMCACHED) 679 check_include_files(libmemcached/memcached.h HAVE_LIBMEMCACHED_MEMCACHED_H) 680 check_library_exists(memcached memcached "" HAVE_LIBMEMCACHED) 681 if(HAVE_LIBMEMCACHED_MEMCACHED_H AND HAVE_LIBMEMCACHED) 682 set(USE_MEMCACHED 1) 683 else() 684 message(FATAL_ERROR "didn't find libmemcached") 685 endif() 686endif() 687 688if(WITH_GEOIP) 689 check_library_exists(geoip GeoIP_country_name_by_addr "" HAVE_GEOIP) 690endif() 691 692if(WITH_MAXMINDDB) 693 check_library_exists(maxminddb MMDB_open "" HAVE_MAXMINDDB) 694endif() 695 696if(NOT BUILD_STATIC) 697 check_include_files(dlfcn.h HAVE_DLFCN_H) 698else() 699 unset(HAVE_DLFCN_H) 700endif() 701 702if(HAVE_DLFCN_H) 703 check_library_exists(dl dlopen "" HAVE_LIBDL) 704else() 705 unset(HAVE_LIBDL) 706endif() 707 708set(LIGHTTPD_VERSION_ID 10400) 709set(PACKAGE_NAME "${CMAKE_PROJECT_NAME}") 710set(PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}") 711 712if(NOT SBINDIR) 713 set(SBINDIR "sbin") 714endif() 715 716if(NOT LIGHTTPD_MODULES_DIR) 717 set(LIGHTTPD_MODULES_DIR "lib${LIB_SUFFIX}/lighttpd") 718endif() 719 720if(NOT WIN32) 721 set(LIGHTTPD_LIBRARY_DIR "${CMAKE_INSTALL_PREFIX}/${LIGHTTPD_MODULES_DIR}") 722else() 723 ## We use relative path in windows 724 set(LIGHTTPD_LIBRARY_DIR "lib") 725endif() 726 727## Write out config.h 728configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) 729 730add_definitions(-DHAVE_CONFIG_H) 731 732include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) 733 734set(COMMON_SRC 735 base64.c buffer.c burl.c log.c 736 http_header.c http_kv.c keyvalue.c chunk.c 737 http_chunk.c stream.c fdevent.c gw_backend.c 738 stat_cache.c plugin.c etag.c array.c 739 data_string.c data_array.c 740 data_integer.c 741 algo_md5.c algo_sha1.c algo_splaytree.c 742 fdevent_select.c fdevent_libev.c 743 fdevent_poll.c fdevent_linux_sysepoll.c 744 fdevent_solaris_devpoll.c fdevent_solaris_port.c 745 fdevent_freebsd_kqueue.c 746 connections-glue.c 747 configfile-glue.c 748 http-header-glue.c 749 http_auth.c 750 http_vhostdb.c 751 request.c 752 sock_addr.c 753 rand.c 754 safe_memclear.c 755) 756 757if(WIN32) 758 message(STATUS "Adding local getopt implementation.") 759 set(COMMON_SRC ${COMMON_SRC} xgetopt.c) 760endif() 761 762add_executable(lemon lemon.c) 763 764## Build parsers by using lemon... 765lemon_parser(configparser.y) 766lemon_parser(mod_ssi_exprparser.y) 767 768set(L_INSTALL_TARGETS) 769 770add_executable(lighttpd-angel lighttpd-angel.c) 771set(L_INSTALL_TARGETS ${L_INSTALL_TARGETS} lighttpd-angel) 772add_target_properties(lighttpd-angel COMPILE_FLAGS "-DSBIN_DIR=\\\\\"${CMAKE_INSTALL_PREFIX}/${SBINDIR}\\\\\"") 773 774add_executable(lighttpd 775 server.c 776 response.c 777 connections.c 778 h2.c 779 reqpool.c 780 inet_ntop_cache.c 781 ls-hpack/lshpack.c 782 algo_xxhash.c 783 network.c 784 network_write.c 785 data_config.c 786 vector.c 787 configfile.c 788 configparser.c 789 ${COMMON_SRC} 790) 791set(L_INSTALL_TARGETS ${L_INSTALL_TARGETS} lighttpd) 792 793add_and_install_library(mod_access mod_access.c) 794add_and_install_library(mod_accesslog mod_accesslog.c) 795add_and_install_library(mod_alias mod_alias.c) 796add_and_install_library(mod_auth "mod_auth.c") 797add_and_install_library(mod_authn_file "mod_authn_file.c") 798if(NOT WIN32) 799 add_and_install_library(mod_cgi mod_cgi.c) 800endif() 801add_and_install_library(mod_deflate mod_deflate.c) 802add_and_install_library(mod_dirlisting mod_dirlisting.c) 803add_and_install_library(mod_evasive mod_evasive.c) 804add_and_install_library(mod_evhost mod_evhost.c) 805add_and_install_library(mod_expire mod_expire.c) 806add_and_install_library(mod_extforward mod_extforward.c) 807add_and_install_library(mod_fastcgi mod_fastcgi.c) 808add_and_install_library(mod_flv_streaming mod_flv_streaming.c) 809add_and_install_library(mod_indexfile mod_indexfile.c) 810add_and_install_library(mod_proxy mod_proxy.c) 811add_and_install_library(mod_redirect mod_redirect.c) 812add_and_install_library(mod_rewrite mod_rewrite.c) 813add_and_install_library(mod_rrdtool mod_rrdtool.c) 814add_and_install_library(mod_scgi mod_scgi.c) 815add_and_install_library(mod_secdownload mod_secdownload.c) 816add_and_install_library(mod_setenv mod_setenv.c) 817add_and_install_library(mod_simple_vhost mod_simple_vhost.c) 818add_and_install_library(mod_sockproxy mod_sockproxy.c) 819add_and_install_library(mod_ssi "mod_ssi_exprparser.c;mod_ssi_expr.c;mod_ssi.c") 820add_and_install_library(mod_staticfile mod_staticfile.c) 821add_and_install_library(mod_status mod_status.c) 822add_and_install_library(mod_uploadprogress mod_uploadprogress.c) 823add_and_install_library(mod_userdir mod_userdir.c) 824add_and_install_library(mod_usertrack mod_usertrack.c) 825add_and_install_library(mod_vhostdb mod_vhostdb.c) 826add_and_install_library(mod_webdav mod_webdav.c) 827add_and_install_library(mod_wstunnel mod_wstunnel.c) 828 829add_executable(test_array 830 t/test_array.c 831 array.c 832 data_array.c 833 data_integer.c 834 data_string.c 835 buffer.c 836) 837add_test(NAME test_array COMMAND test_array) 838 839add_executable(test_buffer 840 t/test_buffer.c 841 buffer.c 842) 843add_test(NAME test_buffer COMMAND test_buffer) 844 845add_executable(test_burl 846 t/test_burl.c 847 burl.c 848 buffer.c 849 base64.c 850) 851add_test(NAME test_burl COMMAND test_burl) 852 853add_executable(test_base64 854 t/test_base64.c 855 buffer.c 856 base64.c 857) 858add_test(NAME test_base64 COMMAND test_base64) 859 860add_executable(test_configfile 861 t/test_configfile.c 862 buffer.c 863 array.c 864 data_config.c 865 data_integer.c 866 data_string.c 867 http_header.c 868 http_kv.c 869 vector.c 870 log.c 871 sock_addr.c 872) 873add_test(NAME test_configfile COMMAND test_configfile) 874 875add_executable(test_keyvalue 876 t/test_keyvalue.c 877 burl.c 878 buffer.c 879 base64.c 880 array.c 881 data_integer.c 882 data_string.c 883 log.c 884) 885add_test(NAME test_keyvalue COMMAND test_keyvalue) 886 887add_executable(test_mod_access 888 t/test_mod_access.c 889 buffer.c 890 array.c 891 data_integer.c 892 data_string.c 893 log.c 894) 895add_test(NAME test_mod_access COMMAND test_mod_access) 896 897add_executable(test_mod_evhost 898 t/test_mod_evhost.c 899 buffer.c 900 array.c 901 data_integer.c 902 data_string.c 903 log.c 904) 905add_test(NAME test_mod_evhost COMMAND test_mod_evhost) 906 907add_executable(test_mod_simple_vhost 908 t/test_mod_simple_vhost.c 909 buffer.c 910 array.c 911 data_integer.c 912 data_string.c 913 log.c 914) 915add_test(NAME test_mod_simple_vhost COMMAND test_mod_simple_vhost) 916 917add_executable(test_mod_userdir 918 t/test_mod_userdir.c 919 buffer.c 920 array.c 921 data_integer.c 922 data_string.c 923 log.c 924) 925add_test(NAME test_mod_userdir COMMAND test_mod_userdir) 926 927add_executable(test_request 928 t/test_request.c 929 base64.c 930 buffer.c 931 burl.c 932 array.c 933 data_integer.c 934 data_string.c 935 http_header.c 936 http_kv.c 937 log.c 938 sock_addr.c 939) 940add_test(NAME test_request COMMAND test_request) 941 942if(HAVE_PCRE_H) 943 target_link_libraries(lighttpd ${PCRE_LDFLAGS}) 944 add_target_properties(lighttpd COMPILE_FLAGS ${PCRE_CFLAGS}) 945 target_link_libraries(mod_rewrite ${PCRE_LDFLAGS}) 946 add_target_properties(mod_rewrite COMPILE_FLAGS ${PCRE_CFLAGS}) 947 target_link_libraries(mod_dirlisting ${PCRE_LDFLAGS}) 948 add_target_properties(mod_dirlisting COMPILE_FLAGS ${PCRE_CFLAGS}) 949 target_link_libraries(mod_redirect ${PCRE_LDFLAGS}) 950 add_target_properties(mod_redirect COMPILE_FLAGS ${PCRE_CFLAGS}) 951 target_link_libraries(test_configfile ${PCRE_LDFLAGS}) 952 add_target_properties(test_configfile COMPILE_FLAGS ${PCRE_CFLAGS}) 953 target_link_libraries(test_keyvalue ${PCRE_LDFLAGS}) 954 add_target_properties(test_keyvalue COMPILE_FLAGS ${PCRE_CFLAGS}) 955endif() 956 957if(WITH_PCRE AND (WITH_MEMCACHED OR WITH_GDBM)) 958 add_and_install_library(mod_trigger_b4_dl mod_trigger_b4_dl.c) 959 target_link_libraries(mod_trigger_b4_dl ${PCRE_LDFLAGS}) 960 add_target_properties(mod_trigger_b4_dl COMPILE_FLAGS ${PCRE_CFLAGS}) 961endif() 962 963if(WITH_LUA) 964 add_and_install_library(mod_magnet "mod_magnet.c;mod_magnet_cache.c") 965 target_link_libraries(mod_magnet ${LUA_LDFLAGS}) 966 add_target_properties(mod_magnet COMPILE_FLAGS ${LUA_CFLAGS}) 967 968 add_and_install_library(mod_cml "mod_cml.c;mod_cml_lua.c;mod_cml_funcs.c") 969 target_link_libraries(mod_cml ${LUA_LDFLAGS} ${CRYPTO_LIBRARY}) 970 add_target_properties(mod_cml COMPILE_FLAGS ${LUA_CFLAGS}) 971 if(WITH_MEMCACHED) 972 target_link_libraries(mod_cml memcached) 973 endif() 974endif() 975 976if(WITH_GEOIP) 977 add_and_install_library(mod_geoip mod_geoip.c) 978 target_link_libraries(mod_geoip GeoIP) 979endif() 980 981if(WITH_MAXMINDDB) 982 add_and_install_library(mod_maxminddb mod_maxminddb.c) 983 target_link_libraries(mod_maxminddb maxminddb) 984endif() 985 986if(HAVE_MYSQL_H AND HAVE_MYSQL) 987 add_and_install_library(mod_mysql_vhost "mod_mysql_vhost.c") 988 target_link_libraries(mod_mysql_vhost mysqlclient) 989 add_and_install_library(mod_vhostdb_mysql "mod_vhostdb_mysql.c") 990 target_link_libraries(mod_vhostdb_mysql mysqlclient) 991 include_directories(/usr/include/mysql) 992 993 add_and_install_library(mod_authn_mysql "mod_authn_mysql.c") 994 set(L_MOD_AUTHN_MYSQL ${CRYPTO_LIBRARY}) 995 if(HAVE_LIBCRYPT) 996 set(L_MOD_AUTHN_MYSQL ${L_MOD_AUTHN_MYSQL} crypt) 997 endif() 998 target_link_libraries(mod_authn_mysql ${L_MOD_AUTHN_MYSQL} mysqlclient) 999endif() 1000 1001if(HAVE_PGSQL_H AND HAVE_PGSQL) 1002 add_and_install_library(mod_vhostdb_pgsql "mod_vhostdb_pgsql.c") 1003 target_link_libraries(mod_vhostdb_pgsql pq) 1004endif() 1005 1006if(HAVE_DBI_H AND HAVE_DBI) 1007 add_and_install_library(mod_vhostdb_dbi "mod_vhostdb_dbi.c") 1008 target_link_libraries(mod_vhostdb_dbi dbi) 1009 1010 add_and_install_library(mod_authn_dbi "mod_authn_dbi.c") 1011 set(L_MOD_AUTHN_DBI ${CRYPTO_LIBRARY}) 1012 if(HAVE_LIBCRYPT) 1013 set(L_MOD_AUTHN_DBI ${L_MOD_AUTHN_DBI} crypt) 1014 endif() 1015 target_link_libraries(mod_authn_dbi ${L_MOD_AUTHN_DBI} dbi) 1016endif() 1017 1018set(L_MOD_WEBDAV) 1019if(HAVE_SQLITE3_H) 1020 set(L_MOD_WEBDAV ${L_MOD_WEBDAV} sqlite3) 1021endif() 1022if(HAVE_LIBXML_H) 1023 target_link_libraries(mod_webdav ${XML2_LDFLAGS}) 1024endif() 1025if(HAVE_UUID_UUID_H) 1026 if(NEED_LIBUUID) 1027 set(L_MOD_WEBDAV ${L_MOD_WEBDAV} uuid) 1028 endif() 1029endif() 1030 1031target_link_libraries(mod_webdav ${L_MOD_WEBDAV}) 1032 1033set(L_MOD_AUTHN_FILE) 1034if(HAVE_LIBCRYPT) 1035 set(L_MOD_AUTHN_FILE ${L_MOD_AUTHN_FILE} crypt) 1036endif() 1037target_link_libraries(mod_authn_file ${L_MOD_AUTHN_FILE}) 1038 1039if(WITH_KRB5) 1040 check_library_exists(krb5 krb5_init_context "" HAVE_KRB5) 1041 add_and_install_library(mod_authn_gssapi "mod_authn_gssapi.c") 1042 set(L_MOD_AUTHN_GSSAPI ${L_MOD_AUTHN_GSSAPI} krb5 gssapi_krb5) 1043 target_link_libraries(mod_authn_gssapi ${L_MOD_AUTHN_GSSAPI}) 1044endif() 1045 1046if(WITH_LDAP) 1047 set(L_MOD_AUTHN_LDAP ${L_MOD_AUTHN_LDAP} ldap lber) 1048 add_and_install_library(mod_authn_ldap "mod_authn_ldap.c") 1049 target_link_libraries(mod_authn_ldap ${L_MOD_AUTHN_LDAP}) 1050 add_and_install_library(mod_vhostdb_ldap "mod_vhostdb_ldap.c") 1051 target_link_libraries(mod_vhostdb_ldap ${L_MOD_AUTHN_LDAP}) 1052endif() 1053 1054if(WITH_PAM) 1055 add_and_install_library(mod_authn_pam "mod_authn_pam.c") 1056 set(L_MOD_AUTHN_PAM ${L_MOD_AUTHN_PAM} pam) 1057 target_link_libraries(mod_authn_pam ${L_MOD_AUTHN_PAM}) 1058endif() 1059 1060if(WITH_SASL) 1061 add_and_install_library(mod_authn_sasl "mod_authn_sasl.c") 1062 set(L_MOD_AUTHN_SASL ${L_MOD_AUTHN_SASL} sasl2) 1063 target_link_libraries(mod_authn_sasl ${L_MOD_AUTHN_SASL}) 1064endif() 1065 1066if(HAVE_ZLIB_H OR HAVE_BZLIB_H OR HAVE_BROTLI) 1067 if(HAVE_ZLIB_H) 1068 set(L_MOD_DEFLATE ${L_MOD_DEFLATE} ${ZLIB_LIBRARY}) 1069 endif() 1070 if(HAVE_BZLIB_H) 1071 set(L_MOD_DEFLATE ${L_MOD_DEFLATE} bz2) 1072 endif() 1073 if(HAVE_BROTLI) 1074 set(L_MOD_DEFLATE ${L_MOD_DEFLATE} brotlienc) 1075 endif() 1076 target_link_libraries(mod_deflate ${L_MOD_DEFLATE}) 1077endif() 1078 1079if(HAVE_LIBFAM) 1080 target_link_libraries(lighttpd fam) 1081endif() 1082 1083if(HAVE_GDBM_H) 1084 target_link_libraries(mod_trigger_b4_dl gdbm) 1085endif() 1086 1087if(WITH_MEMCACHED) 1088 target_link_libraries(mod_trigger_b4_dl memcached) 1089endif() 1090 1091if(HAVE_XATTR) 1092 target_link_libraries(lighttpd attr) 1093endif() 1094 1095if(HAVE_XXHASH) 1096 target_link_libraries(lighttpd xxhash) 1097endif() 1098 1099if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") 1100 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -g -Wshadow -W -pedantic ${WARN_CFLAGS}") 1101 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2") 1102 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0") 1103 set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} -O2") 1104 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WARN_LDFLAGS}") 1105 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WARN_LDFLAGS}") 1106endif() 1107 1108if((NOT APPLE) OR CMAKE_C_COMPILER_ID MATCHES "GNU") 1109 add_target_properties(lighttpd LINK_FLAGS "-Wl,-export-dynamic") 1110endif() 1111 1112set_target_properties(lighttpd PROPERTIES CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) 1113 1114if(WIN32) 1115 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNVALGRIND") 1116 add_target_properties(lighttpd COMPILE_FLAGS "-DLI_DECLARE_EXPORTS") 1117 target_link_libraries(lighttpd ws2_32) 1118 target_link_libraries(mod_proxy ws2_32) 1119 target_link_libraries(mod_fcgi ws2_32) 1120 target_link_libraries(mod_scgi ws2_32) 1121 target_link_libraries(mod_ssi ws2_32) 1122 1123 if(MINGW) 1124 target_link_libraries(lighttpd msvcr70) 1125 add_target_properties(lighttpd LINK_FLAGS "-Wl,-subsystem,console") 1126 endif() 1127endif() 1128 1129if(NOT BUILD_STATIC) 1130 if(HAVE_LIBDL) 1131 target_link_libraries(lighttpd dl) 1132 endif() 1133endif() 1134 1135if(NOT ${CRYPTO_LIBRARY} EQUAL "") 1136 target_link_libraries(lighttpd ${CRYPTO_LIBRARY}) 1137 target_link_libraries(mod_auth ${CRYPTO_LIBRARY}) 1138 set(L_MOD_AUTHN_FILE ${L_MOD_AUTHN_FILE} ${CRYPTO_LIBRARY}) 1139 target_link_libraries(mod_authn_file ${L_MOD_AUTHN_FILE}) 1140 target_link_libraries(mod_secdownload ${CRYPTO_LIBRARY}) 1141 target_link_libraries(mod_usertrack ${CRYPTO_LIBRARY}) 1142 target_link_libraries(mod_wstunnel ${CRYPTO_LIBRARY}) 1143endif() 1144 1145if(HAVE_OPENSSL) 1146 add_and_install_library(mod_openssl "mod_openssl.c") 1147 set(L_MOD_OPENSSL ${L_MOD_OPENSSL} ssl crypto) 1148 target_link_libraries(mod_openssl ${L_MOD_OPENSSL}) 1149endif() 1150 1151if(HAVE_WOLFSSL) 1152 add_and_install_library(mod_wolfssl "mod_wolfssl.c") 1153 target_link_libraries(mod_wolfssl wolfssl) 1154endif() 1155 1156if(HAVE_LIBGNUTLS) 1157 add_and_install_library(mod_gnutls "mod_gnutls.c") 1158 target_link_libraries(mod_gnutls gnutls) 1159endif() 1160 1161if(HAVE_LIBMBEDTLS AND HAVE_LIBMEDCRYPTO AND HAVE_LIBMEDX509) 1162 add_and_install_library(mod_mbedtls "mod_mbedtls.c") 1163 set(L_MOD_MBEDTLS ${L_MOD_MBEDTLS} mbedtls mbedcrypto mbedx509) 1164 target_link_libraries(mod_mbedtls ${L_MOD_MBEDTLS}) 1165 # not doing "cross module" linkage yet (e.g. mod_authn, secdownload) 1166endif() 1167 1168if(HAVE_LIBSSL3 AND HAVE_LIBSMIME3 AND HAVE_LIBNSS3 AND HAVE_LIBNSSUTIL3) 1169 add_and_install_library(mod_nss "mod_nss.c") 1170 set(L_MOD_NSS ${L_MOD_NSS} ssl3 smime3 nss3 nssutil3) 1171 target_link_libraries(mod_nss ${L_MOD_NSS}) 1172endif() 1173 1174if(WITH_LIBEV) 1175 target_link_libraries(lighttpd ${LIBEV_LDFLAGS}) 1176 add_target_properties(lighttpd COMPILE_FLAGS ${LIBEV_CFLAGS}) 1177endif() 1178 1179if(WITH_LIBUNWIND) 1180 target_link_libraries(lighttpd ${LIBUNWIND_LDFLAGS}) 1181 add_target_properties(lighttpd COMPILE_FLAGS ${LIBUNWIND_CFLAGS}) 1182 1183 target_link_libraries(test_array ${LIBUNWIND_LDFLAGS}) 1184 add_target_properties(test_array COMPILE_FLAGS ${LIBUNWIND_CFLAGS}) 1185 target_link_libraries(test_buffer ${LIBUNWIND_LDFLAGS}) 1186 add_target_properties(test_buffer COMPILE_FLAGS ${LIBUNWIND_CFLAGS}) 1187 target_link_libraries(test_burl ${LIBUNWIND_LDFLAGS}) 1188 add_target_properties(test_burl COMPILE_FLAGS ${LIBUNWIND_CFLAGS}) 1189 target_link_libraries(test_base64 ${LIBUNWIND_LDFLAGS}) 1190 add_target_properties(test_base64 COMPILE_FLAGS ${LIBUNWIND_CFLAGS}) 1191 target_link_libraries(test_configfile ${PCRE_LDFLAGS} ${LIBUNWIND_LDFLAGS}) 1192 add_target_properties(test_configfile COMPILE_FLAGS ${PCRE_CFLAGS} ${LIBUNWIND_CFLAGS}) 1193 target_link_libraries(test_keyvalue ${PCRE_LDFLAGS} ${LIBUNWIND_LDFLAGS}) 1194 add_target_properties(test_keyvalue COMPILE_FLAGS ${PCRE_CFLAGS} ${LIBUNWIND_CFLAGS}) 1195 target_link_libraries(test_mod_access ${LIBUNWIND_LDFLAGS}) 1196 add_target_properties(test_mod_access COMPILE_FLAGS ${LIBUNWIND_CFLAGS}) 1197 target_link_libraries(test_mod_evhost ${LIBUNWIND_LDFLAGS}) 1198 add_target_properties(test_mod_evhost COMPILE_FLAGS ${LIBUNWIND_CFLAGS}) 1199 target_link_libraries(test_mod_simple_vhost ${LIBUNWIND_LDFLAGS}) 1200 add_target_properties(test_mod_simple_vhost COMPILE_FLAGS ${LIBUNWIND_CFLAGS}) 1201 target_link_libraries(test_mod_userdir ${LIBUNWIND_LDFLAGS}) 1202 add_target_properties(test_mod_userdir COMPILE_FLAGS ${LIBUNWIND_CFLAGS}) 1203 target_link_libraries(test_request ${LIBUNWIND_LDFLAGS}) 1204 add_target_properties(test_request COMPILE_FLAGS ${LIBUNWIND_CFLAGS}) 1205endif() 1206 1207if(NOT WIN32) 1208install(TARGETS ${L_INSTALL_TARGETS} 1209 RUNTIME DESTINATION ${SBINDIR} 1210 LIBRARY DESTINATION ${LIGHTTPD_MODULES_DIR} 1211 ARCHIVE DESTINATION ${LIGHTTPD_MODULES_DIR}/static) 1212else() 1213## HACK to make win32 to install our libraries in desired directory.. 1214install(TARGETS lighttpd 1215 RUNTIME DESTINATION ${SBINDIR} 1216 ARCHIVE DESTINATION lib/static) 1217list(REMOVE_ITEM L_INSTALL_TARGETS lighttpd) 1218install(TARGETS ${L_INSTALL_TARGETS} 1219 RUNTIME DESTINATION ${SBINDIR}/lib 1220 LIBRARY DESTINATION lib 1221 ARCHIVE DESTINATION lib/static) 1222endif() 1223