jhlegarreta
(Jon Haitz Legarreta Gorroño)
November 19, 2022, 9:34pm
1
Hi CMake folks,
we have a case in ITK where we would like to pass some additional arguments to the ExternalProject_Add
command depending on the CMake version:
InsightSoftwareConsortium:master
← jhlegarreta:FixWrappingCMakePolicyWarnings
opened 08:32PM - 29 Oct 22 UTC
Set `DOWNLOAD_EXTRACT_TIMESTAMP` to `FALSE`: the timestamps of the
extracted fi… les will reflect the time at which the extraction was
performed.
Configure/autoconf based projects like SWIG and PCRE depend on the
timestamps of the extracted files, and the external projects require
setting `DOWNLOAD_EXTRACT_TIMESTAMP` to `FALSE` to build robustly.
Suppresses CMake warnings in wrapping modules.
Fixes:
```
CMake Warning (dev) at /usr/local/share/cmake-3.24/Modules/ExternalProject.cmake:3074 (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.
Call Stack (most recent call first):
/usr/local/share/cmake-3.24/Modules/ExternalProject.cmake:4170 (_ep_add_download_command)
Wrapping/Generators/SwigInterface/CMakeLists.txt:142 (ExternalProject_Add)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found BISON: /usr/bin/bison (found version "3.5.1")
CMake Warning (dev) at /usr/local/share/cmake-3.24/Modules/ExternalProject.cmake:3074 (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.
Call Stack (most recent call first):
/usr/local/share/cmake-3.24/Modules/ExternalProject.cmake:4170 (_ep_add_download_command)
Wrapping/Generators/SwigInterface/CMakeLists.txt:243 (ExternalProject_Add)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at /usr/local/share/cmake-3.24/Modules/ExternalProject.cmake:3074 (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.
Call Stack (most recent call first):
/usr/local/share/cmake-3.24/Modules/ExternalProject.cmake:4170 (_ep_add_download_command)
Wrapping/Generators/CastXML/CMakeLists.txt:63 (ExternalProject_Add)
This warning is for project developers. Use -Wno-dev to suppress it.
```
raised for example in:
https://open.cdash.org/build/8245525/configure
Related documentation:
https://cmake.org/cmake/help/latest/module/ExternalProject.html?highlight=download_extract_timestamp
https://cmake.org/cmake/help/latest/policy/CMP0135.html
## PR Checklist
- [x] No [API changes](https://github.com/InsightSoftwareConsortium/ITK/blob/master/CONTRIBUTING.md#breaking-changes) were made (or the changes have been approved)
- [x] No [major design changes](https://github.com/InsightSoftwareConsortium/ITK/blob/master/CONTRIBUTING.md#design-changes) were made (or the changes have been approved)
The approach does not seem to work: CMake does not understand as we had expected the passed extra arguments:
InsightSoftwareConsortium:master
← jhlegarreta:FixWrappingCMakePolicyWarnings
> Shouldn't that already have preserved the old behavior, even when using CMake … 3.24?
@N-Dekker According to
https://github.com/InsightSoftwareConsortium/ITK/blob/49150c8a701f629a122646f708a802f961d1ace7/CMakeLists.txt#L10
```
# CMake versions greater than the ITK_NEWEST_VALIDATED_POLICIES_VERSION policies will
# continue to generate policy warnings "CMake Warning (dev)...Policy CMP0XXX is not set:"
```
So I guess they will appear for 3.24.
> Yes, for this project likely either behavior of the timestamp should be OK. However, I thought there was motivation to use the NEW CMP135 behavior where it could be used, like the castXML project. To do that the CMP135 could be set to new, and this line removed, or the value could be set to TRUE.
> The minimum require version certainly should not be updated to 3.24. ExternalProject_Add appears to ignore unknown names arguments, however I am not sure this is behavior that should be relied upon?
> The alternate would be conditionally assign DOWNLOAD_EXTRACT_TIMESTAMP FALSE to a variable and use that.
@blowekamp Thanks for the suggestions and directions forward. Tried to do them in 6e20e06.
- The warning in the `CastXML` has been silenced.
- They are back for `SWIG` though, and the variable contents are not properly parsed by `ExternalProject_Add`:
https://open.cdash.org/build/8248990/configure
```
CMake Error at /usr/local/share/cmake-3.24/Modules/ExternalProject.cmake:3479 (get_property):
get_property could not find TARGET DOWNLOAD_EXTRACT_TIMESTAMP FALSE.
Perhaps it has not yet been created.
Call Stack (most recent call first):
/usr/local/share/cmake-3.24/Modules/ExternalProject.cmake:3661 (_ep_get_file_deps)
/usr/local/share/cmake-3.24/Modules/ExternalProject.cmake:4173 (_ep_add_configure_command)
Wrapping/Generators/SwigInterface/CMakeLists.txt:254 (ExternalProject_Add)
```
The variable value seems to be OK, though. Not sure what's going on here; I run out of ideas.
Any guess/suggestion of what I may be missing?
Thanks.
ben.boeckel
(Ben Boeckel (Kitware))
November 19, 2022, 11:09pm
2
Use set(download_extract_timestamp_flag DOWNLOAD_EXTRACT_TIMESTAMP FALSE)
. The quoting here causes EP to see a single DOWNLOAD_EXTRACT_TIMESTAMP FALSE
argument which has no meaning to it.
jhlegarreta
(Jon Haitz Legarreta Gorroño)
November 20, 2022, 2:13pm
3
Worked like a charm. Thanks Ben !