lighttpd 1.4.x https://www.lighttpd.net/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1101 lines
32 KiB

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