summaryrefslogtreecommitdiff
path: root/src/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/CMakeLists.txt')
-rw-r--r--src/CMakeLists.txt568
1 files changed, 285 insertions, 283 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b3d620c45..9812fc0e4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,89 +1,91 @@
add_library(git2internal OBJECT)
set_target_properties(git2internal PROPERTIES C_STANDARD 90)
-IF(DEBUG_POOL)
- SET(GIT_DEBUG_POOL 1)
-ENDIF()
-ADD_FEATURE_INFO(debugpool GIT_DEBUG_POOL "debug pool allocator")
-IF(DEBUG_STRICT_ALLOC)
- SET(GIT_DEBUG_STRICT_ALLOC 1)
-ENDIF()
-ADD_FEATURE_INFO(debugalloc GIT_DEBUG_STRICT_ALLOC "debug strict allocators")
+if(DEBUG_POOL)
+ set(GIT_DEBUG_POOL 1)
+endif()
+add_feature_info(debugpool GIT_DEBUG_POOL "debug pool allocator")
+
+if(DEBUG_STRICT_ALLOC)
+ set(GIT_DEBUG_STRICT_ALLOC 1)
+endif()
+add_feature_info(debugalloc GIT_DEBUG_STRICT_ALLOC "debug strict allocators")
+
+if(DEBUG_STRICT_OPEN)
+ set(GIT_DEBUG_STRICT_OPEN 1)
+endif()
+add_feature_info(debugopen GIT_DEBUG_STRICT_OPEN "path validation in open")
-IF(DEBUG_STRICT_OPEN)
- SET(GIT_DEBUG_STRICT_OPEN 1)
-ENDIF()
-ADD_FEATURE_INFO(debugopen GIT_DEBUG_STRICT_OPEN "path validation in open")
-INCLUDE(PkgBuildConfig)
-INCLUDE(SanitizeBool)
+include(PkgBuildConfig)
+include(SanitizeBool)
# This variable will contain the libraries we need to put into
# libgit2.pc's Requires.private. That is, what we're linking to or
# what someone who's statically linking us needs to link to.
-SET(LIBGIT2_PC_REQUIRES "")
+set(LIBGIT2_PC_REQUIRES "")
# This will be set later if we use the system's http-parser library or
# use iconv (OSX) and will be written to the Libs.private field in the
# pc file.
-SET(LIBGIT2_PC_LIBS "")
+set(LIBGIT2_PC_LIBS "")
-SET(LIBGIT2_INCLUDES
+set(LIBGIT2_INCLUDES
"${CMAKE_CURRENT_BINARY_DIR}"
"${libgit2_SOURCE_DIR}/src"
"${libgit2_SOURCE_DIR}/include")
-SET(LIBGIT2_SYSTEM_INCLUDES "")
-SET(LIBGIT2_LIBS "")
+set(LIBGIT2_SYSTEM_INCLUDES "")
+set(LIBGIT2_LIBS "")
enable_warnings(missing-declarations)
-IF (HAVE_FUTIMENS)
- SET(GIT_USE_FUTIMENS 1)
-ENDIF ()
-ADD_FEATURE_INFO(futimens GIT_USE_FUTIMENS "futimens support")
+if(HAVE_FUTIMENS)
+ set(GIT_USE_FUTIMENS 1)
+endif ()
+add_feature_info(futimens GIT_USE_FUTIMENS "futimens support")
-CHECK_PROTOTYPE_DEFINITION(qsort_r
+check_prototype_definition(qsort_r
"void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))"
"" "stdlib.h" HAVE_QSORT_R_BSD)
-IF (HAVE_QSORT_R_BSD)
+if(HAVE_QSORT_R_BSD)
target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_BSD)
-ENDIF()
+endif()
-CHECK_PROTOTYPE_DEFINITION(qsort_r
+check_prototype_definition(qsort_r
"void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)"
"" "stdlib.h" HAVE_QSORT_R_GNU)
-IF (HAVE_QSORT_R_GNU)
+if(HAVE_QSORT_R_GNU)
target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_GNU)
-ENDIF()
+endif()
-CHECK_FUNCTION_EXISTS(qsort_s HAVE_QSORT_S)
-IF (HAVE_QSORT_S)
+check_function_exists(qsort_s HAVE_QSORT_S)
+if(HAVE_QSORT_S)
target_compile_definitions(git2internal PRIVATE HAVE_QSORT_S)
-ENDIF ()
+endif()
# Find required dependencies
-IF(WIN32)
- LIST(APPEND LIBGIT2_LIBS ws2_32)
-ELSEIF(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
- LIST(APPEND LIBGIT2_LIBS socket nsl)
- LIST(APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl")
-ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Haiku")
- LIST(APPEND LIBGIT2_LIBS network)
- LIST(APPEND LIBGIT2_PC_LIBS "-lnetwork")
-ENDIF()
-
-CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" NEED_LIBRT)
-IF(NEED_LIBRT)
- LIST(APPEND LIBGIT2_LIBS rt)
- LIST(APPEND LIBGIT2_PC_LIBS "-lrt")
-ENDIF()
-
-IF(THREADSAFE)
- LIST(APPEND LIBGIT2_LIBS ${CMAKE_THREAD_LIBS_INIT})
- LIST(APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT})
-ENDIF()
-ADD_FEATURE_INFO(threadsafe THREADSAFE "threadsafe support")
+if(WIN32)
+ list(APPEND LIBGIT2_LIBS ws2_32)
+elseif(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
+ list(APPEND LIBGIT2_LIBS socket nsl)
+ list(APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl")
+elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku")
+ list(APPEND LIBGIT2_LIBS network)
+ list(APPEND LIBGIT2_PC_LIBS "-lnetwork")
+endif()
+
+check_library_exists(rt clock_gettime "time.h" NEED_LIBRT)
+if(NEED_LIBRT)
+ list(APPEND LIBGIT2_LIBS rt)
+ list(APPEND LIBGIT2_PC_LIBS "-lrt")
+endif()
+
+if(THREADSAFE)
+ list(APPEND LIBGIT2_LIBS ${CMAKE_THREAD_LIBS_INIT})
+ list(APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT})
+endif()
+add_feature_info(threadsafe THREADSAFE "threadsafe support")
if(WIN32 AND EMBED_SSH_PATH)
@@ -96,204 +98,204 @@ if(WIN32 AND EMBED_SSH_PATH)
set(GIT_SSH 1)
endif()
-IF (WIN32 AND WINHTTP)
- SET(GIT_WINHTTP 1)
+if(WIN32 AND 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_LIBS winhttp)
- LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
- ELSE()
- LIST(APPEND LIBGIT2_LIBS "winhttp")
- LIST(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
- ENDIF ()
-
- LIST(APPEND LIBGIT2_LIBS "rpcrt4" "crypt32" "ole32")
- LIST(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
-ENDIF()
+ if(MINGW)
+ add_subdirectory("${libgit2_SOURCE_DIR}/deps/winhttp" "${libgit2_BINARY_DIR}/deps/winhttp")
+ list(APPEND LIBGIT2_LIBS winhttp)
+ list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
+ else()
+ list(APPEND LIBGIT2_LIBS "winhttp")
+ list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
+ endif()
+
+ list(APPEND LIBGIT2_LIBS "rpcrt4" "crypt32" "ole32")
+ list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
+endif()
include(SelectHTTPSBackend)
include(SelectHashes)
target_sources(git2internal PRIVATE ${SRC_SHA1})
# 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)
+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_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_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_INCLUDES "${libgit2_SOURCE_DIR}/deps/pcre")
- LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:pcre>)
-ELSE()
- MESSAGE(FATAL_ERROR "The REGEX_BACKEND option provided is not supported")
-ENDIF()
+ 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_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_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_INCLUDES "${libgit2_SOURCE_DIR}/deps/pcre")
+ list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:pcre>)
+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(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()
+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()
# Optional external dependency: zlib
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_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_INCLUDES "${libgit2_SOURCE_DIR}/deps/chromium-zlib")
- LIST(APPEND LIBGIT2_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_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
- LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:zlib>)
- ADD_FEATURE_INFO(zlib ON "using bundled zlib")
-ENDIF()
+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_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_INCLUDES "${libgit2_SOURCE_DIR}/deps/chromium-zlib")
+ list(APPEND LIBGIT2_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_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
+ list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:zlib>)
+ add_feature_info(zlib ON "using bundled zlib")
+endif()
# 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()
-ENDIF()
-IF (LIBSSH2_FOUND)
- SET(GIT_SSH 1)
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
- LIST(APPEND LIBGIT2_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()
-ADD_FEATURE_INFO(SSH GIT_SSH "SSH transport support")
+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()
+endif()
+if(LIBSSH2_FOUND)
+ set(GIT_SSH 1)
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
+ list(APPEND LIBGIT2_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()
+add_feature_info(SSH GIT_SSH "SSH transport support")
# Optional external dependency: ntlmclient
-IF (USE_NTLMCLIENT)
- SET(GIT_NTLM 1)
- ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/ntlmclient" "${libgit2_BINARY_DIR}/deps/ntlmclient")
- LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/ntlmclient")
- LIST(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:ntlmclient>")
-ENDIF()
-ADD_FEATURE_INFO(ntlmclient GIT_NTLM "NTLM authentication support for Unix")
+if(USE_NTLMCLIENT)
+ set(GIT_NTLM 1)
+ add_subdirectory("${libgit2_SOURCE_DIR}/deps/ntlmclient" "${libgit2_BINARY_DIR}/deps/ntlmclient")
+ list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/ntlmclient")
+ list(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:ntlmclient>")
+endif()
+add_feature_info(ntlmclient GIT_NTLM "NTLM authentication support for Unix")
# Optional external dependency: GSSAPI
-INCLUDE(SelectGSSAPI)
+include(SelectGSSAPI)
# Optional external dependency: iconv
-IF (USE_ICONV)
- FIND_PACKAGE(Iconv)
-ENDIF()
-IF (ICONV_FOUND)
- SET(GIT_USE_ICONV 1)
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${ICONV_INCLUDE_DIR})
- LIST(APPEND LIBGIT2_LIBS ${ICONV_LIBRARIES})
- LIST(APPEND LIBGIT2_PC_LIBS ${ICONV_LIBRARIES})
-ENDIF()
-ADD_FEATURE_INFO(iconv GIT_USE_ICONV "iconv encoding conversion support")
-
-
-IF (THREADSAFE)
- IF (NOT WIN32)
- FIND_PACKAGE(Threads REQUIRED)
- ENDIF()
-
- SET(GIT_THREADS 1)
-ENDIF()
-
-IF (USE_NSEC)
- SET(GIT_USE_NSEC 1)
-ENDIF()
-
-IF (HAVE_STRUCT_STAT_ST_MTIM)
- SET(GIT_USE_STAT_MTIM 1)
-ELSEIF (HAVE_STRUCT_STAT_ST_MTIMESPEC)
- SET(GIT_USE_STAT_MTIMESPEC 1)
-ELSEIF (HAVE_STRUCT_STAT_ST_MTIME_NSEC)
- SET(GIT_USE_STAT_MTIME_NSEC 1)
-ENDIF()
+if(USE_ICONV)
+ find_package(Iconv)
+endif()
+if(ICONV_FOUND)
+ set(GIT_USE_ICONV 1)
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES ${ICONV_INCLUDE_DIR})
+ list(APPEND LIBGIT2_LIBS ${ICONV_LIBRARIES})
+ list(APPEND LIBGIT2_PC_LIBS ${ICONV_LIBRARIES})
+endif()
+add_feature_info(iconv GIT_USE_ICONV "iconv encoding conversion support")
+
+
+if(THREADSAFE)
+ if(NOT WIN32)
+ find_package(Threads REQUIRED)
+ endif()
+
+ set(GIT_THREADS 1)
+endif()
+
+if(USE_NSEC)
+ set(GIT_USE_NSEC 1)
+endif()
+
+if(HAVE_STRUCT_STAT_ST_MTIM)
+ set(GIT_USE_STAT_MTIM 1)
+elseif(HAVE_STRUCT_STAT_ST_MTIMESPEC)
+ set(GIT_USE_STAT_MTIMESPEC 1)
+elseif(HAVE_STRUCT_STAT_ST_MTIME_NSEC)
+ set(GIT_USE_STAT_MTIME_NSEC 1)
+endif()
target_compile_definitions(git2internal PRIVATE _FILE_OFFSET_BITS=64)
@@ -307,7 +309,7 @@ target_sources(git2internal PRIVATE ${SRC_H})
# On Windows use specific platform sources
if(WIN32 AND NOT CYGWIN)
- SET(WIN_RC "win32/git2.rc")
+ set(WIN_RC "win32/git2.rc")
file(GLOB SRC_OS win32/*.c win32/*.h)
list(SORT SRC_OS)
@@ -320,9 +322,9 @@ else()
target_sources(git2internal PRIVATE ${SRC_OS})
endif()
-IF (USE_LEAK_CHECKER STREQUAL "valgrind")
+if(USE_LEAK_CHECKER STREQUAL "valgrind")
target_compile_definitions(git2internal PRIVATE VALGRIND)
-ENDIF()
+endif()
file(GLOB SRC_GIT2 *.c *.h
allocators/*.c allocators/*.h
@@ -332,65 +334,65 @@ file(GLOB SRC_GIT2 *.c *.h
list(SORT SRC_GIT2)
target_sources(git2internal PRIVATE ${SRC_GIT2})
-IF(APPLE)
+if(APPLE)
# The old Secure Transport API has been deprecated in macOS 10.15.
- SET_SOURCE_FILES_PROPERTIES(streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated)
-ENDIF()
+ set_source_files_properties(streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated)
+endif()
# the xdiff dependency is not (yet) warning-free, disable warnings as
# errors for the xdiff sources until we've sorted them out
-IF(MSVC)
- SET_SOURCE_FILES_PROPERTIES(xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS -WX-)
- SET_SOURCE_FILES_PROPERTIES(xdiff/xutils.c PROPERTIES COMPILE_FLAGS -WX-)
-ENDIF()
+if(MSVC)
+ set_source_files_properties(xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS -WX-)
+ set_source_files_properties(xdiff/xutils.c PROPERTIES COMPILE_FLAGS -WX-)
+endif()
# Determine architecture of the machine
-IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
- SET(GIT_ARCH_64 1)
-ELSEIF (CMAKE_SIZEOF_VOID_P EQUAL 4)
- SET(GIT_ARCH_32 1)
-ELSEIF (CMAKE_SIZEOF_VOID_P)
- MESSAGE(FATAL_ERROR "Unsupported architecture (pointer size is ${CMAKE_SIZEOF_VOID_P} bytes)")
-ELSE()
- MESSAGE(FATAL_ERROR "Unsupported architecture (CMAKE_SIZEOF_VOID_P is unset)")
-ENDIF()
-
-CONFIGURE_FILE(features.h.in git2/sys/features.h)
-
-IDE_SPLIT_SOURCES(git2internal)
-LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal>)
-
-TARGET_INCLUDE_DIRECTORIES(git2internal PRIVATE ${LIBGIT2_INCLUDES} PUBLIC ${libgit2_SOURCE_DIR}/include)
-TARGET_INCLUDE_DIRECTORIES(git2internal SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
-
-SET(LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE)
-SET(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
-SET(LIBGIT2_SYSTEM_INCLUDES ${LIBGIT2_SYSTEM_INCLUDES} PARENT_SCOPE)
-SET(LIBGIT2_LIBS ${LIBGIT2_LIBS} PARENT_SCOPE)
-
-IF(XCODE_VERSION)
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(GIT_ARCH_64 1)
+elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ set(GIT_ARCH_32 1)
+elseif(CMAKE_SIZEOF_VOID_P)
+ message(FATAL_ERROR "Unsupported architecture (pointer size is ${CMAKE_SIZEOF_VOID_P} bytes)")
+else()
+ message(FATAL_ERROR "Unsupported architecture (CMAKE_SIZEOF_VOID_P is unset)")
+endif()
+
+configure_file(features.h.in git2/sys/features.h)
+
+ide_split_sources(git2internal)
+list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal>)
+
+target_include_directories(git2internal PRIVATE ${LIBGIT2_INCLUDES} PUBLIC ${libgit2_SOURCE_DIR}/include)
+target_include_directories(git2internal SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
+
+set(LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE)
+set(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
+set(LIBGIT2_SYSTEM_INCLUDES ${LIBGIT2_SYSTEM_INCLUDES} PARENT_SCOPE)
+set(LIBGIT2_LIBS ${LIBGIT2_LIBS} PARENT_SCOPE)
+
+if(XCODE_VERSION)
# This is required for Xcode to actually link the libgit2 library
# when using only object libraries.
- FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.c "")
- LIST(APPEND LIBGIT2_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/dummy.c)
-ENDIF()
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.c "")
+ list(APPEND LIBGIT2_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/dummy.c)
+endif()
# Compile and link libgit2
-ADD_LIBRARY(git2 ${WIN_RC} ${LIBGIT2_OBJECTS})
-TARGET_LINK_LIBRARIES(git2 ${LIBGIT2_LIBS})
+add_library(git2 ${WIN_RC} ${LIBGIT2_OBJECTS})
+target_link_libraries(git2 ${LIBGIT2_LIBS})
-SET_TARGET_PROPERTIES(git2 PROPERTIES C_STANDARD 90)
-SET_TARGET_PROPERTIES(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
-SET_TARGET_PROPERTIES(git2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
-SET_TARGET_PROPERTIES(git2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
+set_target_properties(git2 PROPERTIES C_STANDARD 90)
+set_target_properties(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
+set_target_properties(git2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
+set_target_properties(git2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
# Win64+MSVC+static libs = linker error
-IF(MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS)
- SET_TARGET_PROPERTIES(git2 PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64")
-ENDIF()
+if(MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS)
+ set_target_properties(git2 PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64")
+endif()
-IDE_SPLIT_SOURCES(git2)
+ide_split_sources(git2)
if(SONAME)
set_target_properties(git2 PROPERTIES VERSION ${libgit2_VERSION})
@@ -403,7 +405,7 @@ if(SONAME)
endif()
endif()
-PKG_BUILD_CONFIG(NAME libgit2
+pkg_build_config(NAME libgit2
VERSION ${libgit2_VERSION}
DESCRIPTION "The git library, take 2"
LIBS_SELF git2
@@ -411,17 +413,17 @@ PKG_BUILD_CONFIG(NAME libgit2
REQUIRES ${LIBGIT2_PC_REQUIRES}
)
-IF (MSVC_IDE)
- # Precompiled headers
- SET_TARGET_PROPERTIES(git2 PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
- SET_SOURCE_FILES_PROPERTIES(win32/precompiled.c COMPILE_FLAGS "/Ycprecompiled.h")
-ENDIF ()
+if(MSVC_IDE)
+ # Precompiled headers
+ set_target_properties(git2 PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
+ set_source_files_properties(win32/precompiled.c COMPILE_FLAGS "/Ycprecompiled.h")
+endif()
# Install
-INSTALL(TARGETS git2
+install(TARGETS git2
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
-INSTALL(DIRECTORY ${libgit2_SOURCE_DIR}/include/git2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-INSTALL(FILES ${libgit2_SOURCE_DIR}/include/git2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+install(DIRECTORY ${libgit2_SOURCE_DIR}/include/git2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+install(FILES ${libgit2_SOURCE_DIR}/include/git2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})