summaryrefslogtreecommitdiff
path: root/Modules/FindGit.cmake
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-10-08 09:13:45 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-10-08 09:13:45 +0900
commitfa10a4a91520c9add2283a053dd755a7e5db9f4b (patch)
treeb4c33311cdf36a37e72e3c4bd013e59b42a815f6 /Modules/FindGit.cmake
parent4ca455f44f42bf3257fe1ce752ca7447e9568a27 (diff)
downloadcmake-fa10a4a91520c9add2283a053dd755a7e5db9f4b.tar.gz
cmake-fa10a4a91520c9add2283a053dd755a7e5db9f4b.tar.bz2
cmake-fa10a4a91520c9add2283a053dd755a7e5db9f4b.zip
Imported Upstream version 3.14.1upstream/3.14.1
Diffstat (limited to 'Modules/FindGit.cmake')
-rw-r--r--Modules/FindGit.cmake55
1 files changed, 34 insertions, 21 deletions
diff --git a/Modules/FindGit.cmake b/Modules/FindGit.cmake
index fae31eb83..3491cdcc2 100644
--- a/Modules/FindGit.cmake
+++ b/Modules/FindGit.cmake
@@ -1,27 +1,34 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindGit
-# -------
-#
-# The module defines the following variables:
-#
-# ``GIT_EXECUTABLE``
-# Path to Git command-line client.
-# ``Git_FOUND``, ``GIT_FOUND``
-# True if the Git command-line client was found.
-# ``GIT_VERSION_STRING``
-# The version of Git found.
-#
-# Example usage:
-#
-# .. code-block:: cmake
-#
-# find_package(Git)
-# if(Git_FOUND)
-# message("Git found: ${GIT_EXECUTABLE}")
-# endif()
+#[=======================================================================[.rst:
+FindGit
+-------
+
+The module defines the following ``IMPORTED`` targets (when
+:prop_gbl:`CMAKE_ROLE` is ``PROJECT``):
+
+``Git::Git``
+ Executable of the Git command-line client.
+
+The module defines the following variables:
+
+``GIT_EXECUTABLE``
+ Path to Git command-line client.
+``Git_FOUND``, ``GIT_FOUND``
+ True if the Git command-line client was found.
+``GIT_VERSION_STRING``
+ The version of Git found.
+
+Example usage:
+
+.. code-block:: cmake
+
+ find_package(Git)
+ if(Git_FOUND)
+ message("Git found: ${GIT_EXECUTABLE}")
+ endif()
+#]=======================================================================]
# Look for 'git' or 'eg' (easy git)
#
@@ -77,6 +84,12 @@ if(GIT_EXECUTABLE)
string(REPLACE "git version " "" GIT_VERSION_STRING "${git_version}")
endif()
unset(git_version)
+
+ get_property(_findgit_role GLOBAL PROPERTY CMAKE_ROLE)
+ if(_findgit_role STREQUAL "PROJECT" AND NOT TARGET Git::Git)
+ add_executable(Git::Git IMPORTED)
+ set_property(TARGET Git::Git PROPERTY IMPORTED_LOCATION "${GIT_EXECUTABLE}")
+ endif()
endif()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)