浏览代码

BUG: In CMake/ExternalProject.cmake, when a GIT_REPOSITORY is set. Make sure the corresponding directory is removed.

Since git doesn't allow to clone if the repository exists,
let's delete it. Git will re-recreate it when the clone command will be invoked.
Jean-Christophe Fillion-Robin 15 年之前
父节点
当前提交
1a259ba595
共有 1 个文件被更改,包括 14 次插入2 次删除
  1. 14 2
      CMake/ExternalProject.cmake

+ 14 - 2
CMake/ExternalProject.cmake

@@ -703,7 +703,19 @@ function(_ep_add_download_command name)
       )
       )
 
 
     get_filename_component(src_name "${source_dir}" NAME)
     get_filename_component(src_name "${source_dir}" NAME)
-    get_filename_component(work_dir "${source_dir}" PATH)
+    get_filename_component(work_dir "${source_dir}/../" REALPATH)
+
+    # Since git doesn't allow to clone if the repository exists,
+    # let's delete it. Git will re-recreate it when the clone command will be invoked
+    execute_process(
+      COMMAND ${CMAKE_COMMAND} -E remove_directory ${source_dir}
+      RESULT_VARIABLE error_code
+      )
+    if(error_code)
+      message(FATAL_ERROR "Failed to remove directory: ${source_dir}")
+    endif()
+    
+    
     set(comment "Performing download step (GIT clone) for '${name}'")
     set(comment "Performing download step (GIT clone) for '${name}'")
     set(cmd ${Git_EXECUTABLE} clone ${git_repository} ${src_name})
     set(cmd ${Git_EXECUTABLE} clone ${git_repository} ${src_name})
     list(APPEND depends ${stamp_dir}/${name}-gitinfo.txt)
     list(APPEND depends ${stamp_dir}/${name}-gitinfo.txt)
@@ -999,4 +1011,4 @@ function(ExternalProject_Add name)
   # on install.
   # on install.
   #
   #
   _ep_add_test_command(${name})
   _ep_add_test_command(${name})
-endfunction(ExternalProject_Add)
+endfunction(ExternalProject_Add)