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