Skip to content

BUG: Fix check for including old cmake documentation code#6248

Merged
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:release-4.14from
gdevenyi:cmake-doc-4.14
May 9, 2026
Merged

BUG: Fix check for including old cmake documentation code#6248
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:release-4.14from
gdevenyi:cmake-doc-4.14

Conversation

@gdevenyi
Copy link
Copy Markdown
Contributor

@gdevenyi gdevenyi commented May 9, 2026

cmake CMP0106 was introduced in 3.18 not 4.0.

This fixes a bug for cmake versions between 3.18 and 4.0.

@gdevenyi gdevenyi marked this pull request as ready for review May 9, 2026 17:15
Copilot AI review requested due to automatic review settings May 9, 2026 17:15
@github-actions github-actions Bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots area:Documentation Issues affecting the Documentation module labels May 9, 2026
@gdevenyi
Copy link
Copy Markdown
Contributor Author

gdevenyi commented May 9, 2026

@hjmjohnson A followup to my other work I just discovered while preparing a big build matrix of different Linux versions.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 9, 2026

Greptile Summary

Corrects the CMake version threshold used to decide whether to include(Documentation.cmake) from 4.0 to 3.18, which is when CMP0106 was introduced and the module was deprecated. CMake versions between 3.18 and 4.0 were incorrectly including the deprecated module, causing deprecation warnings.

  • Version guard fix: CMAKE_VERSION VERSION_LESS 3.18 now accurately gates the legacy include(Documentation.cmake) path; the inline option() path is used for all CMake >= 3.18.
  • Minor stale comment: The explanatory comment above the condition still refers to "CMake >= 4.0" as the cutoff, which is now inaccurate after the threshold change.

Confidence Score: 5/5

Safe to merge — this is a one-line version string fix with a well-understood and verified root cause.

The change is a precise single-line correction to a CMake version comparison. The new threshold matches when CMP0106 was introduced (3.18), the fix prevents spurious deprecation warnings on 3.18–3.x toolchains, and the only remaining concern is a now-slightly-stale inline comment.

No files require special attention beyond the already-noted stale comment in Utilities/Doxygen/CMakeLists.txt.

Important Files Changed

Filename Overview
Utilities/Doxygen/CMakeLists.txt Version threshold corrected from 4.0 to 3.18 so CMake 3.18–3.x users no longer trigger the deprecated Documentation.cmake include; a stale inline comment still references "CMake >= 4.0" as the inline cutoff.

Reviews (1): Last reviewed commit: "BUG: Fix check for including old cmake d..." | Re-trigger Greptile

Comment thread Utilities/Doxygen/CMakeLists.txt Outdated
Comment on lines 6 to 8
# (preserving any auxiliary behavior it provides on era-original toolchains)
# and inline the BUILD_DOCUMENTATION option on CMake >= 4.0 where the file
# no longer ships.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 The block comment above the condition still says "CMake >= 4.0 where the file no longer ships," but with this fix the inline option() path now activates starting at 3.18. The description is now misleading for users on 3.18–3.x, where the module still ships but is deprecated.

Suggested change
# (preserving any auxiliary behavior it provides on era-original toolchains)
# and inline the BUILD_DOCUMENTATION option on CMake >= 4.0 where the file
# no longer ships.
# (preserving any auxiliary behavior it provides on era-original toolchains)
# and inline the BUILD_DOCUMENTATION option on CMake >= 3.18 where the module
# is deprecated (CMP0106) or no longer ships (CMake 4.0+).

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes the CMake version gate in Utilities/Doxygen/CMakeLists.txt so ITK no longer includes CMake’s deprecated Documentation.cmake module for CMake versions where it triggers CMP0106 warnings (CMake 3.18+), while still supporting older CMake releases.

Changes:

  • Update the version check to include Documentation.cmake only for CMake < 3.18 (instead of < 4.0).
  • Keep BUILD_DOCUMENTATION option definition for newer CMake versions to avoid relying on the removed/deprecated module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Utilities/Doxygen/CMakeLists.txt Outdated
Comment on lines 7 to 8
# and inline the BUILD_DOCUMENTATION option on CMake >= 4.0 where the file
# no longer ships.
Comment thread Utilities/Doxygen/CMakeLists.txt Outdated
Change-Id: I4d77548f49fe01da14dbf1a4839e3d65ba0e678a
@hjmjohnson
Copy link
Copy Markdown
Member

@gdevenyi I pushed 39ecf6eae7 on top of your branch (force-with-lease) to drop the if/else entirely and keep just option(BUILD_DOCUMENTATION ...). Hope that's OK — happy to revert if you'd prefer the minimal one-line gate change.

Why drop the conditional?

The old conditional + comment block (which I had authored in c157a10 and was wrong) tried to gate the legacy include(${CMAKE_ROOT}/Modules/Documentation.cmake) so it ran on "older CMake" and the inline option() ran on "CMake ≥ 4.0 where the file no longer ships". After your gate-correction to < 3.18, the comment justification (>= 4.0 where the file no longer ships) no longer matched the actual cutoff — the real reason the inline path is taken on 3.18–3.31 is that cmake_minimum_required(VERSION 3.5...3.30) sets CMP0106 to NEW, which makes the deprecated include() a fatal error.

Once that's the rationale, the legacy branch only ever runs on CMake 3.5–3.17, and the only thing it provides that the inline path doesn't is a handful of auxiliary variables (DOCUMENTATION_HTML_HELP, DOCUMENTATION_HTML_TARZ, DOCUMENTATION_INCLUDE_TARGET_INSTALLATION). I grepped the entire release-4.14 tree — none of those are referenced anywhere — so the legacy branch was effectively a no-op. main already deleted the same conditional for the same reason.

Final form:

# CMake's Documentation.cmake (the source of BUILD_DOCUMENTATION on legacy
# toolchains) is deprecated under CMP0106 since CMake 3.18 and removed in
# CMake 4.0.  Define the option directly; no auxiliary variable from that
# module is referenced in this tree.
option(BUILD_DOCUMENTATION "Build the documentation (Doxygen)." OFF)

@gdevenyi
Copy link
Copy Markdown
Contributor Author

gdevenyi commented May 9, 2026

This is fine. My agent also suggested this but I always want to offer minimal change solutions.

@hjmjohnson hjmjohnson merged commit d72b445 into InsightSoftwareConsortium:release-4.14 May 9, 2026
3 of 9 checks passed
gdevenyi added a commit to gdevenyi/minc-toolkit-v2 that referenced this pull request May 9, 2026
Bumps the pinned ITK release-4.14 SHA from b31208a2 (2026-05-05) to
d72b4459 (2026-05-09) to incorporate the Documentation.cmake gate fix
merged in InsightSoftwareConsortium/ITK#6248.

Without that upstream fix, ITK 4.14's Utilities/Doxygen/CMakeLists.txt
included the deprecated Modules/Documentation.cmake unconditionally on
CMake versions older than 4.0, hitting CMP0106 errors on Ubuntu 22.04
(CMake 3.22), Fedora 42/43 (CMake 3.30+), and similar. The upstream
patch tightens the version gate to CMake < 3.18 (when CMP0106 was
introduced), restoring the ability to configure ITK 4.14 against any
modern CMake without policy overrides on our side.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Documentation Issues affecting the Documentation module type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants