COMP: Fix the test link when ITK is built with wrapping enabled - #1
Merged
Merged
Conversation
ITK creates ImpactTestDriver and links it with the keyword signature (ITKModuleTest.cmake), so impact_link_python_embed's plain-signature call makes CMake stop: "All uses of target_link_libraries with a target must be either all-keyword or all-plain". It only fires when ITK is built with ITK_WRAP_PYTHON=ON, since the function returns early otherwise. ImpactGTestDriver has the mirror of the problem: its own link is plain, so it breaks as soon as the function adds a keyword call. Its block runs even when Module_ITKGoogleTest is OFF, because ITK still exports a GTest::GTest target.
Apple's linker fails with "ld: unknown option: --no-as-needed", so the Python-embed link breaks on macOS once it is reached. The flag exists to stop GNU ld dropping libpython, which Apple's linker never does, so pass it only where it is understood.
hjmjohnson
marked this pull request as ready for review
September 17, 2026 14:59
Collaborator
|
Thanks! |
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.
Configuring against an ITK built with
ITK_WRAP_PYTHON=ONfails intest/CMakeLists.txt, and the link it sets up is rejected by Apple's linker. Two CMake-only fixes; no C++ changes.1. Plain vs keyword target_link_libraries
ITK creates the driver and links it with the keyword signature
(
ITKModuleTest.cmake), so the plain call inimpact_link_python_embedstopsconfigure:
ImpactGTestDriveris the mirror image: its own link is plain, so it fails assoon as the function adds a keyword call. That block runs even with
Module_ITKGoogleTest=OFF, because ITK still exports aGTest::GTesttarget.Both now use
PRIVATE.2. --no-as-needed on linkers that reject it
The flag keeps GNU ld from dropping libpython, which Apple's linker never does.
It is now passed only where it is understood.
Why this is not visible in CI today
impact_link_python_embedreturns early unlessITK_WRAP_PYTHONis set, so thefailure needs an ITK built with wrapping enabled.
Verified in a downstream build matrix, macOS arm64, LibTorch from the
torchPython package:
main(6.0.0)main(6.0.0)release-5.4The 5.4 column is why this reads as a wrapping-enabled issue rather than an
ITK 6 one.
https://claude.ai/code/session_01S5zzoU6yyUwdLEvjM2s6iS