1include(CheckCSourceCompiles) 2include(CheckIncludeFiles) 3include(CheckFunctionExists) 4include(CheckVariableExists) 5include(CheckTypeSize) 6include(CheckLibraryExists) 7include(CMakeDetermineCCompiler) 8include(FindThreads) 9include(FindPkgConfig) 10 11include(LighttpdMacros) 12 13add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES) 14 15option(WITH_XATTR "with xattr-support for the stat-cache [default: off]") 16option(WITH_MYSQL "with mysql-support for the mod_sql_vhost [default: off]") 17# option(WITH_POSTGRESQL "with postgress-support for the mod_sql_vhost [default: off]") 18option(WITH_OPENSSL "with openssl-support [default: off]") 19option(WITH_PCRE "with regex support [default: on]" ON) 20option(WITH_WEBDAV_PROPS "with property-support for mod_webdav [default: off]") 21option(WITH_WEBDAV_LOCKS "locks in webdav [default: off]") 22option(WITH_BZIP "with bzip2-support for mod_compress [default: off]") 23option(WITH_ZLIB "with deflate-support for mod_compress [default: on]" ON) 24option(WITH_LDAP "with LDAP-support for the mod_auth [default: off]") 25option(WITH_LUA "with lua 5.1 for mod_magnet [default: off]") 26# option(WITH_VALGRIND "with internal support for valgrind [default: off]") 27# option(WITH_KERBEROS5 "use Kerberos5 support with OpenSSL [default: off]") 28option(WITH_FAM "fam/gamin for reducing number of stat() calls [default: off]") 29option(WITH_GDBM "gdbm storage for mod_trigger_b4_dl [default: off]") 30option(WITH_MEMCACHE "memcached storage for mod_trigger_b4_dl [default: off]") 31option(WITH_LIBEV "libev support for fdevent handlers [default: off]") 32option(WITH_LIBUNWIND "with libunwind to print backtraces in asserts [default: off]") 33 34if(CMAKE_COMPILER_IS_GNUCC) 35 option(BUILD_EXTRA_WARNINGS "extra warnings") 36 37 if(BUILD_EXTRA_WARNINGS) 38 set(WARN_CFLAGS "-g -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-align -Wsign-compare -Wnested-externs -Wpointer-arith -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security") 39 set(WARN_LDFLAGS "-Wl,--as-needed") 40 # -Werror -Wbad-function-cast -Wmissing-prototypes 41 endif() 42endif() 43 44option(BUILD_STATIC "build a static lighttpd with all modules added") 45 46if(BUILD_STATIC) 47 set(LIGHTTPD_STATIC 1) 48else() 49 set(CMAKE_SHARED_LIBRARY_PREFIX "") 50endif() 51 52if(WITH_LIBEV) 53 find_package(LibEV REQUIRED) 54 set(HAVE_LIBEV 1) 55endif() 56 57if(WITH_LIBUNWIND) 58 pkg_check_modules(LIBUNWIND REQUIRED libunwind) 59 set(HAVE_LIBUNWIND 1) 60endif() 61 62if(WITH_WEBDAV_PROPS) 63 set(WITH_XML 1) 64 set(WITH_SQLITE3 1) 65 set(WITH_UUID 1) 66endif() 67 68check_include_files(sys/devpoll.h HAVE_SYS_DEVPOLL_H) 69check_include_files(sys/epoll.h HAVE_SYS_EPOLL_H) 70check_include_files(sys/event.h HAVE_SYS_EVENT_H) 71check_include_files(sys/mman.h HAVE_SYS_MMAN_H) 72check_include_files(sys/poll.h HAVE_SYS_POLL_H) 73check_include_files(sys/port.h HAVE_SYS_PORT_H) 74check_include_files(sys/prctl.h HAVE_SYS_PRCTL_H) 75check_include_files(sys/resource.h HAVE_SYS_RESOURCE_H) 76check_include_files(sys/sendfile.h HAVE_SYS_SENDFILE_H) 77check_include_files(sys/select.h HAVE_SYS_SELECT_H) 78check_include_files(sys/types.h HAVE_SYS_TYPES_H) 79check_include_files(sys/uio.h HAVE_SYS_UIO_H) 80check_include_files(sys/un.h HAVE_SYS_UN_H) 81check_include_files(sys/wait.h HAVE_SYS_WAIT_H) 82check_include_files(sys/time.h HAVE_SYS_TIME_H) 83check_include_files(unistd.h HAVE_UNISTD_H) 84check_include_files(pthread.h HAVE_PTHREAD_H) 85check_include_files(getopt.h HAVE_GETOPT_H) 86check_include_files(inttypes.h HAVE_INTTYPES_H) 87check_include_files(poll.h HAVE_POLL_H) 88check_include_files(pwd.h HAVE_PWD_H) 89check_include_files(stddef.h HAVE_STDDEF_H) 90check_include_files(stdint.h HAVE_STDINT_H) 91check_include_files(syslog.h HAVE_SYSLOG_H) 92 93# check for fastcgi lib, for the tests only 94check_include_files(fastcgi.h HAVE_FASTCGI_H) 95check_include_files(fastcgi/fastcgi.h HAVE_FASTCGI_FASTCGI_H) 96 97# will be needed for auth 98check_include_files(crypt.h HAVE_CRYPT_H) 99# check if we need libcrypt for crypt_r() 100check_library_exists(crypt crypt_r "" HAVE_LIBCRYPT_CRYPT_R) 101if(HAVE_LIBCRYPT_CRYPT_R) 102 set(HAVE_CRYPT_R 1) 103 set(HAVE_LIBCRYPT 1) 104else() 105 check_library_exists(crypt crypt "" HAVE_LIBCRYPT) 106endif() 107check_function_exists(crypt_r HAVE_CRYPT_R) 108check_function_exists(crypt HAVE_CRYPT) 109 110check_include_files(sys/inotify.h HAVE_SYS_INOTIFY_H) 111if(HAVE_SYS_INOTIFY_H) 112 check_function_exists(inotify_init HAVE_INOTIFY_INIT) 113endif() 114 115set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h) 116check_type_size(socklen_t HAVE_SOCKLEN_T) 117set(CMAKE_EXTRA_INCLUDE_FILES) 118 119check_type_size(long SIZEOF_LONG) 120check_type_size(off_t SIZEOF_OFF_T) 121 122check_function_exists(chroot HAVE_CHROOT) 123check_function_exists(epoll_ctl HAVE_EPOLL_CTL) 124check_function_exists(fork HAVE_FORK) 125check_function_exists(getrlimit HAVE_GETRLIMIT) 126check_function_exists(getuid HAVE_GETUID) 127check_function_exists(gmtime_r HAVE_GMTIME_R) 128check_function_exists(inet_ntop HAVE_INET_NTOP) 129check_function_exists(kqueue HAVE_KQUEUE) 130check_function_exists(localtime_r HAVE_LOCALTIME_R) 131check_function_exists(lstat HAVE_LSTAT) 132check_function_exists(madvise HAVE_MADVISE) 133check_function_exists(memcpy HAVE_MEMCPY) 134check_function_exists(memset HAVE_MEMSET) 135check_function_exists(mmap HAVE_MMAP) 136check_function_exists(pathconf HAVE_PATHCONF) 137check_function_exists(poll HAVE_POLL) 138check_function_exists(port_create HAVE_PORT_CREATE) 139check_function_exists(prctl HAVE_PRCTL) 140check_function_exists(pread HAVE_PREAD) 141check_function_exists(posix_fadvise HAVE_POSIX_FADVISE) 142check_function_exists(select HAVE_SELECT) 143check_function_exists(sendfile HAVE_SENDFILE) 144check_function_exists(send_file HAVE_SEND_FILE) 145check_function_exists(sendfile64 HAVE_SENDFILE64) 146check_function_exists(sendfilev HAVE_SENDFILEV) 147check_function_exists(sigaction HAVE_SIGACTION) 148check_function_exists(signal HAVE_SIGNAL) 149check_function_exists(sigtimedwait HAVE_SIGTIMEDWAIT) 150check_function_exists(strptime HAVE_STRPTIME) 151check_function_exists(syslog HAVE_SYSLOG) 152check_function_exists(writev HAVE_WRITEV) 153check_function_exists(inet_aton HAVE_INET_ATON) 154check_function_exists(issetugid HAVE_ISSETUGID) 155check_function_exists(inet_pton HAVE_INET_PTON) 156check_function_exists(memset_s HAVE_MEMSET_S) 157check_function_exists(explicit_bzero HAVE_EXPLICIT_BZERO) 158check_c_source_compiles(" 159 #include <sys/types.h> 160 #include <sys/socket.h> 161 #include <netinet/in.h> 162 163 int main() { 164 struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0; 165 return 0; 166 }" HAVE_IPV6) 167check_c_source_compiles(" 168 __attribute__((weak)) void __dummy(void *x) { } 169 int main() { 170 void *x; 171 __dummy(x); 172 } 173 " HAVE_WEAK_SYMBOLS) 174 175## refactor me 176macro(XCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags) 177# reset the variables at the beginning 178 set(${_include_DIR}) 179 set(${_link_DIR}) 180 set(${_link_FLAGS}) 181 set(${_cflags}) 182 183 find_program(${_package}CONFIG_EXECUTABLE NAMES ${_package} PATHS /usr/local/bin ) 184 185 # if pkg-config has been found 186 if(${_package}CONFIG_EXECUTABLE) 187 set(XCONFIG_EXECUTABLE "${${_package}CONFIG_EXECUTABLE}") 188 message(STATUS "found ${_package}: ${XCONFIG_EXECUTABLE}") 189 190 exec_program(${XCONFIG_EXECUTABLE} ARGS --libs OUTPUT_VARIABLE __link_FLAGS) 191 string(REPLACE "\n" "" ${_link_FLAGS} ${__link_FLAGS}) 192 exec_program(${XCONFIG_EXECUTABLE} ARGS --cflags OUTPUT_VARIABLE __cflags) 193 string(REPLACE "\n" "" ${_cflags} ${__cflags}) 194 else() 195 message(STATUS "found ${_package}: no") 196 endif() 197endmacro(XCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags) 198 199if(WITH_XATTR) 200 check_include_files(attr/attributes.h HAVE_ATTR_ATTRIBUTES_H) 201 if(HAVE_ATTR_ATTRIBUTES_H) 202 check_library_exists(attr attr_get "" HAVE_XATTR) 203 endif() 204else() 205 unset(HAVE_ATTR_ATTRIBUTES_H) 206 unset(HAVE_XATTR) 207endif() 208 209if(WITH_MYSQL) 210 xconfig(mysql_config MYSQL_INCDIR MYSQL_LIBDIR MYSQL_LDFLAGS MYSQL_CFLAGS) 211 212 set(CMAKE_REQUIRED_INCLUDES /usr/include/mysql) 213 check_include_files(mysql.h HAVE_MYSQL_H) 214 set(CMAKE_REQUIRED_INCLUDES) 215 if(HAVE_MYSQL_H) 216 check_library_exists(mysqlclient mysql_real_connect "" HAVE_MYSQL) 217 endif() 218else() 219 unset(HAVE_MYSQL_H) 220 unset(HAVE_MYSQL) 221endif() 222 223if(WITH_OPENSSL) 224 check_include_files(openssl/ssl.h HAVE_OPENSSL_SSL_H) 225 if(HAVE_OPENSSL_SSL_H) 226 check_library_exists(crypto BIO_f_base64 "" HAVE_LIBCRYPTO) 227 if(HAVE_LIBCRYPTO) 228 set(OPENSSL_NO_KRB5 1) 229 check_library_exists(ssl SSL_new "" HAVE_LIBSSL) 230 endif() 231 endif() 232else() 233 unset(HAVE_OPENSSL_SSL_H) 234 unset(HAVE_LIBCRYPTO) 235 unset(HAVE_LIBSSL) 236endif() 237 238if(WITH_PCRE) 239 ## if we have pcre-config, use it 240 xconfig(pcre-config PCRE_INCDIR PCRE_LIBDIR PCRE_LDFLAGS PCRE_CFLAGS) 241 if(PCRE_LDFLAGS OR PCRE_CFLAGS) 242 message(STATUS "found pcre at: LDFLAGS: ${PCRE_LDFLAGS} CFLAGS: ${PCRE_CFLAGS}") 243 244 if(NOT PCRE_CFLAGS STREQUAL "\n") 245 ## if it is empty we'll get newline returned 246 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PCRE_CFLAGS}") 247 endif() 248 249 set(HAVE_PCRE_H 1) 250 set(HAVE_LIBPCRE 1) 251 else() 252 if(NOT WIN32) 253 check_include_files(pcre.h HAVE_PCRE_H) 254 check_library_exists(pcre pcre_exec "" HAVE_LIBPCRE) 255 set(PCRE_LDFLAGS -lpcre) 256 else() 257 find_path(PCRE_INCLUDE_DIR pcre.h 258 /usr/local/include 259 /usr/include 260 ) 261 262 set(PCRE_NAMES pcre) 263 find_library(PCRE_LIBRARY 264 NAMES ${PCRE_NAMES} 265 PATHS /usr/lib /usr/local/lib 266 ) 267 268 if(PCRE_INCLUDE_DIR AND PCRE_LIBRARY) 269 set(CMAKE_REQUIRED_INCLUDES ${PCRE_INCLUDE_DIR}) 270 set(CMAKE_REQUIRED_LIBRARIES ${PCRE_LIBRARY}) 271 check_include_files(pcre.h HAVE_PCRE_H) 272 check_library_exists(pcre pcre_exec "" HAVE_LIBPCRE) 273 set(CMAKE_REQUIRED_INCLUDES) 274 set(CMAKE_REQUIRED_LIBRARIES) 275 include_directories(${PCRE_INCLUDE_DIR}) 276 endif() 277 endif() 278 endif() 279 280 if(NOT HAVE_PCRE_H) 281 message(FATAL_ERROR "pcre.h couldn't be found") 282 endif() 283 if(NOT HAVE_LIBPCRE) 284 message(FATAL_ERROR "libpcre couldn't be found") 285 endif() 286else() 287 unset(HAVE_PCRE_H) 288 unset(HAVE_LIBPCRE) 289endif() 290 291 292if(WITH_XML) 293 xconfig(xml2-config XML2_INCDIR XML2_LIBDIR XML2_LDFLAGS XML2_CFLAGS) 294 if(XML2_LDFLAGS OR XML2_CFLAGS) 295 message(STATUS "found xml2 at: LDFLAGS: ${XML2_LDFLAGS} CFLAGS: ${XML2_CFLAGS}") 296 297 ## if it is empty we'll get newline returned 298 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${XML2_CFLAGS}") 299 300 check_include_files(libxml/tree.h HAVE_LIBXML_H) 301 302 set(CMAKE_REQUIRED_FLAGS ${XML2_LDFLAGS}) 303 check_library_exists(xml2 xmlParseChunk "" HAVE_LIBXML) 304 set(CMAKE_REQUIRED_FLAGS) 305 else() 306 check_include_files(libxml.h HAVE_LIBXML_H) 307 check_library_exists(xml2 xmlParseChunk "" HAVE_LIBXML) 308 endif() 309 310 if(NOT HAVE_LIBXML_H) 311 message(FATAL_ERROR "libxml/tree.h couldn't be found") 312 endif() 313 if(NOT HAVE_LIBXML) 314 message(FATAL_ERROR "libxml2 couldn't be found") 315 endif() 316else() 317 unset(HAVE_LIBXML_H) 318 unset(HAVE_LIBXML) 319endif() 320 321if(WITH_SQLITE3) 322 check_include_files(sqlite3.h HAVE_SQLITE3_H) 323 check_library_exists(sqlite3 sqlite3_reset "" HAVE_SQLITE3) 324else() 325 unset(HAVE_SQLITE3_H) 326 unset(HAVE_SQLITE3) 327endif() 328 329if(WITH_UUID) 330 check_include_files(uuid/uuid.h HAVE_UUID_UUID_H) 331 check_library_exists(uuid uuid_generate "" NEED_LIBUUID) 332 if(NOT NEED_LIBUUID) 333 check_function_exists(uuid_generate HAVE_LIBUUID) 334 else() 335 set(HAVE_LIBUUID 1) 336 endif() 337else() 338 unset(HAVE_UUID_UUID_H) 339 unset(NEED_LIBUUID) 340 unset(HAVE_LIBUUID) 341endif() 342 343if(WITH_ZLIB) 344 if(NOT WIN32) 345 check_include_files(zlib.h HAVE_ZLIB_H) 346 check_library_exists(z deflate "" HAVE_LIBZ) 347 set(ZLIB_LIBRARY z) 348 else() 349 find_path(ZLIB_INCLUDE_DIR zlib.h 350 /usr/local/include 351 /usr/include 352 ) 353 354 set(ZLIB_NAMES z zlib zdll) 355 find_library(ZLIB_LIBRARY 356 NAMES ${ZLIB_NAMES} 357 PATHS /usr/lib /usr/local/lib 358 ) 359 360 if(ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY) 361 set(CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIR}) 362 set(CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARY}) 363 get_filename_component(ZLIB_NAME ${ZLIB_LIBRARY} NAME) 364 check_include_files(zlib.h HAVE_ZLIB_H) 365 check_library_exists(${ZLIB_NAME} deflate "" HAVE_LIBZ) 366 set(CMAKE_REQUIRED_INCLUDES) 367 set(CMAKE_REQUIRED_LIBRARIES) 368 include_directories(${ZLIB_INCLUDE_DIR}) 369 endif() 370 endif() 371else() 372 unset(HAVE_ZLIB_H) 373 unset(HAVE_LIBZ) 374 unset(ZLIB_INCLUDE_DIR) 375 unset(ZLIB_LIBRARY) 376endif() 377 378if(WITH_BZIP) 379 check_include_files(bzlib.h HAVE_BZLIB_H) 380 check_library_exists(bz2 BZ2_bzCompress "" HAVE_LIBBZ2) 381else() 382 unset(HAVE_BZLIB_H) 383 unset(HAVE_LIBBZ2) 384endif() 385 386if(WITH_LDAP) 387 check_include_files(ldap.h HAVE_LDAP_H) 388 check_library_exists(ldap ldap_bind "" HAVE_LIBLDAP) 389 check_include_files(lber.h HAVE_LBER_H) 390 check_library_exists(lber ber_printf "" HAVE_LIBLBER) 391 set(LDAP_DEPRECATED 1) # Using deprecated ldap api 392else() 393 unset(HAVE_LDAP_H) 394 unset(HAVE_LIBLDAP) 395 unset(HAVE_LBER_H) 396 unset(HAVE_LIBLBER) 397endif() 398 399if(WITH_LUA) 400 pkg_search_module(LUA REQUIRED lua lua5.1 lua-5.1) 401 message(STATUS "found lua at: INCDIR: ${LUA_INCLUDE_DIRS} LIBDIR: ${LUA_LIBRARY_DIRS} LDFLAGS: ${LUA_LDFLAGS} CFLAGS: ${LUA_CFLAGS}") 402 set(HAVE_LIBLUA 1 "Have liblua") 403 set(HAVE_LUA_H 1 "Have liblua header") 404else() 405 unset(HAVE_LIBLUA) 406 unset(HAVE_LUA_H) 407endif() 408 409if(WITH_FAM) 410 check_include_files(fam.h HAVE_FAM_H) 411 check_library_exists(fam FAMOpen2 "" HAVE_LIBFAM) 412 if(HAVE_LIBFAM) 413 set(CMAKE_REQUIRED_LIBRARIES fam) 414 check_function_exists(FAMNoExists HAVE_FAMNOEXISTS) 415 endif() 416else() 417 unset(HAVE_FAM_H) 418 unset(HAVE_LIBFAM) 419 unset(HAVE_FAMNOEXISTS) 420endif() 421 422if(WITH_GDBM) 423 check_include_files(gdbm.h HAVE_GDBM_H) 424 check_library_exists(gdbm gdbm_open "" HAVE_GDBM) 425else() 426 unset(HAVE_GDBM_H) 427 unset(HAVE_GDBM) 428endif() 429 430if(WITH_MEMCACHE) 431 check_include_files(memcache.h HAVE_MEMCACHE_H) 432 check_library_exists(memcache mc_new "" HAVE_MEMCACHE) 433else() 434 unset(HAVE_MEMCACHE_H) 435 unset(HAVE_MEMCACHE) 436endif() 437 438if(NOT BUILD_STATIC) 439 check_include_files(dlfcn.h HAVE_DLFCN_H) 440else() 441 unset(HAVE_DLFCN_H) 442endif() 443 444if(HAVE_DLFCN_H) 445 check_library_exists(dl dlopen "" HAVE_LIBDL) 446else() 447 unset(HAVE_LIBDL) 448endif() 449 450set(LIGHTTPD_VERSION_ID 10400) 451set(PACKAGE_NAME "${CMAKE_PROJECT_NAME}") 452set(PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}") 453 454if(NOT SBINDIR) 455 set(SBINDIR "sbin") 456endif() 457 458if(NOT LIGHTTPD_MODULES_DIR) 459 set(LIGHTTPD_MODULES_DIR "lib${LIB_SUFFIX}/lighttpd") 460endif() 461 462if(NOT WIN32) 463 set(LIGHTTPD_LIBRARY_DIR "${CMAKE_INSTALL_PREFIX}/${LIGHTTPD_MODULES_DIR}") 464else() 465 ## We use relative path in windows 466 set(LIGHTTPD_LIBRARY_DIR "lib") 467endif() 468 469## Write out config.h 470configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) 471 472add_definitions(-DHAVE_CONFIG_H) 473 474include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) 475 476set(COMMON_SRC 477 base64.c buffer.c log.c 478 keyvalue.c chunk.c 479 http_chunk.c stream.c fdevent.c 480 stat_cache.c plugin.c joblist.c etag.c array.c 481 data_string.c data_count.c data_array.c 482 data_integer.c md5.c data_fastcgi.c 483 fdevent_select.c fdevent_libev.c 484 fdevent_poll.c fdevent_linux_sysepoll.c 485 fdevent_solaris_devpoll.c fdevent_solaris_port.c 486 fdevent_freebsd_kqueue.c 487 data_config.c 488 inet_ntop_cache.c crc32.c 489 connections-glue.c 490 configfile-glue.c 491 http-header-glue.c 492 splaytree.c network_writev.c 493 network_write_mmap.c network_write_no_mmap.c 494 network_write.c network_linux_sendfile.c 495 network_freebsd_sendfile.c 496 network_solaris_sendfilev.c network_openssl.c 497 status_counter.c safe_memclear.c network_darwin_sendfile.c 498) 499 500if(WIN32) 501 message(STATUS "Adding local getopt implementation.") 502 set(COMMON_SRC ${COMMON_SRC} xgetopt.c) 503endif() 504 505add_executable(lemon lemon.c) 506 507## Build parsers by using lemon... 508lemon_parser(configparser.y) 509lemon_parser(mod_ssi_exprparser.y) 510 511set(L_INSTALL_TARGETS) 512 513add_executable(lighttpd-angel lighttpd-angel.c) 514set(L_INSTALL_TARGETS ${L_INSTALL_TARGETS} lighttpd-angel) 515add_target_properties(lighttpd-angel COMPILE_FLAGS "-DSBIN_DIR=\\\\\"${CMAKE_INSTALL_PREFIX}/${SBINDIR}\\\\\"") 516 517add_executable(lighttpd 518 server.c 519 response.c 520 connections.c 521 network.c 522 configfile.c 523 configparser.c 524 request.c 525 proc_open.c 526 ${COMMON_SRC} 527) 528set(L_INSTALL_TARGETS ${L_INSTALL_TARGETS} lighttpd) 529 530add_and_install_library(mod_access mod_access.c) 531add_and_install_library(mod_accesslog mod_accesslog.c) 532add_and_install_library(mod_alias mod_alias.c) 533add_and_install_library(mod_auth "mod_auth.c;http_auth.c") 534if(NOT WIN32) 535 add_and_install_library(mod_cgi mod_cgi.c) 536endif() 537add_and_install_library(mod_cml "mod_cml.c;mod_cml_lua.c;mod_cml_funcs.c") 538add_and_install_library(mod_compress mod_compress.c) 539add_and_install_library(mod_dirlisting mod_dirlisting.c) 540add_and_install_library(mod_evasive mod_evasive.c) 541add_and_install_library(mod_evhost mod_evhost.c) 542add_and_install_library(mod_expire mod_expire.c) 543add_and_install_library(mod_extforward mod_extforward.c) 544add_and_install_library(mod_fastcgi mod_fastcgi.c) 545add_and_install_library(mod_flv_streaming mod_flv_streaming.c) 546add_and_install_library(mod_indexfile mod_indexfile.c) 547add_and_install_library(mod_magnet "mod_magnet.c;mod_magnet_cache.c") 548add_and_install_library(mod_mysql_vhost mod_mysql_vhost.c) 549add_and_install_library(mod_proxy mod_proxy.c) 550add_and_install_library(mod_redirect mod_redirect.c) 551add_and_install_library(mod_rewrite mod_rewrite.c) 552add_and_install_library(mod_rrdtool mod_rrdtool.c) 553add_and_install_library(mod_scgi mod_scgi.c) 554add_and_install_library(mod_secdownload mod_secdownload.c) 555add_and_install_library(mod_setenv mod_setenv.c) 556add_and_install_library(mod_simple_vhost mod_simple_vhost.c) 557add_and_install_library(mod_ssi "mod_ssi_exprparser.c;mod_ssi_expr.c;mod_ssi.c") 558add_and_install_library(mod_staticfile mod_staticfile.c) 559add_and_install_library(mod_status mod_status.c) 560add_and_install_library(mod_trigger_b4_dl mod_trigger_b4_dl.c) 561# add_and_install_library(mod_uploadprogress mod_uploadprogress.c) 562add_and_install_library(mod_userdir mod_userdir.c) 563add_and_install_library(mod_usertrack mod_usertrack.c) 564add_and_install_library(mod_webdav mod_webdav.c) 565 566if(HAVE_PCRE_H) 567 target_link_libraries(lighttpd ${PCRE_LDFLAGS}) 568 add_target_properties(lighttpd COMPILE_FLAGS ${PCRE_CFLAGS}) 569 target_link_libraries(mod_rewrite ${PCRE_LDFLAGS}) 570 add_target_properties(mod_rewrite COMPILE_FLAGS ${PCRE_CFLAGS}) 571 target_link_libraries(mod_dirlisting ${PCRE_LDFLAGS}) 572 add_target_properties(mod_dirlisting COMPILE_FLAGS ${PCRE_CFLAGS}) 573 target_link_libraries(mod_redirect ${PCRE_LDFLAGS}) 574 add_target_properties(mod_redirect COMPILE_FLAGS ${PCRE_CFLAGS}) 575 target_link_libraries(mod_ssi ${PCRE_LDFLAGS}) 576 add_target_properties(mod_ssi COMPILE_FLAGS ${PCRE_CFLAGS}) 577 target_link_libraries(mod_trigger_b4_dl ${PCRE_LDFLAGS}) 578 add_target_properties(mod_trigger_b4_dl COMPILE_FLAGS ${PCRE_CFLAGS}) 579endif() 580 581target_link_libraries(mod_magnet ${LUA_LDFLAGS}) 582add_target_properties(mod_magnet COMPILE_FLAGS ${LUA_CFLAGS}) 583 584target_link_libraries(mod_cml ${LUA_LDFLAGS}) 585add_target_properties(mod_cml COMPILE_FLAGS ${LUA_CFLAGS}) 586 587if(HAVE_MYSQL_H AND HAVE_MYSQL) 588 target_link_libraries(mod_mysql_vhost mysqlclient) 589 include_directories(/usr/include/mysql) 590endif() 591 592set(L_MOD_WEBDAV) 593if(HAVE_SQLITE3_H) 594 set(L_MOD_WEBDAV ${L_MOD_WEBDAV} sqlite3) 595endif() 596if(HAVE_LIBXML_H) 597 target_link_libraries(mod_webdav ${XML2_LDFLAGS}) 598endif() 599if(HAVE_UUID_H) 600 if(NEED_LIBUUID) 601 set(L_MOD_WEBDAV ${L_MOD_WEBDAV} uuid) 602 endif() 603endif() 604 605target_link_libraries(mod_webdav ${L_MOD_WEBDAV}) 606 607set(L_MOD_AUTH) 608if(HAVE_LIBCRYPT) 609 set(L_MOD_AUTH ${L_MOD_AUTH} crypt) 610endif() 611 612if(HAVE_LDAP_H) 613 set(L_MOD_AUTH ${L_MOD_AUTH} ldap lber) 614endif() 615target_link_libraries(mod_auth ${L_MOD_AUTH}) 616 617if(HAVE_ZLIB_H) 618 if(HAVE_BZLIB_H) 619 target_link_libraries(mod_compress ${ZLIB_LIBRARY} bz2) 620 else() 621 target_link_libraries(mod_compress ${ZLIB_LIBRARY}) 622 endif() 623endif() 624 625if(HAVE_LIBFAM) 626 target_link_libraries(lighttpd fam) 627endif() 628 629if(HAVE_GDBM_H) 630 target_link_libraries(mod_trigger_b4_dl gdbm) 631endif() 632 633if(HAVE_MEMCACHE_H) 634 target_link_libraries(mod_trigger_b4_dl memcache) 635endif() 636 637if(CMAKE_COMPILER_IS_GNUCC) 638 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -g -Wshadow -W -pedantic ${WARN_CFLAGS}") 639 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2") 640 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0") 641 set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} -O2") 642 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WARN_LDFLAGS}") 643 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WARN_LDFLAGS}") 644 add_definitions(-D_GNU_SOURCE) 645endif() 646 647add_target_properties(lighttpd LINK_FLAGS "-Wl,-export-dynamic") 648 649set_target_properties(lighttpd PROPERTIES CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) 650 651if(WIN32) 652 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNVALGRIND") 653 add_target_properties(lighttpd COMPILE_FLAGS "-DLI_DECLARE_EXPORTS") 654 target_link_libraries(lighttpd ws2_32) 655 target_link_libraries(mod_proxy ws2_32) 656 target_link_libraries(mod_fcgi ws2_32) 657 target_link_libraries(mod_scgi ws2_32) 658 target_link_libraries(mod_ssi ws2_32) 659 660 if(MINGW) 661 target_link_libraries(lighttpd msvcr70) 662 add_target_properties(lighttpd LINK_FLAGS "-Wl,-subsystem,console") 663 endif() 664endif() 665 666if(NOT BUILD_STATIC) 667 if(HAVE_LIBDL) 668 target_link_libraries(lighttpd dl) 669 endif() 670endif() 671 672if(HAVE_LIBSSL AND HAVE_LIBCRYPTO) 673 target_link_libraries(lighttpd ssl) 674 target_link_libraries(lighttpd crypto) 675endif() 676 677if(WITH_LIBEV) 678 target_link_libraries(lighttpd ${LIBEV_LDFLAGS}) 679 add_target_properties(lighttpd COMPILE_FLAGS ${LIBEV_CFLAGS}) 680endif() 681 682if(WITH_LIBUNWIND) 683 target_link_libraries(lighttpd ${LIBUNWIND_LDFLAGS}) 684 add_target_properties(lighttpd COMPILE_FLAGS ${LIBUNWIND_CFLAGS}) 685endif() 686 687if(NOT WIN32) 688install(TARGETS ${L_INSTALL_TARGETS} 689 RUNTIME DESTINATION ${SBINDIR} 690 LIBRARY DESTINATION ${LIGHTTPD_MODULES_DIR} 691 ARCHIVE DESTINATION ${LIGHTTPD_MODULES_DIR}/static) 692else() 693## HACK to make win32 to install our libraries in desired directory.. 694install(TARGETS lighttpd 695 RUNTIME DESTINATION ${SBINDIR} 696 ARCHIVE DESTINATION lib/static) 697list(REMOVE_ITEM L_INSTALL_TARGETS lighttpd) 698install(TARGETS ${L_INSTALL_TARGETS} 699 RUNTIME DESTINATION ${SBINDIR}/lib 700 LIBRARY DESTINATION lib 701 ARCHIVE DESTINATION lib/static) 702endif() 703