Skip to content

COMP: Guard the CMP0169 policy setting so older CMake still configures - #30

Merged
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:masterfrom
gdevenyi:pr/cmake-policy-guard
Sep 21, 2026
Merged

hjmjohnson merged 1 commit into
InsightSoftwareConsortium:masterfrom
gdevenyi:pr/cmake-policy-guard

Conversation

@gdevenyi

@gdevenyi gdevenyi commented Aug 15, 2026 •

Copy link
Copy Markdown

CMakeLists.txt sets policy CMP0169 unconditionally, to keep using the
deprecated FetchContent_Populate. CMP0169 was introduced in CMake 3.30,
and cmake_policy(SET) on an unknown policy is a hard error, so any CMake
older than that fails to configure at all:

CMake Error at CMakeLists.txt:175 (cmake_policy):
  Policy "CMP0169" is not known to this version of CMake.

That includes the CMake 3.28 shipped by Ubuntu 24.04, which is what the
CI runners and the project's own Dockerfile use, and it sits well above
the cmake_minimum_required(VERSION 3.10.2) the project advertises.

Wrapping it in if(POLICY CMP0169) is the standard idiom. Verified
configuring with both CMake 3.28.3 and 4.4.2.


Interface impact: none. On the union of all these changes, configured with USE_FSL_CODE=ON and USE_CIFTI_CODE=ON: all 448 exported symbols across libniftiio, libnifti2, libznz, libfslio, libnifticdf and libcifti are identical to master under nm -D --defined-only, and all ten installed headers are identical under gcc -E -P. Under gcc -dM -E one macro definition differs, intentionally and only in text: #61 makes FSL_RADIOLOGICAL read (-1) so it is safe inside an expression. Its value is still -1, checked by compiling against each installed fslio.h and printing it.

Verification. This branch: builds with gcc 16.1.1, ctest unchanged from master (2 of 345 fail on master itself in this environment; #31 and #29 each fix one). The union of all the PRs: 0 errors under both gcc 16.1.1 and clang 22.1.8, ctest 345/345 under each, and the whole suite under valgrind memcheck with --trace-children=yes gives 484 traced processes with no invalid access, no uninitialised value and no leak in any nifti binary.

Coordination. Every line of every branch was compared, whitespace-normalised, against the diffs of the open PRs (#11, #21, #22, #23, #24). Where one of those already changes a line, the line was left alone, and the few deliberate overlaps are named in the text above. What survives is 17 compiler warnings, all of them on those lines: 9 -Wsign-conversion (5 in fslio.c for #22, 2 in nifti2_io.c and 2 in nifti_tester001.c for #24) and 8 -Wcalloc-transposed-args in nifti_findhdrname and nifti_findimgname, which #11 rewrites. No formatting changes appear anywhere, to stay clear of #10 and #12.

One of a set of independent, single-purpose PRs. Each bases on master and can be merged on its own, in any order.

The full set of PRs (35)

The union of all of them is on the fork as all-changes, if you want to build and test the lot at once.

CI and build

Configuration and documentation

Defects

Warning and check classes

CMakeLists.txt sets policy CMP0169 unconditionally, to keep using the
deprecated FetchContent_Populate.  CMP0169 was introduced in CMake 3.30,
and cmake_policy(SET) on an unknown policy is a hard error, so any CMake
older than that fails to configure at all:

    CMake Error at CMakeLists.txt:175 (cmake_policy):
      Policy "CMP0169" is not known to this version of CMake.

That includes the CMake 3.28 shipped by Ubuntu 24.04, which is what the
CI runners and the project's own Dockerfile use, and it sits well above
the cmake_minimum_required(VERSION 3.10.2) the project advertises.

Wrapping it in if(POLICY CMP0169) is the standard idiom.  Verified
configuring with both CMake 3.28.3 and 4.4.2.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KSPnbwpDjVcAYqDdVqLkMU
This was referenced Aug 15, 2026
@hjmjohnson

Copy link
Copy Markdown
Member

Reviewed as part of a sweep over the open backlog. Merge as-is. This is a real bug, not hygiene.

CMP0169 only exists from CMake 3.30, so cmake_policy(SET CMP0169 OLD) is a hard configure error on every earlier release — including the CMake 3.28 that Ubuntu 24.04 LTS ships. Anyone on a current LTS cannot configure this project at all. if(POLICY CMP0169) is the canonical idiom and behavior on >=3.30 is unchanged.

Worth noting for the record: all four CI jobs are green on this PR and on master, because the GitHub runners carry CMake >= 3.30. The build matrix is structurally unable to observe this failure.

The coverage gap this exposes

There is no CI job on any older CMake, so the project's actual minimum-CMake claim is untested. cmake_minimum_required in the top-level CMakeLists.txt asserts a floor that nothing verifies, and this PR is evidence the floor was already broken.

A single job pinned to the oldest supported CMake — Ubuntu 24.04's 3.28 is the natural choice, since that is the LTS that broke — would have caught this at PR time and would guard the floor going forward. Out of scope here; recorded as a follow-up.

@hjmjohnson
hjmjohnson merged commit e09841f into InsightSoftwareConsortium:master Sep 21, 2026
4 checks passed
@hjmjohnson

Copy link
Copy Markdown
Member

The commit messages in this range were rewritten to remove trailers that do not belong in permanent history: Co-Authored-By: naming an AI tool, and Claude-Session: URLs that resolve for nobody. Only messages changed — the tree at the tip of master is byte-identical, and author, committer, and dates are preserved.

This PR's commit on the rewritten master:

  • 3aefe1b487 COMP: Guard the CMP0169 policy setting so older CMake still configures

The SHA recorded above by GitHub is from the pre-rewrite history and no longer resolves.

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.

2 participants