]> granicus.if.org Git - apache/blob - CMakeLists.txt
Add experimental cmake-based build system for Windows.
[apache] / CMakeLists.txt
1 PROJECT(HTTPD C)
2
3 # Experimental cmake-based build support for Apache httpd on Windows
4 #
5 # General usage:
6 # 0. Read the todos down below and make sure this is good enough for your
7 #    purposes.
8 # 1. cd to a clean directory for building (i.e., don't build in your
9 #    source tree)
10 # 2. cmake -G "some backend, like 'NMake Makefiles'" \
11 #          -DCMAKE_INSTALL_PREFIX=d:/path/to/httpdinst \
12 #          -DPCRE_INCLUDE_DIR=d:/path/to/pcreinst/include \
13 #          -DPCRE_LIBRARIES=d:/path/to/pcreinst/lib/pcre[d].lib \
14 #          -DAPR_INCLUDE_DIR=d:/path/to/aprinst/include \
15 #          -DAPR_LIBRARIES=d:/path/to/aprinst/lib/libapr2.lib \
16 #          -DENABLE_MOD_foo="A|I|O" \
17 #          d:/path/to/httpdsource
18 #    Alternately, use cmake-gui and update settings in the GUI.
19 #
20 #    Other flags of interest:
21 #        CMAKE_C_FLAGS_RELEASE, _DEBUG, _RELWITHDEBINFO, _MINSIZEREL
22 #        CMAKE_BUILD_TYPE
23 #          For NMake Makefiles the choices are at least DEBUG, RELEASE,
24 #          RELWITHDEBINFO, and MINSIZEREL
25 #          Other backends make have other selections.
26 # 3. build using chosen backend (e.g., "nmake install")
27 #
28 # PCRE_INCLUDE_DIR, PCRE_LIBRARIES, APR_INCLUDE_DIR, APR_LIBRARIES:
29 #     cmake doesn't bundle FindXXX for these packages, so the crucial
30 #     information has to be specified in this manner
31 #
32 # ENABLE_MOD_foo:
33 #     Each module has a default setting which can be overridden with one of the
34 #     following values:
35 #         A        build and Activate module
36 #         I        build module but leave it Inactive (commented-out LoadModule)
37 #         O        Omit module completely
38 #     Example: -DENABLE_MOD_ALLOWHANDLERS="O" (Omit the module)
39 #         
40 # Todos for Windows build:
41 # . Support APR 1.x in addition to APR trunk
42 # . Handling of module prerequisites
43 # . Find support libraries:
44 #   + "Find" PCRE and APR (no bundled cmake FindXXX macros)
45 #   + LUA, libxml2, zlib, distcache
46 # . Modules not yet supported:
47 #   + mod_ldap, mod_authnz_ldap, mod_socache_dc, mod_deflate, mod_proxy_html, mod_xml2enc,
48 #     mod_lua, mod_serf, apreq+mod_apreq, mod_session_crypto
49 #   + mod_lbmethod_rr and mod_firehose, which don't compile on Windows
50 # . Add a way to configure additional statically-linked modules (like --with-module on Unix)
51 # . Build buildmark.c when httpd.exe is regenerated
52 # . ab + HAVE_OPENSSL isn't working at all, even for plain
53 # . ApacheMonitor has a build error
54 # . install/customize .conf files
55 # . install docroot and CGI examples
56 # . install .h fils that are in odd places
57 # . Generally: go through the existing Windows build and see what is missing, whether a
58 #   feature or some build nuance
59
60 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
61
62 FIND_PACKAGE(OpenSSL)
63
64 # Options for support libraries not supported by cmake-bundled FindFOO
65 SET(APR_INCLUDE_DIR       "C:/APR/include"               CACHE STRING "Directory with APR[-Util] include files")
66 SET(APR_LIBRARIES         "C:/APR/lib/libapr-2.lib"      CACHE STRING "APR libraries to link with")
67 SET(PCRE_INCLUDE_DIR      "C:/PCRE/include"              CACHE STRING "Directory with PCRE include files")
68 SET(PCRE_LIBRARIES        "C:/PCRE/lib/pcred.lib"        CACHE STRING "PCRE libraries to link with")
69 # end support library configuration
70
71 # Options for each available module
72 #   "A" ("A"ctive) means installed and active in default .conf, fail if can't be built
73 #   "I" ("I"nactive) means installed and inactive (LoadModule commented out) in default .conf, fail if can't be built
74 #   "O" ("O"mit) means not installed, no LoadModule
75 # Options to be added later:
76 #   "a" - like "A", but ignore with a warning if any prereqs aren't available
77 #   "i" - like "I", but ignore with a warning if any prereqs aren't available
78
79 SET(MODULE_LIST
80   "modules/aaa/mod_access_compat.c+A+mod_access compatibility"
81   "modules/aaa/mod_allowhandlers.c+I+restrict allowed handlers"
82   "modules/aaa/mod_allowmethods.c+I+restrict allowed HTTP methods"
83   "modules/aaa/mod_auth_basic.c+A+basic authentication"
84   "modules/aaa/mod_auth_digest.c+I+RFC2617 Digest authentication"
85   "modules/aaa/mod_auth_form.c+I+form authentication"
86   "modules/aaa/mod_authn_anon.c+A+anonymous user authentication control"
87   "modules/aaa/mod_authn_core.c+A+core authentication module"
88   "modules/aaa/mod_authn_dbd.c+I+SQL-based authentication control"
89   "modules/aaa/mod_authn_dbm.c+I+DBM-based authentication control"
90   "modules/aaa/mod_authn_file.c+A+file-based authentication control"
91   "modules/aaa/mod_authn_socache.c+A+Cached authentication control"
92   "modules/aaa/mod_authnz_fcgi.c+I+FastCGI authorizer-based authentication and authorization"
93   "modules/aaa/mod_authnz_ldap.c+O+LDAP based authentication"
94   "modules/aaa/mod_authz_core.c+A+core authorization provider vector module"
95   "modules/aaa/mod_authz_dbd.c+I+SQL based authorization and Login/Session support"
96   "modules/aaa/mod_authz_dbm.c+I+DBM-based authorization control"
97   "modules/aaa/mod_authz_groupfile.c+A+'require group' authorization control"
98   "modules/aaa/mod_authz_host.c+A+host-based authorization control"
99   "modules/aaa/mod_authz_owner.c+I+'require file-owner' authorization control"
100   "modules/aaa/mod_authz_user.c+I+'require user' authorization control"
101   "modules/arch/win32/mod_isapi.c+I+isapi extension support"
102   "modules/cache/mod_cache.c+I+dynamic file caching.  At least one storage management module (e.g. mod_cache_disk) is also necessary."
103   "modules/cache/mod_cache_disk.c+I+disk caching module"
104   "modules/cache/mod_cache_socache.c+A+shared object caching module"
105   "modules/cache/mod_file_cache.c+A+File cache"
106   "modules/cache/mod_socache_dbm.c+I+dbm small object cache provider"
107   "modules/cache/mod_socache_dc.c+O+distcache small object cache provider"
108   "modules/cache/mod_socache_memcache.c+I+memcache small object cache provider"
109   "modules/cache/mod_socache_shmcb.c+A+ shmcb small object cache provider"
110   "modules/cluster/mod_heartbeat.c+I+Generates Heartbeats"
111   "modules/cluster/mod_heartmonitor.c+I+Collects Heartbeats"
112   "modules/core/mod_macro.c+I+Define and use macros in configuration files"
113   "modules/core/mod_watchdog.c+I+Watchdog module"
114   "modules/database/mod_dbd.c+I+Apache DBD Framework"
115   "modules/dav/fs/mod_dav_fs.c+I+DAV provider for the filesystem."
116   "modules/dav/lock/mod_dav_lock.c+I+DAV provider for generic locking"
117   "modules/dav/main/mod_dav.c+I+WebDAV protocol handling."
118   "modules/debugging/mod_bucketeer.c+I+buckets manipulation filter.  Useful only for developers and testing purposes."
119   "modules/debugging/mod_dumpio.c+I+I/O dump filter"
120   "modules/debugging/mod_firehose.c+O+Firehose dump filter"
121   "modules/echo/mod_echo.c+I+ECHO server"
122   "modules/examples/mod_case_filter.c+I+Example uppercase conversion filter"
123   "modules/examples/mod_case_filter_in.c+I+Example uppercase conversion input filter"
124   "modules/examples/mod_example_hooks.c+I+Example hook callback handler module"
125   "modules/examples/mod_example_ipc.c+I+Example of shared memory and mutex usage"
126   "modules/filters/mod_buffer.c+A+Filter Buffering"
127   "modules/filters/mod_charset_lite.c+O+character set translation"
128   "modules/filters/mod_data.c+I+RFC2397 data encoder"
129   "modules/filters/mod_deflate.c+O+Deflate transfer encoding support"
130   "modules/filters/mod_ext_filter.c+I+external filter module"
131   "modules/filters/mod_filter.c+A+Smart Filtering"
132   "modules/filters/mod_include.c+A+Server Side Includes"
133   "modules/filters/mod_proxy_html.c+O+Fix HTML Links in a Reverse Proxy"
134   "modules/filters/mod_ratelimit.c+I+Output Bandwidth Limiting"
135   "modules/filters/mod_reflector.c+I+Reflect request through the output filter stack"
136   "modules/filters/mod_reqtimeout.c+A+Limit time waiting for request from client"
137   "modules/filters/mod_request.c+I+Request Body Filtering"
138   "modules/filters/mod_sed.c+I+filter request and/or response bodies through sed"
139   "modules/filters/mod_substitute.c+I+response content rewrite-like filtering"
140   "modules/filters/mod_xml2enc.c+O+i18n support for markup filters"
141   "modules/generators/mod_asis.c+A+as-is filetypes"
142   "modules/generators/mod_autoindex.c+A+directory listing"
143   "modules/generators/mod_cgi.c+A+CGI scripts"
144   "modules/generators/mod_info.c+A+server information"
145   "modules/generators/mod_status.c+A+process/thread monitoring"
146   "modules/http/mod_mime.c+A+mapping of file-extension to MIME.  Disabling this module is normally not recommended."
147   "modules/ldap/mod_ldap.c+O+LDAP caching and connection pooling services"
148   "modules/loggers/mod_log_config.c+A+logging configuration.  You won't be able to log requests to the server without this module."
149   "modules/loggers/mod_log_debug.c+A+configurable debug logging"
150   "modules/loggers/mod_log_forensic.c+I+forensic logging"
151   "modules/loggers/mod_logio.c+I+input and output logging"
152   "modules/lua/mod_lua.c+O+Apache Lua Framework"
153   "modules/mappers/mod_actions.c+A+Action triggering on requests"
154   "modules/mappers/mod_alias.c+A+mapping of requests to different filesystem parts"
155   "modules/mappers/mod_dir.c+A+directory request handling"
156   "modules/mappers/mod_imagemap.c+I+server-side imagemaps"
157   "modules/mappers/mod_negotiation.c+A+content negotiation"
158   "modules/mappers/mod_rewrite.c+A+rule based URL manipulation"
159   "modules/mappers/mod_speling.c+A+correct common URL misspellings"
160   "modules/mappers/mod_userdir.c+A+mapping of requests to user-specific directories"
161   "modules/mappers/mod_vhost_alias.c+I+mass virtual hosting module"
162   "modules/metadata/mod_cern_meta.c+I+CERN-type meta files"
163   "modules/metadata/mod_env.c+A+clearing/setting of ENV vars"
164   "modules/metadata/mod_expires.c+A+Expires header control"
165   "modules/metadata/mod_headers.c+A+HTTP header control"
166   "modules/metadata/mod_ident.c+I+RFC 1413 identity check"
167   "modules/metadata/mod_mime_magic.c+I+automagically determining MIME type"
168   "modules/metadata/mod_remoteip.c+A+translate header contents to an apparent client remote_ip"
169   "modules/metadata/mod_setenvif.c+A+basing ENV vars on headers"
170   "modules/metadata/mod_unique_id.c+A+per-request unique ids"
171   "modules/metadata/mod_usertrack.c+A+user-session tracking"
172   "modules/metadata/mod_version.c+A+determining httpd version in config files"
173   "modules/proxy/balancers/mod_lbmethod_bybusyness.c+A+Apache proxy Load balancing by busyness"
174   "modules/proxy/balancers/mod_lbmethod_byrequests.c+A+Apache proxy Load balancing by request counting"
175   "modules/proxy/balancers/mod_lbmethod_bytraffic.c+A+Apache proxy Load balancing by traffic counting"
176   "modules/proxy/balancers/mod_lbmethod_heartbeat.c+A+Apache proxy Load balancing from Heartbeats"
177   "modules/proxy/mod_proxy_ajp.c+I+Apache proxy AJP module.  Requires and is enabled by --enable-proxy."
178   "modules/proxy/mod_proxy_balancer.c+A+Apache proxy BALANCER module.  Requires and is enabled by --enable-proxy."
179   "modules/proxy/mod_proxy.c+A+Apache proxy module"
180   "modules/proxy/mod_proxy_connect.c+I+Apache proxy CONNECT module.  Requires and is enabled by --enable-proxy."
181   "modules/proxy/mod_proxy_express.c+I+mass reverse-proxy module. Requires --enable-proxy."
182   "modules/proxy/mod_proxy_fcgi.c+I+Apache proxy FastCGI module.  Requires and is enabled by --enable-proxy."
183   "modules/proxy/mod_proxy_ftp.c+I+Apache proxy FTP module.  Requires and is enabled by --enable-proxy."
184   "modules/proxy/mod_proxy_http.c+A+Apache proxy HTTP module.  Requires and is enabled by --enable-proxy."
185   "modules/proxy/mod_proxy_scgi.c+I+Apache proxy SCGI module.  Requires and is enabled by --enable-proxy."
186   "modules/proxy/mod_proxy_wstunnel.c+I+Apache proxy Websocket Tunnel module.  Requires and is enabled by --enable-proxy."
187   "modules/proxy/mod_serf.c+O+Reverse proxy module using Serf"
188   "modules/session/mod_session.c+I+session module"
189   "modules/session/mod_session_cookie.c+I+session cookie module"
190   "modules/session/mod_session_crypto.c+O+session crypto module"
191   "modules/session/mod_session_dbd.c+I+session dbd module"
192   "modules/slotmem/mod_slotmem_plain.c+A+slotmem provider that uses plain memory"
193   "modules/slotmem/mod_slotmem_shm.c+A+slotmem provider that uses shared memory"
194   "modules/ssl/mod_ssl.c+A+SSL/TLS support"
195   "modules/test/mod_dialup.c+I+rate limits static files to dialup modem speeds"
196   "modules/test/mod_optional_fn_export.c+I+example optional function exporter"
197   "modules/test/mod_optional_fn_import.c+I+example optional function importer"
198   "modules/test/mod_optional_hook_export.c+I+example optional hook exporter"
199   "modules/test/mod_optional_hook_import.c+I+example optional hook importer"
200   "modules/test/mod_policy.c+I+HTTP protocol compliance filters"
201 )
202
203 # Define extra definitions, sources, headers, etc. required by some modules.
204 # This could be included in the master list of modules above, though it 
205 # certainly would get a lot more unreadable.
206 SET(mod_authz_dbd_extra_defines      AUTHZ_DBD_DECLARE_EXPORT)
207 SET(mod_cache_extra_defines          CACHE_DECLARE_EXPORT)
208 SET(mod_cache_extra_sources
209   modules/cache/cache_storage.c      modules/cache/cache_util.c
210 )
211 SET(mod_cache_disk_extra_libs        mod_cache)
212 SET(mod_cache_socache_extra_libs     mod_cache)
213 SET(mod_dav_extra_defines            DAV_DECLARE_EXPORT)
214 SET(mod_dav_extra_sources
215   modules/dav/main/liveprop.c        modules/dav/main/props.c
216   modules/dav/main/std_liveprop.c    modules/dav/main/providers.c
217   modules/dav/main/util.c            modules/dav/main/util_lock.c
218 )
219 SET(mod_dav_fs_extra_sources
220   modules/dav/fs/dbm.c               modules/dav/fs/lock.c
221   modules/dav/fs/repos.c
222 )
223 SET(mod_dav_fs_extra_libs            mod_dav)
224 SET(mod_dav_lock_extra_sources       modules/dav/lock/locks.c)
225 SET(mod_dav_lock_extra_libs          mod_dav)
226 SET(mod_dbd_extra_defines            DBD_DECLARE_EXPORT)
227 SET(mod_heartbeat_extra_libs         mod_watchdog)
228 SET(mod_optional_hook_export_extra_defines AP_DECLARE_EXPORT) # bogus reuse of core API prefix
229 SET(mod_proxy_extra_defines          PROXY_DECLARE_EXPORT)
230 SET(mod_proxy_extra_sources          modules/proxy/proxy_util.c)
231 SET(mod_proxy_ajp_extra_sources
232   modules/proxy/ajp_header.c         modules/proxy/ajp_link.c
233   modules/proxy/ajp_msg.c            modules/proxy/ajp_utils.c
234 )
235 SET(mod_proxy_ajp_extra_libs         mod_proxy)
236 SET(mod_proxy_balancer_extra_libs    mod_proxy)
237 SET(mod_proxy_connect_extra_libs     mod_proxy)
238 SET(mod_proxy_express_extra_libs     mod_proxy)
239 SET(mod_proxy_fcgi_extra_libs        mod_proxy)
240 SET(mod_proxy_ftp_extra_libs         mod_proxy)
241 SET(mod_proxy_http_extra_libs        mod_proxy)
242 SET(mod_proxy_scgi_extra_libs        mod_proxy)
243 SET(mod_proxy_wstunnel_extra_libs    mod_proxy)
244 SET(mod_ratelimit_extra_defines      AP_RL_DECLARE_EXPORT)
245 SET(mod_sed_extra_sources
246   modules/filters/regexp.c           modules/filters/sed0.c
247   modules/filters/sed1.c
248 )
249 SET(mod_session_extra_defines        SESSION_DECLARE_EXPORT)
250 SET(mod_session_cookie_extra_libs    mod_session)
251 SET(mod_session_dbd_extra_libs       mod_session)
252 SET(mod_ssl_extra_includes           ${OPENSSL_INCLUDE_DIR})
253 SET(mod_ssl_extra_sources
254   modules/ssl/ssl_engine_config.c    modules/ssl/ssl_engine_dh.c
255   modules/ssl/ssl_engine_init.c      modules/ssl/ssl_engine_io.c
256   modules/ssl/ssl_engine_kernel.c    modules/ssl/ssl_engine_log.c
257   modules/ssl/ssl_engine_mutex.c     modules/ssl/ssl_engine_ocsp.c
258   modules/ssl/ssl_engine_pphrase.c   modules/ssl/ssl_engine_rand.c
259   modules/ssl/ssl_engine_vars.c      modules/ssl/ssl_scache.c
260   modules/ssl/ssl_util.c             modules/ssl/ssl_util_ocsp.c
261   modules/ssl/ssl_util_ssl.c         modules/ssl/ssl_util_stapling.c
262 )
263 SET(mod_ssl_extra_libs               ${OPENSSL_LIBRARIES})
264 SET(mod_status_extra_defines         STATUS_DECLARE_EXPORT)
265 SET(mod_watchdog_extra_defines       AP_WD_DECLARE_EXPORT)
266
267 SET(MODULE_SRCS)
268
269 SET(moduleselections)
270 FOREACH (modinfo ${MODULE_LIST})
271   STRING(REGEX REPLACE "([^+]*)\\+([^+]*)\\+([^+]*)" "\\1;\\2;\\3" modinfolist ${modinfo})
272   LIST(LENGTH modinfolist modinfolen)
273   SET(primarysourcefile)
274   SET(defaultenable)
275   SET(helptext)
276   FOREACH(i ${modinfolist})
277     IF("${primarysourcefile}" STREQUAL "")
278       SET(primarysourcefile ${i})
279     ELSEIF("${defaultenable}" STREQUAL "")
280       SET(defaultenable ${i})
281     ELSEIF("${helptext}" STREQUAL "")
282       SET(helptext ${i})
283     ELSE()
284       MESSAGE(FATAL " Unexpected field or plus sign in >${modinfo}<")
285     ENDIF()
286   ENDFOREACH()
287
288   # MESSAGE("  primary source file: ${primarysourcefile}")
289   # MESSAGE("enablement by default: ${defaultenable}")
290   # MESSAGE("            help text: ${helptext}")
291
292   STRING(REGEX MATCH   "[^/]+\\.c"              mod_basename    ${primarysourcefile})
293   STRING(REGEX MATCH   "[^.]+"                  mod_name        ${mod_basename})
294
295   STRING(TOUPPER "ENABLE_${mod_name}" mod_option_name)
296
297   SET(${mod_option_name} ${defaultenable} CACHE STRING ${helptext})
298   SET(MODULE_SRCS "${MODULE_SRCS};${primarysourcefile}")
299   SET(moduleselections "${moduleselections};${mod_option_name}")
300
301 ENDFOREACH()
302
303 SET(install_targets)
304 SET(install_modules) # special handling vs. other installed targets
305
306 ADD_EXECUTABLE(gen_test_char server/gen_test_char.c)
307 GET_TARGET_PROPERTY(GEN_TEST_CHAR_EXE gen_test_char LOCATION)
308 ADD_CUSTOM_COMMAND(
309   COMMENT "Generating character tables, test_char.h, for current locale"
310   DEPENDS gen_test_char
311   COMMAND ${GEN_TEST_CHAR_EXE} > ${PROJECT_BINARY_DIR}/test_char.h
312   OUTPUT ${PROJECT_BINARY_DIR}/test_char.h
313 )
314 ADD_CUSTOM_TARGET(
315   test_char_header ALL
316   DEPENDS ${PROJECT_BINARY_DIR}/test_char.h
317 )
318
319 SET(HTTPD_MAIN_SOURCES
320   server/main.c
321 )
322
323 SET(LIBHTTPD_SOURCES
324   modules/arch/win32/mod_win32.c
325   modules/core/mod_so.c
326   modules/http/byterange_filter.c
327   modules/http/chunk_filter.c
328   modules/http/http_core.c
329   modules/http/http_etag.c
330   modules/http/http_filters.c
331   modules/http/http_protocol.c
332   modules/http/http_request.c
333   os/win32/ap_regkey.c
334   os/win32/modules.c
335   os/win32/util_win32.c
336   server/buildmark.c
337   server/config.c
338   server/connection.c
339   server/core.c
340   server/core_filters.c
341   server/eoc_bucket.c
342   server/eor_bucket.c
343   server/error_bucket.c
344   server/listen.c
345   server/log.c
346   server/mpm/winnt/child.c
347   server/mpm/winnt/mpm_winnt.c
348   server/mpm/winnt/nt_eventlog.c
349   server/mpm/winnt/service.c
350   server/mpm_common.c
351   server/protocol.c
352   server/provider.c
353   server/request.c
354   server/scoreboard.c
355   server/util.c
356   server/util_cfgtree.c
357   server/util_cookies.c
358   server/util_expr_eval.c
359   server/util_expr_parse.c
360   server/util_expr_scan.c
361   server/util_fcgi.c
362   server/util_filter.c
363   server/util_md5.c
364   server/util_mutex.c
365   server/util_pcre.c
366   server/util_regex.c
367   server/util_script.c
368   server/util_time.c
369   server/util_xml.c
370   server/vhost.c
371 )
372
373 CONFIGURE_FILE(os/win32/win32_config_layout.h
374                ${PROJECT_BINARY_DIR}/ap_config_layout.h)
375
376 SET(HTTPD_INCLUDE_DIRECTORIES
377   ${PROJECT_BINARY_DIR}
378   # see discussion in cmake bug 13188 regarding oddities with relative paths
379   ${CMAKE_CURRENT_SOURCE_DIR}/include
380   ${CMAKE_CURRENT_SOURCE_DIR}/os/win32
381   ${CMAKE_CURRENT_SOURCE_DIR}/modules/core
382   ${CMAKE_CURRENT_SOURCE_DIR}/modules/database
383   ${CMAKE_CURRENT_SOURCE_DIR}/modules/dav/main
384   ${CMAKE_CURRENT_SOURCE_DIR}/modules/filters
385   ${CMAKE_CURRENT_SOURCE_DIR}/modules/generators
386   ${CMAKE_CURRENT_SOURCE_DIR}/modules/proxy
387   ${CMAKE_CURRENT_SOURCE_DIR}/modules/session
388   ${CMAKE_CURRENT_SOURCE_DIR}/modules/ssl
389   ${CMAKE_CURRENT_SOURCE_DIR}/server
390   ${APR_INCLUDE_DIR}
391   ${APR_PRIVATE_INCLUDE_DIRS}
392   ${PCRE_INCLUDE_DIR}
393 )
394
395 INCLUDE_DIRECTORIES(${HTTPD_INCLUDE_DIRECTORIES})
396
397 SET(HTTPD_SYSTEM_LIBS
398   ws2_32
399   mswsock
400 )
401
402 ###########   HTTPD MODULES     ############
403 SET(LoadModules)
404 FOREACH (mod ${MODULE_SRCS})
405   # Build different forms of the module name; e.g., 
406   #   mod_short_name->mod_cgi.c, mod_name->mod_cgi, mod_module_name->cgi_module
407   STRING(REGEX MATCH   "[^/]+\\.c"              mod_basename  ${mod})
408   STRING(REGEX MATCH   "[^.]+"                  mod_name        ${mod_basename})
409   STRING(REGEX REPLACE "^mod_(.*)" "\\1_module" mod_module_name ${mod_name})
410
411   # Is it enabled?
412   STRING(TOUPPER "ENABLE_${mod_name}" enable_mod)
413
414   IF("${${enable_mod}}" STREQUAL "")
415     MESSAGE(FATAL " ENABLE_MOD_foo VAR not set for module ${mod}")
416   ENDIF()
417   
418   IF(${${enable_mod}} STREQUAL "O")
419     # ignore
420   ELSE()
421     # Handle whether or not the LoadModule is commented out.
422     IF(${${enable_mod}} STREQUAL "A")
423       SET(LoadModules ${LoadModules} "LoadModule ${mod_module_name} modules/${mod_name}.so\n")
424     ELSEIF(${${enable_mod}} STREQUAL "I")
425       SET(LoadModules ${LoadModules} "# LoadModule ${mod_module_name} modules/${mod_name}.so\n")
426     ELSE()
427       MESSAGE(FATAL " ${enable_mod} must be set to \"A\", \"I\", or \"O\" instead of \"${${enable_mod}}\"")
428     ENDIF()
429
430     # Handle building it.
431     SET(mod_extra_sources "${mod_name}_extra_sources")
432     SET(all_mod_sources ${mod} ${${mod_extra_sources}})
433     ADD_LIBRARY(${mod_name} SHARED ${all_mod_sources})
434     SET(install_modules ${install_modules} ${mod_name})
435     SET(mod_extra_libs "${mod_name}_extra_libs")
436     SET_TARGET_PROPERTIES(${mod_name} PROPERTIES SUFFIX .so)
437     TARGET_LINK_LIBRARIES(${mod_name} ${${mod_extra_libs}} libhttpd ${APR_LIBRARIES} ${HTTPD_SYSTEM_LIBS})
438
439     # Extra defines?
440     SET(mod_extra_defines "${mod_name}_extra_defines")
441     IF(NOT ${${mod_extra_defines}} STREQUAL "")
442       SET_TARGET_PROPERTIES(${mod_name} PROPERTIES COMPILE_DEFINITIONS ${${mod_extra_defines}})
443     ENDIF()
444
445     # Extra includes?
446     SET(mod_extra_includes "${mod_name}_extra_includes")
447     IF(NOT ${${mod_extra_includes}} STREQUAL "")
448       SET(tmp_includes ${${mod_extra_includes}} ${HTTPD_INCLUDE_DIRECTORIES})
449       SET_TARGET_PROPERTIES(${mod_name} PROPERTIES INCLUDE_DIRECTORIES "${tmp_includes}")
450       GET_PROPERTY(tmp_includes TARGET ${mod_name} PROPERTY INCLUDE_DIRECTORIES)
451     ENDIF()
452
453   ENDIF()
454 ENDFOREACH()
455
456 ###########   HTTPD LIBRARIES   ############
457 ADD_LIBRARY(libhttpd SHARED ${LIBHTTPD_SOURCES})
458 SET(install_targets ${install_targets} libhttpd)
459 TARGET_LINK_LIBRARIES(libhttpd ${APR_LIBRARIES} ${PCRE_LIBRARIES} ${HTTPD_SYSTEM_LIBS})
460 SET_TARGET_PROPERTIES(libhttpd PROPERTIES COMPILE_FLAGS -DAP_DECLARE_EXPORT)
461 ADD_DEPENDENCIES(libhttpd test_char_header)
462
463 ###########   HTTPD EXECUTABLES   ##########
464 ADD_EXECUTABLE(httpd server/main.c build/win32/httpd.rc)
465 SET(install_targets ${install_targets} httpd)
466 TARGET_LINK_LIBRARIES(httpd libhttpd)
467
468 ADD_EXECUTABLE(ab support/ab.c)
469 SET(install_targets ${install_targets} ab)
470 IF(OPENSSL_FOUND)
471   SET_TARGET_PROPERTIES(ab PROPERTIES COMPILE_DEFINITIONS HAVE_OPENSSL)
472   SET(tmp_includes ${HTTPD_INCLUDE_DIRECTORIES} ${OPENSSL_INCLUDE_DIR})
473   SET_TARGET_PROPERTIES(ab PROPERTIES INCLUDE_DIRECTORIES "${tmp_includes}")
474   TARGET_LINK_LIBRARIES(ab ${APR_LIBRARIES} ${OPENSSL_LIBRARIES})
475 ELSE()
476   TARGET_LINK_LIBRARIES(ab ${APR_LIBRARIES})
477 ENDIF()
478 GET_PROPERTY(tmp_includes TARGET ab PROPERTY INCLUDE_DIRECTORIES)
479
480 # getting duplicate manifest error with ApacheMonitor
481 # ADD_EXECUTABLE(ApacheMonitor support/win32/ApacheMonitor.c support/win32/ApacheMonitor.rc)
482 # SET(install_targets ${install_targets} ApacheMonitor)
483 # SET_TARGET_PROPERTIES(ApacheMonitor PROPERTIES WIN32_EXECUTABLE TRUE)
484 # TARGET_LINK_LIBRARIES(ApacheMonitor ${HTTPD_SYSTEM_LIBS} comctl32 wtsapi32)
485
486 ADD_EXECUTABLE(htcacheclean support/htcacheclean.c)
487 SET(install_targets ${install_targets} htcacheclean)
488 TARGET_LINK_LIBRARIES(htcacheclean ${APR_LIBRARIES})
489
490 ADD_EXECUTABLE(htdbm support/htdbm.c support/passwd_common.c)
491 SET(install_targets ${install_targets} htdbm)
492 TARGET_LINK_LIBRARIES(htdbm ${APR_LIBRARIES})
493
494 ADD_EXECUTABLE(htdigest support/htdigest.c)
495 SET(install_targets ${install_targets} htdigest)
496 TARGET_LINK_LIBRARIES(htdigest ${APR_LIBRARIES})
497
498 ADD_EXECUTABLE(htpasswd support/htpasswd.c support/passwd_common.c)
499 SET(install_targets ${install_targets} htpasswd)
500 TARGET_LINK_LIBRARIES(htpasswd ${APR_LIBRARIES})
501
502 ADD_EXECUTABLE(logresolve support/logresolve.c)
503 SET(install_targets ${install_targets} logresolve)
504 TARGET_LINK_LIBRARIES(logresolve ${APR_LIBRARIES})
505
506 ADD_EXECUTABLE(rotatelogs support/rotatelogs.c)
507 SET(install_targets ${install_targets} rotatelogs)
508 TARGET_LINK_LIBRARIES(rotatelogs ${APR_LIBRARIES})
509
510 INSTALL(TARGETS ${install_targets}
511         RUNTIME DESTINATION bin
512         LIBRARY DESTINATION lib
513         ARCHIVE DESTINATION lib
514        )
515 INSTALL(TARGETS ${install_modules}
516         RUNTIME DESTINATION modules
517        )
518 INSTALL(DIRECTORY include/ DESTINATION include
519     FILES_MATCHING PATTERN "*.h"
520 )
521 INSTALL(DIRECTORY docs/icons/ DESTINATION icons)
522 INSTALL(DIRECTORY docs/error/ DESTINATION error)
523 INSTALL(DIRECTORY docs/manual/ DESTINATION manual
524     FILES_MATCHING PATTERN "BUILDING" EXCLUDE
525 )
526 INSTALL(DIRECTORY DESTINATION logs)
527 INSTALL(DIRECTORY DESTINATION cgi-bin)
528
529 MESSAGE(STATUS "Module selections:")
530 FOREACH(modsel ${moduleselections})
531   MESSAGE(STATUS "  ${modsel} ${${modsel}}")
532 ENDFOREACH()