Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

COMP: Set DOWNLOAD_EXTRACT_TIMESTAMP to TRUE in wrapping modules #3709

Conversation

jhlegarreta
Copy link
Member

@jhlegarreta jhlegarreta commented Oct 29, 2022

Set DOWNLOAD_EXTRACT_TIMESTAMP to TRUE: the timestamps of the
extracted files will reflect the timestamps in the archive.

Configure/autoconf based projects like SWIG and PCRE have timestamped
files for their auto configuration dependencies. Thus, they depend on
the timestamps of the extracted files, and the external projects require
setting DOWNLOAD_EXTRACT_TIMESTAMP to TRUE to build robustly.

Set the CMP0135 policy to NEW for the CastXML CMake-based project.

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

@github-actions github-actions bot added type:Compiler Compiler support or related warnings type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots labels Oct 29, 2022
@jhlegarreta
Copy link
Member Author

@N-Dekker
Copy link
Contributor

Thanks for addressing this warning Jon. Just looking at https://cmake.org/cmake/help/latest/policy/CMP0135.html Is the new CMake default behavior indeed preferable, for external projects CastXML and PCRE?

@dzenanz
Copy link
Member

dzenanz commented Oct 31, 2022

As those are usually extracted only once, it should probably not matter?

@jhlegarreta
Copy link
Member Author

Thanks for addressing this warning Jon. Just looking at https://cmake.org/cmake/help/latest/policy/CMP0135.html Is the new CMake default behavior indeed preferable, for external projects CastXML and PCRE?

TBH, I do not know what the impact of the OLD vs. NEW policy would be: i.e. if timestamps are checked somehow. Maybe to download again the contents depending on its value? Not sure. In any case, I believe we should have no warnings. If setting the DOWNLOAD_EXTRACT_TIMESTAMP variable is preferred over this, I'd happy to hear the rationale/suggestions. Also, then the change in PR #3552 should be maybe commented as to why it should apply only to specific parts.

@blowekamp
Copy link
Member

I have been encountering a new problem in SimpleITK related to automate needing to be rerun in PCRE and SWIG. It appears related to timestamps of file triggering the need to re-run. It may be related to this CMP.

So setting this policy to new may not be with out side effects. I'm currently investigating....

@blowekamp
Copy link
Member

My tests are confirming that configure/autoconf based projects like SWIG and PCRE[2] depend on the time stamps of the extracted files and the external project require setting DOWNLOAD_EXTRACT_TIMESTAMP to 0 to build robustly. This should be changed in this PR.

The reported build error is related to the aclocal (or specific version of it) executable missing. Which is caused but autoconf being triggered due to timestamps. For this error to occur the system must have CMake >2.24, missing the required aclocal. Additionally the "extract time" for the extract files may vary based on the time it takes to extract the files from the archive, and the order of the files in the archive.

@jhlegarreta jhlegarreta force-pushed the FixWrappingCMakePolicyWarnings branch from e7072ad to 4622287 Compare October 31, 2022 13:37
@jhlegarreta jhlegarreta changed the title COMP: Set CMake Policy 135 to NEW to suppress warnings in wrapping COMP: Set DOWNLOAD_EXTRACT_TIMESTAMP to FALSE in wrapping modules Oct 31, 2022
@jhlegarreta jhlegarreta force-pushed the FixWrappingCMakePolicyWarnings branch from 4622287 to 0277e73 Compare October 31, 2022 13:40
@jhlegarreta
Copy link
Member Author

💯 Thanks Brad. I've amended the commit.

@N-Dekker
Copy link
Contributor

DOWNLOAD_EXTRACT_TIMESTAMP is introduced with CMake 3.24: https://cmake.org/cmake/help/latest/release/3.24.html?highlight=download_extract_timestamp#modules Does that mean that cmake_minimum_required should then be adjusted as well?

ITK/CMakeLists.txt

Lines 13 to 15 in d81a02c

