/usr/share/ECM/find-modules/FindLibGit2.cmake is in extra-cmake-modules 5.18.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | #.rst:
# FindLibGit2
# -----------
#
# Try to find libgit2 on a Unix system.
#
# This will define the following variables:
#
# ``LIBGIT2_FOUND``
# True if (the requested version of) libgit2 is available
# ``LIBGIT2_VERSION``
# The version of libgit2
# ``LIBGIT2_LIBRARIES``
# This can be passed to target_link_libraries() instead of the ``LibGit2::LibGit2``
# target
# ``LIBGIT2_INCLUDE_DIRS``
# This should be passed to target_include_directories() if the target is not
# used for linking
# ``LIBGIT2_DEFINITIONS``
# This should be passed to target_compile_options() if the target is not
# used for linking
#
# If ``LIBGIT2_FOUND`` is TRUE, it will also define the following imported target:
#
# ``LibGit2::LibGit2``
# The libgit2 library
#
# In general we recommend using the imported target, as it is easier to use.
# Bear in mind, however, that if the target is in the link interface of an
# exported library, it must be made available by the package config file.
#
# Since 1.3.0.
#=============================================================================
# Copyright 2014 Alex Merry <alex.merry@kde.org>
# Copyright 2014 Martin Gräßlin <mgraesslin@kde.org>
# Copyright 2014 Christoph Cullmann <cullmann@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
ecm_find_package_version_check(LibGit2)
# Use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
find_package(PkgConfig)
pkg_check_modules(PKG_GIT2 QUIET git2)
set(LIBGIT2_DEFINITIONS ${PKG_GIT2_CFLAGS_OTHER})
find_path(LIBGIT2_INCLUDE_DIR
NAMES
git2.h
HINTS
${PKG_GIT2_INCLUDE_DIRS}
)
find_library(LIBGIT2_LIBRARY
NAMES
git2
HINTS
${PKG_GIT2_LIBRARY_DIRS}
)
# get version from header, should work on windows, too
if(LIBGIT2_INCLUDE_DIR)
file(STRINGS "${LIBGIT2_INCLUDE_DIR}/git2/version.h" LIBGIT2_H REGEX "^#define LIBGIT2_VERSION \"[^\"]*\"$")
string(REGEX REPLACE "^.*LIBGIT2_VERSION \"([0-9]+).*$" "\\1" LIBGIT2_VERSION_MAJOR "${LIBGIT2_H}")
string(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_MINOR "${LIBGIT2_H}")
string(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_PATCH "${LIBGIT2_H}")
set(LIBGIT2_VERSION "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${LIBGIT2_VERSION_PATCH}")
set(LIBGIT2_MAJOR_VERSION "${LIBGIT2_VERSION_MAJOR}")
set(LIBGIT2_MINOR_VERSION "${LIBGIT2_VERSION_MINOR}")
set(LIBGIT2_PATCH_VERSION "${LIBGIT2_VERSION_PATCH}")
unset(LIBGIT2_H)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibGit2
FOUND_VAR
LIBGIT2_FOUND
REQUIRED_VARS
LIBGIT2_LIBRARY
LIBGIT2_INCLUDE_DIR
VERSION_VAR
LIBGIT2_VERSION
)
if(LIBGIT2_FOUND AND NOT TARGET LibGit2::LibGit2)
add_library(LibGit2::LibGit2 UNKNOWN IMPORTED)
set_target_properties(LibGit2::LibGit2 PROPERTIES
IMPORTED_LOCATION "${LIBGIT2_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${LIBGIT2_DEFINITIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBGIT2_INCLUDE_DIR}"
)
endif()
mark_as_advanced(LIBGIT2_LIBRARY LIBGIT2_INCLUDE_DIR)
set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARY})
set(LIBGIT2_INCLUDE_DIRS ${LIBGIT2_INCLUDE_DIR})
include(FeatureSummary)
set_package_properties(LibGit2 PROPERTIES
URL "https://libgit2.github.com/"
DESCRIPTION "A plain C library to interface with the git version control system."
)
|