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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 # Read README.cmake before using this.
20 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
26 # See what version we're building. Just look at AP_SERVER_MINORVERSION_NUMBER
27 SET(minorversion_regex "^#define AP_SERVER_MINORVERSION_NUMBER ([0-9]+)$")
28 FILE(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/include/ap_release.h minorversion REGEX ${minorversion_regex})
29 STRING(REGEX REPLACE ${minorversion_regex} "\\1" minorversion ${minorversion})
31 # Options for support libraries not supported by cmake-bundled FindFOO
32 SET(APR_INCLUDE_DIR "C:/APR/include" CACHE STRING "Directory with APR[-Util] include files")
33 SET(APR_LIBRARIES "C:/APR/lib/libapr-1.lib;C:/APR/lib/libaprutil-1.lib"
34 CACHE STRING "APR libraries to link with")
35 SET(PCRE_INCLUDE_DIR "C:/PCRE/include" CACHE STRING "Directory with PCRE include files")
36 SET(PCRE_LIBRARIES "C:/PCRE/lib/pcred.lib" CACHE STRING "PCRE libraries to link with")
37 SET(LIBXML2_ICONV_INCLUDE_DIR "" CACHE STRING "Directory with iconv include files for libxml2")
38 SET(LIBXML2_ICONV_LIBRARIES "" CACHE STRING "iconv libraries to link with for libxml2")
39 # end support library configuration
42 SET(WITH_MODULES "" CACHE STRING "comma-separated paths to single-file modules to statically link into the server")
44 # Options for each available module
45 # "A" ("A"ctive) means installed and active in default .conf, fail if can't be built
46 # "I" ("I"nactive) means installed and inactive (LoadModule commented out) in default .conf, fail if can't be built
47 # "O" ("O"mit) means not installed, no LoadModule
48 # "a" - like "A", but ignore with a warning if any prereqs aren't available
49 # "i" - like "I", but ignore with a warning if any prereqs aren't available
52 "modules/aaa/mod_access_compat.c+A+mod_access compatibility"
53 "modules/aaa/mod_allowmethods.c+I+restrict allowed HTTP methods"
54 "modules/aaa/mod_auth_basic.c+A+basic authentication"
55 "modules/aaa/mod_auth_digest.c+I+RFC2617 Digest authentication"
56 "modules/aaa/mod_auth_form.c+I+form authentication"
57 "modules/aaa/mod_authn_anon.c+A+anonymous user authentication control"
58 "modules/aaa/mod_authn_core.c+A+core authentication module"
59 "modules/aaa/mod_authn_dbd.c+I+SQL-based authentication control"
60 "modules/aaa/mod_authn_dbm.c+I+DBM-based authentication control"
61 "modules/aaa/mod_authn_file.c+A+file-based authentication control"
62 "modules/aaa/mod_authn_socache.c+A+Cached authentication control"
63 "modules/aaa/mod_authnz_ldap.c+O+LDAP based authentication"
64 "modules/aaa/mod_authz_core.c+A+core authorization provider vector module"
65 "modules/aaa/mod_authz_dbd.c+I+SQL based authorization and Login/Session support"
66 "modules/aaa/mod_authz_dbm.c+I+DBM-based authorization control"
67 "modules/aaa/mod_authz_groupfile.c+A+'require group' authorization control"
68 "modules/aaa/mod_authz_host.c+A+host-based authorization control"
69 "modules/aaa/mod_authz_owner.c+I+'require file-owner' authorization control"
70 "modules/aaa/mod_authz_user.c+I+'require user' authorization control"
71 "modules/arch/win32/mod_isapi.c+I+isapi extension support"
72 "modules/cache/mod_cache.c+I+dynamic file caching. At least one storage management module (e.g. mod_cache_disk) is also necessary."
73 "modules/cache/mod_cache_disk.c+I+disk caching module"
74 "modules/cache/mod_cache_socache.c+A+shared object caching module"
75 "modules/cache/mod_file_cache.c+A+File cache"
76 "modules/cache/mod_socache_dbm.c+I+dbm small object cache provider"
77 "modules/cache/mod_socache_dc.c+O+distcache small object cache provider"
78 "modules/cache/mod_socache_memcache.c+I+memcache small object cache provider"
79 "modules/cache/mod_socache_shmcb.c+A+ shmcb small object cache provider"
80 "modules/cluster/mod_heartbeat.c+I+Generates Heartbeats"
81 "modules/cluster/mod_heartmonitor.c+I+Collects Heartbeats"
82 "modules/core/mod_macro.c+I+Define and use macros in configuration files"
83 "modules/core/mod_watchdog.c+I+Watchdog module"
84 "modules/database/mod_dbd.c+I+Apache DBD Framework"
85 "modules/dav/fs/mod_dav_fs.c+I+DAV provider for the filesystem."
86 "modules/dav/lock/mod_dav_lock.c+I+DAV provider for generic locking"
87 "modules/dav/main/mod_dav.c+I+WebDAV protocol handling."
88 "modules/debugging/mod_bucketeer.c+I+buckets manipulation filter. Useful only for developers and testing purposes."
89 "modules/debugging/mod_dumpio.c+I+I/O dump filter"
90 "modules/echo/mod_echo.c+I+ECHO server"
91 "modules/examples/mod_case_filter.c+I+Example uppercase conversion filter"
92 "modules/examples/mod_case_filter_in.c+I+Example uppercase conversion input filter"
93 "modules/examples/mod_example_hooks.c+I+Example hook callback handler module"
94 "modules/examples/mod_example_ipc.c+I+Example of shared memory and mutex usage"
95 "modules/filters/mod_buffer.c+A+Filter Buffering"
96 "modules/filters/mod_charset_lite.c+O+character set translation"
97 "modules/filters/mod_data.c+I+RFC2397 data encoder"
98 "modules/filters/mod_deflate.c+i+Deflate transfer encoding support"
99 "modules/filters/mod_ext_filter.c+I+external filter module"
100 "modules/filters/mod_filter.c+A+Smart Filtering"
101 "modules/filters/mod_include.c+A+Server Side Includes"
102 "modules/filters/mod_proxy_html.c+i+Fix HTML Links in a Reverse Proxy"
103 "modules/filters/mod_ratelimit.c+I+Output Bandwidth Limiting"
104 "modules/filters/mod_reflector.c+I+Reflect request through the output filter stack"
105 "modules/filters/mod_reqtimeout.c+A+Limit time waiting for request from client"
106 "modules/filters/mod_request.c+I+Request Body Filtering"
107 "modules/filters/mod_sed.c+I+filter request and/or response bodies through sed"
108 "modules/filters/mod_substitute.c+I+response content rewrite-like filtering"
109 "modules/filters/mod_xml2enc.c+i+i18n support for markup filters"
110 "modules/generators/mod_asis.c+A+as-is filetypes"
111 "modules/generators/mod_autoindex.c+A+directory listing"
112 "modules/generators/mod_cgi.c+A+CGI scripts"
113 "modules/generators/mod_info.c+A+server information"
114 "modules/generators/mod_status.c+A+process/thread monitoring"
115 "modules/http/mod_mime.c+A+mapping of file-extension to MIME. Disabling this module is normally not recommended."
116 "modules/ldap/mod_ldap.c+O+LDAP caching and connection pooling services"
117 "modules/loggers/mod_log_config.c+A+logging configuration. You won't be able to log requests to the server without this module."
118 "modules/loggers/mod_log_debug.c+A+configurable debug logging"
119 "modules/loggers/mod_log_forensic.c+I+forensic logging"
120 "modules/loggers/mod_logio.c+I+input and output logging"
121 "modules/lua/mod_lua.c+O+Apache Lua Framework"
122 "modules/mappers/mod_actions.c+A+Action triggering on requests"
123 "modules/mappers/mod_alias.c+A+mapping of requests to different filesystem parts"
124 "modules/mappers/mod_dir.c+A+directory request handling"
125 "modules/mappers/mod_imagemap.c+I+server-side imagemaps"
126 "modules/mappers/mod_negotiation.c+A+content negotiation"
127 "modules/mappers/mod_rewrite.c+A+rule based URL manipulation"
128 "modules/mappers/mod_speling.c+A+correct common URL misspellings"
129 "modules/mappers/mod_userdir.c+A+mapping of requests to user-specific directories"
130 "modules/mappers/mod_vhost_alias.c+I+mass virtual hosting module"
131 "modules/metadata/mod_cern_meta.c+I+CERN-type meta files"
132 "modules/metadata/mod_env.c+A+clearing/setting of ENV vars"
133 "modules/metadata/mod_expires.c+A+Expires header control"
134 "modules/metadata/mod_headers.c+A+HTTP header control"
135 "modules/metadata/mod_ident.c+I+RFC 1413 identity check"
136 "modules/metadata/mod_mime_magic.c+I+automagically determining MIME type"
137 "modules/metadata/mod_remoteip.c+A+translate header contents to an apparent client remote_ip"
138 "modules/metadata/mod_setenvif.c+A+basing ENV vars on headers"
139 "modules/metadata/mod_unique_id.c+A+per-request unique ids"
140 "modules/metadata/mod_usertrack.c+A+user-session tracking"
141 "modules/metadata/mod_version.c+A+determining httpd version in config files"
142 "modules/proxy/balancers/mod_lbmethod_bybusyness.c+A+Apache proxy Load balancing by busyness"
143 "modules/proxy/balancers/mod_lbmethod_byrequests.c+A+Apache proxy Load balancing by request counting"
144 "modules/proxy/balancers/mod_lbmethod_bytraffic.c+A+Apache proxy Load balancing by traffic counting"
145 "modules/proxy/balancers/mod_lbmethod_heartbeat.c+A+Apache proxy Load balancing from Heartbeats"
146 "modules/proxy/mod_proxy_ajp.c+I+Apache proxy AJP module. Requires and is enabled by --enable-proxy."
147 "modules/proxy/mod_proxy_balancer.c+A+Apache proxy BALANCER module. Requires and is enabled by --enable-proxy."
148 "modules/proxy/mod_proxy.c+A+Apache proxy module"
149 "modules/proxy/mod_proxy_connect.c+I+Apache proxy CONNECT module. Requires and is enabled by --enable-proxy."
150 "modules/proxy/mod_proxy_express.c+I+mass reverse-proxy module. Requires --enable-proxy."
151 "modules/proxy/mod_proxy_fcgi.c+I+Apache proxy FastCGI module. Requires and is enabled by --enable-proxy."
152 "modules/proxy/mod_proxy_ftp.c+I+Apache proxy FTP module. Requires and is enabled by --enable-proxy."
153 "modules/proxy/mod_proxy_http.c+A+Apache proxy HTTP module. Requires and is enabled by --enable-proxy."
154 "modules/proxy/mod_proxy_scgi.c+I+Apache proxy SCGI module. Requires and is enabled by --enable-proxy."
155 "modules/proxy/mod_proxy_wstunnel.c+I+Apache proxy Websocket Tunnel module. Requires and is enabled by --enable-proxy."
156 "modules/session/mod_session.c+I+session module"
157 "modules/session/mod_session_cookie.c+I+session cookie module"
158 "modules/session/mod_session_crypto.c+O+session crypto module"
159 "modules/session/mod_session_dbd.c+I+session dbd module"
160 "modules/slotmem/mod_slotmem_plain.c+A+slotmem provider that uses plain memory"
161 "modules/slotmem/mod_slotmem_shm.c+A+slotmem provider that uses shared memory"
162 "modules/ssl/mod_ssl.c+i+SSL/TLS support"
163 "modules/test/mod_dialup.c+I+rate limits static files to dialup modem speeds"
164 "modules/test/mod_optional_fn_export.c+I+example optional function exporter"
165 "modules/test/mod_optional_fn_import.c+I+example optional function importer"
166 "modules/test/mod_optional_hook_export.c+I+example optional hook exporter"
167 "modules/test/mod_optional_hook_import.c+I+example optional hook importer"
170 IF(NOT ${minorversion} STREQUAL "4")
171 # more modules in trunk
174 "modules/aaa/mod_allowhandlers.c+I+restrict allowed handlers"
175 "modules/aaa/mod_authnz_fcgi.c+I+FastCGI authorizer-based authentication and authorization"
176 "modules/debugging/mod_firehose.c+O+Firehose dump filter"
177 "modules/proxy/mod_serf.c+O+Reverse proxy module using Serf"
178 "modules/test/mod_policy.c+I+HTTP protocol compliance filters"
182 # Define extra definitions, sources, headers, etc. required by some modules.
183 # This could be included in the master list of modules above, though it
184 # certainly would get a lot more unreadable.
185 SET(mod_authz_dbd_extra_defines AUTHZ_DBD_DECLARE_EXPORT)
186 SET(mod_cache_extra_defines CACHE_DECLARE_EXPORT)
187 SET(mod_cache_extra_sources
188 modules/cache/cache_storage.c modules/cache/cache_util.c
190 SET(mod_cache_disk_extra_libs mod_cache)
191 SET(mod_cache_socache_extra_libs mod_cache)
192 SET(mod_dav_extra_defines DAV_DECLARE_EXPORT)
193 SET(mod_dav_extra_sources
194 modules/dav/main/liveprop.c modules/dav/main/props.c
195 modules/dav/main/std_liveprop.c modules/dav/main/providers.c
196 modules/dav/main/util.c modules/dav/main/util_lock.c
198 SET(mod_dav_fs_extra_sources
199 modules/dav/fs/dbm.c modules/dav/fs/lock.c
200 modules/dav/fs/repos.c
202 SET(mod_dav_fs_extra_libs mod_dav)
203 SET(mod_dav_lock_extra_sources modules/dav/lock/locks.c)
204 SET(mod_dav_lock_extra_libs mod_dav)
205 SET(mod_dbd_extra_defines DBD_DECLARE_EXPORT)
206 SET(mod_deflate_requires ZLIB_FOUND)
208 SET(mod_deflate_extra_includes ${ZLIB_INCLUDE_DIR})
209 SET(mod_deflate_extra_libs ${ZLIB_LIBRARIES})
211 SET(mod_heartbeat_extra_libs mod_watchdog)
212 SET(mod_optional_hook_export_extra_defines AP_DECLARE_EXPORT) # bogus reuse of core API prefix
213 SET(mod_proxy_extra_defines PROXY_DECLARE_EXPORT)
214 SET(mod_proxy_extra_sources modules/proxy/proxy_util.c)
215 SET(mod_proxy_ajp_extra_sources
216 modules/proxy/ajp_header.c modules/proxy/ajp_link.c
217 modules/proxy/ajp_msg.c modules/proxy/ajp_utils.c
219 SET(mod_proxy_ajp_extra_libs mod_proxy)
220 SET(mod_proxy_balancer_extra_libs mod_proxy)
221 SET(mod_proxy_connect_extra_libs mod_proxy)
222 SET(mod_proxy_express_extra_libs mod_proxy)
223 SET(mod_proxy_fcgi_extra_libs mod_proxy)
224 SET(mod_proxy_ftp_extra_libs mod_proxy)
225 SET(mod_proxy_http_extra_libs mod_proxy)
226 SET(mod_proxy_html_requires LIBXML2_FOUND)
228 SET(mod_proxy_html_extra_includes "${LIBXML2_INCLUDE_DIR};${LIBXML2_ICONV_INCLUDE_DIR}")
229 SET(mod_proxy_html_extra_libs "${LIBXML2_LIBRARIES};${LIBXML2_ICONV_LIBRARIES}")
231 SET(mod_proxy_scgi_extra_libs mod_proxy)
232 SET(mod_proxy_wstunnel_extra_libs mod_proxy)
233 SET(mod_ratelimit_extra_defines AP_RL_DECLARE_EXPORT)
234 SET(mod_sed_extra_sources
235 modules/filters/regexp.c modules/filters/sed0.c
236 modules/filters/sed1.c
238 SET(mod_session_extra_defines SESSION_DECLARE_EXPORT)
239 SET(mod_session_cookie_extra_libs mod_session)
240 SET(mod_session_dbd_extra_libs mod_session)
241 SET(mod_ssl_requires OPENSSL_FOUND)
243 SET(mod_ssl_extra_includes ${OPENSSL_INCLUDE_DIR})
244 SET(mod_ssl_extra_libs ${OPENSSL_LIBRARIES})
246 SET(mod_ssl_extra_sources
247 modules/ssl/ssl_engine_config.c modules/ssl/ssl_engine_dh.c
248 modules/ssl/ssl_engine_init.c modules/ssl/ssl_engine_io.c
249 modules/ssl/ssl_engine_kernel.c modules/ssl/ssl_engine_log.c
250 modules/ssl/ssl_engine_mutex.c modules/ssl/ssl_engine_ocsp.c
251 modules/ssl/ssl_engine_pphrase.c modules/ssl/ssl_engine_rand.c
252 modules/ssl/ssl_engine_vars.c modules/ssl/ssl_scache.c
253 modules/ssl/ssl_util.c modules/ssl/ssl_util_ocsp.c
254 modules/ssl/ssl_util_ssl.c modules/ssl/ssl_util_stapling.c
256 SET(mod_status_extra_defines STATUS_DECLARE_EXPORT)
257 SET(mod_xml2enc_requires LIBXML2_FOUND)
259 SET(mod_xml2enc_extra_includes "${LIBXML2_INCLUDE_DIR};${LIBXML2_ICONV_INCLUDE_DIR}")
260 SET(mod_xml2enc_extra_libs "${LIBXML2_LIBRARIES};${LIBXML2_ICONV_LIBRARIES}")
262 SET(mod_watchdog_extra_defines AP_WD_DECLARE_EXPORT)
266 SET(moduleselections)
267 FOREACH (modinfo ${MODULE_LIST})
268 STRING(REGEX REPLACE "([^+]*)\\+([^+]*)\\+([^+]*)" "\\1;\\2;\\3" modinfolist ${modinfo})
269 LIST(LENGTH modinfolist modinfolen)
270 SET(primarysourcefile)
273 FOREACH(i ${modinfolist})
274 IF("${primarysourcefile}" STREQUAL "")
275 SET(primarysourcefile ${i})
276 ELSEIF("${defaultenable}" STREQUAL "")
277 SET(defaultenable ${i})
278 ELSEIF("${helptext}" STREQUAL "")
281 MESSAGE(FATAL_ERROR "Unexpected field or plus sign in >${modinfo}<")
285 # MESSAGE(" primary source file: ${primarysourcefile}")
286 # MESSAGE("enablement by default: ${defaultenable}")
287 # MESSAGE(" help text: ${helptext}")
289 STRING(REGEX MATCH "[^/]+\\.c" mod_basename ${primarysourcefile})
290 STRING(REGEX MATCH "[^.]+" mod_name ${mod_basename})
292 STRING(TOUPPER "ENABLE_${mod_name}" mod_option_name)
294 SET(${mod_option_name} ${defaultenable} CACHE STRING ${helptext})
295 SET(MODULE_SRCS "${MODULE_SRCS};${primarysourcefile}")
296 SET(moduleselections "${moduleselections};${mod_option_name}")
301 SET(install_modules) # special handling vs. other installed targets
302 SET(builtin_module_shortnames "win32 mpm_winnt http so") # core added automatically
303 SET(extra_builtin_modules) # the ones specified with -DWITH_MODULES=
305 IF(WITH_MODULES) # modules statically linked with the server
306 STRING(REPLACE "," ";" WITH_MODULE_LIST ${WITH_MODULES})
307 FOREACH(static_mod ${WITH_MODULE_LIST})
308 STRING(REGEX MATCH "[^/]+\\.c" mod_basename ${static_mod})
309 STRING(REGEX REPLACE "^mod_(.*)\\.c" "\\1" mod_module_name ${mod_basename})
310 SET(builtin_module_shortnames "${builtin_module_shortnames} ${mod_module_name}")
311 CONFIGURE_FILE(${static_mod} ${PROJECT_BINARY_DIR}/ COPYONLY)
312 SET(extra_builtin_modules ${extra_builtin_modules} ${PROJECT_BINARY_DIR}/${mod_basename})
314 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)
316 MESSAGE(FATAL_ERROR "build-modules-c.awk failed (${rv})")
319 # no extra built-in modules; use the default modules.c to avoid the awk prereq
320 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/os/win32/modules.c ${PROJECT_BINARY_DIR}/ COPYONLY)
323 ADD_EXECUTABLE(gen_test_char server/gen_test_char.c)
324 GET_TARGET_PROPERTY(GEN_TEST_CHAR_EXE gen_test_char LOCATION)
326 COMMENT "Generating character tables, test_char.h, for current locale"
327 DEPENDS gen_test_char
328 COMMAND ${GEN_TEST_CHAR_EXE} > ${PROJECT_BINARY_DIR}/test_char.h
329 OUTPUT ${PROJECT_BINARY_DIR}/test_char.h
333 DEPENDS ${PROJECT_BINARY_DIR}/test_char.h
336 SET(HTTPD_MAIN_SOURCES
341 ${extra_builtin_modules}
342 ${PROJECT_BINARY_DIR}/modules.c
343 modules/arch/win32/mod_win32.c
344 modules/core/mod_so.c
345 modules/http/byterange_filter.c
346 modules/http/chunk_filter.c
347 modules/http/http_core.c
348 modules/http/http_etag.c
349 modules/http/http_filters.c
350 modules/http/http_protocol.c
351 modules/http/http_request.c
353 os/win32/util_win32.c
358 server/core_filters.c
361 server/error_bucket.c
364 server/mpm/winnt/child.c
365 server/mpm/winnt/mpm_winnt.c
366 server/mpm/winnt/nt_eventlog.c
367 server/mpm/winnt/service.c
374 server/util_cfgtree.c
375 server/util_cookies.c
376 server/util_expr_eval.c
377 server/util_expr_parse.c
378 server/util_expr_scan.c
390 IF(NOT ${minorversion} STREQUAL "4")
391 # more libhttpd sources in trunk
398 CONFIGURE_FILE(os/win32/win32_config_layout.h
399 ${PROJECT_BINARY_DIR}/ap_config_layout.h)
401 SET(HTTPD_INCLUDE_DIRECTORIES
402 ${PROJECT_BINARY_DIR}
403 # see discussion in cmake bug 13188 regarding oddities with relative paths
404 ${CMAKE_CURRENT_SOURCE_DIR}/include
405 ${CMAKE_CURRENT_SOURCE_DIR}/os/win32
406 ${CMAKE_CURRENT_SOURCE_DIR}/modules/core
407 ${CMAKE_CURRENT_SOURCE_DIR}/modules/database
408 ${CMAKE_CURRENT_SOURCE_DIR}/modules/dav/main
409 ${CMAKE_CURRENT_SOURCE_DIR}/modules/filters
410 ${CMAKE_CURRENT_SOURCE_DIR}/modules/generators
411 ${CMAKE_CURRENT_SOURCE_DIR}/modules/proxy
412 ${CMAKE_CURRENT_SOURCE_DIR}/modules/session
413 ${CMAKE_CURRENT_SOURCE_DIR}/modules/ssl
414 ${CMAKE_CURRENT_SOURCE_DIR}/server
416 ${APR_PRIVATE_INCLUDE_DIRS}
420 INCLUDE_DIRECTORIES(${HTTPD_INCLUDE_DIRECTORIES})
422 SET(HTTPD_SYSTEM_LIBS
427 ########### HTTPD MODULES ############
429 FOREACH (mod ${MODULE_SRCS})
430 # Build different forms of the module name; e.g.,
431 # mod_short_name->mod_cgi.c, mod_name->mod_cgi, mod_module_name->cgi_module
432 STRING(REGEX MATCH "[^/]+\\.c" mod_basename ${mod})
433 STRING(REGEX MATCH "[^.]+" mod_name ${mod_basename})
434 STRING(REGEX REPLACE "^mod_(.*)" "\\1_module" mod_module_name ${mod_name})
437 STRING(TOUPPER "ENABLE_${mod_name}" enable_mod)
438 SET(enable_mod_val ${${enable_mod}})
440 IF(NOT ${enable_mod_val} STREQUAL "O") # build of module is desired
441 SET(mod_requires "${mod_name}_requires")
442 STRING(TOUPPER ${enable_mod_val} enable_mod_val_upper)
443 IF(NOT ${${mod_requires}} STREQUAL "") # module has some prerequisite
444 IF(NOT ${${mod_requires}}) # prerequisite doesn't exist
445 IF(NOT ${enable_mod_val} STREQUAL ${enable_mod_val_upper}) # lower case, so optional based on prereq
446 MESSAGE(STATUS "${mod_name} was requested but couldn't be built due to a missing prerequisite (${${mod_requires}})")
447 SET(enable_mod_val_upper "O") # skip due to missing prerequisite
448 ELSE() # must be upper case "A" or "I" (or coding error above)
449 MESSAGE(FATAL_ERROR "${mod_name} was requested but couldn't be built due to a missing prerequisite (${${mod_requires}})")
453 # map a->A, i->I, O->O for remaining logic since prereq checking is over
454 SET(enable_mod_val ${enable_mod_val_upper})
457 IF(${enable_mod_val} STREQUAL "O")
460 # Handle whether or not the LoadModule is commented out.
461 IF(${enable_mod_val} STREQUAL "A")
462 SET(LoadModules "${LoadModules}LoadModule ${mod_module_name} modules/${mod_name}.so\n")
463 ELSEIF(${enable_mod_val} STREQUAL "I")
464 SET(LoadModules "${LoadModules}# LoadModule ${mod_module_name} modules/${mod_name}.so\n")
466 MESSAGE(FATAL_ERROR "${enable_mod} must be set to \"A\", \"I\", or \"O\" instead of \"${enable_mod_val}\"")
469 # Handle building it.
470 SET(mod_extra_sources "${mod_name}_extra_sources")
471 SET(all_mod_sources ${mod} ${${mod_extra_sources}})
472 ADD_LIBRARY(${mod_name} SHARED ${all_mod_sources})
473 SET(install_modules ${install_modules} ${mod_name})
474 SET(mod_extra_libs "${mod_name}_extra_libs")
475 SET_TARGET_PROPERTIES(${mod_name} PROPERTIES SUFFIX .so)
476 TARGET_LINK_LIBRARIES(${mod_name} ${${mod_extra_libs}} libhttpd ${APR_LIBRARIES} ${HTTPD_SYSTEM_LIBS})
479 SET(mod_extra_defines "${mod_name}_extra_defines")
480 IF(NOT ${${mod_extra_defines}} STREQUAL "")
481 SET_TARGET_PROPERTIES(${mod_name} PROPERTIES COMPILE_DEFINITIONS ${${mod_extra_defines}})
485 SET(mod_extra_includes "${mod_name}_extra_includes")
486 IF(NOT "${${mod_extra_includes}}" STREQUAL "")
487 SET(tmp_includes ${${mod_extra_includes}} ${HTTPD_INCLUDE_DIRECTORIES})
488 SET_TARGET_PROPERTIES(${mod_name} PROPERTIES INCLUDE_DIRECTORIES "${tmp_includes}")
489 GET_PROPERTY(tmp_includes TARGET ${mod_name} PROPERTY INCLUDE_DIRECTORIES)
495 ########### HTTPD LIBRARIES ############
496 ADD_LIBRARY(libhttpd SHARED ${LIBHTTPD_SOURCES})
497 SET(install_targets ${install_targets} libhttpd)
498 TARGET_LINK_LIBRARIES(libhttpd ${APR_LIBRARIES} ${PCRE_LIBRARIES} ${HTTPD_SYSTEM_LIBS})
499 SET_TARGET_PROPERTIES(libhttpd PROPERTIES COMPILE_FLAGS -DAP_DECLARE_EXPORT)
500 ADD_DEPENDENCIES(libhttpd test_char_header)
502 ########### HTTPD EXECUTABLES ##########
503 ADD_EXECUTABLE(httpd server/main.c build/win32/httpd.rc)
504 SET(install_targets ${install_targets} httpd)
505 TARGET_LINK_LIBRARIES(httpd libhttpd)
507 ADD_EXECUTABLE(ab support/ab.c)
508 SET(install_targets ${install_targets} ab)
510 SET_TARGET_PROPERTIES(ab PROPERTIES COMPILE_DEFINITIONS HAVE_OPENSSL)
511 SET(tmp_includes ${HTTPD_INCLUDE_DIRECTORIES} ${OPENSSL_INCLUDE_DIR})
512 SET_TARGET_PROPERTIES(ab PROPERTIES INCLUDE_DIRECTORIES "${tmp_includes}")
513 TARGET_LINK_LIBRARIES(ab ${APR_LIBRARIES} ${OPENSSL_LIBRARIES})
515 TARGET_LINK_LIBRARIES(ab ${APR_LIBRARIES})
517 GET_PROPERTY(tmp_includes TARGET ab PROPERTY INCLUDE_DIRECTORIES)
519 # getting duplicate manifest error with ApacheMonitor
520 # ADD_EXECUTABLE(ApacheMonitor support/win32/ApacheMonitor.c support/win32/ApacheMonitor.rc)
521 # SET(install_targets ${install_targets} ApacheMonitor)
522 # SET_TARGET_PROPERTIES(ApacheMonitor PROPERTIES WIN32_EXECUTABLE TRUE)
523 # TARGET_LINK_LIBRARIES(ApacheMonitor ${HTTPD_SYSTEM_LIBS} comctl32 wtsapi32)
525 ADD_EXECUTABLE(htcacheclean support/htcacheclean.c)
526 SET(install_targets ${install_targets} htcacheclean)
527 TARGET_LINK_LIBRARIES(htcacheclean ${APR_LIBRARIES})
529 ADD_EXECUTABLE(htdbm support/htdbm.c support/passwd_common.c)
530 SET(install_targets ${install_targets} htdbm)
531 TARGET_LINK_LIBRARIES(htdbm ${APR_LIBRARIES})
533 ADD_EXECUTABLE(htdigest support/htdigest.c)
534 SET(install_targets ${install_targets} htdigest)
535 TARGET_LINK_LIBRARIES(htdigest ${APR_LIBRARIES})
537 ADD_EXECUTABLE(htpasswd support/htpasswd.c support/passwd_common.c)
538 SET(install_targets ${install_targets} htpasswd)
539 TARGET_LINK_LIBRARIES(htpasswd ${APR_LIBRARIES})
541 ADD_EXECUTABLE(logresolve support/logresolve.c)
542 SET(install_targets ${install_targets} logresolve)
543 TARGET_LINK_LIBRARIES(logresolve ${APR_LIBRARIES})
545 ADD_EXECUTABLE(rotatelogs support/rotatelogs.c)
546 SET(install_targets ${install_targets} rotatelogs)
547 TARGET_LINK_LIBRARIES(rotatelogs ${APR_LIBRARIES})
549 ########### CONFIGURATION FILES ###########
550 # Set up variables used in the .conf file templates
551 SET(LoadModule "${LoadModules}")
552 SET(Port "80" CACHE STRING "http port to listen on")
553 SET(SSLPort "443" CACHE STRING "https port to listen on")
554 SET(ServerRoot "${CMAKE_INSTALL_PREFIX}")
555 SET(exp_cgidir "${CMAKE_INSTALL_PREFIX}/cgi-bin")
556 SET(exp_htdocsdir "${CMAKE_INSTALL_PREFIX}/htdocs")
557 SET(exp_iconsdir "${CMAKE_INSTALL_PREFIX}/icons")
558 SET(exp_errordir "${CMAKE_INSTALL_PREFIX}/error")
559 SET(exp_manualdir "${CMAKE_INSTALL_PREFIX}/manual")
560 SET(rel_logfiledir "logs")
561 SET(rel_runtimedir "logs")
562 SET(rel_sysconfdir "conf")
563 FILE(GLOB_RECURSE conffiles RELATIVE ${CMAKE_SOURCE_DIR}/docs/conf "docs/conf/*")
564 FOREACH(template ${conffiles})
565 STRING(REPLACE ".conf.in" ".conf" conf ${template})
566 FILE(READ "docs/conf/${template}" template_text)
567 IF(template MATCHES ".conf.in$")
568 # substitute @var@/@@var@@ in .conf.in
569 STRING(REPLACE "@@" "@" template_text ${template_text})
570 STRING(CONFIGURE "${template_text}" template_text @ONLY)
572 FILE(WRITE ${CMAKE_BINARY_DIR}/conf/original/${conf} "${template_text}")
573 FILE(WRITE ${CMAKE_BINARY_DIR}/conf/${conf} "${template_text}")
576 ########### INSTALLATION ###########
577 INSTALL(TARGETS ${install_targets}
578 RUNTIME DESTINATION bin
579 LIBRARY DESTINATION lib
580 ARCHIVE DESTINATION lib
582 INSTALL(TARGETS ${install_modules}
583 RUNTIME DESTINATION modules
585 INSTALL(DIRECTORY include/ DESTINATION include
586 FILES_MATCHING PATTERN "*.h"
588 INSTALL(DIRECTORY docs/manual/ DESTINATION manual
589 FILES_MATCHING PATTERN "BUILDING" EXCLUDE
591 INSTALL(DIRECTORY DESTINATION logs)
592 INSTALL(DIRECTORY DESTINATION cgi-bin)
594 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)")
596 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)")
598 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)")
600 # Copy generated .conf files from the build directory to the install,
601 # without overwriting stuff already there.
602 INSTALL(CODE "EXECUTE_PROCESS(COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/build/cpR_noreplace.pl ${CMAKE_BINARY_DIR}/conf ${CMAKE_INSTALL_PREFIX}/conf)")
603 # But conf/original is supposed to be overwritten.
604 # Note: FILE(TO_NATIVE_PATH ...) leaves the backslashes unescaped, which
605 # generates warnings. Just do it manually since this build only supports
607 STRING(REPLACE "/" "\\\\" native_src ${CMAKE_BINARY_DIR}/conf/original)
608 STRING(REPLACE "/" "\\\\" native_dest ${CMAKE_INSTALL_PREFIX}/conf/original)
609 INSTALL(CODE "EXECUTE_PROCESS(COMMAND xcopy ${native_src} ${native_dest} /Q /S /Y)")
611 MESSAGE(STATUS "Module selections:")
612 FOREACH(modsel ${moduleselections})
613 MESSAGE(STATUS " ${modsel} ${${modsel}}")