Skip to content

Commit b18a3b7

Browse files
committed
fix: Set DOWNLOAD_EXTRACT_TIMESTAMP to 1 if build with CMake >= 3.24
See https://cmake.org/cmake/help/latest/policy/CMP0135.html This will avoid warnings like the following: CMake Warning (dev) at /path/to/cmake-3.28.1-linux-x86_64/share/cmake-3.28/Modules/ExternalProject.cmake:3198 (message): The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is not set. The policy's OLD behavior will be used. When using a URL download, the timestamps of extracted files should preferably be that of the time of extraction, otherwise code that depends on the extracted contents might not be rebuilt if the URL changes. The OLD behavior preserves the timestamps from the archive instead, but this is usually not what you want. Update your project to the NEW behavior or specify the DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this robustness issue. Adapted from dff357a ("ExternalProjectDependency: Set DOWNLOAD_EXTRACT_TIMESTAMP to 1 if CMake >= 3.24", 2023-07-29)
1 parent b461a21 commit b18a3b7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ if(CMakePythonDistributions_SUPERBUILD)
128128
)
129129
endif()
130130

131+
set(ep_download_extract_timestamp_arg)
132+
if(CMAKE_VERSION VERSION_EQUAL "3.24" OR CMAKE_VERSION VERSION_GREATER "3.24")
133+
# See https://cmake.org/cmake/help/latest/policy/CMP0135.html
134+
set(ep_download_extract_timestamp_arg DOWNLOAD_EXTRACT_TIMESTAMP 1)
135+
endif()
136+
131137
#
132138
# CMakeProject_SOURCE_DIR: Always expect the sources (needed for `sdist`)
133139
#
@@ -145,6 +151,7 @@ if(CMakePythonDistributions_SUPERBUILD)
145151
BUILD_COMMAND ""
146152
BUILD_IN_SOURCE 1
147153
INSTALL_COMMAND ""
154+
${ep_download_extract_timestamp_arg}
148155
${ep_download_no_progress_args}
149156
)
150157
message(STATUS "SuperBuild - CMakeProject-src-download")
@@ -338,6 +345,7 @@ set(CMAKE_EXE_LINKER_FLAGS \"-lstdc++ -lgcc -lrt\" CACHE STRING \"Initial cache\
338345
BUILD_COMMAND ""
339346
BUILD_IN_SOURCE 1
340347
INSTALL_COMMAND ""
348+
${ep_download_extract_timestamp_arg}
341349
${ep_download_no_progress_args}
342350
)
343351
message(STATUS "SuperBuild - CMakeProject-binary-download")

0 commit comments

Comments
 (0)