diff options
author | David Cole <david.cole@kitware.com> | 2012-04-28 15:40:12 (GMT) |
---|---|---|
committer | David Cole <david.cole@kitware.com> | 2012-04-28 19:02:17 (GMT) |
commit | 08db81e00807c1dfc6846e9b3228c54dfe37a67f (patch) | |
tree | 841232910f39dbb06a169324c51fec82e33554b5 /Modules/ExternalProject.cmake | |
parent | d14c02434a51fa9066febf15e336362d3adefd4a (diff) | |
download | CMake-08db81e00807c1dfc6846e9b3228c54dfe37a67f.zip CMake-08db81e00807c1dfc6846e9b3228c54dfe37a67f.tar.gz CMake-08db81e00807c1dfc6846e9b3228c54dfe37a67f.tar.bz2 |
ExternalProject: Avoid repeated git clone operations (#12564)
By tracking a stamp file within the git clone script itself.
Avoids a 2nd git clone operation after switching from Debug
to Release builds in Visual Studio, or vice-versa.
Diffstat (limited to 'Modules/ExternalProject.cmake')
-rw-r--r-- | Modules/ExternalProject.cmake | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 1bca18c..0353e45 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -252,12 +252,23 @@ define_property(DIRECTORY PROPERTY "EP_STEP_TARGETS" INHERITED ) -function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag src_name work_dir) +function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag src_name work_dir gitclone_infofile gitclone_stampfile) file(WRITE ${script_filename} "if(\"${git_tag}\" STREQUAL \"\") message(FATAL_ERROR \"Tag for git checkout should not be empty.\") endif() +set(run 0) + +if(\"${gitclone_infofile}\" IS_NEWER_THAN \"${gitclone_stampfile}\") + set(run 1) +endif() + +if(NOT run) + message(STATUS \"Avoiding repeated git clone, stamp file is up to date: '${gitclone_stampfile}'\") + return() +endif() + execute_process( COMMAND \${CMAKE_COMMAND} -E remove_directory \"${source_dir}\" RESULT_VARIABLE error_code @@ -302,6 +313,19 @@ if(error_code) message(FATAL_ERROR \"Failed to update submodules in: '${work_dir}/${src_name}'\") endif() +# Complete success, update the script-last-run stamp file: +# +execute_process( + COMMAND \${CMAKE_COMMAND} -E copy + \"${gitclone_infofile}\" + \"${gitclone_stampfile}\" + WORKING_DIRECTORY \"${work_dir}/${src_name}\" + RESULT_VARIABLE error_code + ) +if(error_code) + message(FATAL_ERROR \"Failed to copy script-last-run stamp file: '${gitclone_stampfile}'\") +endif() + " ) @@ -1115,6 +1139,7 @@ function(_ep_add_download_command name) # _ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir} ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${src_name} ${work_dir} + ${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt ) set(comment "Performing download step (git clone) for '${name}'") set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitclone.cmake) |