Jelajahi Sumber

ExternalProject: Allow ALWAYS step property to be switched (#15368)

Within an existing build tree, if the stamp for a step already exists
when one activates the ALWAYS option, we still want it to always build.
Remove the step stamp file during CMake configuration to ensure it does
not exist when the ALWAYS option is enabled.
Brad King 11 tahun lalu
induk
melakukan
a4605973ff
1 mengubah file dengan 9 tambahan dan 0 penghapusan
  1. 9 0
      Modules/ExternalProject.cmake

+ 9 - 0
Modules/ExternalProject.cmake

@@ -1456,6 +1456,15 @@ function(ExternalProject_Add_Step name step)
   if(always)
   if(always)
     set_property(SOURCE ${stamp_file} PROPERTY SYMBOLIC 1)
     set_property(SOURCE ${stamp_file} PROPERTY SYMBOLIC 1)
     set(touch)
     set(touch)
+    # Remove any existing stamp in case the option changed in an existing tree.
+    if(CMAKE_CONFIGURATION_TYPES)
+      foreach(cfg ${CMAKE_CONFIGURATION_TYPES})
+        string(REPLACE "/${CMAKE_CFG_INTDIR}" "/${cfg}" stamp_file_config "${stamp_file}")
+        file(REMOVE ${stamp_file_config})
+      endforeach()
+    else()
+      file(REMOVE ${stamp_file})
+    endif()
   else()
   else()
     set(touch ${CMAKE_COMMAND} -E touch ${stamp_file})
     set(touch ${CMAKE_COMMAND} -E touch ${stamp_file})
   endif()
   endif()