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