| 
 
 
 | 
| Keep Server Online 
 If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
 
 or
 
 
   
 A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
 
 Thank You! Steffen
 
 Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
 |  | 
 | 
| | 
| | 
|  Topic: HOWTO: Building Apache and dependencies using CMake | Page 1, 2, 3, 4, 5  Next |  
| Author |  |  
| tangent Moderator
 
 
 Joined: 16 Aug 2020
 Posts: 397
 Location: UK
 
 | 
|  Posted: Fri 18 Dec '20 19:10    Post subject: HOWTO: Building Apache and dependencies using CMake |   |  
| 
 |  
| This is an update to the previous excellent work from idblew and others mentioned in post https://www.apachelounge.com/viewtopic.php?t=6462
 
 Note:
 If you find any issues please report in the Building & Member Downloads forum (not in How-to's & Documentation & Tips NOR this topic)
 
 Improvements or faults you can post here.
 
 Change log :
 
 18 Dec 2020 : 1.0 - Initial release.
 19 Dec 2020 : 1.1 - Switch to Strawberry Perl. Remove LIBSSH2, YAJL and MOD_SECURITY.
 05 Jan 2021 : 1.2 - Add LUA to src tree.
 16 Feb 2021 : 1.3 - Patch CURL build support for OpenSSL. Update CURL , NGHTTP2 and OpenSSL versions.
 27 Aug 2021 : 1.4 - Update CURL, EXPAT, HTTPD, LIBXML2. NGHTTP2, OpenSSL and PCRE versions.
 22 Nov 2021 : 1.5 - Update CURL, HTTPD, JANSSON and NGHTTP2 versions.
 28 Dec 2021 : 1.6 - Update HTTPD and OpenSSL versions.
 14 Jan 2022 : 1.7 - Update EXPAT and CURL versions. Patch APR (1.7.0) handle leak (PR 61165).
 19 Mar 2022 : 1.8 - Update CURL, EXPAT, HTTPD, LUA, NGHTTP2, OpenSSL and PCRE versions.
 13 Jun 2022 : 1.9 - Update CURL, EXPAT, HTTPD, LIBXML2, OpenSSL, PCRE2 and ZLIB versions.
 10 Nov 2022 : 2.0 - Update CURL, EXPAT, LIBXML2, OpenSSL, and ZLIB versions. Default to OpenSSL V3. Set CURL default SSL backend to Schannel rather than OpenSSL.
 05 Feb 2023 : 2.1 - Update APR, APR-UTIL, CURL, HTTPD, NGHTTP2, and PCRE2 versions.
 08 Mar 2023 : 2.2 - Update CURL, HTTPD, NGHTTP2, and OpenSSL versions.
 12 May 2023 : 2.3 - Update APR, CURL, HTTPD, LIBXML2, and OpenSSL versions.
 10 Aug 2023 : 2.4 - Update CURL, LIBXML2, LUA, NGHTTP2, and OpenSSL versions.
 20 Oct 2023 : 2.5 - Update BROTLI, CURL, HTTPD, NGHTTP2, and OpenSSL versions.
 04 Feb 2024 : 2.6 - Patch HTTPD ApacheMonitor.rc file to comment out MANIFEST file reference, which otherwise causes a duplicate resource cvtres/link error following recent updates to VS2022. Update CURL, LIBXML2, NGHTTP2, OpenSSL and ZLIB versions.
 04 Apr 2024 : 2.7 - Update CURL, EXPAT, HTTPD, LIBXML2, NGHTTP2 and PCRE2 versions.
 07 Jun 2024 : 2.8 - Update CURL, LIBXML2, NGHTTP2, OpenSSL and PCRE2 versions.
 25 Jul 2024 : 2.9 - Update HTTPD, LIBXML2 and LUA versions.
 06 Sep 2024 : 3.0 - Update APR, CURL, LIBXML2 NGHTTP2 and OpenSSL versions. Add option to CURL build to disable searching for idn2 library.
 13 Nov 2024 : 3.1 - Update CURL, EXPAT, LIBXML2, and NGHTTP2 versions. Patch HTTPD mod_rewrite.c to apply Eric Coverner's trunk fix patch r1919860 as mentioned in the Apache Lounge 2.4.62 Changelog.
 24 Jan 2025 : 3.2 - Bump CURL (8.11.1), HTTPD (2.4.63) and OPENSSL (3.4.0). 2025-01-24
 01 Mar 2025 : 3.3 - Bump CURL (8.12.1), LIBXML2 (2.13.6), and PCRE (10.45). Regress OPENSSL (3.3.3). Add CURL options to disable using libpsl and libssh2. Add BUILD_TYPE option support to OpenSSL.
 08 Apr 2025 : 3.4 - Bump CURL (8.13.0), EXPAT (2.7.1), JANSSON (2.14.1), LIBXML2 (2.14.1), and NGHTTP2 (1.65.0). Don't define VCVARSALL variable if already set. Drop support for old PCRE series and revise CMake options. Switch LIBXML2 build to using CMake. Revise CURL CMake config to prevent possible command line overflow. Resolve mod_session_crypto issue by updating APR-UTIL build to use OpenSSL with APU_HAVE_CRYPTO. Refine script logic when BUILD_TYPE is set to DEBUG.
 10 Jul 2025 : 3.5 - Bump APR (1.7.6), CURL (8.14.1), HTTPD (2.4.64), LIBXML2 (2.14.4), LUA (5.4.8), NGHTTP2 (1.66.0), and OPENSSL (3.5.1). Drop OpenSSL 1.x series. Build CURL shared and static libs at same time. Build HTTPD mod_log_rotate (JBlond) module if source file present.
 25 Jul 2025 : 3.6 - Bump CURL (8.15.0), HTTPD (2.4.65), LIBXML2 (2.14.5).
 05 Aug 2025 : 3.7 - Patch HTTPD CMakeLists.txt file to build WinTTY console binary.
 09 Aug 2025 : 3.8 - Rework LUA CMakeLists.txt file patch, and CURL edits to match code updates.
 11 Aug 2025 : 3.9 - Refine LIBXML2 CMake options, correct APR-UTIL string check logic, plus CURL edit comment.
 02 Oct 2025 : 4.0 - Bump CURL (8.16.0), EXPAT (2.7.3), LIBXML2 (2.15.0), NGHTTP2 (1.67.1), OPENSSL (3.5.4) and PCRE2 (10.46). Remove PCRE2 CMakeLists.txt patch (no longer needed), and simliarly LIBXML2 CMake option for LZMA.
 
 The following topics gives some additional backgound on the choices made for building CURL
 https://www.apachelounge.com/viewtopic.php?p=39886
 https://www.apachelounge.com/viewtopic.php?p=41513
 
 In this variant I have chosen a command line solution, developing a batch file (post below) to build the required packages from source. I've not used GitHub to directly download sources, since I wanted a solution that would build without an active Internet connection.
 
 This build process requires a suitable Windows based platform, onto which which you can install and configure the necessary toolsets, viz:
 
 Visual Studio Build Tools 2022
Since October 2024, Microsoft has regretfully suspended availability of their Windows 11 virtual machine images at https://developer.microsoft.com/en-us/windows/downloads/virtual-machines, so for now you will need to provision a suitable alternative.Visual Studio Community 2022 (optional)
 CMake for Windows - (bundled with Visual Studio)
 Strawberry Perl - (no later than version 5.32.1.1 if you need to support 32-bit builds)
 Netwide Assembler (NASM)
 
 Several members have requested details on building ZLIB, LUA, APR-ICONV, etc., and these are covered in the process below using CMake where possible, and NMake.
 
 Sequence
 
 Preparation
Prepare the following structure with source folders based on the appropriate version of each package you choose to build. This list matches the latest package versions at the time of writing.
 
 You can of course change the folder path names in the source tree (no whitespace advised), updating the paths in the build batch file accordingly.
 
 
  	  | Code: |  	  | C:\Development └ Apache24
 ├ src
 │   ├ apr-1.7.6
 │   ├ apr-iconv-1.2.2
 │   ├ apr-util-1.6.3
 │   ├ brotli-1.1.0
 │   ├ curl-8.16.0
 │   ├ expat-2.7.3
 │   ├ httpd-2.4.65
 │   ├ jansson-2.14.1
 │   ├ libxml2-2.15.0
 │   ├ lua-5.4.8
 │   ├ mod_fcgid-2.3.9
 │   ├ nghttp2-1.67.1
 │   ├ openssl-3.5.4
 │   ├ pcre2-10.46
 │   └ zlib-1.3.1
 │
 └ build
 | 
 Note you don't need to prepare sub-folders below 'build', which get created during build process.
 
 Source Packages
 Download and extract the required packages (*.tar.gz  or *.zip format) into the appropriate source folders shown above. I use 7-Zip to extract the package files from source archives.
 
 Note, the build batch file does patch source files where necessary (using Perl), but you may well wish to apply later security patches and updates manually to the source structures as appropriate.
 
 Build Batch File
 Download the build batch file code from the post below in this thread, and save it in the above 'build' folder as build_all.bat
 
 a) Edit the build batch file to set BUILD_BASE as required, if using a different path to that above.
 b) Update the target PREFIX, if the default location of C:\Apache24 isn't acceptable (again no whitespace advised).
 c) Choose 32 or 64 bit builds by setting the PLATFORM variable in the build batch file to x86 or x64 as required.
 d) Similarly, set the variable BUILD_TYPE to Release or Debug.
 e) Update the path to the vcvarsall.bat file if need be to match your Visual Studio toolset.
 f) Edit the package version details to match your downloads as appropriate.
 g) Set the CURL_USE_OPENSSL variable to OFF if you don't want to build CURL with OpenSSL support.
 h) Comment out the CURL_DEFAULT_SSL_BACKEND variable if you want the default CURL backend to be OpenSSL.
 
 Additional Notes
 a) The build process doesn't clear source folders in case they've been patched. However, the package folder below 'build' is deleted each time.
 b) Package EXPAT is now required when building APR-UTIL
 c) Building APR-ICONV will rebuild APR using NMake, the output of which goes into the APR source folder rather than the build folder.
 d) CMakeLists.txt for LUA 5.4 is an extra file which can be downloaded from https://pastebin.com/i5aSxa2G (for LUA 5.3 CMakeLists.txt can be downloaded from https://pastebin.com/QtHm9nLC).
 e) HTTPD 2.4.48 onwards builds with LUA 5.4, with no need to patch the mod_lua source module.
 f) You may choose to build further packages to provide additional functionality in CURL and NGHTTP2, e.g. packages LIBPSL, LIBSSH2, NGHTTP3, NGTCP2, ZSTANDARD, PYTHON, etc. These are currently beyond the scope of this HOWTO but can be added using similar build logic.
 g) It may be necessary to turn off real time AV scanning to prevent file lock failures during the build process.
 h) The various Perl inline patch edit sections may look daunting but note there are numerous ^ escape characters in there to cope with the vagaries of batch file continuation lines, embedded double quotes, and right parentheses in "if then else" blocks.
 
 Build
 Open a command or Powershell window with administrative rights, change to the above build folder, and run the build_all.bat batch file. Ideally, redirect the build process output to a log file so you can check for errors. If using Powershell, you can use the tee command, viz:
 
 
  	  | Code: |  	  | C:\Development\Apache24\build> .\build_all.bat 2>&1 | tee build_all.log | 
 N.B A Windows native binary of tee can be found still at https://gnuwin32.sourceforge.net/packages/coreutils.htm
 
 Checks
 When finished search the log file output for fatal errors (hopefully none).
 
 Confirm Apache files have been created below PREFIX and run as expected, viz:
 
 
  	  | Code: |  	  | cd /d C:\Apache24\bin .\openssl version
 .\httpd -V
 .\httpd -X
 | 
 I hope people find this updated HOWTO useful.
 
 Last edited by tangent on Thu 02 Oct '25 22:05; edited 41 times in total
 |  |  
