Documente Academic
Documente Profesional
Documente Cultură
PROJECT(HTTPD C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
INCLUDE(CheckSymbolExists)
INCLUDE(CheckCSourceCompiles)
FIND_PACKAGE(LibXml2)
FIND_PACKAGE(Lua51)
FIND_PACKAGE(OpenSSL)
FIND_PACKAGE(ZLIB)
# PCRE names its libraries differently for debug vs. release builds.
# We can't query our own CMAKE_BUILD_TYPE at configure time.
# If the debug version exists in PREFIX/lib, default to that one.
IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/pcred.lib")
SET(default_pcre_libraries ${CMAKE_INSTALL_PREFIX}/lib/pcred.lib)
ELSE()
SET(default_pcre_libraries ${CMAKE_INSTALL_PREFIX}/lib/pcre.lib)
ENDIF()
IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/nghttp2d.lib")
SET(default_nghttp2_libraries "${CMAKE_INSTALL_PREFIX}/lib/nghttp2d.lib")
ELSE()
SET(default_nghttp2_libraries "${CMAKE_INSTALL_PREFIX}/lib/nghttp2.lib")
ENDIF()
# Misc. options
OPTION(INSTALL_PDB "Install .pdb files (if generated)" ON)
OPTION(INSTALL_MANUAL "Install manual" ON)
MACRO(CHECK_APR_FEATURE which_define)
CHECK_SYMBOL_EXISTS(${which_define} "${APR_INCLUDE_DIR}/apr.h;$
{APR_INCLUDE_DIR}/apu.h" tmp_${which_define})
IF(${tmp_${which_define}})
CHECK_C_SOURCE_COMPILES("#include \"${APR_INCLUDE_DIR}/apr.h\"
#include \"${APR_INCLUDE_DIR}/apu.h\"
int main() {
#ifndef ${which_define}
#error gobble
#endif
#if !${which_define}
#error gobble
#endif
return 1;}" ${which_define})
ELSE()
SET(${which_define})
ENDIF()
IF(${${which_define}})
SET(${which_define} TRUE)
ELSE()
SET(${which_define} FALSE)
ENDIF()
ENDMACRO()
CHECK_APR_FEATURE(APR_HAS_XLATE)
CHECK_APR_FEATURE(APU_HAVE_CRYPTO)
MESSAGE(STATUS "")
MESSAGE(STATUS "Summary of feature detection:")
MESSAGE(STATUS "")
MESSAGE(STATUS "LIBXML2_FOUND ............ : ${LIBXML2_FOUND}")
MESSAGE(STATUS "LUA51_FOUND .............. : ${LUA51_FOUND}")
MESSAGE(STATUS "NGHTTP2_FOUND ............ : ${NGHTTP2_FOUND}")
MESSAGE(STATUS "OPENSSL_FOUND ............ : ${OPENSSL_FOUND}")
MESSAGE(STATUS "ZLIB_FOUND ............... : ${ZLIB_FOUND}")
MESSAGE(STATUS "APR_HAS_LDAP ............. : ${APR_HAS_LDAP}")
MESSAGE(STATUS "APR_HAS_XLATE ............ : ${APR_HAS_XLATE}")
MESSAGE(STATUS "APU_HAVE_CRYPTO .......... : ${APU_HAVE_CRYPTO}")
MESSAGE(STATUS "")
SET(MODULE_PATHS)
FOREACH (modinfo ${MODULE_LIST})
STRING(REGEX REPLACE "([^+]*)\\+([^+]*)\\+([^+]*)" "\\1;\\2;\\3" modinfolist $
{modinfo})
SET(path_to_module)
SET(defaultenable)
SET(helptext)
FOREACH(i ${modinfolist})
IF("${path_to_module}" STREQUAL "")
SET(path_to_module ${i})
ELSEIF("${defaultenable}" STREQUAL "")
SET(defaultenable ${i})
ELSEIF("${helptext}" STREQUAL "")
SET(helptext ${i})
ELSE()
MESSAGE(FATAL_ERROR "Unexpected field or plus sign in >${modinfo}<")
ENDIF()
ENDFOREACH()
ENDFOREACH()
SET(install_targets)
SET(install_bin_pdb)
SET(install_modules) # special handling vs. other installed targets
SET(install_modules_pdb)
SET(builtin_module_shortnames "win32 mpm_winnt http so") # core added automatically
SET(extra_builtin_modules) # the ones specified with -DWITH_MODULES=
ADD_EXECUTABLE(gen_test_char server/gen_test_char.c)
GET_TARGET_PROPERTY(GEN_TEST_CHAR_EXE gen_test_char LOCATION)
ADD_CUSTOM_COMMAND(
COMMENT "Generating character tables, test_char.h, for current locale"
DEPENDS gen_test_char
COMMAND ${GEN_TEST_CHAR_EXE} > ${PROJECT_BINARY_DIR}/test_char.h
OUTPUT ${PROJECT_BINARY_DIR}/test_char.h
)
ADD_CUSTOM_TARGET(
test_char_header ALL
DEPENDS ${PROJECT_BINARY_DIR}/test_char.h
)
SET(HTTPD_MAIN_SOURCES
server/main.c
)
SET(LIBHTTPD_SOURCES
${extra_builtin_modules}
${PROJECT_BINARY_DIR}/modules.c
modules/arch/win32/mod_win32.c
modules/core/mod_so.c
modules/http/byterange_filter.c
modules/http/chunk_filter.c
modules/http/http_core.c
modules/http/http_etag.c
modules/http/http_filters.c
modules/http/http_protocol.c
modules/http/http_request.c
os/win32/ap_regkey.c
os/win32/util_win32.c
server/buildmark.c
server/config.c
server/connection.c
server/core.c
server/core_filters.c
server/eoc_bucket.c
server/eor_bucket.c
server/error_bucket.c
server/listen.c
server/log.c
server/mpm/winnt/child.c
server/mpm/winnt/mpm_winnt.c
server/mpm/winnt/nt_eventlog.c
server/mpm/winnt/service.c
server/mpm_common.c
server/protocol.c
server/provider.c
server/request.c
server/scoreboard.c
server/util.c
server/util_cfgtree.c
server/util_cookies.c
server/util_expr_eval.c
server/util_expr_parse.c
server/util_fcgi.c
server/util_expr_scan.c
server/util_filter.c
server/util_md5.c
server/util_mutex.c
server/util_pcre.c
server/util_regex.c
server/util_script.c
server/util_time.c
server/util_xml.c
server/vhost.c
)
CONFIGURE_FILE(os/win32/win32_config_layout.h
${PROJECT_BINARY_DIR}/ap_config_layout.h)
SET(HTTPD_INCLUDE_DIRECTORIES
${PROJECT_BINARY_DIR}
${EXTRA_INCLUDES}
# see discussion in cmake bug 13188 regarding oddities with relative paths
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/os/win32
${CMAKE_CURRENT_SOURCE_DIR}/modules/core
${CMAKE_CURRENT_SOURCE_DIR}/modules/database
${CMAKE_CURRENT_SOURCE_DIR}/modules/dav/main
${CMAKE_CURRENT_SOURCE_DIR}/modules/filters
${CMAKE_CURRENT_SOURCE_DIR}/modules/generators
${CMAKE_CURRENT_SOURCE_DIR}/modules/proxy
${CMAKE_CURRENT_SOURCE_DIR}/modules/session
${CMAKE_CURRENT_SOURCE_DIR}/modules/ssl
${CMAKE_CURRENT_SOURCE_DIR}/server
${APR_INCLUDE_DIR}
${PCRE_INCLUDE_DIR}
)
INCLUDE_DIRECTORIES(${HTTPD_INCLUDE_DIRECTORIES})
SET(HTTPD_SYSTEM_LIBS
ws2_32
mswsock
)
# Is it enabled?
STRING(TOUPPER "ENABLE_${mod_shortname}" enable_mod)
SET(enable_mod_val ${${enable_mod}})
# Extra defines?
SET(mod_extra_defines "${mod_name}_extra_defines")
IF(NOT ${${mod_extra_defines}} STREQUAL "")
SET_TARGET_PROPERTIES(${mod_name} PROPERTIES COMPILE_DEFINITIONS ${$
{mod_extra_defines}})
ENDIF()
# Extra includes?
SET(mod_extra_includes "${mod_name}_extra_includes")
IF(NOT "${${mod_extra_includes}}" STREQUAL "")
SET(tmp_includes ${HTTPD_INCLUDE_DIRECTORIES} ${${mod_extra_includes}})
SET_TARGET_PROPERTIES(${mod_name} PROPERTIES INCLUDE_DIRECTORIES "$
{tmp_includes}")
GET_PROPERTY(tmp_includes TARGET ${mod_name} PROPERTY INCLUDE_DIRECTORIES)
ENDIF()
ENDIF()
ENDFOREACH()
SET(standard_support
ab
htcacheclean
htdbm
htdigest
htpasswd
httxt2dbm
logresolve
rotatelogs
)
SET(htdbm_extra_sources support/passwd_common.c)
SET(htpasswd_extra_sources support/passwd_common.c)
FOREACH(pgm ${standard_support})
SET(extra_sources ${pgm}_extra_sources)
ADD_EXECUTABLE(${pgm} support/${pgm}.c ${${extra_sources}} build/win32/httpd.rc)
SET(install_targets ${install_targets} ${pgm})
SET(install_bin_pdb ${install_bin_pdb} ${PROJECT_BINARY_DIR}/${pgm}.pdb)
DEFINE_WITH_BLANKS(define_long_name "LONG_NAME" "Apache HTTP Server ${pgm}
program")
SET_TARGET_PROPERTIES(${pgm} PROPERTIES COMPILE_FLAGS "-DAPP_FILE $
{define_long_name} -DBIN_NAME=${pgm}.exe ${EXTRA_COMPILE_FLAGS}")
TARGET_LINK_LIBRARIES(${pgm} ${EXTRA_LIBS} ${APR_LIBRARIES})
ENDFOREACH()
IF(OPENSSL_FOUND)
ADD_EXECUTABLE(abs support/ab.c build/win32/httpd.rc)
SET(install_targets ${install_targets} abs)
SET(install_bin_pdb ${install_bin_pdb} ${PROJECT_BINARY_DIR}/abs.pdb)
SET_TARGET_PROPERTIES(abs PROPERTIES COMPILE_DEFINITIONS HAVE_OPENSSL)
SET(tmp_includes ${HTTPD_INCLUDE_DIRECTORIES} ${OPENSSL_INCLUDE_DIR})
SET_TARGET_PROPERTIES(abs PROPERTIES INCLUDE_DIRECTORIES "${tmp_includes}")
DEFINE_WITH_BLANKS(define_long_name "LONG_NAME" "Apache HTTP Server ab/SSL
program")
SET_TARGET_PROPERTIES(abs PROPERTIES COMPILE_FLAGS "-DAPP_FILE $
{define_long_name} -DBIN_NAME=abs.exe ${EXTRA_COMPILE_FLAGS}")
TARGET_LINK_LIBRARIES(abs ${EXTRA_LIBS} ${APR_LIBRARIES} ${OPENSSL_LIBRARIES})
ENDIF()
GET_PROPERTY(tmp_includes TARGET ab PROPERTY INCLUDE_DIRECTORIES)
IF(INSTALL_PDB)
INSTALL(FILES ${install_bin_pdb}
DESTINATION bin
CONFIGURATIONS RelWithDebInfo Debug)
INSTALL(FILES ${install_modules_pdb}
DESTINATION modules
CONFIGURATIONS RelWithDebInfo Debug)
ENDIF()
IF(INSTALL_MANUAL) # Silly? This takes a while, and a dev doesn't need it.
INSTALL(DIRECTORY docs/manual/ DESTINATION manual)
ENDIF()
# Copy generated .conf files from the build directory to the install,
# without overwriting stuff already there.
INSTALL(CODE "EXECUTE_PROCESS(COMMAND perl $
{CMAKE_CURRENT_SOURCE_DIR}/build/cpR_noreplace.pl ${CMAKE_BINARY_DIR}/conf $
{CMAKE_INSTALL_PREFIX}/conf)")
# But conf/original is supposed to be overwritten.
# Note: FILE(TO_NATIVE_PATH ...) leaves the backslashes unescaped, which
# generates warnings. Just do it manually since this build only supports
# Windows anyway.
STRING(REPLACE "/" "\\\\" native_src ${CMAKE_BINARY_DIR}/conf/original)
STRING(REPLACE "/" "\\\\" native_dest ${CMAKE_INSTALL_PREFIX}/conf/original)
INSTALL(CODE "EXECUTE_PROCESS(COMMAND xcopy ${native_src} ${native_dest} /Q /S
/Y)")