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