Blame README.cmake

Packit 90a5c9
Experimental cmake-based build support for Apache httpd on Microsoft Windows
Packit 90a5c9
Packit 90a5c9
Status
Packit 90a5c9
------
Packit 90a5c9
Packit 90a5c9
This build support is currently intended only for Microsoft Windows.
Packit 90a5c9
Packit 90a5c9
This build support is experimental.  Specifically,
Packit 90a5c9
Packit 90a5c9
* It does not support all features of Apache httpd.
Packit 90a5c9
* Some components may not be built correctly and/or in a manner
Packit 90a5c9
  compatible with the previous Windows build support.
Packit 90a5c9
* Build interfaces, such as the mechanisms which are used to enable
Packit 90a5c9
  optional functionality or specify prerequisites, may change from
Packit 90a5c9
  release to release as feedback is received from users and bugs and
Packit 90a5c9
  limitations are resolved.
Packit 90a5c9
Packit 90a5c9
Important: Refer to the "Known Bugs and Limitations" section for further
Packit 90a5c9
           information.
Packit 90a5c9
Packit 90a5c9
           It is beyond the scope of this document to document or explain
Packit 90a5c9
           how to utilize the various cmake features, such as different
Packit 90a5c9
           build backends or provisions for finding support libraries.
Packit 90a5c9
Packit 90a5c9
           Please refer to the cmake documentation for additional information
Packit 90a5c9
           that applies to building any project with cmake.
Packit 90a5c9
Packit 90a5c9
Prerequisites
Packit 90a5c9
-------------
Packit 90a5c9
Packit 90a5c9
The following tools must be in PATH:
Packit 90a5c9
Packit 90a5c9
* cmake, version 2.8 or later
Packit 90a5c9
  cmake version 3.1.3 or later is required to work with current OpenSSL
Packit 90a5c9
  releases.  (OpenSSL is an optional prerequisite of httpd.)
Packit 90a5c9
* Perl
Packit 90a5c9
* If the WITH_MODULES feature is used: awk
Packit 90a5c9
* If using a command-line compiler: compiler and linker and related tools
Packit 90a5c9
  (Refer to the cmake documentation for more information.)
Packit 90a5c9
Packit 90a5c9
The following support libraries are mandatory:
Packit 90a5c9
Packit 90a5c9
* APR, built with cmake
Packit 90a5c9
  + Either APR 2.0-dev (trunk) or APR 1.5.x and APR-Util 1.5.x.
Packit 90a5c9
  + When building APR (but not APR-Util), specify the build option
Packit 90a5c9
    APR_INSTALL_PRIVATE_H so that non-standard files required for building
Packit 90a5c9
    Apache httpd are installed.
Packit 90a5c9
  + Additional APR settings affect httpd but are not mandatory, such as
Packit 90a5c9
    APR_HAVE_IPV6.
Packit 90a5c9
* PCRE
Packit 90a5c9
Packit 90a5c9
Certain optional features of APR 2.0-dev (trunk) or APR-Util 1.5.x
Packit 90a5c9
allow some optional features of httpd to be enabled.  For example,
Packit 90a5c9
APU_HAVE_CRYPTO is required for mod_session_crypto.
Packit 90a5c9
Packit 90a5c9
Additional support libraries allow some optional features of httpd to be
Packit 90a5c9
enabled:
Packit 90a5c9
Packit 90a5c9
* libxml2 (e.g., mod_proxy_html)
Packit 90a5c9
* lua 5.1 (mod_lua)
Packit 90a5c9
* nghttp2 (mod_http2)
Packit 90a5c9
* openssl (mod_ssl and https support for ab)
Packit 90a5c9
* zlib (mod_deflate)
Packit 90a5c9
Packit 90a5c9
OpenSSL
Packit 90a5c9
-------
Packit 90a5c9
Packit 90a5c9
If you have a binary install of OpenSSL in a well-known directory (e.g.,
Packit 90a5c9
%HOME%\OpenSSL-Win64) and you wish to build httpd against a different
Packit 90a5c9
install of OpenSSL, the cmake build may unexpectedly select OpenSSL
Packit 90a5c9
libraries in the well-known directory even if the expected include files
Packit 90a5c9
are used.  Check the cmake output from your httpd build to confirm that
Packit 90a5c9
the expected OpenSSL libraries and include files are used.
Packit 90a5c9
Packit 90a5c9
The cmake FindOpenSSL module searches for OpenSSL libraries in a "VC"
Packit 90a5c9
subdirectory of the OpenSSL install with filenames that indicate the build
Packit 90a5c9
type (e.g., "<PREFIX>/lib/VC/ssleay32MD.lib"); defining CMAKE_PREFIX_PATH
Packit 90a5c9
or OPENSSL_ROOT_DIR or even OPENSSL_LIBRARIES does not circumvent finding
Packit 90a5c9
these libraries.
Packit 90a5c9
Packit 90a5c9
To work around this issue, rename the well-known OpenSSL directory while
Packit 90a5c9
building httpd.  Let us know if you find a better solution.
Packit 90a5c9
Packit 90a5c9
nghttp2
Packit 90a5c9
-------
Packit 90a5c9
Packit 90a5c9
This is required for mod_http2.
Packit 90a5c9
Packit 90a5c9
cmake-based build support for nghttp2 for Windows can be found at
Packit 90a5c9
https://github.com/trawick/nghttp2-minimal-cmake.  That easily fits into
Packit 90a5c9
a build system that already uses cmake for httpd, apr, and perhaps other
Packit 90a5c9
packages.  A dynamic build of nghttp2 using its normal Windows build
Packit 90a5c9
system should also be usable by nghttp2.
Packit 90a5c9
Packit 90a5c9
How to build
Packit 90a5c9
------------
Packit 90a5c9
Packit 90a5c9
1. cd to a clean directory for building (i.e., don't build in your
Packit 90a5c9
   source tree)
Packit 90a5c9
Packit 90a5c9
2. Make sure cmake and Perl are in PATH.  Additionally, some backends 
Packit 90a5c9
   require compile tools in PATH.  (Hint: "Visual Studio Command Prompt")
Packit 90a5c9
   In the unlikely event that you use -DWITH_MODULES, described below, make
Packit 90a5c9
   sure awk is in PATH.
Packit 90a5c9
Packit 90a5c9
3. cmake -G "some backend, like 'NMake Makefiles'"
Packit 90a5c9
     -DCMAKE_INSTALL_PREFIX=d:/path/to/httpdinst
Packit 90a5c9
     -DENABLE_foo=A|I|O|a|i
Packit 90a5c9
     -DENABLE_MODULES=A|I|O|a|i
Packit 90a5c9
     d:/path/to/httpdsource
Packit 90a5c9
Packit 90a5c9
   Alternately, you can use the cmake-gui and update settings in the GUI.
Packit 90a5c9
Packit 90a5c9
   PCRE_INCLUDE_DIR, PCRE_LIBRARIES, APR_INCLUDE_DIR, APR_LIBRARIES,
Packit 90a5c9
     NGHTTP2_INCLUDE_DIR, NGHTTP2_LIBRARIES:
Packit 90a5c9
Packit 90a5c9
       cmake doesn't bundle FindXXX for these packages, so the crucial
Packit 90a5c9
       information has to be specified in this manner if they aren't found
Packit 90a5c9
       in their default location.
Packit 90a5c9
Packit 90a5c9
     -DPCRE_INCLUDE_DIR=d:/path/to/pcreinst/include
Packit 90a5c9
     -DPCRE_LIBRARIES=d:/path/to/pcreinst/lib/pcre[d].lib
Packit 90a5c9
Packit 90a5c9
       These will have to be specified only if PCRE is installed to a different
Packit 90a5c9
       directory than httpd, or if debug *and* release builds of PCRE were
Packit 90a5c9
       installed there and you want to control which is used.  (Currently the
Packit 90a5c9
       build will use pcred.lib (debug) if it is found in the default location
Packit 90a5c9
       and not overridden with -DPCRE_LIBRARIES.)
Packit 90a5c9
Packit 90a5c9
     -DAPR_INCLUDE_DIR=d:/path/to/aprinst/include
