From 73e309c47a7275f5b718f3a84ee4159f03e67fe3 Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Fri, 15 May 2026 11:53:17 +0100 Subject: [PATCH 1/5] Stab in the dark attempt at fixing the Windows CI with Claude: * CMakeLists.txt: Fix CMake generation failure with non-MSVC compilers (e.g. MinGW GCC) caused by unconditional use of $ generator expressions, which are only supported by the MSVC linker. Guard all TARGET_PDB_FILE usage with IF(INSTALL_PDB), and default INSTALL_PDB to OFF for non-MSVC compilers. Co-Authored-By: Claude Opus 4.6 --- CMakeLists.txt | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 46811e0d87d..27cea887b3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,7 +124,7 @@ SET(CHECK_LIBRARIES "${default_check_libraries}" CACHE STRING "Check lib # end support library configuration # Misc. options -OPTION(INSTALL_PDB "Install .pdb files (if generated)" ON) +OPTION(INSTALL_PDB "Install .pdb files (if generated)" ${MSVC}) OPTION(INSTALL_MANUAL "Install manual" ON) SET(ENABLE_MODULES "O" CACHE STRING "Minimum module enablement (e.g., \"i\" to build all but those without prerequisites)") @@ -854,7 +854,9 @@ FOREACH (mod ${MODULE_PATHS}) SET(all_mod_sources ${tmp_mod_main_source} ${${mod_extra_sources}}) ADD_LIBRARY(${mod_name} SHARED ${all_mod_sources} build/win32/httpd.rc) SET(install_modules ${install_modules} ${mod_name}) - SET(install_modules_pdb ${install_modules_pdb} "$") + IF(INSTALL_PDB) + SET(install_modules_pdb ${install_modules_pdb} "$") + ENDIF() IF("${${mod_name}_install_lib}") SET(installed_mod_libs_exps ${installed_mod_libs_exps} @@ -897,7 +899,9 @@ SET_TARGET_PROPERTIES(libhttpd PROPERTIES LINK_FLAGS /base:@${PROJECT_BINARY_DIR}/BaseAddr.ref,libhttpd.dll ) SET(install_targets ${install_targets} libhttpd) -SET(install_bin_pdb ${install_bin_pdb} $) +IF(INSTALL_PDB) + SET(install_bin_pdb ${install_bin_pdb} $) +ENDIF() TARGET_LINK_LIBRARIES(libhttpd ${EXTRA_LIBS} ${APR_LIBRARIES} ${PCRE_LIBRARIES} ${HTTPD_SYSTEM_LIBS}) TARGET_COMPILE_DEFINITIONS(libhttpd PRIVATE "LONG_NAME=Apache HTTP Server Core" @@ -910,7 +914,9 @@ ADD_DEPENDENCIES(libhttpd test_char_header) ########### HTTPD EXECUTABLES ########## ADD_EXECUTABLE(httpd server/main.c build/win32/httpd.rc) SET(install_targets ${install_targets} httpd) -SET(install_bin_pdb ${install_bin_pdb} $) +IF(INSTALL_PDB) + SET(install_bin_pdb ${install_bin_pdb} $) +ENDIF() TARGET_COMPILE_DEFINITIONS(httpd PRIVATE "APP_FILE" "LONG_NAME=Apache HTTP Server" @@ -940,7 +946,9 @@ FOREACH(pgm ${standard_support}) SET(extra_sources ${pgm}_extra_sources) ADD_EXECUTABLE(${pgm} support/${pgm}.c ${${extra_sources}} build/win32/httpd.rc) SET(install_targets ${install_targets} ${pgm}) - SET(install_bin_pdb ${install_bin_pdb} $) + IF(INSTALL_PDB) + SET(install_bin_pdb ${install_bin_pdb} $) + ENDIF() TARGET_COMPILE_DEFINITIONS(${pgm} PRIVATE "APP_FILE" "LONG_NAME=Apache HTTP Server ${pgm} program" @@ -952,7 +960,9 @@ ENDFOREACH() ADD_EXECUTABLE(ab support/ab.c build/win32/httpd.rc) SET(install_targets ${install_targets} ab) -SET(install_bin_pdb ${install_bin_pdb} $) +IF(INSTALL_PDB) + SET(install_bin_pdb ${install_bin_pdb} $) +ENDIF() SET(tmp_includes ${HTTPD_INCLUDE_DIRECTORIES}) SET_TARGET_PROPERTIES(ab PROPERTIES INCLUDE_DIRECTORIES "${tmp_includes}") TARGET_COMPILE_DEFINITIONS(ab PRIVATE @@ -965,7 +975,9 @@ TARGET_LINK_LIBRARIES(ab ${EXTRA_LIBS} ${APR_LIBRARIES} Ws2_32.lib) IF(OPENSSL_FOUND) ADD_EXECUTABLE(abs support/ab.c build/win32/httpd.rc) SET(install_targets ${install_targets} abs) - SET(install_bin_pdb ${install_bin_pdb} $) + IF(INSTALL_PDB) + SET(install_bin_pdb ${install_bin_pdb} $) + ENDIF() SET_TARGET_PROPERTIES(abs PROPERTIES COMPILE_DEFINITIONS HAVE_OPENSSL) SET(tmp_includes ${HTTPD_INCLUDE_DIRECTORIES} ${OPENSSL_INCLUDE_DIR}) SET_TARGET_PROPERTIES(abs PROPERTIES INCLUDE_DIRECTORIES "${tmp_includes}") From 87e021e84bdc6e5129d6344d5e76a7f391d68dcf Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Fri, 15 May 2026 12:16:29 +0100 Subject: [PATCH 2/5] CMake: fix windres resource compilation with MinGW: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * CMakeLists.txt: TARGET_COMPILE_DEFINITIONS does not correctly handle values with spaces for MinGW windres, which invokes cc1.exe as its preprocessor. Defines like LONG_NAME="Apache HTTP Server htdbm program" get split on spaces, causing "fatal error: HTTP\: No such file or directory" and similar errors. LONG_NAME, BIN_NAME, APP_FILE, and ICON_FILE are only used in build/win32/httpd.rc, so generate per-target wrapper .rc files with these defines baked in as #define directives, then #include the real httpd.rc. This avoids command-line quoting entirely. Also fix TARGET_COMPILE_OPTIONS in the standard_support FOREACH loop which incorrectly referenced ${mod_name} from the outer modules loop instead of ${pgm}. Claude's explanation of the root cause: Root cause: Commit ed4ffd04a8 replaced the DEFINE_WITH_BLANKS() macro with TARGET_COMPILE_DEFINITIONS(), which correctly handles spaces for the C compiler but NOT for MinGW's windres.exe. The resource compiler invokes cc1.exe as its preprocessor, and -DLONG_NAME="Apache HTTP Server htdbm program" gets split on spaces — each word after Apache gets treated as an input file, causing the fatal error: HTTP\: No such file or directory errors. Co-Authored-By: Claude Opus 4.6 --- CMakeLists.txt | 84 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27cea887b3f..b05cb05010b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,6 +142,20 @@ FOREACH(onelib ${APR_LIBRARIES}) ENDIF() ENDFOREACH() +# Generate a per-target wrapper .rc file with the given preprocessor +# definitions baked in, to avoid passing values with spaces on the +# windres command line where quoting is not handled correctly. +FUNCTION(GENERATE_RC_FILE target_name rc_path_var) + SET(_rc_file "${CMAKE_BINARY_DIR}/rc/${target_name}_httpd.rc") + SET(_content "") + FOREACH(_def ${ARGN}) + STRING(APPEND _content "#define ${_def}\n") + ENDFOREACH() + STRING(APPEND _content "#include \"${CMAKE_SOURCE_DIR}/build/win32/httpd.rc\"\n") + FILE(WRITE "${_rc_file}" "${_content}") + SET(${rc_path_var} "${_rc_file}" PARENT_SCOPE) +ENDFUNCTION() + MACRO(GET_MOD_ENABLE_RANK macro_modname macro_mod_enable_val macro_output_rank) IF(${macro_mod_enable_val} STREQUAL "O") SET(${macro_output_rank} 0) @@ -852,7 +866,11 @@ FOREACH (mod ${MODULE_PATHS}) SET(tmp_mod_main_source ${${mod_main_source}}) ENDIF() SET(all_mod_sources ${tmp_mod_main_source} ${${mod_extra_sources}}) - ADD_LIBRARY(${mod_name} SHARED ${all_mod_sources} build/win32/httpd.rc) + GENERATE_RC_FILE(${mod_name} _mod_rc + "LONG_NAME ${mod_name} for Apache HTTP Server" + "BIN_NAME ${mod_name}.so" + ) + ADD_LIBRARY(${mod_name} SHARED ${all_mod_sources} ${_mod_rc}) SET(install_modules ${install_modules} ${mod_name}) IF(INSTALL_PDB) SET(install_modules_pdb ${install_modules_pdb} "$") @@ -870,10 +888,6 @@ FOREACH (mod ${MODULE_PATHS}) LINK_FLAGS /base:@${PROJECT_BINARY_DIR}/BaseAddr.ref,${mod_name}.so ) TARGET_LINK_LIBRARIES(${mod_name} ${${mod_extra_libs}} libhttpd ${EXTRA_LIBS} ${APR_LIBRARIES} ${HTTPD_SYSTEM_LIBS}) - TARGET_COMPILE_DEFINITIONS(${mod_name} PRIVATE - "LONG_NAME=${mod_name} for Apache HTTP Server" - "BIN_NAME=${mod_name}.so" - ) TARGET_COMPILE_OPTIONS(${mod_name} PRIVATE "${EXTRA_COMPILE_FLAGS}") # Extra defines? @@ -894,7 +908,11 @@ FOREACH (mod ${MODULE_PATHS}) ENDFOREACH() ########### HTTPD LIBRARIES ############ -ADD_LIBRARY(libhttpd SHARED ${LIBHTTPD_SOURCES} build/win32/httpd.rc) +GENERATE_RC_FILE(libhttpd _libhttpd_rc + "LONG_NAME Apache HTTP Server Core" + "BIN_NAME libhttpd.dll" +) +ADD_LIBRARY(libhttpd SHARED ${LIBHTTPD_SOURCES} ${_libhttpd_rc}) SET_TARGET_PROPERTIES(libhttpd PROPERTIES LINK_FLAGS /base:@${PROJECT_BINARY_DIR}/BaseAddr.ref,libhttpd.dll ) @@ -904,25 +922,23 @@ IF(INSTALL_PDB) ENDIF() TARGET_LINK_LIBRARIES(libhttpd ${EXTRA_LIBS} ${APR_LIBRARIES} ${PCRE_LIBRARIES} ${HTTPD_SYSTEM_LIBS}) TARGET_COMPILE_DEFINITIONS(libhttpd PRIVATE - "LONG_NAME=Apache HTTP Server Core" - "BIN_NAME=libhttpd.dll" "AP_DECLARE_EXPORT" ) TARGET_COMPILE_OPTIONS(libhttpd PRIVATE ${PCRE_CFLAGS} ${EXTRA_COMPILE_FLAGS}) ADD_DEPENDENCIES(libhttpd test_char_header) ########### HTTPD EXECUTABLES ########## -ADD_EXECUTABLE(httpd server/main.c build/win32/httpd.rc) +GENERATE_RC_FILE(httpd _httpd_rc + "APP_FILE" + "LONG_NAME Apache HTTP Server" + "BIN_NAME httpd.exe" + "ICON_FILE ${CMAKE_SOURCE_DIR}/build/win32/apache.ico" +) +ADD_EXECUTABLE(httpd server/main.c ${_httpd_rc}) SET(install_targets ${install_targets} httpd) IF(INSTALL_PDB) SET(install_bin_pdb ${install_bin_pdb} $) ENDIF() -TARGET_COMPILE_DEFINITIONS(httpd PRIVATE - "APP_FILE" - "LONG_NAME=Apache HTTP Server" - "BIN_NAME=httpd.exe" - "ICON_FILE=${CMAKE_SOURCE_DIR}/build/win32/apache.ico" -) TARGET_COMPILE_OPTIONS(httpd PRIVATE "${EXTRA_COMPILE_FLAGS}") SET_TARGET_PROPERTIES(httpd PROPERTIES LINK_FLAGS "/stack:0x40000" @@ -944,36 +960,41 @@ SET(htpasswd_extra_sources support/passwd_common.c) FOREACH(pgm ${standard_support}) SET(extra_sources ${pgm}_extra_sources) - ADD_EXECUTABLE(${pgm} support/${pgm}.c ${${extra_sources}} build/win32/httpd.rc) + GENERATE_RC_FILE(${pgm} _pgm_rc + "APP_FILE" + "LONG_NAME Apache HTTP Server ${pgm} program" + "BIN_NAME ${pgm}.exe" + ) + ADD_EXECUTABLE(${pgm} support/${pgm}.c ${${extra_sources}} ${_pgm_rc}) SET(install_targets ${install_targets} ${pgm}) IF(INSTALL_PDB) SET(install_bin_pdb ${install_bin_pdb} $) ENDIF() - TARGET_COMPILE_DEFINITIONS(${pgm} PRIVATE - "APP_FILE" - "LONG_NAME=Apache HTTP Server ${pgm} program" - "BIN_NAME=${pgm}.exe" - ) - TARGET_COMPILE_OPTIONS(${mod_name} PRIVATE "${EXTRA_COMPILE_FLAGS}") + TARGET_COMPILE_OPTIONS(${pgm} PRIVATE "${EXTRA_COMPILE_FLAGS}") TARGET_LINK_LIBRARIES(${pgm} ${EXTRA_LIBS} ${APR_LIBRARIES}) ENDFOREACH() -ADD_EXECUTABLE(ab support/ab.c build/win32/httpd.rc) +GENERATE_RC_FILE(ab _ab_rc + "APP_FILE" + "LONG_NAME Apache HTTP Server ab program" + "BIN_NAME ab.exe" +) +ADD_EXECUTABLE(ab support/ab.c ${_ab_rc}) SET(install_targets ${install_targets} ab) IF(INSTALL_PDB) SET(install_bin_pdb ${install_bin_pdb} $) ENDIF() SET(tmp_includes ${HTTPD_INCLUDE_DIRECTORIES}) SET_TARGET_PROPERTIES(ab PROPERTIES INCLUDE_DIRECTORIES "${tmp_includes}") -TARGET_COMPILE_DEFINITIONS(ab PRIVATE - "APP_FILE" - "LONG_NAME=Apache HTTP Server ab program" - "BIN_NAME=ab.exe" -) TARGET_LINK_LIBRARIES(ab ${EXTRA_LIBS} ${APR_LIBRARIES} Ws2_32.lib) IF(OPENSSL_FOUND) - ADD_EXECUTABLE(abs support/ab.c build/win32/httpd.rc) + GENERATE_RC_FILE(abs _abs_rc + "APP_FILE" + "LONG_NAME Apache HTTP Server ab/SSL program" + "BIN_NAME abs.exe" + ) + ADD_EXECUTABLE(abs support/ab.c ${_abs_rc}) SET(install_targets ${install_targets} abs) IF(INSTALL_PDB) SET(install_bin_pdb ${install_bin_pdb} $) @@ -981,11 +1002,6 @@ IF(OPENSSL_FOUND) SET_TARGET_PROPERTIES(abs PROPERTIES COMPILE_DEFINITIONS HAVE_OPENSSL) SET(tmp_includes ${HTTPD_INCLUDE_DIRECTORIES} ${OPENSSL_INCLUDE_DIR}) SET_TARGET_PROPERTIES(abs PROPERTIES INCLUDE_DIRECTORIES "${tmp_includes}") - TARGET_COMPILE_DEFINITIONS(abs PRIVATE - "APP_FILE" - "LONG_NAME=Apache HTTP Server ab/SSL program" - "BIN_NAME=abs.exe" - ) TARGET_LINK_LIBRARIES(abs ${EXTRA_LIBS} ${APR_LIBRARIES} ${OPENSSL_LIBRARIES} Ws2_32.lib) ENDIF() From 345f4f69bc96e94d46b7575cddfa119c01a829ea Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Fri, 15 May 2026 12:34:45 +0100 Subject: [PATCH 3/5] CMake: fix windres failing with spaces in include paths: * CMakeLists.txt (GENERATE_RC_FILE): For MinGW, compile the .rc file via ADD_CUSTOM_COMMAND with only the include paths actually needed by httpd.rc (just ${CMAKE_SOURCE_DIR}/include for ap_release.h). This avoids passing all target include directories to windres, which cannot handle -I paths containing spaces such as the default CMAKE_INSTALL_PREFIX of "C:/Program Files (x86)/HTTPD/include". Co-Authored-By: Claude Opus 4.6 --- CMakeLists.txt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b05cb05010b..734577e7e32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,6 +145,9 @@ ENDFOREACH() # Generate a per-target wrapper .rc file with the given preprocessor # definitions baked in, to avoid passing values with spaces on the # windres command line where quoting is not handled correctly. +# For MinGW, compile the .rc via a custom command with only the +# needed include paths, since windres also cannot handle -I paths +# containing spaces. FUNCTION(GENERATE_RC_FILE target_name rc_path_var) SET(_rc_file "${CMAKE_BINARY_DIR}/rc/${target_name}_httpd.rc") SET(_content "") @@ -153,7 +156,21 @@ FUNCTION(GENERATE_RC_FILE target_name rc_path_var) ENDFOREACH() STRING(APPEND _content "#include \"${CMAKE_SOURCE_DIR}/build/win32/httpd.rc\"\n") FILE(WRITE "${_rc_file}" "${_content}") - SET(${rc_path_var} "${_rc_file}" PARENT_SCOPE) + IF(MINGW) + SET(_rc_obj "${CMAKE_BINARY_DIR}/rc/${target_name}_httpd.obj") + ADD_CUSTOM_COMMAND( + OUTPUT "${_rc_obj}" + COMMAND ${CMAKE_RC_COMPILER} -O coff + -I "${CMAKE_SOURCE_DIR}/include" + "${_rc_file}" "${_rc_obj}" + DEPENDS "${_rc_file}" + "${CMAKE_SOURCE_DIR}/build/win32/httpd.rc" + "${CMAKE_SOURCE_DIR}/include/ap_release.h" + ) + SET(${rc_path_var} "${_rc_obj}" PARENT_SCOPE) + ELSE() + SET(${rc_path_var} "${_rc_file}" PARENT_SCOPE) + ENDIF() ENDFUNCTION() MACRO(GET_MOD_ENABLE_RANK macro_modname macro_mod_enable_val macro_output_rank) From e5842b26865f0979893b8b5c799f92e3c0e07189 Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Fri, 15 May 2026 12:47:41 +0100 Subject: [PATCH 4/5] CMake: generate empty ap_config_auto.h for MinGW builds: * CMakeLists.txt: ap_config.h includes ap_config_auto.h when __MINGW32__ is defined, but autoconf is not used in the CMake build so the file does not exist. Generate an empty one in the build directory to satisfy the include. Co-Authored-By: Claude Opus 4.6 --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 734577e7e32..9a22bca6b1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -762,6 +762,12 @@ SET(LIBHTTPD_SOURCES CONFIGURE_FILE(os/win32/win32_config_layout.h ${PROJECT_BINARY_DIR}/ap_config_layout.h) +# Generate an empty ap_config_auto.h for MinGW, where ap_config.h +# expects it but autoconf is not used with the CMake build. +IF(MINGW) + FILE(WRITE ${PROJECT_BINARY_DIR}/ap_config_auto.h "") +ENDIF() + SET(HTTPD_INCLUDE_DIRECTORIES ${PROJECT_BINARY_DIR} ${EXTRA_INCLUDES} From cd586a452f41156531c3c73b03a16ff378e59074 Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Fri, 15 May 2026 13:12:06 +0100 Subject: [PATCH 5/5] mod_win32: fix const-correctness in set_interpreter_source: * modules/arch/win32/mod_win32.c (set_interpreter_source): Change third parameter from char * to const char * to match the AP_INIT_TAKE1 function signature. Co-Authored-By: Claude Opus 4.6 --- modules/arch/win32/mod_win32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/arch/win32/mod_win32.c b/modules/arch/win32/mod_win32.c index bddc60d9f9d..0670f70b5e9 100644 --- a/modules/arch/win32/mod_win32.c +++ b/modules/arch/win32/mod_win32.c @@ -74,7 +74,7 @@ static void *merge_win32_dir_configs(apr_pool_t *p, void *basev, void *addv) } static const char *set_interpreter_source(cmd_parms *cmd, void *dv, - char *arg) + const char *arg) { win32_dir_conf *d = (win32_dir_conf *)dv; if (!strcasecmp(arg, "registry")) {