BUG: Use ZLIB::ZLIB imported target for system ZLIB#6491
Conversation
Replace hardcoded ZLIB paths in ITKTargets and module config with the ZLIB::ZLIB imported target. This avoids baking build-host paths into installed CMake config files.
|
Ran the synthetic downstream-consumer matrix (6 CMake-consumption idioms × build-tree/install-tree) against this PR, Minor, non-blocking nit: the PR drops the Differential matrix — this PR (D) vs
|
| consumer | tree | C: main |
A: #6489 | D: this PR |
|---|---|---|---|---|
| modern_libraries | build / install | PASS | PASS | PASS |
| legacy_usefile | build / install | PASS | PASS | PASS |
| config_nomodule | build / install | PASS | PASS | PASS |
| direct_target | build / install | PASS | PASS | PASS |
| components | install | PASS | PASS | PASS |
| components | build | FAIL-build¹ | FAIL-build¹ | FAIL-build¹ |
| naive_thirdparty | build | PASS | PASS | PASS |
| naive_thirdparty | install | PASS | FAIL-configure ⬅ #6489's regression | PASS ✅ |
¹ Documented harness constant — a COMPONENTS-restricted consumer doesn't get the deep-transitive itk_zlib.h on its include path in the build tree; identical across all three variants, so it cancels in the differential. The install tree exports it fine.
naive_thirdparty is the canary: it links ZLIB::ZLIB with no own find_package(ZLIB), relying on ITK to inject the imported target. It is the only cell that moved between variants — and this PR restores it to the main baseline on both trees.
Method & reproduction
Minimal ITK built twice (-DITK_USE_SYSTEM_ZLIB=ON/OFF, -DITK_BUILD_DEFAULT_MODULES=OFF -DModule_ITKIOPNG=ON), installed, then a family of 6 fake consumers swept against both the build tree and the install tree. Export code is generated at configure time, so each variant only needs a reconfigure + reinstall (no recompile): drop the variant Modules/ThirdParty/ZLIB/CMakeLists.txt in, cmake <build-dir>, cmake --install, sweep.
- C =
git show origin/main:Modules/ThirdParty/ZLIB/CMakeLists.txt - A = COMP: Do not require applications to rediscover zlib. #6489 (
ITKZLIB_EXPORT_CODE_INSTALLemptied) - D = this PR (
ITKZLIB_LIBRARIES "ZLIB::ZLIB",find_package(ZLIB)retained in both export blocks)
The self-contained harness used to produce this (driver + 6 consumer projects + the C/A/D orchestrator) is attached to this comment as a tarball for reproduction.
Caveat: this minimal sweep exercises the ImageIO/PNG path, not DCMTK (EXCLUDE_FROM_DEFAULT), which forwards ITKZLIB_LIBRARIES into an external-project -DZLIB_LIBRARIES= string. That path is unchanged in spirit here, but a full forest build would be the belt-and-suspenders confirmation for the ZLIB::ZLIB-as-string-to-subproject case.
|
The skill used to run the downstream simulation tests: |
6c3316c to
371fc39
Compare
Replace hardcoded ZLIB paths in ITKTargets and module config files with the
ZLIB::ZLIBimported target. This prevents build-host paths from being baked into installed CMake config files.Supersedes #6489 (incorrect fix — that PR relied on hardcoded paths rather than relying on the imported interface).