File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / lighttpd / src / CMakeLists.txt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Nov 2 10:35:00 2016 UTC (7 years, 8 months ago) by misho
Branches: lighttpd, MAIN
CVS tags: v1_4_41p8, HEAD
lighttpd 1.4.41

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>