Skip to content

Commit 0c675b8

Browse files
committed
cmake: enforce USE_HTTP_PARSER validity
When `-DUSE_HTTP_PARSER=...` is specified, ensure that the specified HTTP Parser is valid, do not fallback to builtin. Restore `-DUSE_HTTP_PARSER=system` for backcompatibility.
1 parent 533ec83 commit 0c675b8

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ option(USE_SSH "Enable SSH support. Can be set to a specific bac
3434
option(USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON)
3535
option(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS" ON)
3636
option(USE_SHA256 "Enable SHA256. Can be set to HTTPS/Builtin" ON)
37-
option(USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF)
38-
set(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation; either system or builtin.")
37+
option(USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF)
38+
set(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation. One of http-parser, llhttp, or builtin. (Defaults to builtin.)")
3939
# set(USE_XDIFF "" CACHE STRING "Specifies the xdiff implementation; either system or builtin.")
4040
set(REGEX_BACKEND "" CACHE STRING "Regular expression implementation. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")
4141
option(USE_BUNDLED_ZLIB "Use the bundled version of zlib. Can be set to one of Bundled(ON)/Chromium. The Chromium option requires a x86_64 processor with SSE4.2 and CLMUL" OFF)

cmake/SelectHTTPParser.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Optional external dependency: http-parser
2-
if(USE_HTTP_PARSER STREQUAL "http-parser")
3-
find_package(HTTPParser)
2+
if(USE_HTTP_PARSER STREQUAL "http-parser" OR USE_HTTP_PARSER STREQUAL "system")
3+
find_package(HTTP_Parser)
44

55
if(HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
66
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS})
@@ -23,10 +23,12 @@ elseif(USE_HTTP_PARSER STREQUAL "llhttp")
2323
else()
2424
message(FATAL_ERROR "llhttp support was requested but not found")
2525
endif()
26-
else()
26+
elseif(USE_HTTP_PARSER STREQUAL "" OR USE_HTTP_PARSER STREQUAL "builtin")
2727
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/llhttp" "${PROJECT_BINARY_DIR}/deps/llhttp")
2828
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/llhttp")
2929
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS "$<TARGET_OBJECTS:llhttp>")
3030
set(GIT_HTTPPARSER_BUILTIN 1)
3131
add_feature_info(http-parser ON "using bundled parser")
32+
else()
33+
message(FATAL_ERROR "unknown http-parser: ${USE_HTTP_PARSER}")
3234
endif()

0 commit comments

Comments
 (0)