| Back to top |  |  
| tangent Moderator
 
 
 Joined: 16 Aug 2020
 Posts: 397
 Location: UK
 
 | 
|  Posted: Fri 18 Dec '20 19:11    Post subject: |   |  
| 
 |  
| Change log: 
 18 Dec 2020 : 1.0 - Initial release.
 19 Dec 2020 : 1.1 - Switch CURL to SCHANNEL for mod_md. Remove LIBSSH2, YAJL and MOD_SECURITY. Add LUA_COMPAT_ALL compile option to LUA.
 03 Jan 2021 : 1.2 - Move CURL build after NGHTTP2 and update options to include HTTP2, BROTLI and UNICODE.
 16 Feb 2021 : 1.3 - Patch CURL build support for OpenSSL to force use of native CA store on Windows. Request CURL builds with LDAPS support (Schannel based).
 27 Aug 2021 : 1.4 - Update CURL , EXPAT, HTTPD, LIBXML2. NGHTTP2, OpenSSL and PCRE versions.
 22 Nov 2021 : 1.5 - Update CURL, HTTPD, JANSSON and NGHTTP2 versions.
 28 Dec 2021 : 1.6 - Update HTTPD and OpenSSL versions.
 14 Jan 2022 : 1.7 - Update EXPAT and CURL versions. Patch APR (1.7.0) handle leak (PR 61165).
 19 Mar 2022 : 1.8 - Update CURL, EXPAT, HTTPD, LUA, NGHTTP2, OpenSSL and PCRE versions. Provide options to build PCRE2 rather than PCRE, and similarly build OpenSSL3 rather than OpenSSL.
 13 Jun 2022 : 1.9 - Update CURL, EXPAT, HTTPD, LIBXML2, OpenSSL, PCRE2 and ZLIB versions.
 10 Nov 2022 : 2.0 - Update CURL, EXPAT, LIBXML2, OpenSSL, and ZLIB versions. Default to OpenSSL V3. Set CURL default SSL backend to Schannel rather than OpenSSL.
 05 Feb 2023 : 2.1 - Update APR, APR-UTIL, CURL, HTTPD, NGHTTP2, and PCRE2 versions.
 08 Mar 2023 : 2.2 - Update CURL, HTTPD, NGHTTP2, and OpenSSL versions.
 12 May 2023 : 2.3 - Update APR, CURL, HTTPD, LIBXML2, and OpenSSL versions.
 10 Aug 2023 : 2.4 - Update CURL, LIBXML2, LUA, NGHTTP2, and OpenSSL versions.
 20 Oct 2023 : 2.5 - Update BROTLI, CURL, HTTPD, NGHTTP2, and OpenSSL versions.
 04 Feb 2024 : 2.6 - Patch HTTPD ApacheMonitor.rc file to comment out MANIFEST file reference, which otherwise causes a duplicate resource cvtres/link error following recent updates to VS2022. Update CURL, LIBXML2, NGHTTP2, OpenSSL and ZLIB versions.
 04 Apr 2024 : 2.7 - Update CURL, EXPAT, HTTPD, LIBXML2, NGHTTP2 and PCRE2 versions.
 07 Jun 2024 : 2.8 - Update CURL, LIBXML2, NGHTTP2, OpenSSL and PCRE2 versions.
 25 Jul 2024 : 2.9 - Update HTTPD, LIBXML2 and LUA versions.
 06 Sep 2024 : 3.0 - Update APR, CURL, LIBXML2 NGHTTP2 and OpenSSL versions. Add option to CURL build to disable searching for idn2 library.
 13 Nov 2024 : 3.1 - Update CURL, EXPAT, LIBXML2, and NGHTTP2 versions. Patch HTTPD mod_rewrite.c to apply Eric Coverner's trunk fix patch r1919860 as mentioned in the Apache Lounge 2.4.62 Changelog.
 24 Jan 2025 : 3.2 - Bump CURL (8.11.1), HTTPD (2.4.63) and OPENSSL (3.4.0).
 01 Mar 2025 : 3.3 - Bump CURL (8.12.1), LIBXML2 (2.13.6), and PCRE (10.45). Regress OPENSSL (3.3.3). Add CURL options to disable using libpsl and libssh2. Add BUILD_TYPE option support to OpenSSL.
 08 Apr 2025 : 3.4 - Bump CURL (8.13.0), EXPAT (2.7.1), JANSSON (2.14.1), LIBXML2 (2.14.1), and NGHTTP2 (1.65.0). Don't define VCVARSALL variable if already set. Drop support for old PCRE series and revise CMake options. Switch LIBXML2 build to using CMake. Revise CURL CMake config to prevent possible command line overflow. Resolve mod_session_crypto issue by updating APR-UTIL build to use OpenSSL with APU_HAVE_CRYPTO. Refine script logic when BUILD_TYPE is set to DEBUG.
 10 Jul 2025 : 3.5 - Bump APR (1.7.6), CURL (8.14.1), HTTPD (2.4.64), LIBXML2 (2.14.4), LUA (5.4.8), NGHTTP2 (1.66.0), and OPENSSL (3.5.1). Drop OpenSSL 1.x series. Build CURL shared and static libs at same time. Build HTTPD mod_log_rotate (JBlond) module if source file present.
 25 Jul 2025 : 3.6 - Bump CURL (8.15.0), HTTPD (2.4.65), LIBXML2 (2.14.5).
 05 Aug 2025 : 3.7 - Patch HTTPD CMakeLists.txt file to build WinTTY console binary.
 09 Aug 2025 : 3.8 - Rework LUA CMakeLists.txt file patch, and CURL edits to match code updates.
 11 Aug 2025 : 3.9 - Refine LIBXML2 CMake options, correct APR-UTIL string check logic, plus CURL edit comment.
 02 Oct 2025 : 4.0 - Bump CURL (8.16.0), EXPAT (2.7.3), LIBXML2 (2.15.0), NGHTTP2 (1.67.1), OPENSSL (3.5.4) and PCRE2 (10.46). Remove PCRE2 CMakeLists.txt patch (no longer needed), and simliarly LIBXML2 CMake option for LZMA.
 
 
  	  | Code: |  	  | @echo off 
 rem @(#)build_all.bat 4.0 - 2025-10-02 tangent
 rem
 rem 1.0 - Initial release. 2020-12-17
 rem 1.1 - Switch CURL to Schannel (WinSSL) rather than OpenSSL, for mod_md.
 rem       Accordingly, remove LIBSSH2. Remove YAJL and MOD_SECURITY since not core
 rem       ASF/Apache modules. Add LUA_COMPAT_ALL compile option to LUA. 2020-12-18
 rem 1.2 - Move CURL build after NGHTTP2 and update options to include HTTP2, BROTLI and UNICODE. 2021-01-03
 rem 1.3 - Use OpenSSL (conditionally) with CURL and patch to force use of native CA store on Windows.
 rem       Request CURL builds with LDAPS support (Schannel based). 2021-02-16
 rem 1.4 - Remove extraneous CMake INSTALL_MSVC_PDB option entries.
 rem       Bump releases: PCRE (8.45), EXPAT (2.4.1), OPENSSL (1.1.1l), LIBXML2 (2.9.12),
 rem       LUA (5.4.3), NGHTTP2 (1.44.0), CURL (7.78.0), HTTPD (2.4.48). 2021-08-27
 rem 1.5 - Bump releases: JANSSON (2.14), NGHTTP2 (1.46.0), CURL (7.80.0), HTTPD (2.4.51). 2021-11-22
 rem 1.6 - Bump releases: HTTPD (2.4.52), OpenSSL (1.1.1m). 2021-12-28
 rem 1.7 - Bump EXPAT (2.4.2), CURL (7.81.0). Change LUA option LUA_COMPAT_ALL to LUA_COMPAT_5_3.
 rem       Patch APR (1.7.0) handle leak (PR 61165 [Ivan Zhakov]). Refine Perl patch edits.
 rem       Update VCVARSALL script path for MS Visual Studio 2022 (VS17). 2022-01-14
 rem 1.8 - Bump CURL (7.82.0), EXPAT (2.4.7), HTTPD (2.4.53), LUA (5.4.4), NGHTTP2 (1.47.0),
 rem       OPENSSL (1.1.1n/3.0.2), PCRE2 (10.39). Provide options to build PCRE2 rather than PCRE,
 rem       and similarly build OpenSSL3 rather than OpenSSL. 2022-03-17
 rem 1.9 - Bump CURL (7.83.1), EXPAT (2.4.8), HTTPD (2.4.54), LIBXML2 (2.9.14), OPENSSL (1.1.1o/3.0.3),
 rem       PCRE2 (10.40), ZLIB (1.2.12). 2022-06-13
 rem 2.0 - Bump CURL (7.86.0), EXPAT (2.5.0), LIBXML2 (2.10.3), OPENSSL (1.1.1s/3.0.7), ZLIB (1.2.13).
 rem       Add option to set CURL default SSL backend to Schannel rather than OpenSSL. 2022-11-10
 rem 2.1 - Bump APR (1.7.2), APR-UTIL (1.6.3), CURL (7.87.0), HTTPD (2.4.55), NGHTTP2 (1.51.0),
 rem       PCRE2 (10.42). 2023-02-05
 rem 2.2 - Bump CURL (7.88.1), HTTPD (2.4.56), NGHTTP2 (1.52.0), OPENSSL (1.1.1t/3.0.8). 2023-03-08
 rem 2.3 - Bump APR (1.7.4), CURL (8.0.1), HTTPD (2.4.57), LIBXML2 (2.11.2), OPENSSL (1.1.1t/3.1.0). 2023-05-12
 rem 2.4 - Bump CURL (8.2.1), LIBXML2 (2.11.5), LUA (5.4.6), NGHTTP2 (1.55.1), OPENSSL (1.1.1v/3.1.2). 2023-08-10
 rem 2.5 - Bump BROTLI (1.1.0), CURL (8.4.0), HTTPD (2.4.58), NGHTTP2 (1.57.0), OPENSSL (1.1.1w/3.1.3). 2023-10-20
 rem 2.6 - Patch HTTPD ApacheMonitor.rc file to comment out MANIFEST file reference, which otherwise
 rem       causes a duplicate resource cvtres/link error following recent updates to VS2022.
 rem       Bump CURL (8.6.0), LIBXML2 (2.12.5), NGHTTP2 (1.59.0), OPENSSL (3.1.5), ZLIB (1.3.1). 2024-02-04
 rem 2.7 - Bump CURL (8.7.1), EXPAT (2.6.2), HTTPD (2.4.59), LIBXML2 (2.12.6), NGHTTP2 (1.61.0), PCRE2 (10.43). 2024-04-04
 rem 2.8 - Bump CURL (8.8.0), LIBXML2 (2.12.7), NGHTTP2 (1.62.1), OPENSSL (3.1.6), PCRE2 (10.44). 2024-06-07
 rem 2.9 - Bump HTTPD (2.4.62), LIBXML2 (2.13.2), LUA (5.4.7). 2024-07-25
 rem 3.0 - Bump APR (1.7.5), CURL (8.9.1), LIBXML2 (2.13.3), NGHTTP2 (1.63.0), OPENSSL (3.1.17).
 rem       Add option to CURL build to disable searching for idn2 library. 2024-09-06
 rem 3.1 - Bump CURL (8.11.0), EXPAT (2.6.4), LIBXML2 (2.13.5), NGHTTP2 (1.64.0). Patch mod_rewrite.c
 rem       to apply Eric Coverner's patch r1919860 as mentioned in the Apache Lounge 2.4.62 Changelog.
 rem       Expose result of mklink command when creating APR symbolic links, in case it fails. 2024-11-13
 rem 3.2 - Bump CURL (8.11.1), HTTPD (2.4.63), and OPENSSL (3.4.0). 2025-01-24
 rem 3.3 - Bump CURL (8.12.1), LIBXML2 (2.13.6), and PCRE (10.45). Regress OPENSSL (3.3.3).
 rem       Add options to CURL build to disable using libpsl and libssh2 libraries.
 rem       Add BUILD_TYPE option support to OpenSSL. 2025-03-01
 rem 3.4 - Bump CURL (8.13.0), EXPAT (2.7.1), JANSSON (2.14.1), LIBXML2 (2.14.1), and NGHTTP2 (1.65.0).
 rem       Don't define VCVARSALL variable if already set. Drop support for old PCRE series and revise CMake options.
 rem       Switch LIBXML2 build to using CMake. Revise CURL CMake config to prevent possible command line overflow.
 rem       Resolve mod_session_crypto issue by updating APR-UTIL build to use OpenSSL with APU_HAVE_CRYPTO.
 rem       Refine script logic when BUILD_TYPE is set to DEBUG. 2025-04-08
 rem 3.5 - Bump APR (1.7.6), CURL (8.14.1), HTTPD (2.4.64), LIBXML2 (2.14.4), LUA (5.4.8), NGHTTP2 (1.66.0),
 rem       and OPENSSL (3.5.1). Drop OpenSSL 1.x series. Build CURL shared and static libs at same time.
 rem       Build HTTPD mod_log_rotate (JBlond) module if source file present. 2025-07-10
 rem 3.6 - Bump CURL (8.15.0), HTTPD (2.4.65), LIBXML2 (2.14.5). 2025-07-25
 rem 3.7 - Patch HTTPD CMakeLists.txt file to build WinTTY console binary. 2025-08-05
 rem 3.8 - Rework LUA CMakeLists.txt file patch, and CURL edits to match code updates. 2025-08-09
 rem 3.9 - Refine LIBXML2 CMake options, correct APR-UTIL string check logic, plus CURL edit comment. 2025-08-11
 rem 4.0 - Bump CURL (8.16.0), EXPAT (2.7.3), LIBXML2 (2.15.0), NGHTTP2 (1.67.1), OPENSSL (3.5.4) and PCRE2 (10.46).
 rem       Remove PCRE2 CMakeLists.txt patch (no longer needed), and simliarly LIBXML2 CMake option for LZMA. 2025-10-02
 
 rem Apache build command file for Windows.
 rem
 setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
 
 rem Set required build base folder and target prefix.
 rem
 set BUILD_BASE=C:\Development\Apache24\build
 set PREFIX=C:\Apache24
 
 rem Set required build platform to x86 or x64.
 rem
 rem set PLATFORM=x86
 set PLATFORM=x64
 
 rem Set required build type to Release or Debug.
 rem
 rem set BUILD_TYPE=Debug
 set BUILD_TYPE=Release
 
 rem Request PDB files - ON or OFF.
 rem
 set INSTALL_PDB=OFF
 
 rem Define build packages with their version. This is also the recommended build order.
 
 set ZLIB=zlib-1.3.1
 set PCRE2=pcre2-10.46
 set EXPAT=expat-2.7.3
 set OPENSSL=openssl-3.5.4
 set LIBXML2=libxml2-2.15.0
 set JANSSON=jansson-2.14.1
 set BROTLI=brotli-1.1.0
 set LUA=lua-5.4.8
 set APR=apr-1.7.6
 set APR-ICONV=apr-iconv-1.2.2
 set APR-UTIL=apr-util-1.6.3
 set NGHTTP2=nghttp2-1.67.1
 set CURL=curl-8.16.0
 set HTTPD=httpd-2.4.65
 set MOD_FCGID=mod_fcgid-2.3.9
 
 rem Use OpenSSL with CURL - ON or OFF.
 rem
 set CURL_USE_OPENSSL=ON
 rem
 rem Specify CURL default SSL backend. Defaults to OpenSSL if not specified.
 rem NB - you can change the SSL backend at run time with environment variable CURL_SSL_BACKEND.
 rem
 set CURL_DEFAULT_SSL_BACKEND=SCHANNEL
 
 rem ------------------------------------------------------------------------------
 rem
 rem Define path to MS Visual Studio build environment script.
 
 if not defined VCVARSALL (
 set "VCVARSALL=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat"
 )
 if exist "%VCVARSALL%" (
 call "%VCVARSALL%" %PLATFORM%
 ) else (
 echo Could not find "%VCVARSALL%"
 exit /b
 )
 
 rem ------------------------------------------------------------------------------
 rem
 rem ZLIB
 
 rem Check for package and switch to source folder.
 rem
 call :check_package_source %ZLIB%
 
 if !STATUS! == 0 (
 set ZLIB_CMAKE_OPTS=-DCMAKE_INSTALL_PREFIX=%PREFIX% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DBUILD_SHARED_LIBS=ON -DINSTALL_PKGCONFIG_DIR=%PREFIX%/lib/pkgconfig
 call :build_package %ZLIB% "!ZLIB_CMAKE_OPTS!" & if not !STATUS! == 0 exit /b !STATUS!
 )
 
 rem ------------------------------------------------------------------------------
 rem
 rem PCRE2
 
 rem Check for package and switch to source folder.
 rem
 call :check_package_source %PCRE2%
 
 if !STATUS! == 0 (
 set PCRE2_CMAKE_OPTS=-DCMAKE_INSTALL_PREFIX=%PREFIX% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DBUILD_SHARED_LIBS=ON -DPCRE2_BUILD_TESTS=OFF -DPCRE2_BUILD_PCRE2GREP=OFF -DPCRE2_SUPPORT_JIT=OFF -DPCRE2_SUPPORT_UNICODE=ON -DPCRE2_NEWLINE=CRLF -DINSTALL_MSVC_PDB=%INSTALL_PDB%
 call :build_package %PCRE2% "!PCRE2_CMAKE_OPTS!" & if not !STATUS! == 0 exit /b !STATUS!
 )
 
 rem ------------------------------------------------------------------------------
 rem
 rem EXPAT
 
 rem Check for package source folder.
 rem
 call :check_package_source %EXPAT%
 
 if !STATUS! == 0 (
 set EXPAT_CMAKE_OPTS=-DCMAKE_INSTALL_PREFIX=%PREFIX% -DCMAKE_BUILD_TYPE=%BUILD_TYPE%
 call :build_package %EXPAT% "!EXPAT_CMAKE_OPTS!" & if not !STATUS! == 0 exit /b !STATUS!
 )
 
 rem ------------------------------------------------------------------------------
 rem
 rem OPENSSL
 
 rem Check for package and switch to source folder.
 rem
 call :check_package_source %OPENSSL%
 
 if !STATUS! == 0 (
 echo. & echo Building %OPENSSL%
 
 if /i "%PLATFORM%" == "x64" (
 set OS_COMPILER=VC-WIN64A
 ) else (
 set OS_COMPILER=VC-WIN32
 )
 
 if /i "%BUILD_TYPE%" == "Release" (
 set OPENSSL_BUILD_TYPE=--release
 ) else (
 set OPENSSL_BUILD_TYPE=--debug
 )
 set OPENSSL_CONFIGURE_OPTS=--prefix=%PREFIX% --libdir=lib --openssldir=%PREFIX%\conf --with-zlib-include=%PREFIX%\include shared zlib-dynamic enable-camellia no-idea no-mdc2 %OPENSSL_BUILD_TYPE%
 
 perl Configure !OS_COMPILER! !OPENSSL_CONFIGURE_OPTS! & call :get_status
 if !STATUS! == 0 (
 if exist makefile (
 if /i "%INSTALL_PDB%"=="OFF" (
 perl -pi.bak -e ^" ^
 s~^(INSTALL_.*PDBS=^).*~${1}nul~; ^
 ^" makefile
 )
 rem Make clean not distclean, else Makefile gets deleted.
 rem
 nmake clean 2>nul
 nmake & call :get_status
 if !STATUS! == 0 (
 nmake install & call :get_status
 if not !STATUS! == 0 (
 echo nmake install for %OPENSSL% failed with status !STATUS!
 exit /b !STATUS!
 )
 ) else (
 echo nmake for %OPENSSL% failed with status !STATUS!
 exit /b !STATUS!
 )
 ) else (
 echo Cannot find Makefile for %OPENSSL% in !SRC_DIR!
 exit /b !STATUS!
 )
 ) else (
 echo perl configure for %OPENSSL% failed with status !STATUS!
 exit /b !STATUS!
 )
 )
 
 rem ------------------------------------------------------------------------------
 rem
 rem LIBXML2
 
 rem Check for package and switch to source folder.
 rem
 call :check_package_source %LIBXML2%
 
 if !STATUS! == 0 (
 if /i "%BUILD_TYPE%" == "Release" (
 set LIBXML2_DEBUG_MODULE=OFF
 ) else (
 set LIBXML2_DEBUG_MODULE=ON
 )
 set LIBXML2_CMAKE_OPTS=-DCMAKE_INSTALL_PREFIX=%PREFIX% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DBUILD_SHARED_LIBS=ON -DLIBXML2_WITH_ICONV=OFF -DLIBXML2_WITH_PYTHON=OFF -DLIBXML2_WITH_ZLIB=ON -DLIBXML2_WITH_DEBUG=!LIBXML2_DEBUG_MODULE!
 call :build_package %LIBXML2% "!LIBXML2_CMAKE_OPTS!" & if not !STATUS! == 0 exit /b !STATUS!
 )
 
 rem ------------------------------------------------------------------------------
 rem
 rem JANSSON
 
 rem Check for package and switch to source folder.
 rem
 call :check_package_source %JANSSON%
 
 if !STATUS! == 0 (
 set JANSSON_CMAKE_OPTS=-DCMAKE_INSTALL_PREFIX=%PREFIX% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DJANSSON_BUILD_SHARED_LIBS=ON -DJANSSON_BUILD_DOCS=OFF -DJANSSON_INSTALL_CMAKE_DIR=lib/cmake/jansson
 call :build_package %JANSSON% "!JANSSON_CMAKE_OPTS!" & if not !STATUS! == 0 exit /b !STATUS!
 )
 
 rem ------------------------------------------------------------------------------
 rem
 rem BROTLI
 
 rem Check for package and switch to source folder.
 rem
 call :check_package_source %BROTLI%
 
 if !STATUS! == 0 (
 set BROTLI_CMAKE_OPTS=-DCMAKE_INSTALL_PREFIX=%PREFIX% -DCMAKE_BUILD_TYPE=%BUILD_TYPE%
 call :build_package %BROTLI% "!BROTLI_CMAKE_OPTS!" & if not !STATUS! == 0 exit /b !STATUS!
 )
 
 rem ------------------------------------------------------------------------------
 rem
 rem LUA
 
 rem Check for package and switch to source folder.
 rem
 call :check_package_source %LUA%
 
 if !STATUS! == 0 (
 rem Patch CMakeLists.txt to add LUA_COMPAT_5_X compile options.
 rem
 perl -pi.bak -e ^" ^
 s~( LUA_COMPAT_ALL ^)(^\^)^)~${1}LUA_COMPAT_5_1 LUA_COMPAT_5_2 LUA_COMPAT_5_3 ${2}~; ^
 ^" CMakeLists.txt
 
 set LUA_CMAKE_OPTS=-DCMAKE_INSTALL_PREFIX=%PREFIX% -DCMAKE_BUILD_TYPE=%BUILD_TYPE%
 call :build_package %LUA% "!LUA_CMAKE_OPTS!" & if not !STATUS! == 0 exit /b !STATUS!
 )
 
 rem ------------------------------------------------------------------------------
 rem
 rem APR
 
 rem Check for package and switch to source folder.
 rem
 call :check_package_source %APR%
 
 if !STATUS! == 0 (
 rem Patch apr.hw - _WIN32_WINT to 0x600 series - needed for APR-ICONV build.
 perl -pi.bak -e ^" ^
 s~(#define _WIN32_WINNT ^)0x05\d\d$~${1}0x0600~; ^
 ^" include\apr.hw
 
 set APR_CMAKE_OPTS=-DCMAKE_INSTALL_PREFIX=%PREFIX% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DMIN_WINDOWS_VER=0x0600 -DAPR_HAVE_IPV6=ON -DAPR_INSTALL_PRIVATE_H=ON -DAPR_BUILD_TESTAPR=OFF -DINSTALL_PDB=%INSTALL_PDB%
 call :build_package %APR% "!APR_CMAKE_OPTS!" & if not !STATUS! == 0 exit /b !STATUS!
 )
 
 rem ------------------------------------------------------------------------------
 rem
 rem APR-ICONV
 
 rem Note APR-ICONV makefiles rebuild APR since the above CMake puts the build files elsewhere.
 
 rem Check for package and switch to source folder.
 rem
 call :check_package_source %APR-ICONV%
 
 if !STATUS! == 0 (
 echo. & echo Building %APR-ICONV%
 
 rem Create non-version specific folder links to the APR, APR-ICONV and APR-UTIL sources.
 rem The various makefiles assume these exist.
 rem
 pushd "%BUILD_BASE%\..\src"
 mklink /d apr %APR%
 mklink /d apr-iconv %APR-ICONV%
 mklink /d apr-util %APR-UTIL%
 popd
 
 rem Copy apr.h and apr_escape_test_char.h from APR build into API source.
 rem
 copy /y "%BUILD_BASE%\apr\apr*.h" ".\include" 1>nul
 copy /y "%BUILD_BASE%\apr\apr_escape_test_char.h" "..\%APR%\include" 1>nul
 
 rem Choose platform options; reference as delayed expansion variables.
 rem
 if /i "%PLATFORM%" == "x64" (
 set BUILD_CFG=x64
 set BUILD_DIR=x64
 ) else (
 set BUILD_CFG=Win32
 set BUILD_DIR=.
 )
 
 rem Patch modules.mk.win for x64 Debug
 rem
 perl -pi.bak -e ^" ^
 m~(APR_SOURCE\^)\\^)(.+\\^)(Debug\\libapr-1^)~;{${2} ? $s=${2} : $s=$s}; ^
 s~(API_SOURCE\^)\\^)(Debug\\libapriconv-1^)~{$s ? ${1}.$s.${2} : $^&}~e; ^
 s~(CFG_OUTPUT  = ^)(Debug\\iconv^)~{$s ? ${1}.$s.${2} : $^&}~e; ^
 ^" build\modules.mk.win
 
 rmdir /s /q Debug LibD LibR Release x64 1>nul 2>&1
 nmake /f apriconv.mak CFG="apriconv - !BUILD_CFG! %BUILD_TYPE%" & call :get_status
 if not !STATUS! == 0 (
 echo nmake apriconv.mak for %APR-ICONV% failed with status !STATUS!
 exit /b !STATUS!
 )
 nmake /f libapriconv.mak CFG="libapriconv - !BUILD_CFG! %BUILD_TYPE%" & call :get_status
 if not !STATUS! == 0 (
 echo nmake libapriconv.mak for %APR-ICONV% failed with status !STATUS!
 exit /b !STATUS!
 )
 pushd ccs
 nmake /f Makefile.win BUILD_MODE="!BUILD_CFG! %BUILD_TYPE%" BIND_MODE="shared" & call :get_status
 if not !STATUS! == 0 (
 echo nmake ccs Makefile.win for %APR-ICONV% failed with status !STATUS!
 exit /b !STATUS!
 )
 popd
 pushd ces
 nmake /f Makefile.win BUILD_MODE="!BUILD_CFG! %BUILD_TYPE%" BIND_MODE="shared" & call :get_status
 if not !STATUS! == 0 (
 echo nmake ces Makefile.win for %APR-ICONV% failed with status !STATUS!
 exit /b !STATUS!
 )
 popd
 
 rem Manual install required with apr-iconv
 rem
 if exist "!BUILD_DIR!\LibD\apriconv-1.lib" (
 echo -- Installing: "%PREFIX%\lib\apriconv-1.lib"
 copy /b /y "!BUILD_DIR!\LibD\apriconv-1.lib" "%PREFIX%\lib" 1>nul 2>&1
 )
 if exist "!BUILD_DIR!\LibR\apriconv-1.lib" (
 echo -- Installing: "%PREFIX%\lib\apriconv-1.lib"
 copy /b /y "!BUILD_DIR!\LibR\apriconv-1.lib" "%PREFIX%\lib" 1>nul 2>&1
 )
 if exist "!BUILD_DIR!\%BUILD_TYPE%\libapriconv-1.lib" (
 echo -- Installing: "%PREFIX%\lib\libapriconv-1.lib"
 copy /b /y "!BUILD_DIR!\%BUILD_TYPE%\libapriconv-1.lib" "%PREFIX%\lib" 1>nul 2>&1
 )
 if exist "!BUILD_DIR!\%BUILD_TYPE%\libapriconv-1.dll" (
 echo -- Installing: "%PREFIX%\bin\libapriconv-1.dll"
 copy /b /y "!BUILD_DIR!\%BUILD_TYPE%\libapriconv-1.dll" "%PREFIX%\bin" 1>nul 2>&1
 )
 if exist "include\api_version.h" (
 echo -- Installing: "%PREFIX%\include\api_version.h"
 copy /b /y "include\api_version.h" "%PREFIX%\include" 1>nul 2>&1
 )
 if exist "include\apr_iconv.h" (
 echo -- Installing: "%PREFIX%\include\apr_iconv.h"
 copy /b /y "include\apr_iconv.h" "%PREFIX%\include" 1>nul 2>&1
 )
 if exist "!BUILD_DIR!\%BUILD_TYPE%\iconv" (
 echo -- Installing: "%PREFIX%\bin\iconv"
 xcopy "!BUILD_DIR!\%BUILD_TYPE%\iconv\*.so" "%PREFIX%\bin\iconv\" /c /d /i /y 1>nul 2>&1
 )
 )
 
 rem ------------------------------------------------------------------------------
 rem
 rem APR-UTIL
 
 rem Check for package and switch to source folder.
 rem
 call :check_package_source %APR-UTIL%
 
 if !STATUS! == 0 (
 rem Patch CMakelists.txt to support APR-ICONV if we've built it.
 rem
 if exist "%PREFIX%\lib\libapriconv-1.lib" (
 perl -pi.bak -e ^" ^
 s~^(SET.+APR_LIBRARIES[\s]+^)(\x22^)(.+libapr^)(-1.lib^)(.+ CACHE^)~${1}${2}${3}${4}${2} ${2}${3}iconv${4}${5}~; ^
 s~^(apu_have_apr_iconv_10^) 0~${1} 1~; ^
 ^" CMakeLists.txt
 )
 
 rem Check if we're building APR-UTIL 1.6.3
 rem
 if not x%APR-UTIL:1.6.3=% == x%APR-UTIL% (
 rem Patch include\apu.hwc and CMakelists.txt to support OpenSSL, which is needed with APU_HAVE_CRYPTO.
 rem
 if exist "%PREFIX%\lib\libcrypto.lib" (
 perl -pi.bak -e ^" ^
 s~^(APU_HAVE_OPENSSL[\s]+^)0$~${1}\@apu_have_openssl_10\@~; ^
 ^" include\apu.hwc
 
 perl -pi.bak -e ^" ^
 s~^([\s]+^)(SET.+apu_have_crypto_10 1\^)^)$~${1}${2} \n${1}SET(apu_have_openssl_10 1^)~; ^
 ^" CMakeLists.txt
 )
 )
 
 set APR-UTIL_CMAKE_OPTS=-DCMAKE_INSTALL_PREFIX=%PREFIX% -DOPENSSL_ROOT_DIR=%PREFIX% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DAPU_HAVE_CRYPTO=ON -DAPR_BUILD_TESTAPR=OFF -DINSTALL_PDB=%INSTALL_PDB%
 call :build_package %APR-UTIL% "!APR-UTIL_CMAKE_OPTS!" & if not !STATUS! == 0 exit /b !STATUS!
 )
 
 rem ------------------------------------------------------------------------------
 rem
 rem NGHTTP2
 
 rem Check for package and switch to source folder.
 rem
 call :check_package_source %NGHTTP2%
 
 if !STATUS! == 0 (
 set NGHTTP2_CMAKE_OPTS=-DCMAKE_INSTALL_PREFIX=%PREFIX% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DSTATIC_LIB_SUFFIX=_static -DENABLE_LIB_ONLY=ON
 call :build_package %NGHTTP2% "!NGHTTP2_CMAKE_OPTS!" & if not !STATUS! == 0 exit /b !STATUS!
 )
 
 rem ------------------------------------------------------------------------------
 rem
 rem CURL
 
 rem Check for package and switch to source folder.
 rem
 call :check_package_source %CURL%
 
 if !STATUS! == 0 (
 if /i "%CURL_USE_OPENSSL%" == "ON" (
 rem Patch lib\url.c to force use of native CA store on Windows.
 rem
 perl -pi.bak -0777 -Mopen=OUT,:raw -e ^" ^
 s~(return result;\n#endif\n#endif$^)\n  }~${1} \n#if defined(USE_WIN32_CRYPTO^)\n^
 /* Mandate Windows CA store to be used */\n^
 if(\x21set-\x3Essl.primary.CAfile \x26\x26 \x21set-\x3Essl.primary.CApath^) {\n^
 /* User and environment did not specify any CA file or path.*/\n^
 set-\x3Essl.native_ca_store = TRUE;\n^
 }\n#endif\n  }~smg; ^
 ^" lib\url.c
 ) else (
 rem Remove above lib\url.c patch if present.
 rem
 perl -pi.bak -0777 -Mopen=OUT,:raw -e ^" ^
 s~(return result;\n#endif\n#endif^) \n.+native_ca_store = TRUE;\n    }\n#endif~${1}~smg; ^
 ^" lib\url.c
 )
 
 if /i "%CURL_USE_OPENSSL%" == "ON" if /i "%CURL_DEFAULT_SSL_BACKEND%" == "SCHANNEL" (
 rem Patch CMakeLists.txt to add a compiler definition for a default SSL backend of Schannel.
 rem
 perl -pi.bak -e ^" ^
 s~(if\(CURL_USE_OPENSSL\^)^)\n~${1} \n  add_definitions(-DCURL_DEFAULT_SSL_BACKEND=\x22schannel\x22^)\n~m; ^
 ^" CMakeLists.txt
 ) else (
 rem Remove above CMakeLists.txt patch if present.
 rem
 perl -pi.bak -e ^" ^
 s~(if\(CURL_USE_OPENSSL\^)^) \n~${1}\n~m; ^
 s~[ ]+add_definitions\(-DCURL_DEFAULT_SSL_BACKEND=\x22schannel\x22\^)\n~~m; ^
 ^" CMakeLists.txt
 )
 
 rem Patch doc build CMakeLists.txt to reduce number of files processed per batch loop.
 rem This reduces the chance of line length overflow problems with Windows command shell.
 rem
 perl -pi.bak -e ^" ^
 s~(_files_per_batch[\s]+^)200(\^)^)~${1}100${2}~m; ^
 ^" docs\libcurl\CMakeLists.txt
 
 set CURL_CMAKE_OPTS=-DCMAKE_INSTALL_PREFIX=%PREFIX% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCURL_USE_OPENSSL=%CURL_USE_OPENSSL% -DCURL_USE_SCHANNEL=ON -DCURL_WINDOWS_SSPI=ON -DCURL_BROTLI=ON -DUSE_NGHTTP2=ON -DHAVE_LDAP_SSL=ON -DENABLE_UNICODE=ON -DCURL_STATIC_CRT=OFF -DUSE_WIN32_CRYPTO=ON -DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON
 call :build_package %CURL% "!CURL_CMAKE_OPTS!" & if not !STATUS! == 0 exit /b !STATUS!
 )
 
 rem ------------------------------------------------------------------------------
 rem
 rem HTTPD
 
 rem Check for package and switch to source folder.
 rem
 call :check_package_source %HTTPD%
 
 if !STATUS! == 0 (
 rem Patch CMakeLists.txt to build ApacheMonitor.
 rem
 perl -pi.bak -e ^" ^
 s~(^^# ^)(.+ApacheMonitor.+^)~${2}~; ^
 ^" CMakeLists.txt
 
 rem Patch ApacheMonitor.rc to comment out MANIFEST file reference.
 rem
 perl -pi.bak -e ^" ^
 s~(^^CREATEPROCESS_MANIFEST^)~// ${1}~; ^
 ^" support\win32\ApacheMonitor.rc
 
 rem Patch CMakeLists.txt to build WinTTY console binary.
 rem
 perl -pi.bak -e ^" ^
 s~(wtsapi32\^)^)\n~${1} \n\n^
 # Build WinTTY console binary\n^
 ADD_EXECUTABLE(WinTTY support/win32/wintty.c^)\n^
 SET(install_targets \x24\x7Binstall_targets\x7D WinTTY^)\n^
 SET_TARGET_PROPERTIES(WinTTY PROPERTIES WIN32_EXECUTABLE TRUE^)\n^
 SET_TARGET_PROPERTIES(WinTTY PROPERTIES COMPILE_FLAGS \x22\x24\x7BEXTRA_COMPILE_FLAGS\x7D\x22^)\n^
 SET_TARGET_PROPERTIES(WinTTY PROPERTIES LINK_FLAGS \x22/subsystem:console\x22^)\n^
 ~m; ^
 ^" CMakeLists.txt
 
 rem Check if we're building HTTPD 2.4.62 and if so patch mod_rewrite.c
 rem
 if not x%HTTPD:2.4.62=% == x%HTTPD% (
 rem Patch mod_rewrite.c to apply Eric Coverner's patch r1919860 as mentioned
 rem in the Apache Lounge 2.4.62 Changelog
 rem
 rem Note \h denotes horizontal whitespace...
 perl -pi.bak -0777 -Mopen=OUT,:raw -e ^" ^
 s~^([\h]+^)(int is_proxyreq = 0;\n^)(\n[\h]+ctx^)~${1}${2}${1}int prefix_added = 0;\n${3}~smg; ^
 s~^([\h]+^)(newuri = apr_pstrcat[^^;]+;^)\n([\h]+\}^)~${1}${2}\n${1}prefix_added = 1;\n${3}~smg; ^
 ^" modules\mappers\mod_rewrite.c
 )
 
 rem Patch CMakeLists.txt to build JBlond mod_log_rotate, if source module present.
 rem
 if exist "modules\loggers\mod_log_rotate.c" (
 perl -pi.bak -e ^" ^
 s~(.+^)(forensic\+I\+^)(.+^)(\x22^)\n~${1}${2}${3}${4} \n${1}rotate\+I\+log rotation through server process${4}\n~m; ^
 ^" CMakeLists.txt
 )
 
 set HTTPD_CMAKE_OPTS=-DCMAKE_INSTALL_PREFIX=%PREFIX% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DENABLE_MODULES=i -DINSTALL_PDB=%INSTALL_PDB%
 call :build_package %HTTPD% "!HTTPD_CMAKE_OPTS!" & if not !STATUS! == 0 exit /b !STATUS!
 
 rem Install additional support scripts.
 rem
 perl -pe ^" ^
 s~#.+perlbin.+\n~~m; ^
 ^" !src_dir!\support\dbmmanage.in > %PREFIX%\bin\dbmmanage.pl
 
 copy !src_dir!\docs\cgi-examples\printenv %PREFIX%\cgi-bin\printenv.pl 1>nul 2>&1
 )
 
 rem ------------------------------------------------------------------------------
 rem
 rem MOD_FCGID
 
 rem Check for package and switch to source folder.
 rem
 call :check_package_source %MOD_FCGID%
 
 if !STATUS! == 0 (
 rem Package provides both NMake makefile and experimental CMake. We use the latter.
 
 set MOD_FCGID_CMAKE_OPTS=-DCMAKE_INSTALL_PREFIX=%PREFIX% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DINSTALL_PDB=NO
 call :build_package %MOD_FCGID% "!MOD_FCGID_CMAKE_OPTS!" modules\fcgid & if not !STATUS! == 0 exit /b !STATUS!
 )
 exit /b !STATUS!
 
 rem ------------------------------------------------------------------------------
 rem
 rem Get current errorlevel value and assign it to the status variable.
 
 :get_status
 call doskey /exename=err err=%%errorlevel%%
 for /f "usebackq tokens=2 delims== " %%i in (`doskey /m:err`) do (set STATUS=%%i)
 exit /b !STATUS!
 
 rem ------------------------------------------------------------------------------
 rem
 rem Get package and version from release variable passed as first parameter.
 
 :get_package_details
 set RELEASE=%~1
 for /f "delims=-" %%i in ('echo(%RELEASE:-=^&echo(%') do call set "PACKAGE=%%RELEASE:-%%i=%%"
 for %%i in (%RELEASE:-= %) do set VERSION=%%i
 exit /b
 
 rem ------------------------------------------------------------------------------
 rem
 rem Check package source folder exists, from release variable passed as first parameter.
 rem
 :check_package_source
 
 set SRC_DIR=%BUILD_BASE%\..\src\%~1
 if not exist "!SRC_DIR!" (
 echo Warning for package %~1
 echo Could not find package source folder "!SRC_DIR!"
 set STATUS=1
 ) else (
 cd /d "!SRC_DIR!"
 set STATUS=0
 )
 exit /b !STATUS!
 
 rem ------------------------------------------------------------------------------
 rem
 rem Build subroutine.
 rem Parameter one is the package release variable.
 rem Parameter two is any required CMake options.
 rem Parameter three (optional) is any package sub-folder to the CMakeLists.txt file.
 
 :build_package
 
 call :get_package_details %~1
 
 rem Check source folder exists, else exit (non-fatal).
 
 call :check_package_source %~1
 if not !STATUS! == 0 (
 exit /b
 ) else (
 if not "%~3" == "" (
 set SRC_DIR=!SRC_DIR!\%~3
 )
 )
 
 rem Clean up any previous build.
 
 if exist "%BUILD_BASE%\!PACKAGE!" rmdir /s /q "%BUILD_BASE%\!PACKAGE!" 1>nul 2>&1
 mkdir "%BUILD_BASE%\!PACKAGE!" 1>nul 2>&1
 
 rem Build, make and install.
 
 if exist "%BUILD_BASE%\!PACKAGE!" (
 cd /d "%BUILD_BASE%\!PACKAGE!"
 echo. & echo Building %~1
 
 rem Patch CMakeLists.txt to remove debug suffix from libraries. Messes up various builds.
 rem Tried setting CMAKE_DEBUG_POSTFIX to an empty string on the CMake command line but
 rem this doesn't work with all packages, e.g. PCRE2, EXPAT, LIBXML2, etc.
 
 perl -pi -e ^" ^
 s~((DEBUG_POSTFIX^|POSTFIX_DEBUG^)\s+^)([\x22]*^)[-_]*(^|s^)d([\x22]*^)~${1}\x22${4}\x22~; ^
 ^" "!SRC_DIR!\CMakeLists.txt"
 
 rem Run CMake to create an NMake makefile, which we then process.
 
 cmake -G "NMake Makefiles" %~2 -S "!SRC_DIR!" -B . & call :get_status
 if !STATUS! == 0 (
 nmake & call :get_status
 if !STATUS! == 0 (
 nmake install & call :get_status
 if !STATUS! == 0 (
 exit /b !STATUS!
 ) else (
 echo nmake install for !PACKAGE! failed with exit status !STATUS!
 exit /b !STATUS!
 )
 ) else (
 echo nmake for !PACKAGE! failed with exit status !STATUS!
 exit /b !STATUS!
 )
 ) else (
 echo cmake for !PACKAGE! failed with exit status !STATUS!
 exit /b !STATUS!
 )
 ) else (
 echo Failed to make folder "%BUILD_BASE%\!PACKAGE!"
 exit /b 1
 )
 exit /b
 
 | 
 
 Last edited by tangent on Thu 02 Oct '25 22:09; edited 30 times in total
 |  |  
| Back to top |  |  
| James Blond Moderator
 
  
 Joined: 19 Jan 2006
 Posts: 7442
 Location: EU, Germany, Next to Hamburg
 
 | 
|  Posted: Tue 05 Jan '21 16:31    Post subject: Re: HOWTO: Building Apache and dependencies using CMake |   |  
| 
 |  
|  	  | tangent wrote: |  	  | 
 
  	  | Code: |  	  | C:\Development └ Apache24
 ├ src
 │   ├ apr-1.7.0
 │   ├ apr-iconv-1.2.2
 │   ├ apr-util-1.6.1
 │   ├ brotli-1.0.9
 │   ├ curl-7.74.0
 │   ├ expat-2.2.10
 │   ├ httpd-2.4.46
 │   ├ jansson-2.13.1
 │   ├ libxml2-2.9.10
 │   ├ mod_fcgid-2.3.9
 │   ├ nghttp2-1.42.0
 │   ├ openssl-1.1.1i
 │   ├ pcre-8.44
 │   └ zlib-1.2.11
 │
 └ build
 | 
 
 | 
 
 Do you put lua in the src folder, too?
 |  |  
| Back to top |  |  
| tangent Moderator
 
 
 Joined: 16 Aug 2020
 Posts: 397
 Location: UK
 
 | 
|  Posted: Tue 05 Jan '21 17:09    Post subject: |   |  
| 
 |  
| Apologies James; yes, you do. I've updated the source tree in the first post. 
 The batch file contains build code for LUA, but as mentioned the CMakeLists.txt file for LUA 5.3 is an extra from https://pastebin.com/QtHm9nLC
 
 Last edited by tangent on Tue 28 May '24 22:54; edited 1 time in total
 |  |  
| Back to top |  |  
| tangent Moderator
 
 
 Joined: 16 Aug 2020
 Posts: 397
 Location: UK
 
 | 
|  Posted: Tue 16 Feb '21 21:04    Post subject: |   |  
| 
 |  
| Updated the above: 
 1) Patch CURL build support for OpenSSL to force use of native CA store on Windows.
 2) Request CURL builds with LDAPS support (Schannel based).
 3) Update build versions for CURL (7.75.0), NGHTTP2 (1.43.0) and OpenSSL (1.1.1j).
 |  |  
| Back to top |  |  
| nono303 
 
  
 Joined: 20 Dec 2016
 Posts: 214
 Location: Lille, FR, EU
 
 |  |  
| Back to top |  |  
| admin Site Admin
 
  
 Joined: 15 Oct 2005
 Posts: 706
 
 
 |  |  
