FetchContent: Force cmake --fresh to re-execute direct population steps

Issue: #25468
This commit is contained in:
Craig Scott
2024-06-07 17:51:38 +10:00
parent e82e2c38c1
commit 9299cbbdb4
5 changed files with 43 additions and 9 deletions
+14 -3
View File
@@ -1653,9 +1653,19 @@ function(__FetchContent_populateDirect)
# extensive customization options it supports either. Note that
# _EP_SOURCE_DIR and _EP_BINARY_DIR are always included in the saved args,
# so we must not set them here.
set(_EP_STAMP_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-stamp")
set(_EP_TMP_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-tmp")
set(_EP_DOWNLOAD_DIR "${_EP_TMP_DIR}")
if(cmake_role STREQUAL "PROJECT")
# Put these under CMakeFiles so that they are removed by "cmake --fresh",
# which will cause the steps to re-run.
set(_EP_STAMP_DIR "${CMAKE_BINARY_DIR}/CMakeFiles/fc-stamp/${contentNameLower}")
set(_EP_TMP_DIR "${CMAKE_BINARY_DIR}/CMakeFiles/fc-tmp/${contentNameLower}")
else()
# We have no CMakeFiles in script mode, so keep everything together.
set(_EP_STAMP_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-stamp")
set(_EP_TMP_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-tmp")
endif()
# Always put downloaded things under FETCHCONTENT_BASE_DIR so that we can
# reuse previously downloaded content, even after a "cmake --fresh".
set(_EP_DOWNLOAD_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-tmp")
# If CMAKE_DISABLE_SOURCE_CHANGES is set to true and _EP_SOURCE_DIR is an
# existing directory in our source tree, calling file(MAKE_DIRECTORY) on it
@@ -1667,6 +1677,7 @@ function(__FetchContent_populateDirect)
"${_EP_BINARY_DIR}"
"${_EP_STAMP_DIR}"
"${_EP_TMP_DIR}"
"${_EP_DOWNLOAD_DIR}"
)
# We take over the stamp files and use our own for detecting whether each