# CMake build script for the libgit2 project
#
# Building (out of source build):
# > mkdir build && cd build
# > cmake .. [-DSETTINGS=VALUE]
# > cmake --build .
#
# Testing:
# > ctest -V
#
# Install:
# > cmake --build . --target install
PROJECT(libgit2 C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
CMAKE_POLICY(SET CMP0015 NEW)
# Add find modules to the path
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
INCLUDE(CheckLibraryExists)
INCLUDE(AddCFlagIfSupported)
INCLUDE(FindPkgConfig)
# Build options
#
OPTION( SONAME "Set the (SO)VERSION of the target" ON )
OPTION( BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON )
OPTION( THREADSAFE "Build libgit2 as threadsafe" ON )
OPTION( BUILD_CLAR "Build Tests using the Clar suite" ON )
OPTION( BUILD_EXAMPLES "Build library usage example apps" OFF )
OPTION( TAGS "Generate tags" OFF )
OPTION( PROFILE "Generate profiling information" OFF )
OPTION( ENABLE_TRACE "Enables tracing support" OFF )
OPTION( LIBGIT2_FILENAME "Name of the produced binary" OFF )
OPTION( USE_ICONV "Link with and use iconv library" OFF )
OPTION( USE_SSH "Link with libssh to enable SSH support" ON )
OPTION( USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF )
OPTION( VALGRIND "Configure build for valgrind" OFF )
OPTION( CURL "User curl for HTTP if available" ON)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET( USE_ICONV ON )
FIND_PACKAGE(Security)
FIND_PACKAGE(CoreFoundation REQUIRED)
ENDIF()
IF(MSVC)
# This option is only available when building with MSVC. By default, libgit2
# is build using the cdecl calling convention, which is useful if you're
# writing C. However, the CLR and Win32 API both expect stdcall.
#
# If you are writing a CLR program and want to link to libgit2, you'll want
# to turn this on by invoking CMake with the "-DSTDCALL=ON" argument.
OPTION( STDCALL "Build libgit2 with the __stdcall convention" OFF )
# This option must match the settings used in your program, in particular if you
# are linking statically
OPTION( STATIC_CRT "Link the static CRT libraries" ON )
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
ENDIF()
IF(WIN32)
# By default, libgit2 is built with WinHTTP. To use the built-in
# HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument.
OPTION( WINHTTP "Use Win32 WinHTTP routines" ON )
ENDIF()
IF(MSVC)
# Enable MSVC CRTDBG memory leak reporting when in debug mode.
OPTION(MSVC_CRTDBG "Enable CRTDBG memory leak reporting" OFF)
ENDIF()
IF (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
OPTION( USE_OPENSSL "Link with and use openssl library" ON )
ENDIF()
# 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 "")
# 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 "")
# Installation paths
#
SET(BIN_INSTALL_DIR bin CACHE PATH "Where to install binaries to.")
SET(LIB_INSTALL_DIR lib CACHE PATH "Where to install libraries to.")
SET(INCLUDE_INSTALL_DIR include CACHE PATH "Where to install headers to.")
FUNCTION(TARGET_OS_LIBRARIES target)
IF(WIN32)
TARGET_LINK_LIBRARIES(${target} ws2_32)
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
TARGET_LINK_LIBRARIES(${target} socket nsl)
LIST(APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl")
SET(LIBGIT2_PC_LIBS ${LIBGIT2_PC_LIBS} PARENT_SCOPE)
ENDIF()
CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" NEED_LIBRT)
IF(NEED_LIBRT)
TARGET_LINK_LIBRARIES(${target} rt)
LIST(APPEND LIBGIT2_PC_LIBS "-lrt")
SET(LIBGIT2_PC_LIBS ${LIBGIT2_PC_LIBS} PARENT_SCOPE)
ENDIF()
IF(THREADSAFE)
TARGET_LINK_LIBRARIES(${target} ${CMAKE_THREAD_LIBS_INIT})
ENDIF()
ENDFUNCTION()
# For the MSVC IDE, this function splits up the source files like windows
# explorer does. This is esp. useful with the libgit2_clar project, were
# usually 2 or more files share the same name. Sadly, this file grouping
# is a per-directory option in cmake and not per-target, resulting in
# empty virtual folders "tests" for the git2.dll
FUNCTION(MSVC_SPLIT_SOURCES target)
IF(MSVC_IDE)
GET_TARGET_PROPERTY(sources ${target} SOURCES)
FOREACH(source ${sources})
IF(source MATCHES ".*/")
STRING(REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/ "" rel ${source})
IF(rel)
STRING(REGEX REPLACE "/([^/]*)$" "" rel ${rel})
IF(rel)
STRING(REPLACE "/" "\\\\" rel ${rel})
SOURCE_GROUP(${rel} FILES ${source})
ENDIF()
ENDIF()
ENDIF()
ENDFOREACH()
ENDIF()
ENDFUNCTION()
FILE(STRINGS "include/git2/version.h" GIT2_HEADER REGEX "^#define LIBGIT2_VERSION \"[^\"]*\"$")
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"([0-9]+).*$" "\\1" LIBGIT2_VERSION_MAJOR "${GIT2_HEADER}")
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_MINOR "${GIT2_HEADER}")
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_REV "${GIT2_HEADER}")
SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${LIBGIT2_VERSION_REV}")
FILE(STRINGS "include/git2/version.h" GIT2_HEADER_SOVERSION REGEX "^#define LIBGIT2_SOVERSION [0-9]+$")
STRING(REGEX REPLACE "^.*LIBGIT2_SOVERSION ([0-9]+)$" "\\1" LIBGIT2_SOVERSION "${GIT2_HEADER_SOVERSION}")
# Find required dependencies
INCLUDE_DIRECTORIES(src include)
IF (SECURITY_FOUND)
MESSAGE("-- Found Security ${SECURITY_DIRS}")
LIST(APPEND LIBGIT2_PC_LIBS "-framework Security")
ENDIF()
IF (COREFOUNDATION_FOUND)
MESSAGE("-- Found CoreFoundation ${COREFOUNDATION_DIRS}")
LIST(APPEND LIBGIT2_PC_LIBS "-framework CoreFoundation")
ENDIF()
IF (WIN32 AND WINHTTP)
ADD_DEFINITIONS(-DGIT_WINHTTP)
INCLUDE_DIRECTORIES(deps/http-parser)
FILE(GLOB SRC_HTTP deps/http-parser/*.c deps/http-parser/*.h)
# 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)
FIND_PROGRAM(DLLTOOL dlltool CMAKE_FIND_ROOT_PATH_BOTH)
IF (NOT DLLTOOL)
MESSAGE(FATAL_ERROR "Could not find dlltool command")
ENDIF ()
SET(LIBWINHTTP_PATH "${CMAKE_CURRENT_BINARY_DIR}/deps/winhttp")
FILE(MAKE_DIRECTORY ${LIBWINHTTP_PATH})
IF ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(WINHTTP_DEF "${CMAKE_CURRENT_SOURCE_DIR}/deps/winhttp/winhttp64.def")
ELSE()
set(WINHTTP_DEF "${CMAKE_CURRENT_SOURCE_DIR}/deps/winhttp/winhttp.def")
ENDIF()
ADD_CUSTOM_COMMAND(
OUTPUT ${LIBWINHTTP_PATH}/libwinhttp.a
COMMAND ${DLLTOOL} -d ${WINHTTP_DEF} -k -D winhttp.dll -l libwinhttp.a
DEPENDS ${WINHTTP_DEF}
WORKING_DIRECTORY ${LIBWINHTTP_PATH}
)
SET_SOURCE_FILES_PROPERTIES(
${CMAKE_CURRENT_SOURCE_DIR}/src/transports/winhttp.c
PROPERTIES OBJECT_DEPENDS ${LIBWINHTTP_PATH}/libwinhttp.a
)
INCLUDE_DIRECTORIES(deps/winhttp)
LINK_DIRECTORIES(${LIBWINHTTP_PATH})
ENDIF ()
LINK_LIBRARIES(winhttp rpcrt4 crypt32)
ELSE ()
IF (CURL)
PKG_CHECK_MODULES(CURL libcurl)
ENDIF ()
IF (NOT AMIGA AND USE_OPENSSL)
FIND_PACKAGE(OpenSSL)
ENDIF ()
IF (CURL_FOUND)
ADD_DEFINITIONS(-DGIT_CURL)
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS})
LINK_LIBRARIES(${CURL_LIBRARIES})
LIST(APPEND LIBGIT2_PC_LIBS ${CURL_LDFLAGS})
ENDIF()
FIND_PACKAGE(HTTP_Parser)
IF (HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
INCLUDE_DIRECTORIES(${HTTP_PARSER_INCLUDE_DIRS})
LINK_LIBRARIES(${HTTP_PARSER_LIBRARIES})
LIST(APPEND LIBGIT2_PC_LIBS "-lhttp_parser")
ELSE()
M
没有合适的资源?快使用搜索试试~ 我知道了~
git插件,用于visual studio
共2000个文件
c:499个
h:252个
txt:95个
需积分: 10 0 下载量 165 浏览量
2022-03-04
13:08:52
上传
评论
收藏 4.71MB ZIP 举报
温馨提示
`libgit2` is already very usable and is being used in production for many applications including the GitHub.com site, in Plastic SCM and also powering Microsoft's Visual Studio tools for Git. The library provides: * SHA conversions, formatting and shortening * abstracted ODB backend system * commit, tag, tree and blob parsing, editing, and write-back * tree traversal * revision walking * index file (staging area) manipulation * reference management (including packed references) * config file m
资源推荐
资源详情
资源评论
收起资源包目录
git插件,用于visual studio (2000个子文件)
AUTHORS 1KB
deps\regex\regexec.c 130KB
deps\regex\regcomp.c 112KB
src\index.c 81KB
src\checkout.c 74KB
src\merge.c 74KB
deps\zlib\deflate.c 72KB
tests\diff\workdir.c 67KB
deps\http-parser\http_parser.c 62KB
src\remote.c 61KB
tests\diff\rename.c 59KB
src\iterator.c 57KB
src\repository.c 57KB
deps\zlib\inflate.c 54KB
src\submodule.c 52KB
src\diff.c 52KB
src\refdb_fs.c 50KB
deps\regex\regex_internal.c 48KB
tests\repo\iterator.c 48KB
deps\zlib\trees.c 44KB
src\config_file.c 44KB
tests\merge\workdir\setup.c 44KB
tests\checkout\conflict.c 42KB
tests\checkout\tree.c 42KB
src\pack-objects.c 41KB
src\path.c 40KB
tests\status\worktree.c 36KB
src\transports\winhttp.c 35KB
tests\core\buffer.c 34KB
src\pack.c 34KB
tests\diff\blob.c 31KB
tests\status\ignore.c 31KB
src\config.c 31KB
src\rebase.c 30KB
src\diff_tform.c 30KB
src\refs.c 29KB
src\diff_patch.c 29KB
tests\online\push.c 28KB
src\odb.c 27KB
src\stash.c 27KB
tests\refs\revparse.c 27KB
src\indexer.c 26KB
tests\diff\iterator.c 26KB
src\fileops.c 25KB
src\transports\http.c 25KB
src\transports\smart_protocol.c 25KB
tests\status\renames.c 24KB
src\odb_loose.c 24KB
tests\merge\trees\treediff.c 23KB
src\tree.c 23KB
tests\index\tests.c 23KB
tests\checkout\index.c 23KB
deps\zlib\infback.c 23KB
tests\merge\workdir\simple.c 22KB
src\attr_file.c 22KB
tests\repo\init.c 22KB
src\filter.c 22KB
tests\diff\patch.c 21KB
src\describe.c 21KB
tests\revert\workdir.c 21KB
src\revparse.c 20KB
tests\rebase\merge.c 20KB
examples\general.c 20KB
src\date.c 20KB
tests\diff\submodules.c 20KB
tests\config\write.c 20KB
tests\config\read.c 19KB
src\transports\ssh.c 19KB
tests\core\path.c 19KB
tests\path\core.c 18KB
src\odb_pack.c 18KB
tests\online\clone.c 18KB
tests\commit\parse.c 18KB
src\pathspec.c 17KB
src\transports\local.c 17KB
src\buffer.c 17KB
tests\object\raw\write.c 17KB
tests\submodule\update.c 17KB
src\util.c 17KB
src\diff_print.c 17KB
tests\blame\simple.c 17KB
tests\rebase\setup.c 17KB
src\xdiff\xmerge.c 17KB
src\blame_git.c 17KB
tests\core\link.c 17KB
src\push.c 17KB
src\xdiff\xdiffi.c 17KB
tests\cherrypick\workdir.c 16KB
tests\revwalk\mergebase.c 16KB
tests\diff\tree.c 16KB
src\branch.c 16KB
src\win32\posix_w32.c 16KB
tests\network\fetchlocal.c 16KB
tests\stash\save.c 16KB
tests\checkout\nasty.c 15KB
tests\status\submodules.c 15KB
src\notes.c 15KB
tests\index\addall.c 15KB
src\delta.c 15KB
src\status.c 15KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
踏雪无痕老爷子
- 粉丝: 2519
- 资源: 716
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 批量去除图像背景Matlab代码.rar
- 了解 MATLAB 图像处理的基础知识MATLAB代码.rar
- 两种非刚性点集配准算法的 MATLAB 实现.rar
- 拍摄图像并将其保存为视频Matlab代码.rar
- 频域中的图像恢复(维纳滤波器)Matlab代码.rar
- 强调图像中内核形状(例如直线)的过滤器Matlab代码.rar
- 匹配图像特征(第 3 章):学生竞赛团队的计算机视觉训练Matlab代码.rar
- 求解 2D 和 3D 分数矢量亥姆霍兹方程,用于非刚性图像配准Matlab代码.rar
- 求 RGB 图像的平均向量Matlab代码.rar
- 球磁通量计算 (2D) 的高效实现Matlab代码.rar
- 全局到局部坐标变换矩阵Matlab代码.rar
- 曲面的非刚性套准Matlab代码.rar
- 飞秒激光模型 comsol
- springboot项目学生网上选课系统的设计与实现.zip
- springboot项目医疗挂号管理系统.zip
- springboot项目疫情打卡健康评测系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功