Author: brane
Date: Fri Jan 23 08:09:15 2026
New Revision: 1931481

Log:
Do not compile the serf_spider test program if APR doesn't support threads.

* build/scons_extras.py
  (CheckAPRHasThreads): New custom test function.
* SConstruct
  (custom_tests): Add CheckAPRHasThreads.
  (apr_has_threads): Perform the config test.
  (TEST_PROGRAMS): Add serf_spider only if APR has threads.

* test/CMakeLists.txt
  (serf_check_apr_has_threads): New test function.
  (SIMPLE_TEST_TARGETS): Add serf_spider only if APR has threads.
* CMakeLists.txt: Add a note to the summary if APR doesn't have threads.

Modified:
   serf/trunk/CMakeLists.txt
   serf/trunk/SConstruct
   serf/trunk/build/scons_extras.py
   serf/trunk/test/CMakeLists.txt

Modified: serf/trunk/CMakeLists.txt
==============================================================================
--- serf/trunk/CMakeLists.txt   Fri Jan 23 08:02:54 2026        (r1931480)
+++ serf/trunk/CMakeLists.txt   Fri Jan 23 08:09:15 2026        (r1931481)
@@ -635,6 +635,12 @@ if(DOT_CLANGD)
   set(_gen_dot_clangd ON)
 endif()
 
+if(APR_HAS_THREADS)
+  set(_apr_version "${APR_VERSION}")
+else()
+  set(_apr_version "${APR_VERSION} [no threads]")
+endif()
+
 if("SERF_HAVE_BROTLI" IN_LIST SERF_C_DEFINES)
   set(_have_brotli ON)
   if(NOT SERF_WINDOWS)
