[core] support IPv6 in $HTTP["remote-ip"] CIDR cond match (fixes #2706)
[lighttpd.git] / src / CMakeLists.txt
blob9094b0bc95c4569b63c91990a840840d5a878a0f
1 include(CheckCSourceCompiles)
2 include(CheckIncludeFiles)
3 include(CheckFunctionExists)
4 include(CheckVariableExists)
5 include(CheckTypeSize)
6 include(CheckLibraryExists)
7 include(CMakeDetermineCCompiler)
8 include(FindThreads)
9 include(FindPkgConfig)
11 include(LighttpdMacros)
13 add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES)
15 option(WITH_XATTR "with xattr-support for the stat-cache [default: off]")
16 option(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]")
18 option(WITH_OPENSSL "with openssl-support [default: off]")
19 option(WITH_PCRE "with regex support [default: on]" ON)
20 option(WITH_WEBDAV_PROPS "with property-support for mod_webdav [default: off]")
21 option(WITH_WEBDAV_LOCKS "locks in webdav [default: off]")
22 option(WITH_BZIP "with bzip2-support for mod_compress [default: off]")
23 option(WITH_ZLIB "with deflate-support for mod_compress [default: on]" ON)
24 option(WITH_LDAP "with LDAP-support for the mod_auth [default: off]")
25 option(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]")
28 option(WITH_FAM "fam/gamin for reducing number of stat() calls [default: off]")
29 option(WITH_GDBM "gdbm storage for mod_trigger_b4_dl [default: off]")
30 option(WITH_MEMCACHED "memcached storage for mod_trigger_b4_dl [default: off]")
31 option(WITH_LIBEV "libev support for fdevent handlers [default: off]")
32 option(WITH_LIBUNWIND "with libunwind to print backtraces in asserts [default: off]")
34 if(CMAKE_COMPILER_IS_GNUCC)
35         option(BUILD_EXTRA_WARNINGS "extra warnings")
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()
42 endif()
44 option(BUILD_STATIC "build a static lighttpd with all modules added")
46 if(BUILD_STATIC)
47         set(LIGHTTPD_STATIC 1)
48 else()
49         set(CMAKE_SHARED_LIBRARY_PREFIX "")
50 endif()
52 if(WITH_LIBEV)
53         find_package(LibEV REQUIRED)
54         set(HAVE_LIBEV 1)
55 endif()
57 if(WITH_LIBUNWIND)
58         pkg_check_modules(LIBUNWIND REQUIRED libunwind)
59         set(HAVE_LIBUNWIND 1)
60 endif()
62 if(WITH_WEBDAV_PROPS)
63         set(WITH_XML 1)
64         set(WITH_SQLITE3 1)
65         set(WITH_UUID 1)
66 endif()
68 check_include_files(sys/devpoll.h HAVE_SYS_DEVPOLL_H)
69 check_include_files(sys/epoll.h HAVE_SYS_EPOLL_H)
70 check_include_files(sys/event.h HAVE_SYS_EVENT_H)
71 check_include_files(sys/mman.h HAVE_SYS_MMAN_H)
72 check_include_files(sys/poll.h HAVE_SYS_POLL_H)
73 check_include_files(sys/port.h HAVE_SYS_PORT_H)
74 check_include_files(sys/prctl.h HAVE_SYS_PRCTL_H)
75 check_include_files(sys/resource.h HAVE_SYS_RESOURCE_H)
76 check_include_files(sys/sendfile.h HAVE_SYS_SENDFILE_H)
77 check_include_files(sys/select.h HAVE_SYS_SELECT_H)
78 check_include_files(sys/types.h HAVE_SYS_TYPES_H)
79 check_include_files(sys/uio.h HAVE_SYS_UIO_H)
80 check_include_files(sys/un.h HAVE_SYS_UN_H)
81 check_include_files(sys/wait.h HAVE_SYS_WAIT_H)
82 check_include_files(sys/time.h HAVE_SYS_TIME_H)
83 check_include_files(unistd.h HAVE_UNISTD_H)
84 check_include_files(pthread.h HAVE_PTHREAD_H)
85 check_include_files(getopt.h HAVE_GETOPT_H)
86 check_include_files(inttypes.h HAVE_INTTYPES_H)
87 check_include_files(poll.h HAVE_POLL_H)
88 check_include_files(pwd.h HAVE_PWD_H)
89 check_include_files(stddef.h HAVE_STDDEF_H)
90 check_include_files(stdint.h HAVE_STDINT_H)
91 check_include_files(syslog.h HAVE_SYSLOG_H)
93 # check for fastcgi lib, for the tests only
94 check_include_files(fastcgi.h HAVE_FASTCGI_H)
95 check_include_files(fastcgi/fastcgi.h HAVE_FASTCGI_FASTCGI_H)
97 # will be needed for auth
98 check_include_files(crypt.h HAVE_CRYPT_H)
99 # check if we need libcrypt for crypt_r()
100 check_library_exists(crypt crypt_r "" HAVE_LIBCRYPT_CRYPT_R)
101 if(HAVE_LIBCRYPT_CRYPT_R)
102         set(HAVE_CRYPT_R 1)
103         set(HAVE_LIBCRYPT 1)
104 else()
105         check_library_exists(crypt crypt "" HAVE_LIBCRYPT)
106 endif()
107 check_function_exists(crypt_r HAVE_CRYPT_R)
108 check_function_exists(crypt HAVE_CRYPT)
110 check_include_files(sys/inotify.h HAVE_SYS_INOTIFY_H)
111 if(HAVE_SYS_INOTIFY_H)
112         check_function_exists(inotify_init HAVE_INOTIFY_INIT)
113 endif()
115 set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
116 check_type_size(socklen_t HAVE_SOCKLEN_T)
117 set(CMAKE_EXTRA_INCLUDE_FILES)
119 check_type_size(long SIZEOF_LONG)
120 check_type_size(off_t SIZEOF_OFF_T)
122 check_function_exists(chroot HAVE_CHROOT)
123 check_function_exists(epoll_ctl HAVE_EPOLL_CTL)
124 check_function_exists(fork HAVE_FORK)
125 check_function_exists(getrlimit HAVE_GETRLIMIT)
126 check_function_exists(getuid HAVE_GETUID)
127 check_function_exists(gmtime_r HAVE_GMTIME_R)
128 check_function_exists(inet_ntop HAVE_INET_NTOP)
129 check_function_exists(kqueue HAVE_KQUEUE)
130 check_function_exists(localtime_r HAVE_LOCALTIME_R)
131 check_function_exists(lstat HAVE_LSTAT)
132 check_function_exists(madvise HAVE_MADVISE)
133 check_function_exists(memcpy HAVE_MEMCPY)
134 check_function_exists(memset HAVE_MEMSET)
135 check_function_exists(mmap HAVE_MMAP)
136 check_function_exists(pathconf HAVE_PATHCONF)
137 check_function_exists(poll HAVE_POLL)
138 check_function_exists(port_create HAVE_PORT_CREATE)
139 check_function_exists(prctl HAVE_PRCTL)
140 check_function_exists(pread HAVE_PREAD)
141 check_function_exists(posix_fadvise HAVE_POSIX_FADVISE)
142 check_function_exists(select HAVE_SELECT)
143 check_function_exists(sendfile HAVE_SENDFILE)
144 check_function_exists(send_file HAVE_SEND_FILE)
145 check_function_exists(sendfile64 HAVE_SENDFILE64)
146 check_function_exists(sendfilev HAVE_SENDFILEV)
147 check_function_exists(sigaction HAVE_SIGACTION)
148 check_function_exists(signal HAVE_SIGNAL)
149 check_function_exists(sigtimedwait HAVE_SIGTIMEDWAIT)
150 check_function_exists(strptime HAVE_STRPTIME)
151 check_function_exists(syslog HAVE_SYSLOG)
152 check_function_exists(writev HAVE_WRITEV)
153 check_function_exists(inet_aton HAVE_INET_ATON)
154 check_function_exists(issetugid HAVE_ISSETUGID)
155 check_function_exists(inet_pton HAVE_INET_PTON)
156 check_function_exists(memset_s HAVE_MEMSET_S)
157 check_function_exists(explicit_bzero HAVE_EXPLICIT_BZERO)
158 check_c_source_compiles("
159         #include <sys/types.h>
160         #include <sys/socket.h>
161         #include <netinet/in.h>
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)
167 check_c_source_compiles("
168         __attribute__((weak)) void __dummy(void *x) { }
169         int main() {
170                 void *x;
171                 __dummy(x);
172         }
173         " HAVE_WEAK_SYMBOLS)
175 ## refactor me
176 macro(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})
183         find_program(${_package}CONFIG_EXECUTABLE NAMES ${_package} PATHS /usr/local/bin )
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}")
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()
197 endmacro(XCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags)
199 if(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()
204 else()
205         unset(HAVE_ATTR_ATTRIBUTES_H)
206         unset(HAVE_XATTR)
207 endif()
209 if(WITH_MYSQL)
210         xconfig(mysql_config MYSQL_INCDIR MYSQL_LIBDIR MYSQL_LDFLAGS MYSQL_CFLAGS)
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()
218 else()
219         unset(HAVE_MYSQL_H)
220         unset(HAVE_MYSQL)
221 endif()
223 if(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()
232 else()
233         unset(HAVE_OPENSSL_SSL_H)
234         unset(HAVE_LIBCRYPTO)
235         unset(HAVE_LIBSSL)
236 endif()
238 if(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}")
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()
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                         )
262                         set(PCRE_NAMES pcre)
263                         find_library(PCRE_LIBRARY
264                         NAMES ${PCRE_NAMES}
265                         PATHS /usr/lib /usr/local/lib
266                         )
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()
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()
286 else()
287         unset(HAVE_PCRE_H)
288         unset(HAVE_LIBPCRE)
289 endif()
292 if(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}")
297                 ## if it is empty we'll get newline returned
298                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${XML2_CFLAGS}")
300                 check_include_files(libxml/tree.h HAVE_LIBXML_H)
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()
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()
316 else()
317         unset(HAVE_LIBXML_H)
318         unset(HAVE_LIBXML)
319 endif()
321 if(WITH_SQLITE3)
322         check_include_files(sqlite3.h HAVE_SQLITE3_H)
323         check_library_exists(sqlite3 sqlite3_reset "" HAVE_SQLITE3)
324 else()
325         unset(HAVE_SQLITE3_H)
326         unset(HAVE_SQLITE3)
327 endif()
329 if(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()
337 else()
338         unset(HAVE_UUID_UUID_H)
339         unset(NEED_LIBUUID)
340         unset(HAVE_LIBUUID)
341 endif()
343 if(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                 )
354                 set(ZLIB_NAMES z zlib zdll)
355                         find_library(ZLIB_LIBRARY
356                         NAMES ${ZLIB_NAMES}
357                         PATHS /usr/lib /usr/local/lib
358                 )
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()
371 else()
372         unset(HAVE_ZLIB_H)
373         unset(HAVE_LIBZ)
374         unset(ZLIB_INCLUDE_DIR)
375         unset(ZLIB_LIBRARY)
376 endif()
378 if(WITH_BZIP)
379         check_include_files(bzlib.h HAVE_BZLIB_H)
380         check_library_exists(bz2 BZ2_bzCompress "" HAVE_LIBBZ2)
381 else()
382         unset(HAVE_BZLIB_H)
383         unset(HAVE_LIBBZ2)
384 endif()
386 if(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
392 else()
393         unset(HAVE_LDAP_H)
394         unset(HAVE_LIBLDAP)
395         unset(HAVE_LBER_H)
396         unset(HAVE_LIBLBER)
397 endif()
399 if(WITH_LUA)
400         pkg_search_module(LUA REQUIRED lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1 lua)
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")
404 else()
405         unset(HAVE_LIBLUA)
406         unset(HAVE_LUA_H)
407 endif()
409 if(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()
416 else()
417         unset(HAVE_FAM_H)
418         unset(HAVE_LIBFAM)
419         unset(HAVE_FAMNOEXISTS)
420 endif()
422 if(WITH_GDBM)
423         check_include_files(gdbm.h HAVE_GDBM_H)
424         check_library_exists(gdbm gdbm_open "" HAVE_GDBM)
425 else()
426         unset(HAVE_GDBM_H)
427         unset(HAVE_GDBM)
428 endif()
430 if(WITH_MEMCACHED)
431         check_include_files(libmemcached/memcached.h HAVE_LIBMEMCACHED_MEMCACHED_H)
432         check_library_exists(memcached memcached "" HAVE_LIBMEMCACHED)
433         if(HAVE_LIBMEMCACHED_MEMCACHED_H AND HAVE_LIBMEMCACHED)
434                 set(USE_MEMCACHED 1)
435         else()
436                 message(FATAL_ERROR "didn't find libmemcached")
437         endif()
438 endif()
440 if(NOT BUILD_STATIC)
441         check_include_files(dlfcn.h HAVE_DLFCN_H)
442 else()
443         unset(HAVE_DLFCN_H)
444 endif()
446 if(HAVE_DLFCN_H)
447         check_library_exists(dl dlopen "" HAVE_LIBDL)
448 else()
449         unset(HAVE_LIBDL)
450 endif()
452 set(LIGHTTPD_VERSION_ID 10400)
453 set(PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
454 set(PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
456 if(NOT SBINDIR)
457         set(SBINDIR "sbin")
458 endif()
460 if(NOT LIGHTTPD_MODULES_DIR)
461         set(LIGHTTPD_MODULES_DIR "lib${LIB_SUFFIX}/lighttpd")
462 endif()
464 if(NOT WIN32)
465         set(LIGHTTPD_LIBRARY_DIR "${CMAKE_INSTALL_PREFIX}/${LIGHTTPD_MODULES_DIR}")
466 else()
467         ## We use relative path in windows
468         set(LIGHTTPD_LIBRARY_DIR "lib")
469 endif()
471 ## Write out config.h
472 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
474 add_definitions(-DHAVE_CONFIG_H)
476 include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
478 set(COMMON_SRC
479         base64.c buffer.c log.c
480         keyvalue.c chunk.c
481         http_chunk.c stream.c fdevent.c
482         stat_cache.c plugin.c joblist.c etag.c array.c
483         data_string.c data_count.c data_array.c
484         data_integer.c md5.c data_fastcgi.c
485         vector.c
486         fdevent_select.c fdevent_libev.c
487         fdevent_poll.c fdevent_linux_sysepoll.c
488         fdevent_solaris_devpoll.c fdevent_solaris_port.c
489         fdevent_freebsd_kqueue.c
490         data_config.c
491         inet_ntop_cache.c crc32.c
492         connections-glue.c
493         configfile-glue.c
494         http-header-glue.c
495         splaytree.c network_writev.c
496         network_write_mmap.c network_write_no_mmap.c
497         network_write.c network_linux_sendfile.c
498         network_freebsd_sendfile.c
499         network_solaris_sendfilev.c network_openssl.c
500         status_counter.c safe_memclear.c network_darwin_sendfile.c
503 if(WIN32)
504         message(STATUS "Adding local getopt implementation.")
505         set(COMMON_SRC ${COMMON_SRC} xgetopt.c)
506 endif()
508 add_executable(lemon lemon.c)
510 ## Build parsers by using lemon...
511 lemon_parser(configparser.y)
512 lemon_parser(mod_ssi_exprparser.y)
514 set(L_INSTALL_TARGETS)
516 add_executable(lighttpd-angel lighttpd-angel.c)
517 set(L_INSTALL_TARGETS ${L_INSTALL_TARGETS} lighttpd-angel)
518 add_target_properties(lighttpd-angel COMPILE_FLAGS "-DSBIN_DIR=\\\\\"${CMAKE_INSTALL_PREFIX}/${SBINDIR}\\\\\"")
520 add_executable(lighttpd
521         server.c
522         response.c
523         connections.c
524         network.c
525         configfile.c
526         configparser.c
527         request.c
528         proc_open.c
529         ${COMMON_SRC}
531 set(L_INSTALL_TARGETS ${L_INSTALL_TARGETS} lighttpd)
533 add_and_install_library(mod_access mod_access.c)
534 add_and_install_library(mod_accesslog mod_accesslog.c)
535 add_and_install_library(mod_alias mod_alias.c)
536 add_and_install_library(mod_auth "mod_auth.c;http_auth.c")
537 if(NOT WIN32)
538         add_and_install_library(mod_cgi mod_cgi.c)
539 endif()
540 add_and_install_library(mod_cml "mod_cml.c;mod_cml_lua.c;mod_cml_funcs.c")
541 add_and_install_library(mod_compress mod_compress.c)
542 add_and_install_library(mod_dirlisting mod_dirlisting.c)
543 add_and_install_library(mod_evasive mod_evasive.c)
544 add_and_install_library(mod_evhost mod_evhost.c)
545 add_and_install_library(mod_expire mod_expire.c)
546 add_and_install_library(mod_extforward mod_extforward.c)
547 add_and_install_library(mod_fastcgi mod_fastcgi.c)
548 add_and_install_library(mod_flv_streaming mod_flv_streaming.c)
549 add_and_install_library(mod_indexfile mod_indexfile.c)
550 add_and_install_library(mod_magnet "mod_magnet.c;mod_magnet_cache.c")
551 add_and_install_library(mod_mysql_vhost mod_mysql_vhost.c)
552 add_and_install_library(mod_proxy mod_proxy.c)
553 add_and_install_library(mod_redirect mod_redirect.c)
554 add_and_install_library(mod_rewrite mod_rewrite.c)
555 add_and_install_library(mod_rrdtool mod_rrdtool.c)
556 add_and_install_library(mod_scgi mod_scgi.c)
557 add_and_install_library(mod_secdownload mod_secdownload.c)
558 add_and_install_library(mod_setenv mod_setenv.c)
559 add_and_install_library(mod_simple_vhost mod_simple_vhost.c)
560 add_and_install_library(mod_ssi "mod_ssi_exprparser.c;mod_ssi_expr.c;mod_ssi.c")
561 add_and_install_library(mod_staticfile mod_staticfile.c)
562 add_and_install_library(mod_status mod_status.c)
563 add_and_install_library(mod_trigger_b4_dl mod_trigger_b4_dl.c)
564 # add_and_install_library(mod_uploadprogress mod_uploadprogress.c)
565 add_and_install_library(mod_userdir mod_userdir.c)
566 add_and_install_library(mod_usertrack mod_usertrack.c)
567 add_and_install_library(mod_webdav mod_webdav.c)
569 add_executable(test_buffer
570         test_buffer.c
571         buffer.c
573 add_test(NAME test_buffer COMMAND test_buffer)
575 add_executable(test_base64
576         test_base64.c
577         buffer.c
578         base64.c
580 add_test(NAME test_base64 COMMAND test_base64)
582 add_executable(test_configfile
583         test_configfile.c
584         buffer.c
585         array.c
586         data_string.c
587         keyvalue.c
588         log.c
590 add_test(NAME test_configfile COMMAND test_configfile)
592 if(HAVE_PCRE_H)
593         target_link_libraries(lighttpd ${PCRE_LDFLAGS})
594         add_target_properties(lighttpd COMPILE_FLAGS ${PCRE_CFLAGS})
595         target_link_libraries(mod_rewrite ${PCRE_LDFLAGS})
596         add_target_properties(mod_rewrite COMPILE_FLAGS ${PCRE_CFLAGS})
597         target_link_libraries(mod_dirlisting ${PCRE_LDFLAGS})
598         add_target_properties(mod_dirlisting COMPILE_FLAGS ${PCRE_CFLAGS})
599         target_link_libraries(mod_redirect ${PCRE_LDFLAGS})
600         add_target_properties(mod_redirect COMPILE_FLAGS ${PCRE_CFLAGS})
601         target_link_libraries(mod_ssi ${PCRE_LDFLAGS})
602         add_target_properties(mod_ssi COMPILE_FLAGS ${PCRE_CFLAGS})
603         target_link_libraries(mod_trigger_b4_dl ${PCRE_LDFLAGS})
604         add_target_properties(mod_trigger_b4_dl COMPILE_FLAGS ${PCRE_CFLAGS})
605 endif()
607 target_link_libraries(mod_magnet ${LUA_LDFLAGS})
608 add_target_properties(mod_magnet COMPILE_FLAGS ${LUA_CFLAGS})
610 target_link_libraries(mod_cml ${LUA_LDFLAGS})
611 add_target_properties(mod_cml COMPILE_FLAGS ${LUA_CFLAGS})
613 if(HAVE_MYSQL_H AND HAVE_MYSQL)
614         target_link_libraries(mod_mysql_vhost mysqlclient)
615         include_directories(/usr/include/mysql)
616 endif()
618 set(L_MOD_WEBDAV)
619 if(HAVE_SQLITE3_H)
620         set(L_MOD_WEBDAV ${L_MOD_WEBDAV} sqlite3)
621 endif()
622 if(HAVE_LIBXML_H)
623         target_link_libraries(mod_webdav ${XML2_LDFLAGS})
624 endif()
625 if(HAVE_UUID_H)
626         if(NEED_LIBUUID)
627                 set(L_MOD_WEBDAV ${L_MOD_WEBDAV} uuid)
628         endif()
629 endif()
631 target_link_libraries(mod_webdav ${L_MOD_WEBDAV})
633 set(L_MOD_AUTH)
634 if(HAVE_LIBCRYPT)
635         set(L_MOD_AUTH ${L_MOD_AUTH} crypt)
636 endif()
638 if(HAVE_LDAP_H)
639         set(L_MOD_AUTH ${L_MOD_AUTH} ldap lber)
640 endif()
641 target_link_libraries(mod_auth ${L_MOD_AUTH})
643 if(HAVE_ZLIB_H)
644         if(HAVE_BZLIB_H)
645                 target_link_libraries(mod_compress ${ZLIB_LIBRARY} bz2)
646         else()
647                 target_link_libraries(mod_compress ${ZLIB_LIBRARY})
648         endif()
649 endif()
651 if(HAVE_LIBFAM)
652         target_link_libraries(lighttpd fam)
653 endif()
655 if(HAVE_GDBM_H)
656         target_link_libraries(mod_trigger_b4_dl gdbm)
657 endif()
659 if(WITH_MEMCACHED)
660         target_link_libraries(mod_trigger_b4_dl memcached)
661 endif()
663 if(CMAKE_COMPILER_IS_GNUCC)
664         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -g -Wshadow -W -pedantic ${WARN_CFLAGS}")
665         set(CMAKE_C_FLAGS_RELEASE        "${CMAKE_C_FLAGS_RELEASE}     -O2")
666         set(CMAKE_C_FLAGS_DEBUG          "${CMAKE_C_FLAGS_DEBUG}       -O0")
667         set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} -O2")
668         set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WARN_LDFLAGS}")
669         set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WARN_LDFLAGS}")
670         add_definitions(-D_GNU_SOURCE)
671 endif()
673 add_target_properties(lighttpd LINK_FLAGS "-Wl,-export-dynamic")
675 set_target_properties(lighttpd PROPERTIES CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
677 if(WIN32)
678         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNVALGRIND")
679         add_target_properties(lighttpd COMPILE_FLAGS "-DLI_DECLARE_EXPORTS")
680         target_link_libraries(lighttpd ws2_32)
681         target_link_libraries(mod_proxy ws2_32)
682         target_link_libraries(mod_fcgi ws2_32)
683         target_link_libraries(mod_scgi ws2_32)
684         target_link_libraries(mod_ssi ws2_32)
686         if(MINGW)
687                 target_link_libraries(lighttpd msvcr70)
688                 add_target_properties(lighttpd LINK_FLAGS "-Wl,-subsystem,console")
689         endif()
690 endif()
692 if(NOT BUILD_STATIC)
693         if(HAVE_LIBDL)
694                 target_link_libraries(lighttpd dl)
695         endif()
696 endif()
698 if(HAVE_LIBSSL AND HAVE_LIBCRYPTO)
699         target_link_libraries(lighttpd ssl)
700         target_link_libraries(lighttpd crypto)
701 endif()
703 if(WITH_LIBEV)
704         target_link_libraries(lighttpd ${LIBEV_LDFLAGS})
705         add_target_properties(lighttpd COMPILE_FLAGS ${LIBEV_CFLAGS})
706 endif()
708 if(WITH_LIBUNWIND)
709         target_link_libraries(lighttpd ${LIBUNWIND_LDFLAGS})
710         add_target_properties(lighttpd COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
712         target_link_libraries(test_buffer ${LIBUNWIND_LDFLAGS})
713         add_target_properties(test_buffer COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
714         target_link_libraries(test_base64 ${LIBUNWIND_LDFLAGS})
715         add_target_properties(test_base64 COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
716         target_link_libraries(test_configfile ${PCRE_LDFLAGS} ${LIBUNWIND_LDFLAGS})
717         add_target_properties(test_configfile COMPILE_FLAGS ${PCRE_CFLAGS} ${LIBUNWIND_CFLAGS})
718 endif()
720 if(NOT WIN32)
721 install(TARGETS ${L_INSTALL_TARGETS}
722         RUNTIME DESTINATION ${SBINDIR}
723         LIBRARY DESTINATION ${LIGHTTPD_MODULES_DIR}
724         ARCHIVE DESTINATION ${LIGHTTPD_MODULES_DIR}/static)
725 else()
726 ## HACK to make win32 to install our libraries in desired directory..
727 install(TARGETS lighttpd
728         RUNTIME DESTINATION ${SBINDIR}
729         ARCHIVE DESTINATION lib/static)
730 list(REMOVE_ITEM L_INSTALL_TARGETS lighttpd)
731 install(TARGETS ${L_INSTALL_TARGETS}
732         RUNTIME DESTINATION ${SBINDIR}/lib
733         LIBRARY DESTINATION lib
734         ARCHIVE DESTINATION lib/static)
735 endif()