| Back to top |  |  
| admin Site Admin
 
  
 Joined: 15 Oct 2005
 Posts: 706
 
 
 | 
|  Posted: Wed 23 Jun '21 12:05    Post subject: |   |  
| 
 |  
| If you find any issues please report in the Building & Member Downloads forum (not in How-to's & Documentation & Tips NOR this topic) 
 Improvements or faults you can post here.
 |  |  
| Back to top |  |  
| tangent Moderator
 
 
 Joined: 16 Aug 2020
 Posts: 397
 Location: UK
 
 | 
|  Posted: Fri 27 Aug '21 19:43    Post subject: |   |  
| 
 |  
| Bump code for release updates: 
 CURL (7.78.0)
EXPAT (2.4.1)
 HTTPD (2.4.48)
 LIBXML2 (2.9.12)
 LUA (5.4.3)
 NGHTTP2 (1.44.0)
 OPENSSL (1.1.1l)
 PCRE (8.45)
 |  |  
| Back to top |  |  
| tangent Moderator
 
 
 Joined: 16 Aug 2020
 Posts: 397
 Location: UK
 
 | 
|  Posted: Mon 22 Nov '21 16:13    Post subject: |   |  
| 
 |  
| Bump code (somewhat belatedly) for package release updates: 
 CURL (7.80.0)
Note there are no changes to the batch file logic or patches for these later releases; just the version number references.HTTPD (2.4.51)
 JANSSON (2.14)
 NGHTTP2 (1.46.0)
 |  |  
| Back to top |  |  
| tanquang 
 
 
 Joined: 21 Mar 2020
 Posts: 73
 Location: Vietnam
 
 | 
|  Posted: Sat 25 Dec '21 10:52    Post subject: |   |  
| 
 |  
| In some of the previous instructions, they have instructions to remove section comment: 
  	  | Code: |  	  | ... # getting duplicate manifest error with ApacheMonitor
 # ADD_EXECUTABLE(ApacheMonitor support/win32/ApacheMonitor.c support/win32/ApacheMonitor.rc)
 # SET(install_targets ${install_targets} ApacheMonitor)
 # SET(install_bin_pdb ${install_bin_pdb} $<TARGET_PDB_FILE:ApacheMonitor>)
 # SET_TARGET_PROPERTIES(ApacheMonitor PROPERTIES WIN32_EXECUTABLE TRUE)
 # SET_TARGET_PROPERTIES(ApacheMonitor PROPERTIES COMPILE_FLAGS "-DAPP_FILE -DLONG_NAME=ApacheMonitor -DBIN_NAME=ApacheMonitor.exe ${EXTRA_COMPILE_FLAGS}")
 # TARGET_LINK_LIBRARIES(ApacheMonitor ${EXTRA_LIBS} ${HTTPD_SYSTEM_LIBS} comctl32 wtsapi32)
 ...
 | 
 In the CMakeLists.txt file of httpd. Now need to remove them before building anymore?
 |  |  
| Back to top |  |  
| tangent Moderator
 
 
 Joined: 16 Aug 2020
 Posts: 397
 Location: UK
 
 |  |  
| Back to top |  |  
| tanquang 
 
 
 Joined: 21 Mar 2020
 Posts: 73
 Location: Vietnam
 
 | 
|  Posted: Wed 29 Dec '21 2:38    Post subject: |   |  
| 
 |  
| Yes, I still see it are commented. |  |  
| Back to top |  |  
| Steffen Moderator
 
 
 Joined: 15 Oct 2005
 Posts: 3131
 Location: Hilversum, NL, EU
 
 | 
|  Posted: Mon 03 Jan '22 13:39    Post subject: |   |  
| 
 |  
| 
 Looks like the fix is in 2.4.52
 |  |  
| Back to top |  |  
| Steffen Moderator
 
 
 Joined: 15 Oct 2005
 Posts: 3131
 Location: Hilversum, NL, EU
 
 | 
|  Posted: Mon 03 Jan '22 18:49    Post subject: |   |  
| 
 |  
| Above in LUA 5.4.3 is defined LUA_COMPAT_ALL , in the lua source I cannot find checking this flag. Mostly 5.4 is build with LUA_COMPAT_5_3 . 
 See https://www.lua.org/source/5.4/luaconf.h.html
 
 Last edited by Steffen on Mon 03 Jan '22 18:59; edited 1 time in total
 |  |  
| Back to top |  |  
| Steffen Moderator
 
 
 Joined: 15 Oct 2005
 Posts: 3131
 Location: Hilversum, NL, EU
 
 | 
|  Posted: Mon 03 Jan '22 18:56    Post subject: |   |  
| 
 |  
| Is ZLIB build with the asm from \zlib-1.2.11\contrib\masmx64 ? 
 Apache lounge builds zlib with:
 
 
 bld_ml64.bat in contrib\masmx64 and copy inffas8664.c,
 inffasx64.obj and gvmat64.obj in the top-level.
 
 nmake -f win32\Makefile.msc AS=ml64 LOC="-DASMV -DASMINF -I." OBJA="inffasx64.obj gvmat64.obj inffas8664.obj"
 |  |  
| Back to top |  |  
| tangent Moderator
 
 
 Joined: 16 Aug 2020
 Posts: 397
 Location: UK
 
 | 
|  Posted: Sun 09 Jan '22 16:16    Post subject: |   |  
| 
 |  
| Sorry Steffen - I missed your posts over LUA and ZLIB. 
 Yes, I'd since noticed that LUA_COMPAT_ALL has gone from 5.4.3, so will edit the CMake build to pass LUA_COMPAT_5_3 instead.
 
 The ZLIB build is currently the CMake default, so no, it's not using these additional assembler optimised functions. I'll look into adding these refinements in due course.
 
 I've also been looking into adding the patch for the APR handle leak (PR 61165 [Ivan Zhakov]), which is done, plus bumping EXPAT to 2.4.2 and CURL to 7.81.0.
 
 However, as released, CURL 7.81.0 has a problem when building support for OpenSSL alongside Schannel on Windows. Indeed, thanks to Jan-E who has already logged this issue with the CURL developers - https://github.com/curl/curl/pull/8240 and subsequent patch listed here https://github.com/curl/curl/pull/8246
 
 I'll update the HowTo for these enhancements presently.
 |  |  
| Back to top |  |  
| Jan-E 
 
 
 Joined: 09 Mar 2012
 Posts: 1283
 Location: Amsterdam, NL, EU
 
 | 
|  Posted: Mon 10 Jan '22 2:51    Post subject: |   |  
| 
 |  
| That only happened with OpenSSL 1.0.2, not with OpenSSL 1.1.1. |  |  
| Back to top |  |  
| tangent Moderator
 
 
 Joined: 16 Aug 2020
 Posts: 397
 Location: UK
 
 | 
|  Posted: Mon 10 Jan '22 17:40    Post subject: |   |  
| 
 |  
| Hmm, for me the above CMake build of CURL 7.81.0 fails with OpenSSL 1.1.1m, when specifying both OpenSSL and Schannel (-DCURL_USE_OPENSSL=ON -DCURL_USE_SCHANNEL=ON), viz. 
  	  | Code: |  	  | [ 63%] Building C object lib/CMakeFiles/libcurl.dir/vtls/mesalink.c.obj mesalink.c
 [ 63%] Building C object lib/CMakeFiles/libcurl.dir/vtls/nss.c.obj
 nss.c
 [ 63%] Building C object lib/CMakeFiles/libcurl.dir/vtls/openssl.c.obj
 openssl.c
 C:\Apache24\include\openssl/ocsp.h(81): error C2059: syntax error: '<parameter-list>'
 C:\Apache24\include\openssl/ocsp.h(151): error C2059: syntax error: '<parameter-list>'
 C:\Apache24\include\openssl/ocsp.h(152): error C2059: syntax error: '('
 C:\Apache24\include\openssl/ocsp.h(152): error C2143: syntax error: missing ')' before '('
 | 
 If I apply the openssl.h patch at https://github.com/curl/curl/pull/8246 then it builds without error, and I note this header file had been updated from release 7.80.0.
 
 Different environments I guess, but I note the CURL developers have listed a lot of changes in this release. Indeed, I'm not surprised that supporting a number of alternative SSL backends causes some compatibility problems.
 |  |  
| Back to top |  |  
| Jan-E 
 
 
 Joined: 09 Mar 2012
 Posts: 1283
 Location: Amsterdam, NL, EU
 
 |  |  
| Back to top |  |  
 
 | 
 |  | 
 |  |