Packit 90a5c9
     -DAPR_LIBRARIES="d:/path/to/aprinst/lib/libapr-1.lib;d:/path/to/aprinst/lib/libaprutil-1.lib"
Packit 90a5c9
Packit 90a5c9
       These will have to be specified if APR[-Util] was installed to a
Packit 90a5c9
       different directory than httpd.
Packit 90a5c9
Packit 90a5c9
       When building with APR trunk (future APR 2.x, with integrated APR-Util),
Packit 90a5c9
       specify just the path to libapr-2.lib:
Packit 90a5c9
Packit 90a5c9
           -DAPR_LIBRARIES=d:/path/to/aprinst/lib/libapr-2.lib
Packit 90a5c9
Packit 90a5c9
       APR+APR-Util 1.x vs. APR trunk will be detected automatically if they
Packit 90a5c9
       are installed to the same location as httpd.
Packit 90a5c9
Packit 90a5c9
       APR-Util 1.x has an optional LDAP library.  If APR-Util has LDAP enabled
Packit 90a5c9
       and httpd's mod_ldap and mod_authnz_ldap are being used, include the
Packit 90a5c9
       path to the LDAP library in the APR_LIBRARIES setting.  (If APR and
Packit 90a5c9
       APR-Util are found in the default location, the LDAP library will be
Packit 90a5c9
       included if it is present.
Packit 90a5c9
Packit 90a5c9
     -DNGHTTP2_INCLUDE_DIR=d:/path/to/nghttp2inst/include  (which has nghttp2/*.h)
Packit 90a5c9
     -DNGHTTP2_LIBRARIES=d:/path/to/nghttp2inst/lib/nghttp2.lib"
Packit 90a5c9
Packit 90a5c9
       These will have to be specified if nghttp2 was installed to a different
Packit 90a5c9
       directory than httpd.
Packit 90a5c9
Packit 90a5c9
   LIBXML2_ICONV_INCLUDE_DIR, LIBXML2_ICONV_LIBRARIES
Packit 90a5c9
Packit 90a5c9
      If using a module that requires libxml2 *and* the build of libxml2 requires
Packit 90a5c9
      iconv, set these variables to allow iconv includes and libraries to be
Packit 90a5c9
      used.  For example:
Packit 90a5c9
Packit 90a5c9
      -DLIBXML2_ICONV_INCLUDE_DIR=c:\iconv-1.9.2.win32\include
Packit 90a5c9
      -DLIBXML2_ICONV_LIBRARIES=c:\iconv-1.9.2.win32\lib\iconv.lib
Packit 90a5c9
Packit 90a5c9
   CMAKE_C_FLAGS_RELEASE, _DEBUG, _RELWITHDEBINFO, _MINSIZEREL
Packit 90a5c9
   CMAKE_BUILD_TYPE
Packit 90a5c9
Packit 90a5c9
       For NMake Makefiles the choices are at least DEBUG, RELEASE,
Packit 90a5c9
       RELWITHDEBINFO, and MINSIZEREL
Packit 90a5c9
       Other backends may have other selections.
Packit 90a5c9
Packit 90a5c9
   ENABLE_foo:
Packit 90a5c9
Packit 90a5c9
       Each module has a default setting which can be overridden with one of
Packit 90a5c9
       the following values:
Packit 90a5c9
           A        build and Activate module
Packit 90a5c9
           a        build and Activate module IFF prereqs are available; if
Packit 90a5c9
                    prereqs are unavailable, don't build it
Packit 90a5c9
           I        build module but leave it Inactive (commented-out
Packit 90a5c9
                    LoadModule directive)
Packit 90a5c9
           i        build module but leave it Inactive IFF prereqs are
Packit 90a5c9
                    available; if prereqs are unavailable, don't build it
Packit 90a5c9
           O        Omit module completely
Packit 90a5c9
Packit 90a5c9
       Examples: -DENABLE_ACCESS_COMPAT=O
Packit 90a5c9
                 -DENABLE_PROXY_HTML=i
Packit 90a5c9
Packit 90a5c9
   ENABLE_MODULES:
Packit 90a5c9
Packit 90a5c9
       This changes the *minimum* enablement of all modules to the specified
Packit 90a5c9
       value (one of A, a, I, i, O, as described under ENABLE_foo above).
Packit 90a5c9
Packit 90a5c9
       The ranking of enablement from lowest to highest is O, i, I, a, A.
Packit 90a5c9
       If a specific module has a higher rank enablement setting, either from
Packit 90a5c9
       a built-in default or from -DENABLE_foo, ENABLE_MODULES won't affect
Packit 90a5c9
       that module.  However, if a specific module has a lower-rank enablement
Packit 90a5c9
       setting, presumably from a built-in default, the value of ENABLE_MODULES
Packit 90a5c9
       will be used for that module.
Packit 90a5c9
Packit 90a5c9
       Explanations for possible values:
Packit 90a5c9
Packit 90a5c9
       -DENABLE_MODULES=a      build and activate all possible modules,
Packit 90a5c9
                               ignoring any with missing prereqs
Packit 90a5c9
                               (doesn't affect modules with A for ENABLE_foo)
Packit 90a5c9
Packit 90a5c9
       -DENABLE_MODULES=i      build but leave inactive all possible
Packit 90a5c9
                               modules, ignoring any with missing
Packit 90a5c9
                               prereqs
Packit 90a5c9
                               (doesn't affect modules with A, a, or I for 
Packit 90a5c9
                               ENABLE_foo)
Packit 90a5c9
Packit 90a5c9
       -DENABLE_MODULES=O      no impact, since all modules are either
Packit 90a5c9
                               already disabled or have a higher setting
Packit 90a5c9
Packit 90a5c9
       -DENABLE_MODULES=A      build and activate all possible modules,
Packit 90a5c9
                               failing the build if any module is missing
Packit 90a5c9
                               a prereq
Packit 90a5c9
Packit 90a5c9
       -DENABLE_MODULES=I      similar to -DENABLE_MODULES=A
Packit 90a5c9
                               (doesn't affect modules with A or a for
Packit 90a5c9
                               ENABLE_foo)
Packit 90a5c9
Packit 90a5c9
   WITH_MODULES:
Packit 90a5c9
Packit 90a5c9
       Comma-separated paths to single file modules to statically linked into
Packit 90a5c9
       the server, like the --with-module=modpath:/path/to/mod_foo.c with
Packit 90a5c9
       the autoconf-based build.  Key differences: The modpath (e.g., 
Packit 90a5c9
       "generators") isn't provided or used, and the copy of the module
Packit 90a5c9
       source being built is automatically updated when it changes.
Packit 90a5c9
       See also EXTRA_COMPILE_FLAGS, EXTRA_INCLUDES, and EXTRA_LIBS.
Packit 90a5c9
Packit 90a5c9
   EXTRA_COMPILE_FLAGS:
Packit 90a5c9
Packit 90a5c9
       Space-delimited compile flags to define with the build.
Packit 90a5c9
Packit 90a5c9
   EXTRA_INCLUDES:
Packit 90a5c9
Packit 90a5c9
       List of additional directories to search for .h files.  This may
Packit 90a5c9
       be necessary when including third-party modules in the httpd build
Packit 90a5c9
       via WITH_MODULES.
Packit 90a5c9
Packit 90a5c9
   EXTRA_LIBS:
Packit 90a5c9
Packit 90a5c9
       List of additional libraries to link with.  This may be necessary when
Packit 90a5c9
       including third-party modules in the httpd build via WITH_MODULES.
Packit 90a5c9
Packit 90a5c9
   Port and SSLPort:
Packit 90a5c9
Packit 90a5c9
       Port numbers for substitution into default .conf files.  (The defaults
Packit 90a5c9
       are 80 and 443.)
Packit 90a5c9
Packit 90a5c9
   INSTALL_PDB:
Packit 90a5c9
Packit 90a5c9
       If .pdb files are generated for debugging, install them.
Packit 90a5c9
       Default: ON
Packit 90a5c9
Packit 90a5c9
       The .pdb files are generally needed for debugging low-level code
Packit 90a5c9
       problems.  If they aren't installed, they are still available in the
Packit 90a5c9
       build directory for use by alternate packaging implementations or when
Packit 90a5c9
       debugging on the build machine.
Packit 90a5c9
Packit 90a5c9
   INSTALL_MANUAL:
Packit 90a5c9
Packit 90a5c9
       Install the Apache HTTP Server manual.
Packit 90a5c9
       Default: ON
Packit 90a5c9
Packit 90a5c9
       This could be turned off when developing changes in order to speed up
Packit 90a5c9
       installation time.
Packit 90a5c9
Packit 90a5c9
4. Build using the chosen generator (e.g., "nmake install" for cmake's "NMake
Packit 90a5c9
   Makefiles" generator).
Packit 90a5c9
Packit 90a5c9
Running the server and support programs
Packit 90a5c9
---------------------------------------
Packit 90a5c9
Packit 90a5c9
This build system does not copy binaries such as dlls from other projects
Packit 90a5c9
into the httpd install location.  Without taking some precautions, httpd
Packit 90a5c9
and support programs can fail to start or modules can fail to load because
Packit 90a5c9
a support library can't be found in PATH or in the directory of the httpd
Packit 90a5c9
binary.
Packit 90a5c9
Packit 90a5c9
This can be resolved in several different ways:
Packit 90a5c9
Packit 90a5c9
* Install httpd and the various support libraries to a common install
Packit 90a5c9
  prefix so that support libraries and httpd programs are installed in
Packit 90a5c9
  the same bin directory and are found without setting PATH.
Packit 90a5c9
Packit 90a5c9
* Update PATH to include the bin directories of all necessary support
Packit 90a5c9
  libraries.
Packit 90a5c9
Packit 90a5c9
  Depending on where PATH is set, it may not affect starting httpd as
Packit 90a5c9
  a service.
Packit 90a5c9
Packit 90a5c9
* Maintain a script which combines required binaries into a common 
Packit 90a5c9
  location, such as the httpd installion bin directory, and use that
Packit 90a5c9
  script after building or otherwise installing or updating support
Packit 90a5c9
  libraries.
Packit 90a5c9
Packit 90a5c9
* AVOID THE USE of any unrepeatable process of copying dll files around
Packit 90a5c9
  from different install locations until something starts working.  The
Packit 90a5c9
  result is that when you later update a support library to pick up a
Packit 90a5c9
  security fix, httpd will likely continue to use the old, vulnerable
Packit 90a5c9
  library file.
Packit 90a5c9
Packit 90a5c9
Known Bugs and Limitations
Packit 90a5c9
--------------------------
Packit 90a5c9
Packit 90a5c9
* no standard script or makefile is provided to tie together the builds
Packit 90a5c9
  of httpd and support libraries in a manner suitable for typical users
Packit 90a5c9
* no logic to find support libraries or otherwise build these modules:
Packit 90a5c9
  + mod_socache_dc (requires distcache), mod_serf (requires serf)
Packit 90a5c9
  + additionally, mod_firehose doesn't compile on Windows anyway
Packit 90a5c9
* buildmark.c isn't necessarily rebuilt when httpd.exe is regenerated
Packit 90a5c9
* ApacheMonitor has a build error and is disabled
Packit 90a5c9
* CGI examples aren't installed
Packit 90a5c9
* dbmmanage.pl and wintty aren't built/installed
Packit 90a5c9
* module enablement defaults are not in sync with the autoconf-based build
Packit 90a5c9
* no support for static support library builds; unclear if that is a
Packit 90a5c9
  requirement; if so: taking PCRE as an example, we'd need to detect that it
Packit 90a5c9
  is static and then turn on PCRE_STATIC for the libhttpd build
Packit 90a5c9
Packit 90a5c9
Generally:
Packit 90a5c9
Packit 90a5c9
* Many httpd features have not been tested with this build.
Packit 90a5c9
* Developers need to examine the existing Windows build in great detail and see
Packit 90a5c9
  what is missing from the cmake-based build, whether a feature or some build
Packit 90a5c9
  nuance.
Packit 90a5c9
* Any feedback you can provide on your experiences with this build will be
Packit 90a5c9
  helpful.