浏览代码

FetchContent: Ensure can_fetch_default is set early enough

The can_fetch_default variable needs to be set before the call to
_ep_write_gitupdate_script(). Move it to before that call and always
set the variable, even if arg_SCRIPT_FILE is not set. This makes the
generated git update script file easier to follow if someone tries to
follow what it is doing or wants to investigate problems and run it
manually.

Fixes: #26164
Craig Scott 1 年之前
父节点
当前提交
5df592ce31
共有 1 个文件被更改,包括 6 次插入5 次删除
  1. 6 5
      Modules/ExternalProject/shared_internal_commands.cmake

+ 6 - 5
Modules/ExternalProject/shared_internal_commands.cmake

@@ -1535,6 +1535,12 @@ function(_ep_add_update_command name)
     set(comment "Performing update step for '${name}'")
     set(comment_disconnected "Performing disconnected update step for '${name}'")
 
+    if(update_disconnected)
+      set(can_fetch_default NO)
+    else()
+      set(can_fetch_default YES)
+    endif()
+
     set(git_tag "${_EP_GIT_TAG}")
     if(NOT git_tag)
       set(git_tag "master")
@@ -1602,11 +1608,6 @@ function(_ep_add_update_command name)
     set(always 1)
 
     if(arg_SCRIPT_FILE)
-      if(update_disconnected)
-        set(can_fetch_default NO)
-      else()
-        set(can_fetch_default YES)
-      endif()
       set(step_script_contents "include(\"${update_script}\")")
     endif()