README.cmake 13 KB
Newer Older
powelld's avatar
powelld committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
Experimental cmake-based build support for Apache httpd on Microsoft Windows


This build support is currently intended only for Microsoft Windows.

This build support is experimental.  Specifically,

* It does not support all features of Apache httpd.
* Some components may not be built correctly and/or in a manner
  compatible with the previous Windows build support.
* Build interfaces, such as the mechanisms which are used to enable
  optional functionality or specify prerequisites, may change from
  release to release as feedback is received from users and bugs and
  limitations are resolved.

Important: Refer to the "Known Bugs and Limitations" section for further

           It is beyond the scope of this document to document or explain
           how to utilize the various cmake features, such as different
           build backends or provisions for finding support libraries.

           Please refer to the cmake documentation for additional information
           that applies to building any project with cmake.


The following tools must be in PATH:

* cmake, version 2.8 or later
  cmake version 3.1.3 or later is required to work with current OpenSSL
  releases.  (OpenSSL is an optional prerequisite of httpd.)
* Perl
* If the WITH_MODULES feature is used: awk
* If using a command-line compiler: compiler and linker and related tools
  (Refer to the cmake documentation for more information.)

The following support libraries are mandatory:

* APR, built with cmake
  + Either APR 2.0-dev (trunk) or APR 1.5.x and APR-Util 1.5.x.
  + When building APR (but not APR-Util), specify the build option
    APR_INSTALL_PRIVATE_H so that non-standard files required for building
    Apache httpd are installed.
  + Additional APR settings affect httpd but are not mandatory, such as

Certain optional features of APR 2.0-dev (trunk) or APR-Util 1.5.x
allow some optional features of httpd to be enabled.  For example,
APU_HAVE_CRYPTO is required for mod_session_crypto.

Additional support libraries allow some optional features of httpd to be

* libxml2 (e.g., mod_proxy_html)
* lua 5.1 (mod_lua)
* nghttp2 (mod_http2)
* openssl (mod_ssl and https support for ab)
* zlib (mod_deflate)


If you have a binary install of OpenSSL in a well-known directory (e.g.,
%HOME%\OpenSSL-Win64) and you wish to build httpd against a different
install of OpenSSL, the cmake build may unexpectedly select OpenSSL
libraries in the well-known directory even if the expected include files
are used.  Check the cmake output from your httpd build to confirm that
the expected OpenSSL libraries and include files are used.

The cmake FindOpenSSL module searches for OpenSSL libraries in a "VC"
subdirectory of the OpenSSL install with filenames that indicate the build
type (e.g., "<PREFIX>/lib/VC/ssleay32MD.lib"); defining CMAKE_PREFIX_PATH
or OPENSSL_ROOT_DIR or even OPENSSL_LIBRARIES does not circumvent finding
these libraries.

To work around this issue, rename the well-known OpenSSL directory while
building httpd.  Let us know if you find a better solution.


This is required for mod_http2.

cmake-based build support for nghttp2 for Windows can be found at  That easily fits into
a build system that already uses cmake for httpd, apr, and perhaps other
packages.  A dynamic build of nghttp2 using its normal Windows build
system should also be usable by nghttp2.

How to build

1. cd to a clean directory for building (i.e., don't build in your
   source tree)

2. Make sure cmake and Perl are in PATH.  Additionally, some backends 
   require compile tools in PATH.  (Hint: "Visual Studio Command Prompt")
   In the unlikely event that you use -DWITH_MODULES, described below, make
   sure awk is in PATH.

