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.

734 lines
22 KiB

  1. include(CheckCSourceCompiles)
  2. include(CheckIncludeFiles)
  3. include(CheckFunctionExists)
  4. include(CheckVariableExists)
  5. include(CheckTypeSize)
  6. include(CheckLibraryExists)
  7. include(CMakeDetermineCCompiler)
  8. include(FindThreads)
  9. include(FindPkgConfig)
  10. include(LighttpdMacros)
  11. add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES)
  12. option(WITH_XATTR "with xattr-support for the stat-cache [default: off]")
  13. option(WITH_MYSQL "with mysql-support for the mod_sql_vhost [default: off]")
  14. # option(WITH_POSTGRESQL "with postgress-support for the mod_sql_vhost [default: off]")
  15. option(WITH_OPENSSL "with openssl-support [default: off]")
  16. option(WITH_PCRE "with regex support [default: on]" ON)
  17. option(WITH_WEBDAV_PROPS "with property-support for mod_webdav [default: off]")
  18. option(WITH_WEBDAV_LOCKS "locks in webdav [default: off]")
  19. option(WITH_BZIP "with bzip2-support for mod_compress [default: off]")
  20. option(WITH_ZLIB "with deflate-support for mod_compress [default: on]" ON)
  21. option(WITH_LDAP "with LDAP-support for the mod_auth [default: off]")
  22. option(WITH_LUA "with lua 5.1 for mod_magnet [default: off]")
  23. # option(WITH_VALGRIND "with internal support for valgrind [default: off]")
  24. # option(WITH_KERBEROS5 "use Kerberos5 support with OpenSSL [default: off]")
  25. option(WITH_FAM "fam/gamin for reducing number of stat() calls [default: off]")
  26. option(WITH_GDBM "gdbm storage for mod_trigger_b4_dl [default: off]")
  27. option(WITH_MEMCACHED "memcached storage for mod_trigger_b4_dl [default: off]")
  28. option(WITH_LIBEV "libev support for fdevent handlers [default: off]")
  29. option(WITH_LIBUNWIND "with libunwind to print backtraces in asserts [default: off]")
  30. if(CMAKE_COMPILER_IS_GNUCC)
  31. option(BUILD_EXTRA_WARNINGS "extra warnings")
  32. if(BUILD_EXTRA_WARNINGS)
  33. set(WARN_CFLAGS "-g -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-align -Wsign-compare -Wnested-externs -Wpointer-arith -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security")
  34. set(WARN_LDFLAGS "-Wl,--as-needed")
  35. # -Werror -Wbad-function-cast -Wmissing-prototypes
  36. endif()
  37. endif()
  38. option(BUILD_STATIC "build a static lighttpd with all modules added")
  39. if(BUILD_STATIC)
  40. set(LIGHTTPD_STATIC 1)
  41. else()
  42. set(CMAKE_SHARED_LIBRARY_PREFIX "")
  43. endif()
  44. if(WITH_LIBEV)
  45. find_package(LibEV REQUIRED)
  46. set(HAVE_LIBEV 1)
  47. endif()
  48. if(WITH_LIBUNWIND)
  49. pkg_check_modules(LIBUNWIND REQUIRED libunwind)
  50. set(HAVE_LIBUNWIND 1)
  51. endif()
  52. if(WITH_WEBDAV_PROPS)
  53. set(WITH_XML 1)
  54. set(WITH_SQLITE3 1)
  55. set(WITH_UUID 1)
  56. endif()
  57. check_include_files(sys/devpoll.h HAVE_SYS_DEVPOLL_H)
  58. check_include_files(sys/epoll.h HAVE_SYS_EPOLL_H)
  59. check_include_files(sys/event.h HAVE_SYS_EVENT_H)
  60. check_include_files(sys/mman.h HAVE_SYS_MMAN_H)
  61. check_include_files(sys/poll.h HAVE_SYS_POLL_H)
  62. check_include_files(sys/port.h HAVE_SYS_PORT_H)
  63. check_include_files(sys/prctl.h HAVE_SYS_PRCTL_H)
  64. check_include_files(sys/resource.h HAVE_SYS_RESOURCE_H)
  65. check_include_files(sys/sendfile.h HAVE_SYS_SENDFILE_H)
  66. check_include_files(sys/select.h HAVE_SYS_SELECT_H)
  67. check_include_files(sys/types.h HAVE_SYS_TYPES_H)
  68. check_include_files(sys/uio.h HAVE_SYS_UIO_H)
  69. check_include_files(sys/un.h HAVE_SYS_UN_H)
  70. check_include_files(sys/wait.h HAVE_SYS_WAIT_H)
  71. check_include_files(sys/time.h HAVE_SYS_TIME_H)
  72. check_include_files(unistd.h HAVE_UNISTD_H)
  73. check_include_files(pthread.h HAVE_PTHREAD_H)
  74. check_include_files(getopt.h HAVE_GETOPT_H)
  75. check_include_files(inttypes.h HAVE_INTTYPES_H)
  76. check_include_files(poll.h HAVE_POLL_H)
  77. check_include_files(pwd.h HAVE_PWD_H)
  78. check_include_files(stddef.h HAVE_STDDEF_H)
  79. check_include_files(stdint.h HAVE_STDINT_H)
  80. check_include_files(syslog.h HAVE_SYSLOG_H)
  81. # check for fastcgi lib, for the tests only
  82. check_include_files(fastcgi.h HAVE_FASTCGI_H)
  83. check_include_files(fastcgi/fastcgi.h HAVE_FASTCGI_FASTCGI_H)
  84. # will be needed for auth
  85. check_include_files(crypt.h HAVE_CRYPT_H)
  86. # check if we need libcrypt for crypt_r()
  87. check_library_exists(crypt crypt_r "" HAVE_LIBCRYPT_CRYPT_R)
  88. if(HAVE_LIBCRYPT_CRYPT_R)
  89. set(HAVE_CRYPT_R 1)
  90. set(HAVE_LIBCRYPT 1)
  91. else()
  92. check_library_exists(crypt crypt "" HAVE_LIBCRYPT)
  93. endif()
  94. check_function_exists(crypt_r HAVE_CRYPT_R)
  95. check_function_exists(crypt HAVE_CRYPT)
  96. check_include_files(sys/inotify.h HAVE_SYS_INOTIFY_H)
  97. if(HAVE_SYS_INOTIFY_H)
  98. check_function_exists(inotify_init HAVE_INOTIFY_INIT)
  99. endif()
  100. set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
  101. check_type_size(socklen_t HAVE_SOCKLEN_T)
  102. set(CMAKE_EXTRA_INCLUDE_FILES)
  103. check_type_size(long SIZEOF_LONG)
  104. check_type_size(off_t SIZEOF_OFF_T)
  105. check_function_exists(chroot HAVE_CHROOT)
  106. check_function_exists(epoll_ctl HAVE_EPOLL_CTL)
  107. check_function_exists(fork HAVE_FORK)
  108. check_function_exists(getrlimit HAVE_GETRLIMIT)
  109. check_function_exists(getuid HAVE_GETUID)
  110. check_function_exists(gmtime_r HAVE_GMTIME_R)
  111. check_function_exists(inet_ntop HAVE_INET_NTOP)
  112. check_function_exists(kqueue HAVE_KQUEUE)
  113. check_function_exists(localtime_r HAVE_LOCALTIME_R)
  114. check_function_exists(lstat HAVE_LSTAT)
  115. check_function_exists(madvise HAVE_MADVISE)
  116. check_function_exists(memcpy HAVE_MEMCPY)
  117. check_function_exists(memset HAVE_MEMSET)
  118. check_function_exists(mmap HAVE_MMAP)
  119. check_function_exists(pathconf HAVE_PATHCONF)
  120. check_function_exists(poll HAVE_POLL)
  121. check_function_exists(port_create HAVE_PORT_CREATE)
  122. check_function_exists(prctl HAVE_PRCTL)
  123. check_function_exists(pread HAVE_PREAD)
  124. check_function_exists(posix_fadvise HAVE_POSIX_FADVISE)
  125. check_function_exists(select HAVE_SELECT)
  126. check_function_exists(sendfile HAVE_SENDFILE)
  127. check_function_exists(send_file HAVE_SEND_FILE)
  128. check_function_exists(sendfile64 HAVE_SENDFILE64)
  129. check_function_exists(sendfilev HAVE_SENDFILEV)
  130. check_function_exists(sigaction HAVE_SIGACTION)
  131. check_function_exists(signal HAVE_SIGNAL)
  132. check_function_exists(sigtimedwait HAVE_SIGTIMEDWAIT)
  133. check_function_exists(strptime HAVE_STRPTIME)
  134. check_function_exists(syslog HAVE_SYSLOG)
  135. check_function_exists(writev HAVE_WRITEV)
  136. check_function_exists(inet_aton HAVE_INET_ATON)
  137. check_function_exists(issetugid HAVE_ISSETUGID)
  138. check_function_exists(inet_pton HAVE_INET_PTON)
  139. check_function_exists(memset_s HAVE_MEMSET_S)
  140. check_function_exists(explicit_bzero HAVE_EXPLICIT_BZERO)
  141. check_c_source_compiles("
  142. #include <sys/types.h>
  143. #include <sys/socket.h>
  144. #include <netinet/in.h>
  145. int main() {
  146. struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0;
  147. return 0;
  148. }" HAVE_IPV6)
  149. check_c_source_compiles("
  150. __attribute__((weak)) void __dummy(void *x) { }
  151. int main() {
  152. void *x;
  153. __dummy(x);
  154. }
  155. " HAVE_WEAK_SYMBOLS)
  156. ## refactor me
  157. macro(XCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags)
  158. # reset the variables at the beginning
  159. set(${_include_DIR})
  160. set(${_link_DIR})
  161. set(${_link_FLAGS})
  162. set(${_cflags})
  163. find_program(${_package}CONFIG_EXECUTABLE NAMES ${_package} PATHS /usr/local/bin )
  164. # if pkg-config has been found
  165. if(${_package}CONFIG_EXECUTABLE)
  166. set(XCONFIG_EXECUTABLE "${${_package}CONFIG_EXECUTABLE}")
  167. message(STATUS "found ${_package}: ${XCONFIG_EXECUTABLE}")
  168. exec_program(${XCONFIG_EXECUTABLE} ARGS --libs OUTPUT_VARIABLE __link_FLAGS)
  169. string(REPLACE "\n" "" ${_link_FLAGS} ${__link_FLAGS})
  170. exec_program(${XCONFIG_EXECUTABLE} ARGS --cflags OUTPUT_VARIABLE __cflags)
  171. string(REPLACE "\n" "" ${_cflags} ${__cflags})
  172. else()
  173. message(STATUS "found ${_package}: no")
  174. endif()
  175. endmacro(XCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags)
  176. if(WITH_XATTR)
  177. check_include_files(attr/attributes.h HAVE_ATTR_ATTRIBUTES_H)
  178. if(HAVE_ATTR_ATTRIBUTES_H)
  179. check_library_exists(attr attr_get "" HAVE_XATTR)
  180. endif()
  181. else()
  182. unset(HAVE_ATTR_ATTRIBUTES_H)
  183. unset(HAVE_XATTR)
  184. endif()
  185. if(WITH_MYSQL)
  186. xconfig(mysql_config MYSQL_INCDIR MYSQL_LIBDIR MYSQL_LDFLAGS MYSQL_CFLAGS)
  187. set(CMAKE_REQUIRED_INCLUDES /usr/include/mysql)
  188. check_include_files(mysql.h HAVE_MYSQL_H)
  189. set(CMAKE_REQUIRED_INCLUDES)
  190. if(HAVE_MYSQL_H)
  191. check_library_exists(mysqlclient mysql_real_connect "" HAVE_MYSQL)
  192. endif()
  193. else()
  194. unset(HAVE_MYSQL_H)
  195. unset(HAVE_MYSQL)
  196. endif()
  197. if(WITH_OPENSSL)
  198. check_include_files(openssl/ssl.h HAVE_OPENSSL_SSL_H)
  199. if(HAVE_OPENSSL_SSL_H)
  200. check_library_exists(crypto BIO_f_base64 "" HAVE_LIBCRYPTO)
  201. if(HAVE_LIBCRYPTO)
  202. check_library_exists(ssl SSL_new "" HAVE_LIBSSL)
  203. endif()
  204. endif()
  205. else()
  206. unset(HAVE_OPENSSL_SSL_H)
  207. unset(HAVE_LIBCRYPTO)
  208. unset(HAVE_LIBSSL)
  209. endif()
  210. if(WITH_PCRE)
  211. ## if we have pcre-config, use it
  212. xconfig(pcre-config PCRE_INCDIR PCRE_LIBDIR PCRE_LDFLAGS PCRE_CFLAGS)
  213. if(PCRE_LDFLAGS OR PCRE_CFLAGS)
  214. message(STATUS "found pcre at: LDFLAGS: ${PCRE_LDFLAGS} CFLAGS: ${PCRE_CFLAGS}")
  215. if(NOT PCRE_CFLAGS STREQUAL "\n")
  216. ## if it is empty we'll get newline returned
  217. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PCRE_CFLAGS}")
  218. endif()
  219. set(HAVE_PCRE_H 1)
  220. set(HAVE_LIBPCRE 1)
  221. else()
  222. if(NOT WIN32)
  223. check_include_files(pcre.h HAVE_PCRE_H)
  224. check_library_exists(pcre pcre_exec "" HAVE_LIBPCRE)
  225. set(PCRE_LDFLAGS -lpcre)
  226. else()
  227. find_path(PCRE_INCLUDE_DIR pcre.h
  228. /usr/local/include
  229. /usr/include
  230. )
  231. set(PCRE_NAMES pcre)
  232. find_library(PCRE_LIBRARY
  233. NAMES ${PCRE_NAMES}
  234. PATHS /usr/lib /usr/local/lib
  235. )
  236. if(PCRE_INCLUDE_DIR AND PCRE_LIBRARY)
  237. set(CMAKE_REQUIRED_INCLUDES ${PCRE_INCLUDE_DIR})
  238. set(CMAKE_REQUIRED_LIBRARIES ${PCRE_LIBRARY})
  239. check_include_files(pcre.h HAVE_PCRE_H)
  240. check_library_exists(pcre pcre_exec "" HAVE_LIBPCRE)
  241. set(CMAKE_REQUIRED_INCLUDES)
  242. set(CMAKE_REQUIRED_LIBRARIES)
  243. include_directories(${PCRE_INCLUDE_DIR})
  244. endif()
  245. endif()
  246. endif()
  247. if(NOT HAVE_PCRE_H)
  248. message(FATAL_ERROR "pcre.h couldn't be found")
  249. endif()
  250. if(NOT HAVE_LIBPCRE)
  251. message(FATAL_ERROR "libpcre couldn't be found")
  252. endif()
  253. else()
  254. unset(HAVE_PCRE_H)
  255. unset(HAVE_LIBPCRE)
  256. endif()
  257. if(WITH_XML)
  258. xconfig(xml2-config XML2_INCDIR XML2_LIBDIR XML2_LDFLAGS XML2_CFLAGS)
  259. if(XML2_LDFLAGS OR XML2_CFLAGS)
  260. message(STATUS "found xml2 at: LDFLAGS: ${XML2_LDFLAGS} CFLAGS: ${XML2_CFLAGS}")
  261. ## if it is empty we'll get newline returned
  262. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${XML2_CFLAGS}")
  263. check_include_files(libxml/tree.h HAVE_LIBXML_H)
  264. set(CMAKE_REQUIRED_FLAGS ${XML2_LDFLAGS})
  265. check_library_exists(xml2 xmlParseChunk "" HAVE_LIBXML)
  266. set(CMAKE_REQUIRED_FLAGS)
  267. else()
  268. check_include_files(libxml.h HAVE_LIBXML_H)
  269. check_library_exists(xml2 xmlParseChunk "" HAVE_LIBXML)
  270. endif()
  271. if(NOT HAVE_LIBXML_H)
  272. message(FATAL_ERROR "libxml/tree.h couldn't be found")
  273. endif()
  274. if(NOT HAVE_LIBXML)
  275. message(FATAL_ERROR "libxml2 couldn't be found")
  276. endif()
  277. else()
  278. unset(HAVE_LIBXML_H)
  279. unset(HAVE_LIBXML)
  280. endif()
  281. if(WITH_SQLITE3)
  282. check_include_files(sqlite3.h HAVE_SQLITE3_H)
  283. check_library_exists(sqlite3 sqlite3_reset "" HAVE_SQLITE3)
  284. else()
  285. unset(HAVE_SQLITE3_H)
  286. unset(HAVE_SQLITE3)
  287. endif()
  288. if(WITH_UUID)
  289. check_include_files(uuid/uuid.h HAVE_UUID_UUID_H)
  290. check_library_exists(uuid uuid_generate "" NEED_LIBUUID)
  291. if(NOT NEED_LIBUUID)
  292. check_function_exists(uuid_generate HAVE_LIBUUID)
  293. else()
  294. set(HAVE_LIBUUID 1)
  295. endif()
  296. else()
  297. unset(HAVE_UUID_UUID_H)
  298. unset(NEED_LIBUUID)
  299. unset(HAVE_LIBUUID)
  300. endif()
  301. if(WITH_ZLIB)
  302. if(NOT WIN32)
  303. check_include_files(zlib.h HAVE_ZLIB_H)
  304. check_library_exists(z deflate "" HAVE_LIBZ)
  305. set(ZLIB_LIBRARY z)
  306. else()
  307. find_path(ZLIB_INCLUDE_DIR zlib.h
  308. /usr/local/include
  309. /usr/include
  310. )
  311. set(ZLIB_NAMES z zlib zdll)
  312. find_library(ZLIB_LIBRARY
  313. NAMES ${ZLIB_NAMES}
  314. PATHS /usr/lib /usr/local/lib
  315. )
  316. if(ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
  317. set(CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIR})
  318. set(CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARY})
  319. get_filename_component(ZLIB_NAME ${ZLIB_LIBRARY} NAME)
  320. check_include_files(zlib.h HAVE_ZLIB_H)
  321. check_library_exists(${ZLIB_NAME} deflate "" HAVE_LIBZ)
  322. set(CMAKE_REQUIRED_INCLUDES)
  323. set(CMAKE_REQUIRED_LIBRARIES)
  324. include_directories(${ZLIB_INCLUDE_DIR})
  325. endif()
  326. endif()
  327. else()
  328. unset(HAVE_ZLIB_H)
  329. unset(HAVE_LIBZ)
  330. unset(ZLIB_INCLUDE_DIR)
  331. unset(ZLIB_LIBRARY)
  332. endif()
  333. if(WITH_BZIP)
  334. check_include_files(bzlib.h HAVE_BZLIB_H)
  335. check_library_exists(bz2 BZ2_bzCompress "" HAVE_LIBBZ2)
  336. else()
  337. unset(HAVE_BZLIB_H)
  338. unset(HAVE_LIBBZ2)
  339. endif()
  340. if(WITH_LDAP)
  341. check_include_files(ldap.h HAVE_LDAP_H)
  342. check_library_exists(ldap ldap_bind "" HAVE_LIBLDAP)
  343. check_include_files(lber.h HAVE_LBER_H)
  344. check_library_exists(lber ber_printf "" HAVE_LIBLBER)
  345. set(LDAP_DEPRECATED 1) # Using deprecated ldap api
  346. else()
  347. unset(HAVE_LDAP_H)
  348. unset(HAVE_LIBLDAP)
  349. unset(HAVE_LBER_H)
  350. unset(HAVE_LIBLBER)
  351. endif()
  352. if(WITH_LUA)
  353. pkg_search_module(LUA REQUIRED lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1 lua)
  354. message(STATUS "found lua at: INCDIR: ${LUA_INCLUDE_DIRS} LIBDIR: ${LUA_LIBRARY_DIRS} LDFLAGS: ${LUA_LDFLAGS} CFLAGS: ${LUA_CFLAGS}")
  355. set(HAVE_LIBLUA 1 "Have liblua")
  356. set(HAVE_LUA_H 1 "Have liblua header")
  357. else()
  358. unset(HAVE_LIBLUA)
  359. unset(HAVE_LUA_H)
  360. endif()
  361. if(WITH_FAM)
  362. check_include_files(fam.h HAVE_FAM_H)
  363. check_library_exists(fam FAMOpen2 "" HAVE_LIBFAM)
  364. if(HAVE_LIBFAM)
  365. set(CMAKE_REQUIRED_LIBRARIES fam)
  366. check_function_exists(FAMNoExists HAVE_FAMNOEXISTS)
  367. endif()
  368. else()
  369. unset(HAVE_FAM_H)
  370. unset(HAVE_LIBFAM)
  371. unset(HAVE_FAMNOEXISTS)
  372. endif()
  373. if(WITH_GDBM)
  374. check_include_files(gdbm.h HAVE_GDBM_H)
  375. check_library_exists(gdbm gdbm_open "" HAVE_GDBM)
  376. else()
  377. unset(HAVE_GDBM_H)
  378. unset(HAVE_GDBM)
  379. endif()
  380. if(WITH_MEMCACHED)
  381. check_include_files(libmemcached/memcached.h HAVE_LIBMEMCACHED_MEMCACHED_H)
  382. check_library_exists(memcached memcached "" HAVE_LIBMEMCACHED)
  383. if(HAVE_LIBMEMCACHED_MEMCACHED_H AND HAVE_LIBMEMCACHED)
  384. set(USE_MEMCACHED 1)
  385. else()
  386. message(FATAL_ERROR "didn't find libmemcached")
  387. endif()
  388. endif()
  389. if(NOT BUILD_STATIC)
  390. check_include_files(dlfcn.h HAVE_DLFCN_H)
  391. else()
  392. unset(HAVE_DLFCN_H)
  393. endif()
  394. if(HAVE_DLFCN_H)
  395. check_library_exists(dl dlopen "" HAVE_LIBDL)
  396. else()
  397. unset(HAVE_LIBDL)
  398. endif()
  399. set(LIGHTTPD_VERSION_ID 10400)
  400. set(PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
  401. set(PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
  402. if(NOT SBINDIR)
  403. set(SBINDIR "sbin")
  404. endif()
  405. if(NOT LIGHTTPD_MODULES_DIR)
  406. set(LIGHTTPD_MODULES_DIR "lib${LIB_SUFFIX}/lighttpd")
  407. endif()
  408. if(NOT WIN32)
  409. set(LIGHTTPD_LIBRARY_DIR "${CMAKE_INSTALL_PREFIX}/${LIGHTTPD_MODULES_DIR}")
  410. else()
  411. ## We use relative path in windows
  412. set(LIGHTTPD_LIBRARY_DIR "lib")
  413. endif()
  414. ## Write out config.h
  415. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
  416. add_definitions(-DHAVE_CONFIG_H)
  417. include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
  418. set(COMMON_SRC
  419. base64.c buffer.c log.c
  420. keyvalue.c chunk.c
  421. http_chunk.c stream.c fdevent.c
  422. stat_cache.c plugin.c joblist.c etag.c array.c
  423. data_string.c data_count.c data_array.c
  424. data_integer.c md5.c data_fastcgi.c
  425. vector.c
  426. fdevent_select.c fdevent_libev.c
  427. fdevent_poll.c fdevent_linux_sysepoll.c
  428. fdevent_solaris_devpoll.c fdevent_solaris_port.c
  429. fdevent_freebsd_kqueue.c
  430. data_config.c
  431. inet_ntop_cache.c crc32.c
  432. connections-glue.c
  433. configfile-glue.c
  434. http-header-glue.c
  435. splaytree.c network_writev.c
  436. network_write_mmap.c network_write_no_mmap.c
  437. network_write.c network_linux_sendfile.c
  438. network_freebsd_sendfile.c
  439. network_solaris_sendfilev.c network_openssl.c
  440. status_counter.c safe_memclear.c network_darwin_sendfile.c
  441. )
  442. if(WIN32)
  443. message(STATUS "Adding local getopt implementation.")
  444. set(COMMON_SRC ${COMMON_SRC} xgetopt.c)
  445. endif()
  446. add_executable(lemon lemon.c)
  447. ## Build parsers by using lemon...
  448. lemon_parser(configparser.y)
  449. lemon_parser(mod_ssi_exprparser.y)
  450. set(L_INSTALL_TARGETS)
  451. add_executable(lighttpd-angel lighttpd-angel.c)
  452. set(L_INSTALL_TARGETS ${L_INSTALL_TARGETS} lighttpd-angel)
  453. add_target_properties(lighttpd-angel COMPILE_FLAGS "-DSBIN_DIR=\\\\\"${CMAKE_INSTALL_PREFIX}/${SBINDIR}\\\\\"")
  454. add_executable(lighttpd
  455. server.c
  456. response.c
  457. connections.c
  458. network.c
  459. configfile.c
  460. configparser.c
  461. request.c
  462. proc_open.c
  463. ${COMMON_SRC}
  464. )
  465. set(L_INSTALL_TARGETS ${L_INSTALL_TARGETS} lighttpd)
  466. add_and_install_library(mod_access mod_access.c)
  467. add_and_install_library(mod_accesslog mod_accesslog.c)
  468. add_and_install_library(mod_alias mod_alias.c)
  469. add_and_install_library(mod_auth "mod_auth.c;http_auth.c")
  470. if(NOT WIN32)
  471. add_and_install_library(mod_cgi mod_cgi.c)
  472. endif()
  473. add_and_install_library(mod_cml "mod_cml.c;mod_cml_lua.c;mod_cml_funcs.c")
  474. add_and_install_library(mod_compress mod_compress.c)
  475. add_and_install_library(mod_dirlisting mod_dirlisting.c)
  476. add_and_install_library(mod_evasive mod_evasive.c)
  477. add_and_install_library(mod_evhost mod_evhost.c)
  478. add_and_install_library(mod_expire mod_expire.c)
  479. add_and_install_library(mod_extforward mod_extforward.c)
  480. add_and_install_library(mod_fastcgi mod_fastcgi.c)
  481. add_and_install_library(mod_flv_streaming mod_flv_streaming.c)
  482. add_and_install_library(mod_indexfile mod_indexfile.c)
  483. add_and_install_library(mod_magnet "mod_magnet.c;mod_magnet_cache.c")
  484. add_and_install_library(mod_mysql_vhost mod_mysql_vhost.c)
  485. add_and_install_library(mod_proxy mod_proxy.c)
  486. add_and_install_library(mod_redirect mod_redirect.c)
  487. add_and_install_library(mod_rewrite mod_rewrite.c)
  488. add_and_install_library(mod_rrdtool mod_rrdtool.c)
  489. add_and_install_library(mod_scgi mod_scgi.c)
  490. add_and_install_library(mod_secdownload mod_secdownload.c)
  491. add_and_install_library(mod_setenv mod_setenv.c)
  492. add_and_install_library(mod_simple_vhost mod_simple_vhost.c)
  493. add_and_install_library(mod_ssi "mod_ssi_exprparser.c;mod_ssi_expr.c;mod_ssi.c")
  494. add_and_install_library(mod_staticfile mod_staticfile.c)
  495. add_and_install_library(mod_status mod_status.c)
  496. add_and_install_library(mod_trigger_b4_dl mod_trigger_b4_dl.c)
  497. # add_and_install_library(mod_uploadprogress mod_uploadprogress.c)
  498. add_and_install_library(mod_userdir mod_userdir.c)
  499. add_and_install_library(mod_usertrack mod_usertrack.c)
  500. add_and_install_library(mod_webdav mod_webdav.c)
  501. add_executable(test_buffer
  502. test_buffer.c
  503. buffer.c
  504. )
  505. add_test(NAME test_buffer COMMAND test_buffer)
  506. add_executable(test_base64
  507. test_base64.c
  508. buffer.c
  509. base64.c
  510. )
  511. add_test(NAME test_base64 COMMAND test_base64)
  512. add_executable(test_configfile
  513. test_configfile.c
  514. buffer.c
  515. array.c
  516. data_string.c
  517. keyvalue.c
  518. log.c
  519. )
  520. add_test(NAME test_configfile COMMAND test_configfile)
  521. if(HAVE_PCRE_H)
  522. target_link_libraries(lighttpd ${PCRE_LDFLAGS})
  523. add_target_properties(lighttpd COMPILE_FLAGS ${PCRE_CFLAGS})
  524. target_link_libraries(mod_rewrite ${PCRE_LDFLAGS})
  525. add_target_properties(mod_rewrite COMPILE_FLAGS ${PCRE_CFLAGS})
  526. target_link_libraries(mod_dirlisting ${PCRE_LDFLAGS})
  527. add_target_properties(mod_dirlisting COMPILE_FLAGS ${PCRE_CFLAGS})
  528. target_link_libraries(mod_redirect ${PCRE_LDFLAGS})
  529. add_target_properties(mod_redirect COMPILE_FLAGS ${PCRE_CFLAGS})
  530. target_link_libraries(mod_ssi ${PCRE_LDFLAGS})
  531. add_target_properties(mod_ssi COMPILE_FLAGS ${PCRE_CFLAGS})
  532. target_link_libraries(mod_trigger_b4_dl ${PCRE_LDFLAGS})
  533. add_target_properties(mod_trigger_b4_dl COMPILE_FLAGS ${PCRE_CFLAGS})
  534. endif()
  535. target_link_libraries(mod_magnet ${LUA_LDFLAGS})
  536. add_target_properties(mod_magnet COMPILE_FLAGS ${LUA_CFLAGS})
  537. target_link_libraries(mod_cml ${LUA_LDFLAGS})
  538. add_target_properties(mod_cml COMPILE_FLAGS ${LUA_CFLAGS})
  539. if(HAVE_MYSQL_H AND HAVE_MYSQL)
  540. target_link_libraries(mod_mysql_vhost mysqlclient)
  541. include_directories(/usr/include/mysql)
  542. endif()
  543. set(L_MOD_WEBDAV)
  544. if(HAVE_SQLITE3_H)
  545. set(L_MOD_WEBDAV ${L_MOD_WEBDAV} sqlite3)
  546. endif()
  547. if(HAVE_LIBXML_H)
  548. target_link_libraries(mod_webdav ${XML2_LDFLAGS})
  549. endif()
  550. if(HAVE_UUID_H)
  551. if(NEED_LIBUUID)
  552. set(L_MOD_WEBDAV ${L_MOD_WEBDAV} uuid)
  553. endif()
  554. endif()
  555. target_link_libraries(mod_webdav ${L_MOD_WEBDAV})
  556. set(L_MOD_AUTH)
  557. if(HAVE_LIBCRYPT)
  558. set(L_MOD_AUTH ${L_MOD_AUTH} crypt)
  559. endif()
  560. if(HAVE_LDAP_H)
  561. set(L_MOD_AUTH ${L_MOD_AUTH} ldap lber)
  562. endif()
  563. target_link_libraries(mod_auth ${L_MOD_AUTH})
  564. if(HAVE_ZLIB_H)
  565. if(HAVE_BZLIB_H)
  566. target_link_libraries(mod_compress ${ZLIB_LIBRARY} bz2)
  567. else()
  568. target_link_libraries(mod_compress ${ZLIB_LIBRARY})
  569. endif()
  570. endif()
  571. if(HAVE_LIBFAM)
  572. target_link_libraries(lighttpd fam)
  573. endif()
  574. if(HAVE_GDBM_H)
  575. target_link_libraries(mod_trigger_b4_dl gdbm)
  576. endif()
  577. if(WITH_MEMCACHED)
  578. target_link_libraries(mod_trigger_b4_dl memcached)
  579. endif()
  580. if(CMAKE_COMPILER_IS_GNUCC)
  581. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -g -Wshadow -W -pedantic ${WARN_CFLAGS}")
  582. set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
  583. set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
  584. set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} -O2")
  585. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WARN_LDFLAGS}")
  586. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WARN_LDFLAGS}")
  587. add_definitions(-D_GNU_SOURCE)
  588. endif()
  589. add_target_properties(lighttpd LINK_FLAGS "-Wl,-export-dynamic")
  590. set_target_properties(lighttpd PROPERTIES CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
  591. if(WIN32)
  592. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNVALGRIND")
  593. add_target_properties(lighttpd COMPILE_FLAGS "-DLI_DECLARE_EXPORTS")
  594. target_link_libraries(lighttpd ws2_32)
  595. target_link_libraries(mod_proxy ws2_32)
  596. target_link_libraries(mod_fcgi ws2_32)
  597. target_link_libraries(mod_scgi ws2_32)
  598. target_link_libraries(mod_ssi ws2_32)
  599. if(MINGW)
  600. target_link_libraries(lighttpd msvcr70)
  601. add_target_properties(lighttpd LINK_FLAGS "-Wl,-subsystem,console")
  602. endif()
  603. endif()
  604. if(NOT BUILD_STATIC)
  605. if(HAVE_LIBDL)
  606. target_link_libraries(lighttpd dl)
  607. endif()
  608. endif()
  609. if(HAVE_LIBSSL AND HAVE_LIBCRYPTO)
  610. target_link_libraries(lighttpd ssl)
  611. target_link_libraries(lighttpd crypto)
  612. endif()
  613. if(WITH_LIBEV)
  614. target_link_libraries(lighttpd ${LIBEV_LDFLAGS})
  615. add_target_properties(lighttpd COMPILE_FLAGS ${LIBEV_CFLAGS})
  616. endif()
  617. if(WITH_LIBUNWIND)
  618. target_link_libraries(lighttpd ${LIBUNWIND_LDFLAGS})
  619. add_target_properties(lighttpd COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
  620. target_link_libraries(test_buffer ${LIBUNWIND_LDFLAGS})
  621. add_target_properties(test_buffer COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
  622. target_link_libraries(test_base64 ${LIBUNWIND_LDFLAGS})
  623. add_target_properties(test_base64 COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
  624. target_link_libraries(test_configfile ${PCRE_LDFLAGS} ${LIBUNWIND_LDFLAGS})
  625. add_target_properties(test_configfile COMPILE_FLAGS ${PCRE_CFLAGS} ${LIBUNWIND_CFLAGS})
  626. endif()
  627. if(NOT WIN32)
  628. install(TARGETS ${L_INSTALL_TARGETS}
  629. RUNTIME DESTINATION ${SBINDIR}
  630. LIBRARY DESTINATION ${LIGHTTPD_MODULES_DIR}
  631. ARCHIVE DESTINATION ${LIGHTTPD_MODULES_DIR}/static)
  632. else()
  633. ## HACK to make win32 to install our libraries in desired directory..
  634. install(TARGETS lighttpd
  635. RUNTIME DESTINATION ${SBINDIR}
  636. ARCHIVE DESTINATION lib/static)
  637. list(REMOVE_ITEM L_INSTALL_TARGETS lighttpd)
  638. install(TARGETS ${L_INSTALL_TARGETS}
  639. RUNTIME DESTINATION ${SBINDIR}/lib
  640. LIBRARY DESTINATION lib
  641. ARCHIVE DESTINATION lib/static)
  642. endif()