diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2021-11-10 21:49:20 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2021-11-10 22:10:03 -0500 |
commit | 6d94467df805c3c2995b370a5f96bc978bf36600 (patch) | |
tree | 063dba23c02b0dd8b8e1f68afd1d3942905444c8 | |
parent | 010ead54d6af04a49c67ac890af5d0772a73c537 (diff) | |
download | libgit2-6d94467df805c3c2995b370a5f96bc978bf36600.tar.gz |
cmake: refactor http_parser selection
Move http_parser selection into its own cmake module.
-rw-r--r-- | cmake/SelectHTTPParser.cmake | 19 | ||||
-rw-r--r-- | src/CMakeLists.txt | 22 |
2 files changed, 21 insertions, 20 deletions
diff --git a/cmake/SelectHTTPParser.cmake b/cmake/SelectHTTPParser.cmake new file mode 100644 index 000000000..a1724a7c4 --- /dev/null +++ b/cmake/SelectHTTPParser.cmake @@ -0,0 +1,19 @@ +# Optional external dependency: http-parser +if(USE_HTTP_PARSER STREQUAL "system") + find_package(HTTP_Parser) + + if(HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2) + list(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS}) + list(APPEND LIBGIT2_LIBS ${HTTP_PARSER_LIBRARIES}) + list(APPEND LIBGIT2_PC_LIBS "-lhttp_parser") + add_feature_info(http-parser ON "http-parser support (system)") + else() + message(FATAL_ERROR "http-parser support was requested but not found") + endif() +else() + message(STATUS "http-parser version 2 was not found or disabled; using bundled 3rd-party sources.") + add_subdirectory("${libgit2_SOURCE_DIR}/deps/http-parser" "${libgit2_BINARY_DIR}/deps/http-parser") + list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/http-parser") + list(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:http-parser>") + add_feature_info(http-parser ON "http-parser support (bundled)") +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5b2e471f6..9208e6897 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -111,6 +111,8 @@ endif() include(SelectHTTPSBackend) include(SelectHashes) +include(SelectHTTPParser) + target_sources(git2internal PRIVATE ${SRC_SHA1}) # Specify regular expression implementation @@ -165,26 +167,6 @@ else() message(FATAL_ERROR "The REGEX_BACKEND option provided is not supported") endif() -# Optional external dependency: http-parser -if(USE_HTTP_PARSER STREQUAL "system") - find_package(HTTPParser) - - if(HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2) - list(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS}) - list(APPEND LIBGIT2_LIBS ${HTTP_PARSER_LIBRARIES}) - list(APPEND LIBGIT2_PC_LIBS "-lhttp_parser") - add_feature_info(http-parser ON "http-parser support (system)") - else() - message(FATAL_ERROR "http-parser support was requested but not found") - endif() -else() - message(STATUS "http-parser version 2 was not found or disabled; using bundled 3rd-party sources.") - add_subdirectory("${libgit2_SOURCE_DIR}/deps/http-parser" "${libgit2_BINARY_DIR}/deps/http-parser") - list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/http-parser") - list(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:http-parser>") - add_feature_info(http-parser ON "http-parser support (bundled)") -endif() - # Optional external dependency: zlib SanitizeBool(USE_BUNDLED_ZLIB) if(USE_BUNDLED_ZLIB STREQUAL ON) |