3. cmake -G "some backend, like 'NMake Makefiles'"

   Alternately, you can use the cmake-gui and update settings in the GUI.


       cmake doesn't bundle FindXXX for these packages, so the crucial
       information has to be specified in this manner if they aren't found
       in their default location.


       These will have to be specified only if PCRE is installed to a different
       directory than httpd, or if debug *and* release builds of PCRE were
       installed there and you want to control which is used.  (Currently the
       build will use pcred.lib (debug) if it is found in the default location
       and not overridden with -DPCRE_LIBRARIES.)


       These will have to be specified if APR[-Util] was installed to a
       different directory than httpd.

       When building with APR trunk (future APR 2.x, with integrated APR-Util),
       specify just the path to libapr-2.lib:


       APR+APR-Util 1.x vs. APR trunk will be detected automatically if they
       are installed to the same location as httpd.

       APR-Util 1.x has an optional LDAP library.  If APR-Util has LDAP enabled
       and httpd's mod_ldap and mod_authnz_ldap are being used, include the
       path to the LDAP library in the APR_LIBRARIES setting.  (If APR and
       APR-Util are found in the default location, the LDAP library will be
       included if it is present.

     -DNGHTTP2_INCLUDE_DIR=d:/path/to/nghttp2inst/include  (which has nghttp2/*.h)

       These will have to be specified if nghttp2 was installed to a different
       directory than httpd.


      If using a module that requires libxml2 *and* the build of libxml2 requires
      iconv, set these variables to allow iconv includes and libraries to be
      used.  For example:



       For NMake Makefiles the choices are at least DEBUG, RELEASE,
       Other backends may have other selections.


       Each module has a default setting which can be overridden with one of
       the following values:
           A        build and Activate module
           a        build and Activate module IFF prereqs are available; if
                    prereqs are unavailable, don't build it
           I        build module but leave it Inactive (commented-out
                    LoadModule directive)
           i        build module but leave it Inactive IFF prereqs are
                    available; if prereqs are unavailable, don't build it
           O        Omit module completely



       This changes the *minimum* enablement of all modules to the specified
       value (one of A, a, I, i, O, as described under ENABLE_foo above).

       The ranking of enablement from lowest to highest is O, i, I, a, A.
       If a specific module has a higher rank enablement setting, either from
       a built-in default or from -DENABLE_foo, ENABLE_MODULES won't affect
       that module.  However, if a specific module has a lower-rank enablement
       setting, presumably from a built-in default, the value of ENABLE_MODULES
       will be used for that module.

       Explanations for possible values:

       -DENABLE_MODULES=a      build and activate all possible modules,
                               ignoring any with missing prereqs
                               (doesn't affect modules with A for ENABLE_foo)

       -DENABLE_MODULES=i      build but leave inactive all possible
                               modules, ignoring any with missing
                               (doesn't affect modules with A, a, or I for 

       -DENABLE_MODULES=O      no impact, since all modules are either
                               already disabled or have a higher setting

       -DENABLE_MODULES=A      build and activate all possible modules,
                               failing the build if any module is missing
                               a prereq

       -DENABLE_MODULES=I      similar to -DENABLE_MODULES=A
                               (doesn't affect modules with A or a for


       Comma-separated paths to single file modules to statically linked into
       the server, like the --with-module=modpath:/path/to/mod_foo.c with
       the autoconf-based build.  Key differences: The modpath (e.g., 
       "generators") isn't provided or used, and the copy of the module
       source being built is automatically updated when it changes.


       Space-delimited compile flags to define with the build.


       List of additional directories to search for .h files.  This may
       be necessary when including third-party modules in the httpd build
       via WITH_MODULES.


       List of additional libraries to link with.  This may be necessary when
       including third-party modules in the httpd build via WITH_MODULES.

   Port and SSLPort:

       Port numbers for substitution into default .conf files.  (The defaults
       are 80 and 443.)


       If .pdb files are generated for debugging, install them.
       Default: ON

       The .pdb files are generally needed for debugging low-level code
       problems.  If they aren't installed, they are still available in the
       build directory for use by alternate packaging implementations or when
       debugging on the build machine.


       Install the Apache HTTP Server manual.
       Default: ON

       This could be turned off when developing changes in order to speed up
       installation time.

4. Build using the chosen generator (e.g., "nmake install" for cmake's "NMake
   Makefiles" generator).

Running the server and support programs

This build system does not copy binaries such as dlls from other projects
into the httpd install location.  Without taking some precautions, httpd
and support programs can fail to start or modules can fail to load because
a support library can't be found in PATH or in the directory of the httpd

This can be resolved in several different ways:

* Install httpd and the various support libraries to a common install
  prefix so that support libraries and httpd programs are installed in
  the same bin directory and are found without setting PATH.

* Update PATH to include the bin directories of all necessary support

  Depending on where PATH is set, it may not affect starting httpd as
  a service.

* Maintain a script which combines required binaries into a common 
  location, such as the httpd installion bin directory, and use that
  script after building or otherwise installing or updating support

* AVOID THE USE of any unrepeatable process of copying dll files around
  from different install locations until something starts working.  The
  result is that when you later update a support library to pick up a
  security fix, httpd will likely continue to use the old, vulnerable
  library file.

Known Bugs and Limitations

* no standard script or makefile is provided to tie together the builds
  of httpd and support libraries in a manner suitable for typical users
* no logic to find support libraries or otherwise build these modules:
  + mod_socache_dc (requires distcache), mod_serf (requires serf)
  + additionally, mod_firehose doesn't compile on Windows anyway
* buildmark.c isn't necessarily rebuilt when httpd.exe is regenerated
* ApacheMonitor has a build error and is disabled
* CGI examples aren't installed
* and wintty aren't built/installed
* module enablement defaults are not in sync with the autoconf-based build
* no support for static support library builds; unclear if that is a
  requirement; if so: taking PCRE as an example, we'd need to detect that it
  is static and then turn on PCRE_STATIC for the libhttpd build


* Many httpd features have not been tested with this build.
* Developers need to examine the existing Windows build in great detail and see
  what is missing from the cmake-based build, whether a feature or some build
* Any feedback you can provide on your experiences with this build will be