tanquang

CMakeLists.txt

Apr 12th, 2023 (edited)
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 48.64 KB | Source Code | 0 0
  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License.  You may obtain a copy of the License at
  7. #
  8. #     http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. # Read README.cmake before using this.
  17.  
  18. PROJECT(HTTPD C)
  19.  
  20. CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
  21.  
  22. INCLUDE(CheckSymbolExists)
  23. INCLUDE(CheckCSourceCompiles)
  24.  
  25. FIND_PACKAGE(LibXml2)
  26. FIND_PACKAGE(Lua51)
  27. FIND_PACKAGE(OpenSSL)
  28. FIND_PACKAGE(ZLIB)
  29. FIND_PACKAGE(CURL)
  30.  
  31. # Options for support libraries not supported by cmake-bundled FindFOO
  32.  
  33. # Default to using APR trunk (libapr-2.lib) if it exists in PREFIX/lib;
  34. # otherwise, default to APR 1.x + APR-util 1.x
  35. IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/libapr-2.lib")
  36.   SET(default_apr_libraries "${CMAKE_INSTALL_PREFIX}/lib/libapr-2.lib")
  37. ELSEIF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/libapr-1.lib")
  38.   SET(ldaplib "${CMAKE_INSTALL_PREFIX}/lib/apr_ldap-1.lib")
  39.   IF(NOT EXISTS ${ldaplib})
  40.     SET(ldaplib)
  41.   ENDIF()
  42.   SET(default_apr_libraries ${CMAKE_INSTALL_PREFIX}/lib/libapr-1.lib ${CMAKE_INSTALL_PREFIX}/lib/libaprutil-1.lib ${ldaplib})
  43. ELSE()
  44.   SET(default_apr_libraries)
  45. ENDIF()
  46.  
  47. # PCRE names its libraries differently for debug vs. release builds.
  48. # We can't query our own CMAKE_BUILD_TYPE at configure time.
  49. # If the debug version exists in PREFIX/lib, default to that one.
  50. IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/pcre2-8d.lib")
  51.   SET(default_pcre_libraries ${CMAKE_INSTALL_PREFIX}/lib/pcre2-8d.lib)
  52.   SET(default_pcre_cflags "-DHAVE_PCRE2")
  53. ELSEIF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/pcre2-8.lib")
  54.   SET(default_pcre_libraries ${CMAKE_INSTALL_PREFIX}/lib/pcre2-8.lib)
  55.   SET(default_pcre_cflags "-DHAVE_PCRE2")
  56. ELSEIF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/pcred.lib")
  57.   SET(default_pcre_libraries ${CMAKE_INSTALL_PREFIX}/lib/pcred.lib)
  58. ELSE()
  59.   SET(default_pcre_libraries ${CMAKE_INSTALL_PREFIX}/lib/pcre.lib)
  60. ENDIF()
  61.  
  62. IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/nghttp2d.lib")
  63.   SET(default_nghttp2_libraries "${CMAKE_INSTALL_PREFIX}/lib/nghttp2d.lib")
  64. ELSE()
  65.   SET(default_nghttp2_libraries "${CMAKE_INSTALL_PREFIX}/lib/nghttp2.lib")
  66. ENDIF()
  67.  
  68. IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/brotlienc.lib")
  69.   SET(default_brotli_libraries "${CMAKE_INSTALL_PREFIX}/lib/brotlienc.lib" "${CMAKE_INSTALL_PREFIX}/lib/brotlicommon.lib")
  70. ELSE()
  71.   SET(default_brotli_libraries)
  72. ENDIF()
  73.  
  74. IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/libcurl_imp.lib")
  75.   SET(default_curl_libraries "${CMAKE_INSTALL_PREFIX}/lib/libcurl_imp.lib")
  76. ELSEIF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/libcurl.lib")
  77.   SET(default_curl_libraries "${CMAKE_INSTALL_PREFIX}/lib/libcurl.lib")
  78. ELSE()
  79.   SET(default_curl_libraries)
  80. ENDIF()
  81.  
  82. IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/jansson.lib")
  83.   SET(default_jansson_libraries "${CMAKE_INSTALL_PREFIX}/lib/jansson.lib")
  84. ELSE()
  85.   SET(default_jansson_libraries)
  86. ENDIF()
  87.  
  88. SET(APR_INCLUDE_DIR       "${CMAKE_INSTALL_PREFIX}/include" CACHE STRING "Directory with APR[-Util] include files")
  89. SET(APR_LIBRARIES         ${default_apr_libraries}       CACHE STRING "APR libraries to link with")
  90. SET(NGHTTP2_INCLUDE_DIR   "${CMAKE_INSTALL_PREFIX}/include" CACHE STRING "Directory with NGHTTP2 include files within nghttp2 subdirectory")
  91. SET(NGHTTP2_LIBRARIES     ${default_nghttp2_libraries}   CACHE STRING "NGHTTP2 libraries to link with")
  92. SET(PCRE_CFLAGS           "${default_pcre_cflags}"       CACHE STRING "PCRE flags for util_pcre.c compilation")
  93. SET(PCRE_INCLUDE_DIR      "${CMAKE_INSTALL_PREFIX}/include" CACHE STRING "Directory with PCRE include files")
  94. SET(PCRE_LIBRARIES        ${default_pcre_libraries}      CACHE STRING "PCRE libraries to link with")
  95. SET(LIBXML2_ICONV_INCLUDE_DIR     ""                     CACHE STRING "Directory with iconv include files for libxml2")
  96. SET(LIBXML2_ICONV_LIBRARIES       ""                     CACHE STRING "iconv libraries to link with for libxml2")
  97. SET(BROTLI_INCLUDE_DIR    "${CMAKE_INSTALL_PREFIX}/include" CACHE STRING "Directory with include files for Brotli")
  98. SET(BROTLI_LIBRARIES      ${default_brotli_libraries}    CACHE STRING "Brotli libraries to link with")
  99. SET(CURL_INCLUDE_DIR      "${CMAKE_INSTALL_PREFIX}/include" CACHE STRING "Directory with include files for cURL")
  100. SET(CURL_LIBRARIES        ${default_curl_libraries}         CACHE STRING "cURL libraries to link with")
  101. SET(JANSSON_INCLUDE_DIR   "${CMAKE_INSTALL_PREFIX}/include" CACHE STRING "Directory with include files for jansson")
  102. SET(JANSSON_LIBRARIES     "${default_jansson_libraries}" CACHE STRING "Jansson libraries to link with")
  103. # end support library configuration
  104.  
  105. # Misc. options
  106. OPTION(INSTALL_PDB        "Install .pdb files (if generated)"  ON)
  107. OPTION(INSTALL_MANUAL     "Install manual"                     ON)
  108.  
  109. SET(ENABLE_MODULES        "O"                            CACHE STRING "Minimum module enablement (e.g., \"i\" to build all but those without prerequisites)")
  110. SET(WITH_MODULES          ""                             CACHE STRING "comma-separated paths to single-file modules to statically link into the server")
  111. SET(EXTRA_INCLUDES        ""                             CACHE STRING "Extra include directories")
  112. SET(EXTRA_LIBS            ""                             CACHE STRING "Extra libraries")
  113. SET(EXTRA_COMPILE_FLAGS   ""                             CACHE STRING "Extra compile flags")
  114.  
  115. IF(NOT EXISTS "${APR_INCLUDE_DIR}/apr.h")
  116.   MESSAGE(FATAL_ERROR "APR include directory ${APR_INCLUDE_DIR} is not correct.")
  117. ENDIF()
  118. FOREACH(onelib ${APR_LIBRARIES})
  119.   IF(NOT EXISTS ${onelib})
  120.     MESSAGE(FATAL_ERROR "APR library ${onelib} was not found.")
  121.   ENDIF()
  122. ENDFOREACH()
  123.  
  124. MACRO(DEFINE_WITH_BLANKS output_definition input_symbol input_value)
  125.   IF(MSVC_IDE OR ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.8.11)
  126.     SET(${output_definition} "-D${input_symbol}=\"${input_value}\"")
  127.   ELSE()
  128.     # command-line tool + older cmake, where extra quotes must be added and
  129.     # escaped to survive
  130.     SET(${output_definition} "-D${input_symbol}=\"\\\"${input_value}\\\"\"")
  131.   ENDIF()
  132. ENDMACRO()
  133.  
  134. MACRO(GET_MOD_ENABLE_RANK macro_modname macro_mod_enable_val macro_output_rank)
  135.   IF(${macro_mod_enable_val} STREQUAL "O")
  136.     SET(${macro_output_rank} 0)
  137.   ELSEIF(${macro_mod_enable_val} STREQUAL "i")
  138.     SET(${macro_output_rank} 1)
  139.   ELSEIF(${macro_mod_enable_val} STREQUAL "I")
  140.     SET(${macro_output_rank} 2)
  141.   ELSEIF(${macro_mod_enable_val} STREQUAL "a")
  142.     SET(${macro_output_rank} 3)
  143.   ELSEIF(${macro_mod_enable_val} STREQUAL "A")
  144.     SET(${macro_output_rank} 4)
  145.   ELSE()
  146.     MESSAGE(FATAL_ERROR "Unexpected enablement value \"${macro_mod_enable_val}\" for ${macro_modname}")
  147.   ENDIF()
  148. ENDMACRO()
  149.  
  150. GET_MOD_ENABLE_RANK("ENABLE_MODULES setting" ${ENABLE_MODULES} enable_modules_rank)
  151.  
  152. # Figure out what APR/APU features are available
  153. #
  154. # CHECK_APR_FEATURE checks for features defined to 1 or 0 in apr.h or apu.h
  155. # The symbol representing the feature will be set to TRUE or FALSE for
  156. # compatibility with the feature tests set by FindFooPackage.
  157. #
  158. # (unclear why CHECK_SYMBOL_EXISTS is needed, but I was getting "found" for anything
  159. # not defined to either 1 or 0)
  160.  
  161. MACRO(CHECK_APR_FEATURE which_define)
  162.   SET(CMAKE_REQUIRED_INCLUDES "${APR_INCLUDE_DIR}")
  163.   CHECK_SYMBOL_EXISTS(${which_define} "apr.h;apu.h" tmp_${which_define})
  164.   IF(${tmp_${which_define}})
  165.     CHECK_C_SOURCE_COMPILES("#include \"${APR_INCLUDE_DIR}/apr.h\"
  166.      #include \"${APR_INCLUDE_DIR}/apu.h\"
  167.      int main() {
  168.      #ifndef ${which_define}
  169.      #error gobble
  170.      #endif
  171.      #if !${which_define}
  172.      #error gobble
  173.      #endif
  174.      return 1;}" ${which_define})
  175.   ELSE()
  176.     SET(${which_define})
  177.   ENDIF()
  178.   IF(${${which_define}})
  179.     SET(${which_define} TRUE)
  180.   ELSE()
  181.     SET(${which_define} FALSE)
  182.   ENDIF()
  183. ENDMACRO()
  184.  
  185. CHECK_APR_FEATURE(APR_HAS_XLATE)
  186. CHECK_APR_FEATURE(APU_HAVE_CRYPTO)
  187.  
  188. # APR_HAS_LDAP is defined in apr_ldap.h, which exists only in apr 1.x, so use
  189. # special code instead of CHECK_APR_FEATURE()
  190. # As with CHECK_APR_FEATURE(), convert to a TRUE/FALSE result.
  191. CHECK_C_SOURCE_COMPILES("#include \"${APR_INCLUDE_DIR}/apr.h\"
  192. #include \"${APR_INCLUDE_DIR}/apr_ldap.h\"
  193. int main() {
  194. #if !APR_HAS_LDAP
  195. #error gobble
  196. #endif
  197. return 1;}" APR_HAS_LDAP)
  198. IF(${APR_HAS_LDAP})
  199.   SET(APR_HAS_LDAP TRUE)
  200. ELSE()
  201.   SET(APR_HAS_LDAP FALSE)
  202. ENDIF()
  203.  
  204. # See if nghttp2 exists in a configured or defaulted location
  205. SET(NGHTTP2_FOUND TRUE)
  206. IF(EXISTS "${NGHTTP2_INCLUDE_DIR}/nghttp2/nghttp2.h")
  207.   FOREACH(onelib ${NGHTTP2_LIBRARIES})
  208.     IF(NOT EXISTS ${onelib})
  209.       SET(NGHTTP2_FOUND FALSE)
  210.     ENDIF()
  211.   ENDFOREACH()
  212. ELSE()
  213.   SET(NGHTTP2_FOUND FALSE)
  214. ENDIF()
  215.  
  216. # See if we have Brotli
  217. SET(BROTLI_FOUND TRUE)
  218. IF(EXISTS "${BROTLI_INCLUDE_DIR}/brotli/encode.h")
  219.   FOREACH(onelib ${BROTLI_LIBRARIES})
  220.     IF(NOT EXISTS ${onelib})
  221.       SET(BROTLI_FOUND FALSE)
  222.     ENDIF()
  223.   ENDFOREACH()
  224. ELSE()
  225.   SET(BROTLI_FOUND FALSE)
  226. ENDIF()
  227.  
  228. # See if we have Jansson
  229. SET(JANSSON_FOUND TRUE)
  230. IF(EXISTS "${JANSSON_INCLUDE_DIR}/jansson.h")
  231.   FOREACH(onelib ${JANSSON_LIBRARIES})
  232.     IF(NOT EXISTS ${onelib})
  233.       SET(JANSSON_FOUND FALSE)
  234.     ENDIF()
  235.   ENDFOREACH()
  236. ELSE()
  237.   SET(JANSSON_FOUND FALSE)
  238. ENDIF()
  239.  
  240.  
  241. MESSAGE(STATUS "")
  242. MESSAGE(STATUS "Summary of feature detection:")
  243. MESSAGE(STATUS "")
  244. MESSAGE(STATUS "LIBXML2_FOUND ............ : ${LIBXML2_FOUND}")
  245. MESSAGE(STATUS "LUA51_FOUND .............. : ${LUA51_FOUND}")
  246. MESSAGE(STATUS "NGHTTP2_FOUND ............ : ${NGHTTP2_FOUND}")
  247. MESSAGE(STATUS "OPENSSL_FOUND ............ : ${OPENSSL_FOUND}")
  248. MESSAGE(STATUS "ZLIB_FOUND ............... : ${ZLIB_FOUND}")
  249. MESSAGE(STATUS "BROTLI_FOUND ............. : ${BROTLI_FOUND}")
  250. MESSAGE(STATUS "CURL_FOUND ............... : ${CURL_FOUND}")
  251. MESSAGE(STATUS "JANSSON_FOUND ............ : ${JANSSON_FOUND}")
  252. MESSAGE(STATUS "APR_HAS_LDAP ............. : ${APR_HAS_LDAP}")
  253. MESSAGE(STATUS "APR_HAS_XLATE ............ : ${APR_HAS_XLATE}")
  254. MESSAGE(STATUS "APU_HAVE_CRYPTO .......... : ${APU_HAVE_CRYPTO}")
  255. MESSAGE(STATUS "")
  256.  
  257. # Options for each available module
  258. #   "A" ("A"ctive) means installed and active in default .conf, fail if can't be built
  259. #   "I" ("I"nactive) means installed and inactive (LoadModule commented out) in default .conf, fail if can't be built
  260. #   "O" ("O"mit) means not installed, no LoadModule
  261. #   "a" - like "A", but ignore with a warning if any prereqs aren't available
  262. #   "i" - like "I", but ignore with a warning if any prereqs aren't available
  263.  
  264. # Current heuristic for default enablement:
  265. #
  266. #   Module requires a prereq and           -> O
  267. #   finding/usingprereq isn't implemented
  268. #   yet
  269. #
  270. #   Module is included by default in       -> a if it has prereqs, A otherwise
  271. #   autoconf-based build
  272. #
  273. #   Module is included in                  -> i if it has prereqs, I otherwise
  274. #   --enable-modules=most
  275. #
  276. #   Otherwise                              -> O
  277. #
  278. SET(MODULE_LIST
  279.   "modules/aaa/mod_access_compat+A+mod_access compatibility"
  280.   "modules/aaa/mod_allowmethods+I+restrict allowed HTTP methods"
  281.   "modules/aaa/mod_auth_basic+A+basic authentication"
  282.   "modules/aaa/mod_auth_digest+I+RFC2617 Digest authentication"
  283.   "modules/aaa/mod_auth_form+I+form authentication"
  284.   "modules/aaa/mod_authn_anon+I+anonymous user authentication control"
  285.   "modules/aaa/mod_authn_core+A+core authentication module"
  286.   "modules/aaa/mod_authn_dbd+I+SQL-based authentication control"
  287.   "modules/aaa/mod_authn_dbm+I+DBM-based authentication control"
  288.   "modules/aaa/mod_authn_file+A+file-based authentication control"
  289.   "modules/aaa/mod_authn_socache+I+Cached authentication control"
  290.   "modules/aaa/mod_authnz_fcgi+I+FastCGI authorizer-based authentication and authorization"
  291.   "modules/aaa/mod_authnz_ldap+i+LDAP based authentication"
  292.   "modules/aaa/mod_authz_core+A+core authorization provider vector module"
  293.   "modules/aaa/mod_authz_dbd+I+SQL based authorization and Login/Session support"
  294.   "modules/aaa/mod_authz_dbm+I+DBM-based authorization control"
  295.   "modules/aaa/mod_authz_groupfile+A+'require group' authorization control"
  296.   "modules/aaa/mod_authz_host+A+host-based authorization control"
  297.   "modules/aaa/mod_authz_owner+I+'require file-owner' authorization control"
  298.   "modules/aaa/mod_authz_user+A+'require user' authorization control"
  299.   "modules/arch/win32/mod_isapi+I+isapi extension support"
  300.   "modules/cache/mod_cache+I+dynamic file caching.  At least one storage management module (e.g. mod_cache_disk) is also necessary."
  301.   "modules/cache/mod_cache_disk+I+disk caching module"
  302.   "modules/cache/mod_cache_socache+I+shared object caching module"
  303.   "modules/cache/mod_file_cache+I+File cache"
  304.   "modules/cache/mod_socache_dbm+I+dbm small object cache provider"
  305.   "modules/cache/mod_socache_dc+O+distcache small object cache provider"
  306.   "modules/cache/mod_socache_memcache+I+memcache small object cache provider"
  307.   "modules/cache/mod_socache_shmcb+I+ shmcb small object cache provider"
  308.   "modules/cache/mod_socache_redis+I+redis small object cache provider"
  309.   "modules/cluster/mod_heartbeat+I+Generates Heartbeats"
  310.   "modules/cluster/mod_heartmonitor+I+Collects Heartbeats"
  311.   "modules/core/mod_macro+I+Define and use macros in configuration files"
  312.   "modules/core/mod_watchdog+I+Watchdog module"
  313.   "modules/database/mod_dbd+I+Apache DBD Framework"
  314.   "modules/dav/fs/mod_dav_fs+I+DAV provider for the filesystem."
  315.   "modules/dav/lock/mod_dav_lock+I+DAV provider for generic locking"
  316.   "modules/dav/main/mod_dav+I+WebDAV protocol handling."
  317.   "modules/debugging/mod_bucketeer+O+buckets manipulation filter.  Useful only for developers and testing purposes."
  318.   "modules/debugging/mod_dumpio+I+I/O dump filter"
  319.   "modules/echo/mod_echo+O+ECHO server"
  320.   "modules/examples/mod_case_filter+O+Example uppercase conversion filter"
  321.   "modules/examples/mod_case_filter_in+O+Example uppercase conversion input filter"
  322.   "modules/examples/mod_example_hooks+O+Example hook callback handler module"
  323.   "modules/examples/mod_example_ipc+O+Example of shared memory and mutex usage"
  324.   "modules/filters/mod_brotli+i+Brotli compression support"
  325.   "modules/filters/mod_buffer+I+Filter Buffering"
  326.   "modules/filters/mod_charset_lite+i+character set translation"
  327.   "modules/filters/mod_data+O+RFC2397 data encoder"
  328.   "modules/filters/mod_deflate+i+Deflate transfer encoding support"
  329.   "modules/filters/mod_ext_filter+I+external filter module"
  330.   "modules/filters/mod_filter+A+Smart Filtering"
  331.   "modules/filters/mod_include+I+Server Side Includes"
  332.   "modules/filters/mod_proxy_html+i+Fix HTML Links in a Reverse Proxy"
  333.   "modules/filters/mod_ratelimit+I+Output Bandwidth Limiting"
  334.   "modules/filters/mod_reflector+O+Reflect request through the output filter stack"
  335.   "modules/filters/mod_reqtimeout+A+Limit time waiting for request from client"
  336.   "modules/filters/mod_request+I+Request Body Filtering"
  337.   "modules/filters/mod_sed+I+filter request and/or response bodies through sed"
  338.   "modules/filters/mod_substitute+I+response content rewrite-like filtering"
  339.   "modules/filters/mod_xml2enc+i+i18n support for markup filters"
  340.   "modules/generators/mod_asis+I+as-is filetypes"
  341.   "modules/generators/mod_autoindex+A+directory listing"
  342.   "modules/generators/mod_cgi+I+CGI scripts"
  343.   "modules/generators/mod_info+I+server information"
  344.   "modules/generators/mod_status+I+process/thread monitoring"
  345.   "modules/http/mod_mime+A+mapping of file-extension to MIME.  Disabling this module is normally not recommended."
  346.   "modules/http2/mod_http2+i+HTTP/2 protocol support"
  347.   "modules/ldap/mod_ldap+i+LDAP caching and connection pooling services"
  348.   "modules/loggers/mod_log_config+A+logging configuration.  You won't be able to log requests to the server without this module."
  349.   "modules/loggers/mod_log_debug+I+configurable debug logging"
  350.   "modules/loggers/mod_log_forensic+I+forensic logging"
  351.   "modules/loggers/mod_logio+I+input and output logging"
  352.   "modules/lua/mod_lua+i+Apache Lua Framework"
  353.   "modules/md/mod_md+i+Apache Managed Domains (Certificates)"
  354.   "modules/mappers/mod_actions+I+Action triggering on requests"
  355.   "modules/mappers/mod_alias+A+mapping of requests to different filesystem parts"
  356.   "modules/mappers/mod_dir+A+directory request handling"
  357.   "modules/mappers/mod_imagemap+I+server-side imagemaps"
  358.   "modules/mappers/mod_negotiation+I+content negotiation"
  359.   "modules/mappers/mod_rewrite+I+rule based URL manipulation"
  360.   "modules/mappers/mod_speling+I+correct common URL misspellings"
  361.   "modules/mappers/mod_userdir+I+mapping of requests to user-specific directories"
  362.   "modules/mappers/mod_vhost_alias+I+mass virtual hosting module"
  363.   "modules/metadata/mod_cern_meta+O+CERN-type meta files"
  364.   "modules/metadata/mod_env+A+clearing/setting of ENV vars"
  365.   "modules/metadata/mod_expires+I+Expires header control"
  366.   "modules/metadata/mod_headers+A+HTTP header control"
  367.   "modules/metadata/mod_ident+O+RFC 1413 identity check"
  368.   "modules/metadata/mod_mime_magic+O+automagically determining MIME type"
  369.   "modules/metadata/mod_remoteip+I+translate header contents to an apparent client remote_ip"
  370.   "modules/metadata/mod_setenvif+A+basing ENV vars on headers"
  371.   "modules/metadata/mod_unique_id+I+per-request unique ids"
  372.   "modules/metadata/mod_usertrack+I+user-session tracking"
  373.   "modules/metadata/mod_version+A+determining httpd version in config files"
  374.   "modules/proxy/balancers/mod_lbmethod_bybusyness+I+Apache proxy Load balancing by busyness"
  375.   "modules/proxy/balancers/mod_lbmethod_byrequests+I+Apache proxy Load balancing by request counting"
  376.   "modules/proxy/balancers/mod_lbmethod_bytraffic+I+Apache proxy Load balancing by traffic counting"
  377.   "modules/proxy/balancers/mod_lbmethod_heartbeat+I+Apache proxy Load balancing from Heartbeats"
  378.   "modules/proxy/mod_proxy_ajp+I+Apache proxy AJP module.  Requires and is enabled by --enable-proxy."
  379.   "modules/proxy/mod_proxy_balancer+I+Apache proxy BALANCER module.  Requires and is enabled by --enable-proxy."
  380.   "modules/proxy/mod_proxy+I+Apache proxy module"
  381.   "modules/proxy/mod_proxy_connect+I+Apache proxy CONNECT module.  Requires and is enabled by --enable-proxy."
  382.   "modules/proxy/mod_proxy_express+I+mass reverse-proxy module. Requires --enable-proxy."
  383.   "modules/proxy/mod_proxy_fcgi+I+Apache proxy FastCGI module.  Requires and is enabled by --enable-proxy."
  384.   "modules/proxy/mod_proxy_ftp+I+Apache proxy FTP module.  Requires and is enabled by --enable-proxy."
  385.   "modules/proxy/mod_proxy_http+I+Apache proxy HTTP module.  Requires and is enabled by --enable-proxy."
  386.   "modules/proxy/mod_proxy_hcheck+I+Apache proxy health check module.  Requires and is enabled by --enable-proxy."
  387.   "modules/proxy/mod_proxy_scgi+I+Apache proxy SCGI module.  Requires and is enabled by --enable-proxy."
  388.   "modules/proxy/mod_proxy_wstunnel+I+Apache proxy Websocket Tunnel module.  Requires and is enabled by --enable-proxy."
  389.   "modules/http2/mod_proxy_http2+i+Apache proxy HTTP/2 module.  Requires --enable-proxy."
  390.   "modules/session/mod_session+I+session module"
  391.   "modules/session/mod_session_cookie+I+session cookie module"
  392.   "modules/session/mod_session_crypto+i+session crypto module"
  393.   "modules/session/mod_session_dbd+I+session dbd module"
  394.   "modules/slotmem/mod_slotmem_plain+I+slotmem provider that uses plain memory"
  395.   "modules/slotmem/mod_slotmem_shm+I+slotmem provider that uses shared memory"
  396.   "modules/ssl/mod_ssl+i+SSL/TLS support"
  397.   "modules/test/mod_dialup+O+rate limits static files to dialup modem speeds"
  398.   "modules/test/mod_optional_fn_export+O+example optional function exporter"
  399.   "modules/test/mod_optional_fn_import+O+example optional function importer"
  400.   "modules/test/mod_optional_hook_export+O+example optional hook exporter"
  401.   "modules/test/mod_optional_hook_import+O+example optional hook importer"
  402. )
  403.  
  404. # Track which modules actually built have APIs to link against.
  405. SET(installed_mod_libs_exps)
  406.  
  407. # Define extra definitions, sources, headers, etc. required by some modules.
  408. # This could be included in the master list of modules above, though it
  409. # certainly would get a lot more unreadable.
  410. SET(mod_apreq_extra_defines          APREQ_DECLARE_EXPORT)
  411. SET(mod_apreq_extra_sources          modules/apreq/handle.c)
  412. SET(mod_apreq_main_source            modules/apreq/filter.c)
  413. SET(mod_authz_dbd_extra_defines      AUTHZ_DBD_DECLARE_EXPORT)
  414. SET(mod_authnz_ldap_requires         APR_HAS_LDAP)
  415. SET(mod_authnz_ldap_extra_libs       mod_ldap)
  416. SET(mod_cache_extra_defines          CACHE_DECLARE_EXPORT)
  417. SET(mod_cache_extra_sources
  418.   modules/cache/cache_storage.c      modules/cache/cache_util.c
  419. )
  420. SET(mod_cache_install_lib 1)
  421. SET(mod_cache_disk_extra_libs        mod_cache)
  422. SET(mod_cache_socache_extra_libs     mod_cache)
  423. SET(mod_charset_lite_requires        APR_HAS_XLATE)
  424. SET(mod_dav_extra_defines            DAV_DECLARE_EXPORT)
  425. SET(mod_dav_extra_sources
  426.   modules/dav/main/liveprop.c        modules/dav/main/props.c
  427.   modules/dav/main/std_liveprop.c    modules/dav/main/providers.c
  428.   modules/dav/main/util.c            modules/dav/main/util_lock.c
  429. )
  430. SET(mod_dav_install_lib 1)
  431. SET(mod_dav_fs_extra_sources
  432.   modules/dav/fs/dbm.c               modules/dav/fs/lock.c
  433.   modules/dav/fs/repos.c
  434. )
  435. SET(mod_dav_fs_extra_libs            mod_dav)
  436. SET(mod_dav_lock_extra_sources       modules/dav/lock/locks.c)
  437. SET(mod_dav_lock_extra_libs          mod_dav)
  438. SET(mod_dbd_extra_defines            DBD_DECLARE_EXPORT)
  439. SET(mod_deflate_requires             ZLIB_FOUND)
  440. IF(ZLIB_FOUND)
  441.   SET(mod_deflate_extra_includes       ${ZLIB_INCLUDE_DIR})
  442.   SET(mod_deflate_extra_libs           ${ZLIB_LIBRARIES})
  443. ENDIF()
  444. SET(mod_brotli_requires              BROTLI_FOUND)
  445. IF(BROTLI_FOUND)
  446.   SET(mod_brotli_extra_includes        ${BROTLI_INCLUDE_DIR})
  447.   SET(mod_brotli_extra_libs            ${BROTLI_LIBRARIES})
  448. ENDIF()
  449. SET(mod_firehose_requires            SOMEONE_TO_MAKE_IT_COMPILE_ON_WINDOWS)
  450. SET(mod_heartbeat_extra_libs         mod_watchdog)
  451. SET(mod_http2_requires               NGHTTP2_FOUND)
  452. SET(mod_http2_extra_defines          ssize_t=long)
  453. SET(mod_http2_extra_includes         ${NGHTTP2_INCLUDE_DIR})
  454. SET(mod_http2_extra_libs             ${NGHTTP2_LIBRARIES})
  455. SET(mod_http2_extra_sources
  456.    modules/http2/h2_bucket_beam.c     modules/http2/h2_bucket_eos.c
  457.    modules/http2/h2_c1.c              modules/http2/h2_c1_io.c
  458.    modules/http2/h2_c2.c              modules/http2/h2_c2_filter.c
  459.    modules/http2/h2_config.c          modules/http2/h2_conn_ctx.c
  460.    modules/http2/h2_mplx.c            modules/http2/h2_headers.c
  461.    modules/http2/h2_protocol.c        modules/http2/h2_push.c
  462.    modules/http2/h2_request.c         modules/http2/h2_session.c
  463.    modules/http2/h2_stream.c          modules/http2/h2_switch.c
  464.    modules/http2/h2_util.c            modules/http2/h2_workers.c
  465. )
  466. SET(mod_ldap_extra_defines           LDAP_DECLARE_EXPORT)
  467. SET(mod_ldap_extra_libs              wldap32)
  468. SET(mod_ldap_extra_sources
  469.   modules/ldap/util_ldap_cache.c     modules/ldap/util_ldap_cache_mgr.c
  470. )
  471. SET(mod_ldap_main_source             modules/ldap/util_ldap.c)
  472. SET(mod_ldap_requires                APR_HAS_LDAP)
  473. SET(mod_lua_extra_defines            AP_LUA_DECLARE_EXPORT)
  474. SET(mod_lua_extra_includes           ${LUA_INCLUDE_DIR})
  475. SET(mod_lua_extra_libs               ${LUA_LIBRARIES})
  476. SET(mod_lua_extra_sources
  477.   modules/lua/lua_apr.c              modules/lua/lua_config.c
  478.   modules/lua/lua_passwd.c           modules/lua/lua_request.c
  479.   modules/lua/lua_vmprep.c           modules/lua/lua_dbd.c
  480. )
  481. SET(mod_lua_requires                 LUA51_FOUND)
  482. SET(mod_md_requires                  OPENSSL_FOUND CURL_FOUND JANSSON_FOUND)
  483. SET(mod_md_extra_includes            ${OPENSSL_INCLUDE_DIR} ${CURL_INCLUDE_DIR} ${JANSSON_INCLUDE_DIR})
  484. SET(mod_md_extra_libs                ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES} ${JANSSON_LIBRARIES} mod_watchdog)
  485. SET(mod_md_extra_sources
  486.   modules/md/md_acme.c               modules/md/md_acme_acct.c
  487.   modules/md/md_acme_authz.c         modules/md/md_acme_drive.c
  488.   modules/md/md_acmev2_drive.c       modules/md/md_event.c
  489.   modules/md/md_acme_order.c         modules/md/md_core.c
  490.   modules/md/md_curl.c               modules/md/md_crypt.c
  491.   modules/md/md_http.c               modules/md/md_json.c
  492.   modules/md/md_jws.c                modules/md/md_log.c
  493.   modules/md/md_result.c             modules/md/md_reg.c
  494.   modules/md/md_status.c             modules/md/md_store.c
  495.   modules/md/md_store_fs.c           modules/md/md_time.c
  496.   modules/md/md_ocsp.c               modules/md/md_util.c
  497.   modules/md/mod_md_config.c         modules/md/mod_md_drive.c
  498.   modules/md/mod_md_os.c             modules/md/mod_md_status.c
  499.   modules/md/mod_md_ocsp.c           modules/md/md_tailscale.c
  500. )
  501. SET(mod_optional_hook_export_extra_defines AP_DECLARE_EXPORT) # bogus reuse of core API prefix
  502. SET(mod_proxy_extra_defines          PROXY_DECLARE_EXPORT)
  503. SET(mod_proxy_extra_sources          modules/proxy/proxy_util.c)
  504. SET(mod_proxy_install_lib 1)
  505. SET(mod_proxy_ajp_extra_sources
  506.   modules/proxy/ajp_header.c         modules/proxy/ajp_link.c
  507.   modules/proxy/ajp_msg.c            modules/proxy/ajp_utils.c
  508. )
  509. SET(mod_proxy_ajp_extra_libs         mod_proxy)
  510. SET(mod_proxy_balancer_extra_libs    mod_proxy)
  511. SET(mod_proxy_connect_extra_libs     mod_proxy)
  512. SET(mod_proxy_express_extra_libs     mod_proxy)
  513. SET(mod_proxy_fcgi_extra_libs        mod_proxy)
  514. SET(mod_proxy_ftp_extra_libs         mod_proxy)
  515. SET(mod_proxy_hcheck_extra_libs      mod_proxy)
  516. SET(mod_proxy_http_extra_libs        mod_proxy)
  517. SET(mod_proxy_html_requires          LIBXML2_FOUND)
  518. IF(LIBXML2_FOUND)
  519.   SET(mod_proxy_html_extra_includes    "${LIBXML2_INCLUDE_DIR};${LIBXML2_ICONV_INCLUDE_DIR}")
  520.   SET(mod_proxy_html_extra_libs        "${LIBXML2_LIBRARIES};${LIBXML2_ICONV_LIBRARIES}")
  521. ENDIF()
  522. SET(mod_proxy_scgi_extra_libs        mod_proxy)
  523. SET(mod_proxy_wstunnel_extra_libs    mod_proxy)
  524. SET(mod_proxy_http2_requires               NGHTTP2_FOUND)
  525. SET(mod_proxy_http2_extra_defines          ssize_t=long)
  526. SET(mod_proxy_http2_extra_includes         ${NGHTTP2_INCLUDE_DIR})
  527. SET(mod_proxy_http2_extra_libs             ${NGHTTP2_LIBRARIES} mod_proxy)
  528. SET(mod_proxy_http2_extra_sources
  529.   modules/http2/h2_proxy_session.c   modules/http2/h2_proxy_util.c
  530. )
  531. SET(mod_ratelimit_extra_defines      AP_RL_DECLARE_EXPORT)
  532. SET(mod_sed_extra_sources
  533.   modules/filters/regexp.c           modules/filters/sed0.c
  534.   modules/filters/sed1.c
  535. )
  536. SET(mod_serf_requires                AN_UNIMPLEMENTED_SUPPORT_LIBRARY_REQUIREMENT)
  537. SET(mod_session_extra_defines        SESSION_DECLARE_EXPORT)
  538. SET(mod_session_install_lib 1)
  539. SET(mod_session_cookie_extra_libs    mod_session)
  540. SET(mod_session_crypto_requires      APU_HAVE_CRYPTO)
  541. SET(mod_session_crypto_extra_libs    mod_session)
  542. SET(mod_session_dbd_extra_libs       mod_session)
  543. SET(mod_socache_dc_requires          AN_UNIMPLEMENTED_SUPPORT_LIBRARY_REQUIREMENT)
  544. SET(mod_ssl_extra_defines            SSL_DECLARE_EXPORT)
  545. SET(mod_ssl_requires                 OPENSSL_FOUND)
  546. IF(OPENSSL_FOUND)
  547.   SET(mod_ssl_extra_includes           ${OPENSSL_INCLUDE_DIR})
  548.   SET(mod_ssl_extra_libs               ${OPENSSL_LIBRARIES})
  549. ENDIF()
  550. SET(mod_ssl_extra_sources
  551.   modules/ssl/ssl_engine_config.c
  552.   modules/ssl/ssl_engine_init.c      modules/ssl/ssl_engine_io.c
  553.   modules/ssl/ssl_engine_kernel.c    modules/ssl/ssl_engine_log.c
  554.   modules/ssl/ssl_engine_mutex.c     modules/ssl/ssl_engine_ocsp.c
  555.   modules/ssl/ssl_engine_pphrase.c   modules/ssl/ssl_engine_rand.c
  556.   modules/ssl/ssl_engine_vars.c      modules/ssl/ssl_scache.c
  557.   modules/ssl/ssl_util.c             modules/ssl/ssl_util_ocsp.c
  558.   modules/ssl/ssl_util_ssl.c         modules/ssl/ssl_util_stapling.c
  559. )
  560. SET(mod_status_extra_defines         STATUS_DECLARE_EXPORT)
  561. SET(mod_watchdog_install_lib 1)
  562. SET(mod_xml2enc_requires             LIBXML2_FOUND)
  563. IF(LIBXML2_FOUND)
  564.   SET(mod_xml2enc_extra_includes     "${LIBXML2_INCLUDE_DIR};${LIBXML2_ICONV_INCLUDE_DIR}")
  565.   SET(mod_xml2enc_extra_libs         "${LIBXML2_LIBRARIES};${LIBXML2_ICONV_LIBRARIES}")
  566. ENDIF()
  567. SET(mod_watchdog_extra_defines       AP_WD_DECLARE_EXPORT)
  568.  
  569. SET(MODULE_PATHS)
  570. FOREACH (modinfo ${MODULE_LIST})
  571.   STRING(REGEX REPLACE "([^+]*)\\+([^+]*)\\+([^+]*)" "\\1;\\2;\\3" modinfolist ${modinfo})
  572.   SET(path_to_module)
  573.   SET(defaultenable)
  574.   SET(helptext)
  575.   FOREACH(i ${modinfolist})
  576.     IF("${path_to_module}" STREQUAL "")
  577.       SET(path_to_module ${i})
  578.     ELSEIF("${defaultenable}" STREQUAL "")
  579.       SET(defaultenable ${i})
  580.     ELSEIF("${helptext}" STREQUAL "")
  581.       SET(helptext ${i})
  582.     ELSE()
  583.       MESSAGE(FATAL_ERROR "Unexpected field or plus sign in >${modinfo}<")
  584.     ENDIF()
  585.   ENDFOREACH()
  586.  
  587.   # MESSAGE("       path to module: ${path_to_module}")
  588.   # MESSAGE("enablement by default: ${defaultenable}")
  589.   # MESSAGE("            help text: ${helptext}")
  590.  
  591.   STRING(REGEX REPLACE ".*/(mod_[^\\+]+)" "\\1" mod_name       ${path_to_module})
  592.   STRING(REGEX REPLACE "mod_(.*)"         "\\1" mod_shortname  ${mod_name})
  593.  
  594.   STRING(TOUPPER "ENABLE_${mod_shortname}" mod_option_name)
  595.  
  596.   SET(${mod_option_name} ${defaultenable} CACHE STRING ${helptext})
  597.   SET(MODULE_PATHS "${MODULE_PATHS};${path_to_module}")
  598.  
  599. ENDFOREACH()
  600.  
  601. SET(install_targets)
  602. SET(install_bin_pdb)
  603. SET(install_modules) # special handling vs. other installed targets
  604. SET(install_modules_pdb)
  605. SET(builtin_module_shortnames "win32 mpm_winnt http so") # core added automatically
  606. SET(extra_builtin_modules) # the ones specified with -DWITH_MODULES=
  607.  
  608. IF(WITH_MODULES) # modules statically linked with the server
  609.   STRING(REPLACE "," ";" WITH_MODULE_LIST ${WITH_MODULES})
  610.   FOREACH(static_mod ${WITH_MODULE_LIST})
  611.     STRING(REGEX MATCH   "[^/]+\\.c"           mod_basename    ${static_mod})
  612.     STRING(REGEX REPLACE "^mod_(.*)\\.c" "\\1" mod_module_name ${mod_basename})
  613.     SET(builtin_module_shortnames "${builtin_module_shortnames} ${mod_module_name}")
  614.     CONFIGURE_FILE(${static_mod} ${PROJECT_BINARY_DIR}/ COPYONLY)
  615.     SET(extra_builtin_modules ${extra_builtin_modules} ${PROJECT_BINARY_DIR}/${mod_basename})
  616.   ENDFOREACH()
  617.   EXECUTE_PROCESS(COMMAND cmd /c "echo ${builtin_module_shortnames}| awk -f ${CMAKE_CURRENT_SOURCE_DIR}/build/build-modules-c.awk > ${PROJECT_BINARY_DIR}/modules.c" RESULT_VARIABLE rv)
  618.   IF(rv)
  619.     MESSAGE(FATAL_ERROR "build-modules-c.awk failed (${rv})")
  620.   ENDIF()
  621. ELSE()
  622.   # no extra built-in modules; use the default modules.c to avoid the awk prereq
  623.   CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/os/win32/modules.c ${PROJECT_BINARY_DIR}/ COPYONLY)
  624. ENDIF()
  625.  
  626. # for easy reference from .dll/.so builds
  627. CONFIGURE_FILE(os/win32/BaseAddr.ref ${PROJECT_BINARY_DIR}/ COPYONLY)
  628.  
  629. ADD_EXECUTABLE(gen_test_char server/gen_test_char.c)
  630. GET_TARGET_PROPERTY(GEN_TEST_CHAR_EXE gen_test_char LOCATION)
  631. ADD_CUSTOM_COMMAND(
  632.   COMMENT "Generating character tables, test_char.h, for current locale"
  633.   DEPENDS gen_test_char
  634.   COMMAND ${GEN_TEST_CHAR_EXE} > ${PROJECT_BINARY_DIR}/test_char.h
  635.   OUTPUT ${PROJECT_BINARY_DIR}/test_char.h
  636. )
  637. ADD_CUSTOM_TARGET(
  638.   test_char_header ALL
  639.   DEPENDS ${PROJECT_BINARY_DIR}/test_char.h
  640. )
  641.  
  642. SET(HTTPD_MAIN_SOURCES
  643.   server/main.c
  644. )
  645.  
  646. SET(LIBHTTPD_SOURCES
  647.   ${extra_builtin_modules}
  648.   ${PROJECT_BINARY_DIR}/modules.c
  649.   modules/arch/win32/mod_win32.c
  650.   modules/core/mod_so.c
  651.   modules/http/byterange_filter.c
  652.   modules/http/chunk_filter.c
  653.   modules/http/http_core.c
  654.   modules/http/http_etag.c
  655.   modules/http/http_filters.c
  656.   modules/http/http_protocol.c
  657.   modules/http/http_request.c
  658.   os/win32/ap_regkey.c
  659.   os/win32/util_win32.c
  660.   server/buildmark.c
  661.   server/config.c
  662.   server/connection.c
  663.   server/core.c
  664.   server/core_filters.c
  665.   server/eoc_bucket.c
  666.   server/eor_bucket.c
  667.   server/error_bucket.c
  668.   server/listen.c
  669.   server/log.c
  670.   server/mpm/winnt/child.c
  671.   server/mpm/winnt/mpm_winnt.c
  672.   server/mpm/winnt/nt_eventlog.c
  673.   server/mpm/winnt/service.c
  674.   server/mpm_common.c
  675.   server/protocol.c
  676.   server/provider.c
  677.   server/request.c
  678.   server/ssl.c
  679.   server/scoreboard.c
  680.   server/util.c
  681.   server/util_cfgtree.c
  682.   server/util_cookies.c
  683.   server/util_debug.c
  684.   server/util_expr_eval.c
  685.   server/util_expr_parse.c
  686.   server/util_fcgi.c
  687.   server/util_expr_scan.c
  688.   server/util_filter.c
  689.   server/util_md5.c
  690.   server/util_mutex.c
  691.   server/util_pcre.c
  692.   server/util_regex.c
  693.   server/util_script.c
  694.   server/util_time.c
  695.   server/util_xml.c
  696.   server/vhost.c
  697. )
  698.  
  699. CONFIGURE_FILE(os/win32/win32_config_layout.h
  700.                ${PROJECT_BINARY_DIR}/ap_config_layout.h)
  701.  
  702. SET(HTTPD_INCLUDE_DIRECTORIES
  703.   ${PROJECT_BINARY_DIR}
  704.   ${EXTRA_INCLUDES}
  705.   # see discussion in cmake bug 13188 regarding oddities with relative paths
  706.   ${CMAKE_CURRENT_SOURCE_DIR}/include
  707.   ${CMAKE_CURRENT_SOURCE_DIR}/os/win32
  708.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/core
  709.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/database
  710.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/dav/main
  711.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/filters
  712.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/generators
  713.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/http2
  714.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/md
  715.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/proxy
  716.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/session
  717.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/ssl
  718.   ${CMAKE_CURRENT_SOURCE_DIR}/server
  719.   ${CMAKE_CURRENT_SOURCE_DIR}/server/mpm/winnt
  720.   ${APR_INCLUDE_DIR}
  721.   ${PCRE_INCLUDE_DIR}
  722. )
  723.  
  724. # The .h files we install from outside the main include directory
  725. # largely parallel the include directories above.
  726. SET(other_installed_h
  727.   ${PROJECT_BINARY_DIR}/ap_config_layout.h
  728.   ${CMAKE_CURRENT_SOURCE_DIR}/os/win32/os.h
  729.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/cache/mod_cache.h
  730.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/cache/cache_common.h
  731.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/core/mod_so.h
  732.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/core/mod_watchdog.h
  733.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/database/mod_dbd.h
  734.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/dav/main/mod_dav.h
  735.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/filters/mod_include.h
  736.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/filters/mod_xml2enc.h
  737.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/generators/mod_cgi.h
  738.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/generators/mod_status.h
  739.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/http2/mod_http2.h
  740.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/loggers/mod_log_config.h
  741.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/mappers/mod_rewrite.h
  742.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/proxy/mod_proxy.h
  743.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/session/mod_session.h
  744.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/ssl/mod_ssl.h
  745.   ${CMAKE_CURRENT_SOURCE_DIR}/modules/ssl/mod_ssl_openssl.h
  746. )
  747. # When mod_serf is buildable, don't forget to copy modules/proxy/mod_serf.h
  748.  
  749. INCLUDE_DIRECTORIES(${HTTPD_INCLUDE_DIRECTORIES})
  750.  
  751. SET(HTTPD_SYSTEM_LIBS
  752.   ws2_32
  753.   mswsock
  754. )
  755.  
  756. ###########   HTTPD MODULES     ############
  757. SET(LoadModules)
  758. SET(mods_built_and_loaded)
  759. SET(mods_built_but_not_loaded)
  760. SET(mods_omitted)
  761. FOREACH (mod ${MODULE_PATHS})
  762.   # Build different forms of the module name; e.g.,
  763.   #   mod_name->mod_cgi, mod_module_name->cgi_module, mod_shortname->cgi
  764.   STRING(REGEX REPLACE ".*/(mod_[^\\+]+)" "\\1"        mod_name        ${mod})
  765.   STRING(REGEX REPLACE "mod_(.*)"         "\\1_module" mod_module_name ${mod_name})
  766.   STRING(REGEX REPLACE "mod_(.*)"         "\\1"        mod_shortname   ${mod_name})
  767.  
  768.   # Is it enabled?
  769.   STRING(TOUPPER "ENABLE_${mod_shortname}" enable_mod)
  770.   SET(enable_mod_val ${${enable_mod}})
  771.  
  772.   # Is ENABLE_MODULES set to a higher value?
  773.   GET_MOD_ENABLE_RANK(${mod_name} ${enable_mod_val} this_mod_rank)
  774.   IF(this_mod_rank LESS enable_modules_rank)
  775.     # Use the value from ENABLE_MODULES
  776.     SET(enable_mod_val ${ENABLE_MODULES})
  777.   ENDIF()
  778.  
  779.   IF(NOT ${enable_mod_val} STREQUAL "O") # build of module is desired
  780.     SET(mod_requires "${mod_name}_requires")
  781.     STRING(TOUPPER ${enable_mod_val} enable_mod_val_upper)
  782.     IF(NOT "${${mod_requires}}" STREQUAL "") # module has some prerequisite
  783.       FOREACH (required ${${mod_requires}})
  784.         IF(NOT ${required}) # prerequisite doesn't exist
  785.           IF(NOT ${enable_mod_val} STREQUAL ${enable_mod_val_upper}) # lower case, so optional based on prereq
  786.             MESSAGE(STATUS "${mod_name} was requested but couldn't be built due to a missing prerequisite (${required})")
  787.             SET(enable_mod_val_upper "O") # skip due to missing prerequisite
  788.           ELSE() # must be upper case "A" or "I" (or coding error above)
  789.             MESSAGE(FATAL_ERROR "${mod_name} was requested but couldn't be built due to a missing prerequisite (${required})")
  790.           ENDIF()
  791.         ENDIF()
  792.       ENDFOREACH()
  793.     ENDIF()
  794.     # map a->A, i->I, O->O for remaining logic since prereq checking is over
  795.     SET(enable_mod_val ${enable_mod_val_upper})
  796.   ENDIF()
  797.  
  798.   IF(${enable_mod_val} STREQUAL "O")
  799.     # ignore
  800.     SET(mods_omitted ${mods_omitted} ${mod_name})
  801.   ELSE()
  802.     # Handle whether or not the LoadModule is commented out.
  803.     IF(${enable_mod_val} STREQUAL "A")
  804.       SET(LoadModules "${LoadModules}LoadModule ${mod_module_name} modules/${mod_name}.so\n")
  805.       SET(mods_built_and_loaded ${mods_built_and_loaded} ${mod_name})
  806.     ELSEIF(${enable_mod_val} STREQUAL "I")
  807.       SET(LoadModules "${LoadModules}# LoadModule ${mod_module_name} modules/${mod_name}.so\n")
  808.       SET(mods_built_but_not_loaded ${mods_built_but_not_loaded} ${mod_name})
  809.     ELSE()
  810.       MESSAGE(FATAL_ERROR "${enable_mod} must be set to \"A\", \"I\", or \"O\" instead of \"${enable_mod_val}\"")
  811.     ENDIF()
  812.  
  813.     # Handle building it.
  814.     SET(mod_main_source "${mod_name}_main_source")
  815.     SET(mod_extra_sources "${mod_name}_extra_sources")
  816.  
  817.     IF("${${mod_main_source}}" STREQUAL "")
  818.       SET(tmp_mod_main_source "${mod}.c")
  819.     ELSE()
  820.       SET(tmp_mod_main_source ${${mod_main_source}})
  821.     ENDIF()
  822.     SET(all_mod_sources ${tmp_mod_main_source} ${${mod_extra_sources}})
  823.     ADD_LIBRARY(${mod_name} SHARED ${all_mod_sources} build/win32/httpd.rc)
  824.     SET(install_modules ${install_modules} ${mod_name})
  825.     SET(install_modules_pdb ${install_modules_pdb} "$<TARGET_PDB_FILE:${mod_name}>")
  826.     IF("${${mod_name}_install_lib}")
  827.       SET(installed_mod_libs_exps
  828.           ${installed_mod_libs_exps}
  829.           "$<TARGET_LINKER_FILE:${mod_name}>"
  830.           "$<TARGET_LINKER_FILE_DIR:${mod_name}>/${mod_name}.exp"
  831.       )
  832.     ENDIF()
  833.     SET(mod_extra_libs "${mod_name}_extra_libs")
  834.     SET_TARGET_PROPERTIES(${mod_name} PROPERTIES
  835.       SUFFIX .so
  836.       LINK_FLAGS /base:@${PROJECT_BINARY_DIR}/BaseAddr.ref,${mod_name}.so
  837.     )
  838.     TARGET_LINK_LIBRARIES(${mod_name} ${${mod_extra_libs}} libhttpd ${EXTRA_LIBS} ${APR_LIBRARIES} ${HTTPD_SYSTEM_LIBS})
  839.     DEFINE_WITH_BLANKS(define_long_name "LONG_NAME" "${mod_name} for Apache HTTP Server")
  840.     SET_TARGET_PROPERTIES(${mod_name} PROPERTIES COMPILE_FLAGS "${define_long_name} -DBIN_NAME=${mod_name}.so ${EXTRA_COMPILE_FLAGS}")
  841.  
  842.     # Extra defines?
  843.     SET(mod_extra_defines "${mod_name}_extra_defines")
  844.     IF(NOT ${${mod_extra_defines}} STREQUAL "")
  845.       SET_TARGET_PROPERTIES(${mod_name} PROPERTIES COMPILE_DEFINITIONS ${${mod_extra_defines}})
  846.     ENDIF()
  847.  
  848.     # Extra includes?
  849.     SET(mod_extra_includes "${mod_name}_extra_includes")
  850.     IF(NOT "${${mod_extra_includes}}" STREQUAL "")
  851.       SET(tmp_includes ${HTTPD_INCLUDE_DIRECTORIES} ${${mod_extra_includes}})
  852.       SET_TARGET_PROPERTIES(${mod_name} PROPERTIES INCLUDE_DIRECTORIES "${tmp_includes}")
  853.       GET_PROPERTY(tmp_includes TARGET ${mod_name} PROPERTY INCLUDE_DIRECTORIES)
  854.     ENDIF()
  855.  
  856.   ENDIF()
  857. ENDFOREACH()
  858.  
  859. ###########   HTTPD LIBRARIES   ############
  860. ADD_LIBRARY(libhttpd SHARED ${LIBHTTPD_SOURCES} build/win32/httpd.rc)
  861. SET_TARGET_PROPERTIES(libhttpd PROPERTIES
  862.   LINK_FLAGS /base:@${PROJECT_BINARY_DIR}/BaseAddr.ref,libhttpd.dll
  863. )
  864. SET(install_targets ${install_targets} libhttpd)
  865. SET(install_bin_pdb ${install_bin_pdb} $<TARGET_PDB_FILE:libhttpd>)
  866. TARGET_LINK_LIBRARIES(libhttpd ${EXTRA_LIBS} ${APR_LIBRARIES} ${PCRE_LIBRARIES} ${HTTPD_SYSTEM_LIBS})
  867. DEFINE_WITH_BLANKS(define_long_name "LONG_NAME" "Apache HTTP Server Core")
  868. SET_TARGET_PROPERTIES(libhttpd PROPERTIES COMPILE_FLAGS "-DAP_DECLARE_EXPORT ${define_long_name} ${PCRE_CFLAGS} -DBIN_NAME=libhttpd.dll ${EXTRA_COMPILE_FLAGS}")
  869. ADD_DEPENDENCIES(libhttpd test_char_header)
  870.  
  871. ###########   HTTPD EXECUTABLES   ##########
  872. ADD_EXECUTABLE(httpd server/main.c build/win32/httpd.rc)
  873. SET(install_targets ${install_targets} httpd)
  874. SET(install_bin_pdb ${install_bin_pdb} $<TARGET_PDB_FILE:httpd>)
  875. DEFINE_WITH_BLANKS(define_long_name "LONG_NAME" "Apache HTTP Server")
  876. SET_TARGET_PROPERTIES(httpd PROPERTIES COMPILE_FLAGS "-DAPP_FILE ${define_long_name} -DBIN_NAME=httpd.exe -DICON_FILE=${CMAKE_SOURCE_DIR}/build/win32/apache.ico ${EXTRA_COMPILE_FLAGS}")
  877. TARGET_LINK_LIBRARIES(httpd libhttpd ${EXTRA_LIBS})
  878.  
  879. SET(standard_support
  880.   ab
  881.   htcacheclean
  882.   htdbm
  883.   htdigest
  884.   htpasswd
  885.   httxt2dbm
  886.   logresolve
  887.   rotatelogs
  888. )
  889.  
  890. SET(htdbm_extra_sources support/passwd_common.c)
  891. SET(htpasswd_extra_sources support/passwd_common.c)
  892.  
  893. FOREACH(pgm ${standard_support})
  894.   SET(extra_sources ${pgm}_extra_sources)
  895.   ADD_EXECUTABLE(${pgm} support/${pgm}.c ${${extra_sources}} build/win32/httpd.rc)
  896.   SET(install_targets ${install_targets} ${pgm})
  897.   SET(install_bin_pdb ${install_bin_pdb} $<TARGET_PDB_FILE:${pgm}>)
  898.   DEFINE_WITH_BLANKS(define_long_name "LONG_NAME" "Apache HTTP Server ${pgm} program")
  899.   SET_TARGET_PROPERTIES(${pgm} PROPERTIES COMPILE_FLAGS "-DAPP_FILE ${define_long_name} -DBIN_NAME=${pgm}.exe ${EXTRA_COMPILE_FLAGS}")
  900.   TARGET_LINK_LIBRARIES(${pgm} ${EXTRA_LIBS} ${APR_LIBRARIES})
  901. ENDFOREACH()
  902.  
  903. IF(OPENSSL_FOUND)
  904.   ADD_EXECUTABLE(abs support/ab.c build/win32/httpd.rc)
  905.   SET(install_targets ${install_targets} abs)
  906.   SET(install_bin_pdb ${install_bin_pdb} $<TARGET_PDB_FILE:abs>)
  907.   SET_TARGET_PROPERTIES(abs PROPERTIES COMPILE_DEFINITIONS HAVE_OPENSSL)
  908.   SET(tmp_includes ${HTTPD_INCLUDE_DIRECTORIES} ${OPENSSL_INCLUDE_DIR})
  909.   SET_TARGET_PROPERTIES(abs PROPERTIES INCLUDE_DIRECTORIES "${tmp_includes}")
  910.   DEFINE_WITH_BLANKS(define_long_name "LONG_NAME" "Apache HTTP Server ab/SSL program")
  911.   SET_TARGET_PROPERTIES(abs PROPERTIES COMPILE_FLAGS "-DAPP_FILE ${define_long_name} -DBIN_NAME=abs.exe ${EXTRA_COMPILE_FLAGS}")
  912.   TARGET_LINK_LIBRARIES(abs ${EXTRA_LIBS} ${APR_LIBRARIES} ${OPENSSL_LIBRARIES})
  913. ENDIF()
  914. GET_PROPERTY(tmp_includes TARGET ab PROPERTY INCLUDE_DIRECTORIES)
  915.  
  916. # getting duplicate manifest error with ApacheMonitor
  917. # ADD_EXECUTABLE(ApacheMonitor support/win32/ApacheMonitor.c support/win32/ApacheMonitor.rc)
  918. # SET(install_targets ${install_targets} ApacheMonitor)
  919. # SET(install_bin_pdb ${install_bin_pdb} $<TARGET_PDB_FILE:ApacheMonitor>)
  920. # SET_TARGET_PROPERTIES(ApacheMonitor PROPERTIES WIN32_EXECUTABLE TRUE)
  921. # SET_TARGET_PROPERTIES(ApacheMonitor PROPERTIES COMPILE_FLAGS "-DAPP_FILE -DLONG_NAME=ApacheMonitor -DBIN_NAME=ApacheMonitor.exe ${EXTRA_COMPILE_FLAGS}")
  922. # TARGET_LINK_LIBRARIES(ApacheMonitor ${EXTRA_LIBS} ${HTTPD_SYSTEM_LIBS} comctl32 wtsapi32)
  923.  
  924. ###########  CONFIGURATION FILES ###########
  925. # Set up variables used in the .conf file templates
  926. SET(LoadModule          "${LoadModules}")
  927. SET(Port                "80" CACHE STRING "http port to listen on")
  928. SET(SSLPort             "443" CACHE STRING "https port to listen on")
  929. SET(ServerRoot          "${CMAKE_INSTALL_PREFIX}")
  930. SET(exp_cgidir          "${CMAKE_INSTALL_PREFIX}/cgi-bin")
  931. SET(exp_htdocsdir       "${CMAKE_INSTALL_PREFIX}/htdocs")
  932. SET(exp_iconsdir        "${CMAKE_INSTALL_PREFIX}/icons")
  933. SET(exp_errordir        "${CMAKE_INSTALL_PREFIX}/error")
  934. SET(exp_manualdir       "${CMAKE_INSTALL_PREFIX}/manual")
  935. SET(rel_logfiledir      "logs")
  936. SET(rel_runtimedir      "logs")
  937. SET(rel_sysconfdir      "conf")
  938. FILE(GLOB_RECURSE conffiles RELATIVE ${CMAKE_SOURCE_DIR}/docs/conf "docs/conf/*")
  939. FOREACH(template ${conffiles})
  940.   STRING(REPLACE ".conf.in" ".conf" conf ${template})
  941.   FILE(READ "docs/conf/${template}" template_text)
  942.     IF(template MATCHES ".conf.in$")
  943.       # substitute @var@/@@var@@ in .conf.in
  944.       STRING(REPLACE "@@" "@" template_text ${template_text})
  945.       STRING(CONFIGURE "${template_text}" template_text @ONLY)
  946.     ENDIF()
  947.   FILE(WRITE ${CMAKE_BINARY_DIR}/conf/original/${conf} "${template_text}")
  948.   FILE(WRITE ${CMAKE_BINARY_DIR}/conf/${conf} "${template_text}")
  949. ENDFOREACH()
  950.  
  951. ###########   INSTALLATION   ###########
  952. INSTALL(TARGETS ${install_targets}
  953.         RUNTIME DESTINATION bin
  954.         LIBRARY DESTINATION lib
  955.         ARCHIVE DESTINATION lib
  956.        )
  957. INSTALL(TARGETS ${install_modules}
  958.         RUNTIME DESTINATION modules
  959.        )
  960.  
  961. IF(INSTALL_PDB)
  962.   INSTALL(FILES ${install_bin_pdb}
  963.           DESTINATION bin
  964.           CONFIGURATIONS RelWithDebInfo Debug)
  965.  
  966.   INSTALL(FILES ${install_modules_pdb}
  967.           DESTINATION modules
  968.           CONFIGURATIONS RelWithDebInfo Debug)
  969. ENDIF()
  970.  
  971. INSTALL(DIRECTORY include/ DESTINATION include
  972.     FILES_MATCHING PATTERN "*.h"
  973. )
  974. INSTALL(FILES ${other_installed_h} DESTINATION include)
  975. INSTALL(FILES ${installed_mod_libs_exps} DESTINATION lib)
  976. INSTALL(FILES "$<TARGET_LINKER_FILE_DIR:libhttpd>/libhttpd.exp" DESTINATION LIB)
  977.  
  978. IF(INSTALL_MANUAL) # Silly?  This takes a while, and a dev doesn't need it.
  979.   INSTALL(DIRECTORY docs/manual/ DESTINATION manual)
  980. ENDIF()
  981.  
  982. INSTALL(DIRECTORY DESTINATION logs)
  983. INSTALL(DIRECTORY DESTINATION cgi-bin)
  984.  
  985. INSTALL(CODE "EXECUTE_PROCESS(COMMAND perl \"${CMAKE_CURRENT_SOURCE_DIR}/build/cpR_noreplace.pl\" \"${CMAKE_CURRENT_SOURCE_DIR}/docs/error\" \"${CMAKE_INSTALL_PREFIX}/error\" ifdestmissing)")
  986.  
  987. INSTALL(CODE "EXECUTE_PROCESS(COMMAND perl \"${CMAKE_CURRENT_SOURCE_DIR}/build/cpR_noreplace.pl\" \"${CMAKE_CURRENT_SOURCE_DIR}/docs/docroot\" \"${CMAKE_INSTALL_PREFIX}/htdocs\" ifdestmissing)")
  988.  
  989. INSTALL(CODE "EXECUTE_PROCESS(COMMAND perl \"${CMAKE_CURRENT_SOURCE_DIR}/build/cpR_noreplace.pl\" \"${CMAKE_CURRENT_SOURCE_DIR}/docs/icons\" \"${CMAKE_INSTALL_PREFIX}/icons\" ifdestmissing)")
  990.  
  991. # Copy generated .conf files from the build directory to the install,
  992. # without overwriting stuff already there.
  993. INSTALL(CODE "EXECUTE_PROCESS(COMMAND perl \"${CMAKE_CURRENT_SOURCE_DIR}/build/cpR_noreplace.pl\" \"${CMAKE_BINARY_DIR}/conf\" \"${CMAKE_INSTALL_PREFIX}/conf\")")
  994. # But conf/original is supposed to be overwritten.
  995. # Note: FILE(TO_NATIVE_PATH ...) leaves the backslashes unescaped, which
  996. #       generates warnings.  Just do it manually since this build only supports
  997. #       Windows anyway.
  998. STRING(REPLACE "/" "\\\\" native_src ${CMAKE_BINARY_DIR}/conf/original)
  999. STRING(REPLACE "/" "\\\\" native_dest ${CMAKE_INSTALL_PREFIX}/conf/original)
  1000. INSTALL(CODE "EXECUTE_PROCESS(COMMAND xcopy \"${native_src}\" \"${native_dest}\" /Q /S /Y)")
  1001.  
  1002. STRING(TOUPPER "${CMAKE_BUILD_TYPE}" buildtype)
  1003. MESSAGE(STATUS "")
  1004. MESSAGE(STATUS "")
  1005. MESSAGE(STATUS "Apache httpd configuration summary:")
  1006. MESSAGE(STATUS "")
  1007. MESSAGE(STATUS "  Build type ...................... : ${CMAKE_BUILD_TYPE}")
  1008. MESSAGE(STATUS "  Install .pdb (if available)...... : ${INSTALL_PDB}")
  1009. MESSAGE(STATUS "  Install manual .................. : ${INSTALL_MANUAL}")
  1010. MESSAGE(STATUS "  Install prefix .................. : ${CMAKE_INSTALL_PREFIX}")
  1011. MESSAGE(STATUS "  C compiler ...................... : ${CMAKE_C_COMPILER}")
  1012. MESSAGE(STATUS "  APR include directory ........... : ${APR_INCLUDE_DIR}")
  1013. MESSAGE(STATUS "  APR libraries ................... : ${APR_LIBRARIES}")
  1014. MESSAGE(STATUS "  OpenSSL include directory ....... : ${OPENSSL_INCLUDE_DIR}")
  1015. MESSAGE(STATUS "  OpenSSL libraries ............... : ${OPENSSL_LIBRARIES}")
  1016. MESSAGE(STATUS "  PCRE include directory .......... : ${PCRE_INCLUDE_DIR}")
  1017. MESSAGE(STATUS "  PCRE libraries .................. : ${PCRE_LIBRARIES}")
  1018. MESSAGE(STATUS "  libxml2 iconv prereq include dir. : ${LIBXML2_ICONV_INCLUDE_DIR}")
  1019. MESSAGE(STATUS "  libxml2 iconv prereq libraries .. : ${LIBXML2_ICONV_LIBRARIES}")
  1020. MESSAGE(STATUS "  Brotli include directory......... : ${BROTLI_INCLUDE_DIR}")
  1021. MESSAGE(STATUS "  Brotli libraries ................ : ${BROTLI_LIBRARIES}")
  1022. MESSAGE(STATUS "  Curl include directory........... : ${CURL_INCLUDE_DIR}")
  1023. MESSAGE(STATUS "  Curl libraries .................. : ${CURL_LIBRARIES}")
  1024. MESSAGE(STATUS "  Jansson include directory ....... : ${JANSSON_INCLUDE_DIR}")
  1025. MESSAGE(STATUS "  Jansson libraries ............... : ${JANSSON_LIBRARIES}")
  1026. MESSAGE(STATUS "  Extra include directories ....... : ${EXTRA_INCLUDES}")
  1027. MESSAGE(STATUS "  Extra compile flags ............. : ${EXTRA_COMPILE_FLAGS}")
  1028. MESSAGE(STATUS "  Extra libraries ................. : ${EXTRA_LIBS}")
  1029.  
  1030. MESSAGE(STATUS "  Modules built and loaded:")
  1031. FOREACH(mod ${mods_built_and_loaded})
  1032.   MESSAGE(STATUS "    ${mod}")
  1033. ENDFOREACH()
  1034.  
  1035. MESSAGE(STATUS "  Modules built but not loaded:")
  1036. FOREACH(mod ${mods_built_but_not_loaded})
  1037.   MESSAGE(STATUS "    ${mod}")
  1038. ENDFOREACH()
  1039.  
  1040. MESSAGE(STATUS "  Modules not built:")
  1041. FOREACH(mod ${mods_omitted})
  1042.   MESSAGE(STATUS "    ${mod}")
  1043. ENDFOREACH()
  1044.  
Advertisement
Add Comment
Please, Sign In to add comment