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