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