Skip to content

fix(pdfx): gate DOWNLOAD_EXTRACT_TIMESTAMP on CMake < 3.24 (Windows build)#612

Open
Ahmedmmy97 wants to merge 1 commit into
ScerIO:mainfrom
Ahmedmmy97:fix-pdfx-cmake-extract-timestamp
Open

fix(pdfx): gate DOWNLOAD_EXTRACT_TIMESTAMP on CMake < 3.24 (Windows build)#612
Ahmedmmy97 wants to merge 1 commit into
ScerIO:mainfrom
Ahmedmmy97:fix-pdfx-cmake-extract-timestamp

Conversation

@Ahmedmmy97
Copy link
Copy Markdown

Summary

Fixes the Windows build failure reported in #601 (and the duplicate routed via flutter/flutter#186062) for users on CMake < 3.24. The plugin currently passes DOWNLOAD_EXTRACT_TIMESTAMP FALSE to download_project unconditionally, but that ExternalProject_Add keyword was only added in CMake 3.24. On older CMake β€” including 3.20 bundled with Visual Studio 2019 BuildTools β€” the keyword is unrecognised and cmake_parse_arguments absorbs it (and its FALSE value) as additional values of the most recent multi-value keyword, URL. The URL bucket becomes a 3-entry list, the validator in Modules/ExternalProject.cmake walks it, finds entries that don't match ^[a-z]+://, and bails with:

CMake Error at .../cmake-3.20/Modules/ExternalProject.cmake:2771 (message):
  At least one entry of URL is a path (invalid in a list)
Call Stack (most recent call first):
  .../cmake-3.20/Modules/ExternalProject.cmake:3681 (_ep_add_download_command)
  CMakeLists.txt:9 (ExternalProject_Add)

CMake Error at .../pdfx/windows/DownloadProject.cmake:171 (message):
  CMake step for pdfium failed: 1

The plugin declares cmake_minimum_required(VERSION 3.15) while using a 3.24+ keyword unconditionally β€” this PR closes that mismatch.

Fix

Gate the DOWNLOAD_EXTRACT_TIMESTAMP FALSE arguments on CMAKE_VERSION VERSION_LESS "3.24". On modern CMake the behaviour is unchanged. On CMake 3.20–3.23 the option is omitted and download_project succeeds (the only effect of omitting it is a CMake-3.24 deprecation warning about extracted-file timestamps, which is harmless for non-reproducible-build users).

set(_pdfx_extra_args)
if(NOT CMAKE_VERSION VERSION_LESS "3.24")
  list(APPEND _pdfx_extra_args DOWNLOAD_EXTRACT_TIMESTAMP FALSE)
endif()
download_project(
  PROJ pdfium
  URL ${PDFIUM_URL}
  ${_pdfx_extra_args}
)

Verification

Reproduced and verified in a Docker harness using ubuntu:24.04 + the official cmake-3.20.6 Linux binary, the unmodified windows/CMakeLists.txt and DownloadProject.cmake from main. The bug is purely CMake-argument-parsing β€” no Windows-specific behaviour is needed to reproduce it.

Case Outcome
CMake 3.20.6 + current main fails with the exact error chain (ExternalProject.cmake:2773 β†’ 3683 β†’ CMakeLists.txt:9)
CMake 3.20.6 + this PR configures and downloads pdfium successfully
CMake 3.28.x + current main already works; no regression with this PR

The line numbers in the user-reported stack (2771 / 3681) vs reproduction (2773 / 3683) differ by 2 because of patch-level differences between the VS2019-bundled CMake 3.20.x and the official 3.20.6 release; the call-graph and validator logic are identical.

Scope

  • Touches only packages/pdfx/windows/CMakeLists.txt. No Dart, no other platforms.
  • No cmake_minimum_required bump β€” keeps VS2019 BuildTools users supported.
  • The unrelated download_project(PROJ\n pdfium ...) formatting was tightened to one keyword/value per line, matching the rest of the file.

Refs

Deliberately not auto-closing #601 β€” see caveat.

Caveat on #601

The original #601 reporter is on Visual Studio 2026, which ships CMake β‰₯ 3.30. On that version DOWNLOAD_EXTRACT_TIMESTAMP is recognised, so this PR may not address the exact trigger they hit even though their error chain is identical. I haven't been able to reproduce the VS2026 variant. Happy to leave #601 open if the maintainer prefers and re-target this PR at a fresh "build fails on VS2019 / CMake 3.20" issue, or merge as-is and ask the #601 reporter to retest.

DOWNLOAD_EXTRACT_TIMESTAMP was added to ExternalProject_Add in CMake 3.24.
On older CMake (notably 3.20 bundled with Visual Studio 2019 BuildTools),
the keyword is unrecognised, so cmake_parse_arguments absorbs it - and its
FALSE value - as additional values of the previous multi-value keyword,
URL. The validator inside _ep_add_download_command then sees a multi-entry
URL list with non-URL entries and bails with "At least one entry of URL is
a path (invalid in a list)".

The plugin declares cmake_minimum_required(VERSION 3.15) but used a 3.24+
keyword unconditionally. Gate it on CMAKE_VERSION VERSION_LESS "3.24" so
the option is only passed where supported. No behaviour change on modern
CMake; older CMake skips the option (its only effect is to suppress a
3.24 deprecation warning about extracted-file timestamps).

Refs ScerIO#601 (open).
Refs flutter/flutter#186062 (closed there as third-party).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant