mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
FindGit: Cache the GIT_EXECUTABLE version for the current run
The git version should not change while CMake is running. When using FetchContent with many dependencies, the repeated calls to get the git version every time ExternalProject is used can be measurable on some platforms. This commit queries that version only once and then caches it in a global property for the rest of that run. The git version can still safely change between runs because it is not cached, only the GIT_EXECUTABLE location is cached. Relates: #21703
This commit is contained in:
@@ -2630,10 +2630,13 @@ function(_ep_add_download_command name)
|
||||
--non-interactive ${svn_trust_cert_args} ${svn_user_pw_args} ${src_name})
|
||||
list(APPEND depends ${stamp_dir}/${name}-svninfo.txt)
|
||||
elseif(git_repository)
|
||||
unset(CMAKE_MODULE_PATH) # Use CMake builtin find module
|
||||
find_package(Git QUIET)
|
||||
if(NOT GIT_EXECUTABLE)
|
||||
message(FATAL_ERROR "error: could not find git for clone of ${name}")
|
||||
# FetchContent gives us these directly, so don't try to recompute them
|
||||
if(NOT GIT_EXECUTABLE OR NOT GIT_VERSION_STRING)
|
||||
unset(CMAKE_MODULE_PATH) # Use CMake builtin find module
|
||||
find_package(Git QUIET)
|
||||
if(NOT GIT_EXECUTABLE)
|
||||
message(FATAL_ERROR "error: could not find git for clone of ${name}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
_ep_get_git_submodules_recurse(git_submodules_recurse)
|
||||
@@ -2951,10 +2954,13 @@ function(_ep_add_update_command name)
|
||||
--non-interactive ${svn_trust_cert_args} ${svn_user_pw_args})
|
||||
set(always 1)
|
||||
elseif(git_repository)
|
||||
unset(CMAKE_MODULE_PATH) # Use CMake builtin find module
|
||||
find_package(Git QUIET)
|
||||
if(NOT GIT_EXECUTABLE)
|
||||
message(FATAL_ERROR "error: could not find git for fetch of ${name}")
|
||||
# FetchContent gives us these directly, so don't try to recompute them
|
||||
if(NOT GIT_EXECUTABLE OR NOT GIT_VERSION_STRING)
|
||||
unset(CMAKE_MODULE_PATH) # Use CMake builtin find module
|
||||
find_package(Git QUIET)
|
||||
if(NOT GIT_EXECUTABLE)
|
||||
message(FATAL_ERROR "error: could not find git for fetch of ${name}")
|
||||
endif()
|
||||
endif()
|
||||
set(work_dir ${source_dir})
|
||||
set(comment "Performing update step for '${name}'")
|
||||
|
||||
Reference in New Issue
Block a user