Fix macOS CI: stop ITK_USE_FILE polluting global include path#10
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cmake/FindDependencies.cmakewas callinginclude(${ITK_USE_FILE}), which uses the legacyUseITK.cmakepattern that adds ITK's include directories with directory-scopedinclude_directories()(plain-I, not-isystem). Those entries leak into every downstream subdirectory — includingtests/, where GoogleTest is brought in via FetchContent.On
macos-latest(Xcode 16.4), the stricter libc++ rejects the resulting search order with:because an ITK-bundled header dir gets searched before the SDK's libc++ wrappers.
core/CMakeLists.txtalready links the ITK modules it needs as imported targets (ITKCommon,ITKTransform,ITKOptimizers,ITKIOTransform*), each of which propagates its ownINTERFACE_INCLUDE_DIRECTORIESper-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.04still greentest:ubuntu:22.04still greentest:macosnow builds and passes