Skip to content

Fix macOS CI: stop ITK_USE_FILE polluting global include path#10

Merged
csparker247 merged 1 commit into
developfrom
fix-macos-itk-include-pollution
Jun 11, 2026
Merged

Fix macOS CI: stop ITK_USE_FILE polluting global include path#10
csparker247 merged 1 commit into
developfrom
fix-macos-itk-include-pollution

Conversation

@csparker247

@csparker247 csparker247 commented Jun 11, 2026

Copy link
Copy Markdown
Member

Summary

cmake/FindDependencies.cmake was calling include(${ITK_USE_FILE}), which uses the legacy UseITK.cmake pattern that adds ITK's include directories with directory-scoped include_directories() (plain -I, not -isystem). Those entries leak into every downstream subdirectory — including tests/, where GoogleTest is brought in via FetchContent.

On macos-latest (Xcode 16.4), the stricter libc++ rejects the resulting search order with:

<cstdint> tried including <stdint.h> but didn't find libc++'s <stdint.h> header.

because an ITK-bundled header dir gets searched before the SDK's libc++ wrappers.

core/CMakeLists.txt already links the ITK modules it needs as imported targets (ITKCommon, ITKTransform, ITKOptimizers, ITKIOTransform*), each of which propagates its own INTERFACE_INCLUDE_DIRECTORIES per-target. Removing the global include therefore keeps every consumer building, while preventing the include-path pollution that breaks the macOS test job.

Test plan

  • test:ubuntu:24.04 still green
  • test:ubuntu:22.04 still green
  • test:macos now builds and passes

The legacy UseITK.cmake pattern calls include_directories() at the
directory in which it's invoked, which pollutes every downstream
subdirectory's include path with -I (not -isystem) entries from ITK's
bundled third-party headers. On macOS with Xcode 16's stricter libc++,
those entries shadow the SDK's libc++ wrappers when GoogleTest is built
via FetchContent under tests/, producing errors like:

  <cstdint> tried including <stdint.h> but didn't find libc++'s <stdint.h>

core/ already links the ITK modules it needs as imported targets
(ITKCommon, ITKTransform, ITKOptimizers, ITKIOTransform*), each of
which propagates its own INTERFACE_INCLUDE_DIRECTORIES per-target.
Dropping the global include is therefore safe and isolates ITK headers
to the consumers that actually need them.
@csparker247 csparker247 merged commit 6a5d145 into develop Jun 11, 2026
3 checks passed
@csparker247 csparker247 deleted the fix-macos-itk-include-pollution branch June 11, 2026 19:14
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