COMP: Strip dead cmake_minimum_required + standalone wrapper from 4 ingests#6216
Conversation
Four already-merged remote-module ingests still carry their
upstream-original boilerplate at the top of their module CMakeLists:
- cmake_minimum_required(VERSION X.Y.Z) — redundant; ITK's top-level
CMakeLists pins a higher minimum.
- if(NOT ITK_SOURCE_DIR) ... find_package(ITK) ... else()
itk_module_impl() endif() — dead code in-tree because
ITK_SOURCE_DIR is always defined.
Strip both from:
Modules/Filtering/AnisotropicDiffusionLBR
Modules/Filtering/Cuberille
Modules/Filtering/LabelErodeDilate
Modules/Registration/Montage
Lines that had effect inside the in-tree else() branch
(set(ITK_DIR ${CMAKE_BINARY_DIR}) on AnisotropicDiffusionLBR and
Montage) are preserved unconditionally.
The other four merged ingests (GenericLabelInterpolator, MGHIO,
FastBilateral, MeshNoise) were already cleaned up during their
respective ingest PRs.
Matches the v4 ingest-pipeline rules now codified in PR InsightSoftwareConsortium#6204
(sanitize-history.py:patch_drop_cmake_minimum_required and
:patch_standalone_build_guard); future ingests will not introduce
this idiom.
|
| Filename | Overview |
|---|---|
| Modules/Filtering/AnisotropicDiffusionLBR/CMakeLists.txt | Removed cmake_minimum_required and the if(NOT ITK_SOURCE_DIR) guard; set(ITK_DIR) + itk_module_impl() preserved unconditionally from the former else-branch. Correct and clean. |
| Modules/Filtering/Cuberille/CMakeLists.txt | Removed cmake_minimum_required and the standalone-build conditional; bare itk_module_impl() retained. Straightforward cleanup. |
| Modules/Filtering/LabelErodeDilate/CMakeLists.txt | Removed cmake_minimum_required and the standalone-build conditional; bare itk_module_impl() retained. Straightforward cleanup. |
| Modules/Registration/Montage/CMakeLists.txt | Removed cmake_minimum_required and the if(NOT ITK_SOURCE_DIR) guard; set(ITK_DIR) + itk_module_impl() preserved unconditionally from the former else-branch. Correct and clean. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[CMakeLists.txt processed by CMake] --> B{ITK_SOURCE_DIR defined?}
B -- "Before PR: YES (in-tree, always true)" --> C["else-branch:\nset(ITK_DIR)\nitk_module_impl()"]
B -- "Before PR: NO (standalone, unreachable)" --> D["if-branch:\nfind_package(ITK)\ninclude(ITKModuleExternal)"]
D -. dead code .-> D
A2[CMakeLists.txt after PR] --> E["set(ITK_DIR) if applicable\nitk_module_impl()"]
style D fill:#ffcccc,stroke:#cc0000,stroke-dasharray: 5 5
style E fill:#ccffcc,stroke:#007700
Reviews (1): Last reviewed commit: "COMP: Drop dead cmake_minimum_required +..." | Re-trigger Greptile
477ae98
into
InsightSoftwareConsortium:main
…anup-ingested-cmake-min COMP: Strip dead cmake_minimum_required + standalone wrapper from 4 ingests
Strips two upstream-original boilerplate idioms from four already-merged remote-module ingests: per-module
cmake_minimum_required(VERSION X.Y.Z)declarations (redundant with ITK's top-level pin) andif(NOT ITK_SOURCE_DIR) ... else() itk_module_impl() endif()standalone-build wrappers (dead code in-tree, sinceITK_SOURCE_DIRis always defined). Matches the v4 sanitizer rules now codified in #6204 so every future ingest will be born clean.Files changed (4 modules)
Modules/Filtering/AnisotropicDiffusionLBRset(ITK_DIR ${CMAKE_BINARY_DIR})from the in-tree else-branch preserved as unconditionalModules/Filtering/CuberilleModules/Filtering/LabelErodeDilateModules/Registration/Montageset(ITK_DIR ${CMAKE_BINARY_DIR})preserved as unconditionalThe other four already-merged ingests (
GenericLabelInterpolator,MGHIO,FastBilateral,MeshNoise) were already cleaned up during their respective ingest PRs and need no change.The six open ingest PRs (#6206, #6208, #6211, #6212, #6214, #6215) each had an analogous cleanup applied directly on their branches earlier today.
Why both idioms are dead in-tree
cmake_minimum_required(VERSION X.Y.Z): the project's top-levelCMakeLists.txtalready pins a higher minimum than any of these per-module declarations (commonly 3.10.2 / 3.16.3). The per-module line at best does nothing and at worst lowers the floor for that subdirectory below ITK's policy.if(NOT ITK_SOURCE_DIR)standalone-build guard: the upstream remote-module repos used this idiom so the module'sCMakeLists.txtcould be configured both as a fetched ITK module and as a stand-alone CMake project. In an in-tree ingested module,ITK_SOURCE_DIRis always defined, so the if-branch is unreachable.Both patterns are flagged consistently by reviewers (e.g. @dzenanz on PRs #6206 / #6215) and by the v4 sanitizer's run summary.
Local verification
pre-commit run --all-filesexit 0cmake .reconfigure on the build tree clean (32 s)