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