diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2021-11-10 17:30:26 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2021-11-10 21:38:53 -0500 |
commit | b8307e09a5117e03a3b7fe76bf95b2173ea5a920 (patch) | |
tree | 2a2d246d8111cc9208bf3fe096d8d1eed2f1b055 /cmake | |
parent | 30ad7919036beaf782d41e41233c800bf4b43a8c (diff) | |
download | libgit2-ethomson/util3.tar.gz |
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/SelectHttpParser.cmake | 19 | ||||
-rw-r--r-- | cmake/SelectRegex.cmake | 51 | ||||
-rw-r--r-- | cmake/SelectSsh.cmake | 41 | ||||
-rw-r--r-- | cmake/SelectWinHttp.cmake | 17 | ||||
-rw-r--r-- | cmake/SelectZlib.cmake | 34 |
5 files changed, 162 insertions, 0 deletions
diff --git a/cmake/SelectHttpParser.cmake b/cmake/SelectHttpParser.cmake new file mode 100644 index 000000000..ed08ad677 --- /dev/null +++ b/cmake/SelectHttpParser.cmake @@ -0,0 +1,19 @@ +# 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_SYSTEM_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_DEPENDENCY_INCLUDES "${libgit2_SOURCE_DIR}/deps/http-parser") + list(APPEND LIBGIT2_DEPENDENCY_OBJECTS "$<TARGET_OBJECTS:http-parser>") + add_feature_info(http-parser ON "http-parser support (bundled)") +endif() diff --git a/cmake/SelectRegex.cmake b/cmake/SelectRegex.cmake new file mode 100644 index 000000000..1553d6587 --- /dev/null +++ b/cmake/SelectRegex.cmake @@ -0,0 +1,51 @@ +# Specify regular expression implementation +find_package(PCRE) + +if(REGEX_BACKEND STREQUAL "") + check_symbol_exists(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L) + + if(HAVE_REGCOMP_L) + set(REGEX_BACKEND "regcomp_l") + elseif(PCRE_FOUND) + set(REGEX_BACKEND "pcre") + else() + set(REGEX_BACKEND "builtin") + endif() +endif() + +if(REGEX_BACKEND STREQUAL "regcomp_l") + add_feature_info(regex ON "using system regcomp_l") + set(GIT_REGEX_REGCOMP_L 1) +elseif(REGEX_BACKEND STREQUAL "pcre2") + find_package(PCRE2) + + if(NOT PCRE2_FOUND) + MESSAGE(FATAL_ERROR "PCRE2 support was requested but not found") + endif() + + add_feature_info(regex ON "using system PCRE2") + set(GIT_REGEX_PCRE2 1) + + list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE2_INCLUDE_DIRS}) + list(APPEND LIBGIT2_SYSTEM_LIBS ${PCRE2_LIBRARIES}) + list(APPEND LIBGIT2_PC_REQUIRES "libpcre2-8") +elseif(REGEX_BACKEND STREQUAL "pcre") + add_feature_info(regex ON "using system PCRE") + set(GIT_REGEX_PCRE 1) + + list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE_INCLUDE_DIRS}) + list(APPEND LIBGIT2_SYSTEM_LIBS ${PCRE_LIBRARIES}) + list(APPEND LIBGIT2_PC_REQUIRES "libpcre") +elseif(REGEX_BACKEND STREQUAL "regcomp") + add_feature_info(regex ON "using system regcomp") + set(GIT_REGEX_REGCOMP 1) +elseif(REGEX_BACKEND STREQUAL "builtin") + add_feature_info(regex ON "using bundled PCRE") + set(GIT_REGEX_BUILTIN 1) + + add_subdirectory("${libgit2_SOURCE_DIR}/deps/pcre" "${libgit2_BINARY_DIR}/deps/pcre") + list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${libgit2_SOURCE_DIR}/deps/pcre") + list(APPEND LIBGIT2_DEPENDENCY_OBJECTS $<TARGET_OBJECTS:pcre>) +else() + message(FATAL_ERROR "The REGEX_BACKEND option provided is not supported") +endif() diff --git a/cmake/SelectSsh.cmake b/cmake/SelectSsh.cmake new file mode 100644 index 000000000..23dfc9785 --- /dev/null +++ b/cmake/SelectSsh.cmake @@ -0,0 +1,41 @@ +# Optional external dependency: libssh2 +if(USE_SSH) + find_pkglibraries(LIBSSH2 libssh2) + if(NOT LIBSSH2_FOUND) + find_package(LibSSH2) + set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR}) + get_filename_component(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY) + set(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY}) + set(LIBSSH2_LDFLAGS "-lssh2") + endif() + + if(NOT LIBSSH2_FOUND) + message(FATAL_ERROR "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.") + endif() +endif() + +if(LIBSSH2_FOUND) + set(GIT_SSH 1) + list(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS}) + list(APPEND LIBGIT2_SYSTEM_LIBS ${LIBSSH2_LIBRARIES}) + list(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS}) + + check_library_exists("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS) + if(HAVE_LIBSSH2_MEMORY_CREDENTIALS) + set(GIT_SSH_MEMORY_CREDENTIALS 1) + endif() +else() + message(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.") +endif() + +if(WIN32 AND EMBED_SSH_PATH) + file(GLOB SSH_SRC "${EMBED_SSH_PATH}/src/*.c") + list(SORT SSH_SRC) + list(APPEND LIBGIT2_DEPENDENCY_OBJECTS ${SSH_SRC}) + + list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${EMBED_SSH_PATH}/include") + file(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"") + set(GIT_SSH 1) +endif() + +add_feature_info(SSH GIT_SSH "SSH transport support") diff --git a/cmake/SelectWinHttp.cmake b/cmake/SelectWinHttp.cmake new file mode 100644 index 000000000..667b4007e --- /dev/null +++ b/cmake/SelectWinHttp.cmake @@ -0,0 +1,17 @@ +if(WIN32 AND USE_WINHTTP) + set(GIT_WINHTTP 1) + + # Since MinGW does not come with headers or an import library for winhttp, + # we have to include a private header and generate our own import library + if(MINGW) + add_subdirectory("${libgit2_SOURCE_DIR}/deps/winhttp" "${libgit2_BINARY_DIR}/deps/winhttp") + list(APPEND LIBGIT2_SYSTEM_LIBS winhttp) + list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp") + else() + list(APPEND LIBGIT2_SYSTEM_LIBS "winhttp") + list(APPEND LIBGIT2_PC_LIBS "-lwinhttp") + endif() + + list(APPEND LIBGIT2_SYSTEM_LIBS "rpcrt4" "crypt32" "ole32") + list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32") +endif() diff --git a/cmake/SelectZlib.cmake b/cmake/SelectZlib.cmake new file mode 100644 index 000000000..e377d43b6 --- /dev/null +++ b/cmake/SelectZlib.cmake @@ -0,0 +1,34 @@ +# Optional external dependency: zlib +include(SanitizeBool) + +SanitizeBool(USE_BUNDLED_ZLIB) +if(USE_BUNDLED_ZLIB STREQUAL ON) + set(USE_BUNDLED_ZLIB "Bundled") +endif() + +if(USE_BUNDLED_ZLIB STREQUAL "OFF") + find_package(ZLIB) + if(ZLIB_FOUND) + list(APPEND LIBGIT2_SYSTEM_INCLUDES ${ZLIB_INCLUDE_DIRS}) + list(APPEND LIBGIT2_SYSTEM_LIBS ${ZLIB_LIBRARIES}) + if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + list(APPEND LIBGIT2_PC_LIBS "-lz") + else() + list(APPEND LIBGIT2_PC_REQUIRES "zlib") + endif() + add_feature_info(zlib ON "using system zlib") + else() + message(STATUS "zlib was not found; using bundled 3rd-party sources." ) + endif() +endif() +if(USE_BUNDLED_ZLIB STREQUAL "Chromium") + add_subdirectory("${libgit2_SOURCE_DIR}/deps/chromium-zlib" "${libgit2_BINARY_DIR}/deps/chromium-zlib") + list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${libgit2_SOURCE_DIR}/deps/chromium-zlib") + list(APPEND LIBGIT2_DEPENDENCY_OBJECTS $<TARGET_OBJECTS:chromium_zlib>) + add_feature_info(zlib ON "using (Chromium) bundled zlib") +elseif(USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND) + add_subdirectory("${libgit2_SOURCE_DIR}/deps/zlib" "${libgit2_BINARY_DIR}/deps/zlib") + list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib") + list(APPEND LIBGIT2_DEPENDENCY_OBJECTS $<TARGET_OBJECTS:zlib>) + add_feature_info(zlib ON "using bundled zlib") +endif() |