set(ITK_OLDEST_VALIDATED_POLICIES_VERSION "3.16.3")
set(ITK_NEWEST_VALIDATED_POLICIES_VERSION "3.19.7")
cmake_minimum_required(VERSION ${ITK_OLDEST_VALIDATED_POLICIES_VERSION}...${ITK_NEWEST_VALIDATED_POLICIES_VERSION} FATAL_ERROR)

@blowekamp
Copy link
Member

DOWNLOAD_EXTRACT_TIMESTAMP is introduced with CMake 3.24

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.

@N-Dekker
Copy link
Contributor

The minimum require version certainly should not be updated to 3.24.

OK, but we now have set(ITK_NEWEST_VALIDATED_POLICIES_VERSION "3.19.7"), in the root CMakeLists.

set(ITK_NEWEST_VALIDATED_POLICIES_VERSION "3.19.7")

Shouldn't that already have preserved the old behavior, even when using CMake 3.24?

@jhlegarreta jhlegarreta force-pushed the FixWrappingCMakePolicyWarnings branch 4 times, most recently from ac40322 to 6e20e06 Compare October 31, 2022 23:38
@jhlegarreta
Copy link
Member Author

jhlegarreta commented Oct 31, 2022

Shouldn't that already have preserved the old behavior, even when using CMake 3.24?

@N-Dekker According to

# CMake versions greater than the ITK_NEWEST_VALIDATED_POLICIES_VERSION policies will

# 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.

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.

@jhlegarreta jhlegarreta force-pushed the FixWrappingCMakePolicyWarnings branch 3 times, most recently from 729dac8 to 8cd8afc Compare November 23, 2022 01:27
Copy link
Member

@thewtex thewtex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outstanding, thank you so much for addressing this, @jhlegarreta !

@blowekamp
Copy link
Member

@jhlegarreta I apologize. It appears I had the logic of DOWNLOAD_EXTRACT_TIMESTAMP backwards. I corrected it in SimpleITK, but not here.

DOWNLOAD_EXTRACT_TIMESTAMP should be set to TRUE for SWIG and PCRE.

I have reread the documentation for the CMP0135 and it's clarity should be improved.. Setting DOWNLOAD_EXTRACT_TIMESTAMP to TRUE is the OLD behavior. The OLD behaviors preserved the timestamp in the archive. This is required for SWIG and PCRE which have timed stamped files for autoconf dependencies.

@bradking FYI for CMake maintainer.

Set `DOWNLOAD_EXTRACT_TIMESTAMP` to `TRUE`: the timestamps of the
extracted files will reflect the timestamps in the archive.

Configure/autoconf based projects like SWIG and PCRE have timestamped
files for their auto configuration dependencies. Thus, they depend on
the timestamps of the extracted files, and the external projects require
setting `DOWNLOAD_EXTRACT_TIMESTAMP` to `TRUE` to build robustly.

Set the `CMP0135` policy to `NEW` for the CastXML CMake-based project.

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
@jhlegarreta jhlegarreta force-pushed the FixWrappingCMakePolicyWarnings branch from 8cd8afc to 331b474 Compare November 23, 2022 14:25
@jhlegarreta jhlegarreta changed the title COMP: Set DOWNLOAD_EXTRACT_TIMESTAMP to FALSE in wrapping modules COMP: Set DOWNLOAD_EXTRACT_TIMESTAMP to TRUE in wrapping modules Nov 23, 2022
@jhlegarreta
Copy link
Member Author

@blowekamp It's fine, thanks Brad. I should have done a better job understanding as well. I've amended the commit, changed the subject and message body according to what you described. See if it now matches the appropriate behavior.

@dzenanz
Copy link
Member

dzenanz commented Nov 23, 2022

@blowekamp For an open-source project like CMake, if you think that documentation should be improved, the usual response/expectation is to propose the change you think would improve it. I took a look at the doc you pointed out, and I didn't an obvious improvement opportunity.

@thewtex thewtex added this to the ITK 5.3.0 milestone Nov 23, 2022
@thewtex thewtex mentioned this pull request Nov 23, 2022
2 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type:Compiler Compiler support or related warnings type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants