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