Author: brane
Date: Tue Jul 1 02:22:14 2025
New Revision: 1926883
URL: http://svn.apache.org/viewvc?rev=1926883&view=rev
Log:
On the SERF-195 branch: sync with trunk r1926882.
Added:
serf/branches/SERF-195/test/MockHTTPinC/CMakeLists.txt
- copied unchanged from r1926882,
serf/trunk/test/MockHTTPinC/CMakeLists.txt
Modified:
serf/branches/SERF-195/ (props changed)
serf/branches/SERF-195/CMakeLists.txt
serf/branches/SERF-195/README
serf/branches/SERF-195/build/SerfChecks.cmake
serf/branches/SERF-195/test/CMakeLists.txt
Propchange: serf/branches/SERF-195/
------------------------------------------------------------------------------
Merged /serf/trunk:r1926861-1926882
Modified: serf/branches/SERF-195/CMakeLists.txt
URL:
http://svn.apache.org/viewvc/serf/branches/SERF-195/CMakeLists.txt?rev=1926883&r1=1926882&r2=1926883&view=diff
==============================================================================
--- serf/branches/SERF-195/CMakeLists.txt (original)
+++ serf/branches/SERF-195/CMakeLists.txt Tue Jul 1 02:22:14 2025
@@ -222,7 +222,7 @@ if(SERF_WINDOWS)
"secur32.lib"
"ws2_32.lib"
)
- add_compile_definitions("SERF_HAVE_SSPI")
+ list(APPEND SERF_C_DEFINES "SERF_HAVE_SSPI")
endif()
# Process build options for dependency search
@@ -241,6 +241,12 @@ find_package(ZLIB REQUIRED)
find_package(APR REQUIRED)
find_package(APRUtil REQUIRED)
+# We do not want or need OpenSSL's compatibility macros.
+list(APPEND SERF_C_DEFINES "OPENSSL_NO_DEPRECATED")
+
+# Hide OpenSSL's _fp() API.
+list(APPEND SERF_C_DEFINES "OPENSSL_NO_STDIO")
+
# Find optional dependencies
find_package(Brotli)
if(NOT SERF_WINDOWS)
@@ -259,7 +265,7 @@ if(Brotli_FOUND)
list(APPEND SERF_PRIVATE_TARGETS Brotli::Decode)
endif()
if(GSSAPI_FOUND)
- add_compile_definitions("SERF_HAVE_GSSAPI")
+ list(APPEND SERF_C_DEFINES "SERF_HAVE_GSSAPI")
list(APPEND SERF_PRIVATE_TARGETS KRB5::GSSAPI)
endif()
@@ -319,8 +325,7 @@ CheckType("OSSL_HANDSHAKE_STATE" "openss
if(Brotli_FOUND)
CheckType("BrotliDecoderResult" "brotli/decode.h"
"SERF_HAVE_BROTLI_DECODER_RESULT" ${BROTLI_INCLUDES})
# Check for the function only if the type check succeeded.
- get_directory_property(_cdef COMPILE_DEFINITIONS)
- if("SERF_HAVE_BROTLI_DECODER_RESULT" IN_LIST _cdef)
+ if("SERF_HAVE_BROTLI_DECODER_RESULT" IN_LIST SERF_C_DEFINES)
CheckFunction("BrotliDecoderTakeOutput" "NULL, NULL" "SERF_HAVE_BROTLI"
"brotli/decode.h" ${BROTLI_INCLUDES}
Brotli::Decode ${SERF_STANDARD_LIBRARIES})
@@ -333,59 +338,59 @@ endif()
# Process other build options
if(DEBUG)
- add_compile_definitions("DEBUG" "_DEBUG")
+ list(APPEND SERF_C_DEFINES "DEBUG" "_DEBUG")
endif()
if(DISABLE_LOGGING)
- add_compile_definitions("SERF_DISABLE_LOGGING")
+ list(APPEND SERF_C_DEFINES "SERF_DISABLE_LOGGING")
endif()
if(ENABLE_SLOW_TESTS)
- add_compile_definitions("SERF_TEST_DEFLATE_4GBPLUS_BUCKETS")
+ list(APPEND SERF_C_DEFINES "SERF_TEST_DEFLATE_4GBPLUS_BUCKETS")
endif()
-# Define OPENSSL_NO_STDIO to prevent using _fp() API.
-add_compile_definitions("OPENSSL_NO_STDIO")
-
# Set common compiler flags
+set(CMAKE_C_STANDARD 90) # Use C90. MockHTTP overrides this.
+set(CMAKE_C_EXTENSIONS OFF)
+set(CMAKE_C_STANDARD_REQUIRED TRUE)
+
if(NOT MSVC)
if(CC_LIKE_GNUC)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wdeclaration-after-statement")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-prototypes")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89")
+ list(APPEND SERF_C_WARNINGS "-Wall")
+ list(APPEND SERF_C_WARNINGS "-Wdeclaration-after-statement")
+ list(APPEND SERF_C_WARNINGS "-Wmissing-prototypes")
- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
+ string(APPEND CMAKE_C_FLAGS_DEBUG " -O0")
if(SERF_MAINTAINER_MODE)
# Additional warning flags for more pedantic checks
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wimplicit-function-declaration")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-variable-declarations")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunreachable-code")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshorten-64-to-32")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-system-headers")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra-tokens")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wnewline-eof")
+ list(APPEND SERF_C_WARNINGS "-Wimplicit-function-declaration")
+ list(APPEND SERF_C_WARNINGS "-Wmissing-variable-declarations")
+ list(APPEND SERF_C_WARNINGS "-Wunreachable-code")
+ list(APPEND SERF_C_WARNINGS "-Wshorten-64-to-32")
+ list(APPEND SERF_C_WARNINGS "-Wno-system-headers")
+ list(APPEND SERF_C_WARNINGS "-Wextra-tokens")
+ list(APPEND SERF_C_WARNINGS "-Wnewline-eof")
endif()
endif()
else()
# Warning level 4, no unused argument warnings
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4 /wd4100")
+ list(APPEND SERF_C_WARNINGS "/W4" "/wd4100")
# Conditional expression is constant
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127")
+ list(APPEND SERF_C_WARNINGS "/wd4127")
# Assignment within conditional expression
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4706")
+ list(APPEND SERF_C_WARNINGS "/wd4706")
# 'function' undefined; assuming extern returning int
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /we4013")
+ list(APPEND SERF_C_WARNINGS "/we4013")
- add_compile_definitions(
+ list(APPEND SERF_C_DEFINES
"WIN32" "WIN32_LEAN_AND_MEAN"
"NOUSER" "NOGDI" "NONLS" "NOCRYPT"
"_CRT_SECURE_NO_WARNINGS"
"_CRT_NONSTDC_NO_WARNINGS"
)
if(SERF_WIN64)
- add_compile_definitions("WIN64")
+ list(APPEND SERF_C_DEFINES "WIN64")
endif()
set(CMAKE_IMPORT_LIBRARY_PREFIX "${SERF_INSTALL_LIBRARIES}")
@@ -395,7 +400,10 @@ endif(NOT MSVC)
# Define all targets
if(NOT SKIP_SHARED)
add_library(serf_shared SHARED ${SOURCES} ${SHARED_SOURCES})
- target_compile_options(serf_shared PUBLIC ${APR_CFLAGS})
+ target_compile_options(serf_shared
+ PUBLIC ${APR_CFLAGS}
+ PRIVATE ${SERF_C_WARNINGS})
+ target_compile_definitions(serf_shared PRIVATE ${SERF_C_DEFINES})
target_include_directories(serf_shared PUBLIC ${SERF_SOURCE_DIR})
target_link_libraries(serf_shared
PRIVATE ${SERF_PRIVATE_TARGETS}
@@ -426,7 +434,10 @@ endif()
if(NOT SKIP_STATIC)
add_library(serf_static STATIC ${SOURCES})
- target_compile_options(serf_static PUBLIC ${APR_CFLAGS})
+ target_compile_options(serf_static
+ PUBLIC ${APR_CFLAGS}
+ PRIVATE ${SERF_C_WARNINGS})
+ target_compile_definitions(serf_static PRIVATE ${SERF_C_DEFINES})
target_include_directories(serf_static PUBLIC ${SERF_SOURCE_DIR})
target_link_libraries(serf_static
${SERF_PRIVATE_TARGETS}
@@ -520,14 +531,13 @@ if(DOT_CLANGD)
set(_gen_dot_clangd ON)
endif()
-get_directory_property(_cdef COMPILE_DEFINITIONS)
-if("SERF_HAVE_BROTLI" IN_LIST _cdef)
+if("SERF_HAVE_BROTLI" IN_LIST SERF_C_DEFINES)
set(_have_brotli ON)
endif()
-if("SERF_HAVE_GSSAPI" IN_LIST _cdef)
+if("SERF_HAVE_GSSAPI" IN_LIST SERF_C_DEFINES)
set(_have_gssapi ON)
endif()
-if("SERF_HAVE_SSPI" IN_LIST _cdef)
+if("SERF_HAVE_SSPI" IN_LIST SERF_C_DEFINES)
set(_have_sspi ON)
endif()
Modified: serf/branches/SERF-195/README
URL:
http://svn.apache.org/viewvc/serf/branches/SERF-195/README?rev=1926883&r1=1926882&r2=1926883&view=diff
==============================================================================
--- serf/branches/SERF-195/README (original)
+++ serf/branches/SERF-195/README Tue Jul 1 02:22:14 2025
@@ -37,7 +37,10 @@ Fetch the scons-local package:
To build serf:
-$ scons APR=/path/to/apr APU=/path/to/apu OPENSSL=/openssl/base
PREFIX=/path/to/prefix
+$ scons PREFIX=/path/to/prefix \
+ APR=/path/to/apr APU=/path/to/apr-util \
+ OPENSSL=/path/to/openssl ZLIB=/path/to/zlib \
+ BROTLI=/path/to/brotli GSSAPI=/path/to/kerberos
The switches are recorded into .saved_config, so they only need to be
specified the first time scons is run.
@@ -45,14 +48,31 @@ specified the first time scons is run.
PREFIX should specify where serf should be installed. PREFIX defaults to
/usr/local.
-The default for the other three switches (APR, APU, OPENSSL) is /usr.
+The default for the mandatory dependencies (APR, APU, OPENSSL, ZLIB) is /usr.
The build system looks for apr-1-config at $APR/bin/apr-1-config, or
the path should indicate apr-1-config itself. Similarly for the path
-to apu-1-config.
+to apu-1-config in $APU or $APU/bin/apu-1-config.
+
+OPENSSL should specify the root of the install (e.g., /opt/local). The
+includes will be found $OPENSSL/include/openssl and libraries at $OPENSSL/lib.
+
+OPENSSL should specify the root of the install. The includes will be found
+$ZLIB/include and libraries at $ZLIB/lib.
+
+The BROTLI and GSSAPI dependencies are optional.
+
+BROTLI should be the path to the installation of the Brotli compression
+library; for example, BROTLI=/usr/local. The includes will be found
+in $BROTLI/include/brotli and the libraries in $BROTLI/lib.
+
+GSSAPI should be the path to the installation of a package that provides
+the GSSAPI implementation such as Kerberos5 or Heimdal. SCons will look
+for the configuration program $GSSAPI/bin/krb5-config.
+
+NOTE: Do not use the GSSAPI switch on Windows; it provides the SSPI API
+ which Serf uses by default on that platform.
-OPENSSL should specify the root of the install (eg. /opt/local). The
-includes will be found OPENSSL/include and libraries at OPENSSL/lib.
If you wish to use VPATH-style builds (where objects are created in a
distinct directory from the source), you can use:
@@ -103,13 +123,17 @@ $ scons -c
Get the sources, either a release tarball or by checking out the
official repository. The CMake build system currently only exists in
-/trunk and it will be included in the 1.4 release.
+trunk and it will be included in the 1.4 release.
The process for building on Unix and Windows is the same.
$ cmake -B out [build options]
$ cmake --build out
+or, with a multi-config generator:
+
+ $ cmake --build out --config Release
+
"out" in the commands above is the build directory used by CMake.
Build options can be added, for example:
@@ -120,7 +144,30 @@ Build options can be listed using:
$ cmake -LH
-Windows tricks:
+By default, CMake will look for dependencies in ${CMAKE_SEARCH_PREFIX}, which
+you can override on the command line, e.g.::
+
+ $ cmake -DCMAKE_SEARCH_PREFIX=/opt
+
+The search for each the five dependencies can be modified by setting their
+*_ROOT CMake variables:
+
+ $ cmake -DAPR_ROOR=/path/to/apr \
+ -DAPRUtil_ROOT=/path/to/apr-util \
+ -DOPENSSL_ROOT_DIR=/path/to/openssl \
+ -DZLIB_ROOT=/path/to/zlib \
+ -DBrotli_ROOT=/path/to/brotli \
+ -DGSSAPI_ROOT=/path/to/kerberos5
+
+
+1.2.2 MacOS specifics
+
+The CMake build system can search for dependencies from Homebrew or
+MacPorts: use 'cmake -DUSE_HOMEBREW=ON' to search for Homebrew packages,
+or 'cmake -DUSE_MACPORTS=ON' to search installed MacPorts. Just not both.
+
+
+1.2.3 Windows tricks
- Modern versions of Microsoft Visual Studio provide support for
CMake projects out-of-box, including intellisense, integrated
@@ -154,15 +201,33 @@ Windows tricks:
<VCPKG_ROOT>/scripts/buildsystems/vcpkg.cmake
-1.2.1 Running the test suite
-$ cd out
-$ ctest
-# this only seems to run part of the testsuite?
-$ ./test/test_all
-# fails due to missing certificates
-$ cp ../test/*.pem ../test/certs test/
-$ ./test/test_all
-# Succeeds?
+1.2.4 Running the test suite
+
+To run the test suite, go to the CMake output directory, then:
+
+ $ ctest
+
+or, with a multi-config generator:
+
+ $ ctest -C Release
+
+This is equivalent to
+
+ $ cmake --build out --target test
+
+or
+
+ $ cmake --build out --config Release --target test
+
+(or, on Windows using the Visual Studio generator, which always has to be
+ special and different for no discernible benefit:
+
+ $ cmake --build out --config Release --target run_tests
+)
+
+
+1.2.5 Installing Apache Serf
-This should be described in detail.
+ $ cmake --build out --target install
+ $ cmake --build out --config Release --target install
Modified: serf/branches/SERF-195/build/SerfChecks.cmake
URL:
http://svn.apache.org/viewvc/serf/branches/SERF-195/build/SerfChecks.cmake?rev=1926883&r1=1926882&r2=1926883&view=diff
==============================================================================
--- serf/branches/SERF-195/build/SerfChecks.cmake (original)
+++ serf/branches/SERF-195/build/SerfChecks.cmake Tue Jul 1 02:22:14 2025
@@ -21,7 +21,10 @@ include(CheckCSourceCompiles)
include(CheckIncludeFile)
include(CheckTypeSize)
+list(TRANSFORM SERF_C_DEFINES PREPEND "-D" OUTPUT_VARIABLE cdef_)
+
function(_CheckFunction var_ name_ args_ header_ includes_ libraries_)
+ set(CMAKE_REQUIRED_DEFINITIONS ${cdef_})
if(libraries_)
set(CMAKE_REQUIRED_LIBRARIES "${libraries_}")
else()
@@ -61,13 +64,14 @@ function(_CheckFunction var_ name_ args_
unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_REQUIRED_LIBRARIES)
+ unset(CMAKE_REQUIRED_DEFINITIONS)
endfunction(_CheckFunction)
macro(CheckFunction name_ args_ symbol_ header_ includes_)
_CheckFunction("serf_feature_CheckFunction_${name_}_"
"${name_}" "${args_}" "${header_}" "${includes_}" "${ARGN}")
if("${serf_feature_CheckFunction_${name_}_}")
- add_compile_definitions("${symbol_}")
+ list(APPEND SERF_C_DEFINES "${symbol_}")
endif()
endmacro(CheckFunction)
@@ -75,12 +79,13 @@ macro(CheckNotFunction name_ args_ symbo
_CheckFunction("serf_feature_CheckNotFunction_${name_}_"
"${name_}" "${args_}" "${header_}" "${includes_}" "${ARGN}")
if(NOT "${serf_feature_CheckNotFunction_${name_}_}")
- add_compile_definitions("${symbol_}")
+ list(APPEND SERF_C_DEFINES "${symbol_}")
endif()
endmacro(CheckNotFunction)
function(_CheckHeader var_ name_ includes_)
+ set(CMAKE_REQUIRED_DEFINITIONS ${cdef_})
if(includes_)
set(CMAKE_REQUIRED_INCLUDES "${includes_}")
else()
@@ -94,17 +99,19 @@ function(_CheckHeader var_ name_ include
set("${var_}" FALSE PARENT_SCOPE)
endif()
unset(CMAKE_REQUIRED_INCLUDES)
+ unset(CMAKE_REQUIRED_DEFINITIONS)
endfunction(_CheckHeader)
macro(CheckHeader name_ symbol_)
_CheckHeader("serf_feature_CheckHeader_${name_}_" "${name_}" "${ARGN}")
if("${serf_feature_CheckHeader_${name_}_}")
- add_compile_definitions("${symbol_}")
+ list(APPEND SERF_C_DEFINES "${symbol_}")
endif()
endmacro(CheckHeader)
function(_CheckType var_ name_ header_ includes_)
+ set(CMAKE_REQUIRED_DEFINITIONS ${cdef_})
if(includes_)
set(CMAKE_REQUIRED_INCLUDES "${includes_}")
else()
@@ -125,11 +132,12 @@ function(_CheckType var_ name_ header_ i
endif()
unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_EXTRA_INCLUDE_FILES)
+ unset(CMAKE_REQUIRED_DEFINITIONS)
endfunction(_CheckType)
macro(CheckType name_ header_ symbol_)
_CheckType("serf_feature_CheckType_${name_}_" "${name_}" "${header_}"
"${ARGN}")
if("${serf_feature_CheckType_${name_}_}")
- add_compile_definitions("${symbol_}")
+ list(APPEND SERF_C_DEFINES "${symbol_}")
endif()
endmacro(CheckType)
Modified: serf/branches/SERF-195/test/CMakeLists.txt
URL:
http://svn.apache.org/viewvc/serf/branches/SERF-195/test/CMakeLists.txt?rev=1926883&r1=1926882&r2=1926883&view=diff
==============================================================================
--- serf/branches/SERF-195/test/CMakeLists.txt (original)
+++ serf/branches/SERF-195/test/CMakeLists.txt Tue Jul 1 02:22:14 2025
@@ -17,6 +17,7 @@
# under the License.
# ===================================================================
+add_subdirectory(MockHTTPinC)
set(TEST_ALL_SOURCES
"test_all.c"
@@ -30,8 +31,6 @@ set(TEST_ALL_SOURCES
"mock_buckets.c"
"mock_sock_buckets.c"
"test_ssl.c"
- "MockHTTPinC/MockHTTP.c"
- "MockHTTPinC/MockHTTP_server.c"
)
set(TEST_ALL_SUITES
@@ -52,22 +51,20 @@ set(SIMPLE_TEST_TARGETS
"serf_bwtp"
)
-if(CC_LIKE_GNUC)
- # MockHTTP requires C99 standard, so use it for the test suite.
- string(REPLACE "-std=c89" "-std=c99" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
-endif()
-
foreach(TEST_TARGET ${SIMPLE_TEST_TARGETS})
add_executable(${TEST_TARGET} "${TEST_TARGET}.c")
add_dependencies(${TEST_TARGET} serf_static)
+ target_compile_definitions(${TEST_TARGET} PRIVATE ${SERF_C_DEFINES})
+ target_compile_options(${TEST_TARGET} PRIVATE ${SERF_C_WARNINGS})
target_link_libraries(${TEST_TARGET} serf_static)
endforeach()
add_executable(test_all ${TEST_ALL_SOURCES})
-add_dependencies(test_all serf_static)
-target_compile_definitions(test_all PRIVATE "-DMOCKHTTP_OPENSSL")
+add_dependencies(test_all serf_static mockhttpinc)
+target_compile_options(test_all PRIVATE ${SERF_C_WARNINGS})
+target_compile_definitions(test_all PRIVATE ${SERF_C_DEFINES})
target_include_directories(test_all SYSTEM BEFORE PRIVATE
${SERF_DEPENDENCY_INCLUDES})
-target_link_libraries(test_all serf_static)
+target_link_libraries(test_all serf_static mockhttpinc)
file(GLOB RESPONSE_TEST_CASES
"${CMAKE_CURRENT_SOURCE_DIR}/testcases/*.response")
foreach(TEST_CASE ${RESPONSE_TEST_CASES})