@@ -684,7 +690,7 @@ message(STATUS "    GSSAPI .............
 message(STATUS "    SSPI .................... : ${_have_sspi}")
 message(STATUS "    Unbound ................. : ${_have_unbound}")
 message(STATUS "  Dependencies:")
-message(STATUS "    APR ..................... : ${APR_VERSION}")
+message(STATUS "    APR ..................... : ${_apr_version}")
 if(APR_VERSION VERSION_LESS 2.0.0)
 message(STATUS "    APR-Util ................ : ${APRUTIL_VERSION}")
 endif()

Modified: serf/trunk/SConstruct
==============================================================================
--- serf/trunk/SConstruct       Fri Jan 23 08:02:54 2026        (r1931480)
+++ serf/trunk/SConstruct       Fri Jan 23 08:09:15 2026        (r1931481)
@@ -43,7 +43,8 @@ import build.scons_extras
 import build.exports
 
 build.scons_extras.AddEnvironmentMethods()
-custom_tests = {'CheckGnuCC': build.scons_extras.CheckGnuCC}
+custom_tests = {'CheckGnuCC': build.scons_extras.CheckGnuCC,
+                'CheckAPRHasThreads': build.scons_extras.CheckAPRHasThreads}
 
 # SCons 4.7 introduced the function argument list parameter to CheckFunc.
 try:
@@ -650,6 +651,7 @@ for line in stream.readlines():
 ssl_includes = '\n'.join(ssl_include_list)
 
 conf = Configure(env, custom_tests=custom_tests)
+apr_has_threads = conf.CheckAPRHasThreads()
 if not conf.CheckFunc('BIO_set_init', ssl_includes, 'C', 'NULL, 0'):
   env.Append(CPPDEFINES=['SERF_NO_SSL_BIO_WRAPPERS'])
 if not conf.CheckFunc('X509_STORE_get0_param', ssl_includes, 'C', 'NULL'):
@@ -830,11 +832,18 @@ mockhttpinc = mockenv.StaticLibrary('moc
 
 # Check if long-running tests should be enabled
 if tenv.get('ENABLE_SLOW_TESTS', None):
-    tenv.Append(CPPDEFINES=['SERF_TEST_DEFLATE_4GBPLUS_BUCKETS'])
+  tenv.Append(CPPDEFINES=['SERF_TEST_DEFLATE_4GBPLUS_BUCKETS'])
 
-TEST_PROGRAMS = [ 'serf_get', 'serf_response', 'serf_request', 'serf_spider',
-                  'serf_httpd',
-                  'test_all', 'serf_bwtp' ]
+TEST_PROGRAMS = [
+    'serf_get',
+    'serf_response',
+    'serf_request',
+    'serf_httpd',
+    'test_all',
+    'serf_bwtp',
+    ]
+if apr_has_threads:
+  TEST_PROGRAMS.append("serf_spider")
 
 _exe = '.exe' if sys.platform == 'win32' else ''
 TEST_EXES = [os.path.join('test', '%s%s' % (prog, _exe)) for prog in 
TEST_PROGRAMS]

Modified: serf/trunk/build/scons_extras.py
==============================================================================
--- serf/trunk/build/scons_extras.py    Fri Jan 23 08:02:54 2026        
(r1931480)
+++ serf/trunk/build/scons_extras.py    Fri Jan 23 08:09:15 2026        
(r1931481)
@@ -41,6 +41,22 @@ oh noes!
   return result
 
 
+def CheckAPRHasThreads(context):
+  '''Check if APR_HAS_THREADS is defined'''
+
+  src = '''
+#include <apr.h>
+#if !APR_HAS_THREADS
+oh noes!
+#endif
+'''
+
+  context.Display('Checking for thread support in APR... ')
+  result = context.TryCompile(src, '.c')
+  context.Result(result)
+  return result
+
+
 def __env_munge_if(env, method, variables, pattern, **kwargs):
   '''Invoke `env`.`method`(**`kwargs`), unless `pattern` matches the
    values in `variables` that are also in `env`.

Modified: serf/trunk/test/CMakeLists.txt
==============================================================================
--- serf/trunk/test/CMakeLists.txt      Fri Jan 23 08:02:54 2026        
(r1931480)
+++ serf/trunk/test/CMakeLists.txt      Fri Jan 23 08:09:15 2026        
(r1931481)
@@ -17,6 +17,29 @@
 #   under the License.
 # ===================================================================
 
+include(CheckCSourceCompiles)
+
+# Check if APR has threads, serf_spider doesn't compile otherwise.
+function(serf_check_apr_has_threads)
+  set(CMAKE_REQUIRED_LIBRARIES APR::APR)
+  set(source
+      "#include <apr.h>"
+      "#if !APR_HAS_THREADS"
+      "#error \"no threads\""
+      "#endif"
+      "int main(void) { return 0\; }"
+      "")
+  list(JOIN source "\n" source)
+  check_c_source_compiles("${source}" "APR_HAS_THREADS")
+  if(APR_HAS_THREADS)
+    set(APR_HAS_THREADS TRUE PARENT_SCOPE)
+  else()
+    set(APR_HAS_THREADS FALSE PARENT_SCOPE)
+  endif()
+  unset(CMAKE_REQUIRED_LIBRARIES)
+endfunction(serf_check_apr_has_threads)
+serf_check_apr_has_threads()
+
 add_subdirectory(MockHTTPinC)
 
 set(TEST_ALL_SOURCES
@@ -46,10 +69,14 @@ set(SIMPLE_TEST_TARGETS
     "serf_get"
     "serf_response"
     "serf_request"
-    "serf_spider"
     "serf_httpd"
     "serf_bwtp"
 )
+if(APR_HAS_THREADS)
+  list(APPEND SIMPLE_TEST_TARGETS "serf_spider")
+else()
+  message(STATUS "Test program serf_spider will not be built (requires 
APR_HAS_THREADS)")
+endif()
 
 foreach(TEST_TARGET ${SIMPLE_TEST_TARGETS})
   add_executable(${TEST_TARGET} "${TEST_TARGET}.c")

Reply via email to