COMP: Declare ITKGoogleTest where GTest drivers are built - #6780
Conversation
CurvatureFlow, DisplacementField, ImageCompare, IOTransformDCMTK, IONRRD, Review and RegionGrowing call CreateGoogleTestDriver without naming ITKGoogleTest, so their test kits neither enable the module nor carry it on the interface.
A module whose test kit calls CreateGoogleTestDriver but omits ITKGoogleTest from TEST_DEPENDS reports GTest::gtest as an unknown target, four frames from the declaration that is missing.
|
|
My responses have been short and off the cuff to try to quickly address PRs and lengthly comment. I am assuming these PR are not taking much time, and are mostly AI drive. This PR is OK, however... I looked at this a bit closer and considered the transitive dependencies. I see that ITKTestKernel has |
Wait.... I made another comment today that the "GTest" third party library was not installed. The change above would create a problem with an installed ITKTestKernel not having one of its dependencies available. These GTest issues are like an onion 🧅, they have many layers. |
|
Closing in favour of #6781, which carries the details. @blowekamp both of your points hold. One more layer while checking that: an installed ITK ships The scope has moved from an easy fix for a very rare corner case to a complicated problem: it now depends on whether an installed ITK is meant to support GoogleTest-based downstream tests, and that answer decides whether the installed The branch stays on my fork if the guard is wanted later; it was verified red/green with 230/230 ctest. |
|
@hjmjohnson Will all that being said this PR is still OK. It does not introduce any new issues with dependencies or installation. It does manually IMPROVE the dependencies of these modules. It however does not make it easier for other test modules to implicitly get the gtest dependency, and that is OK. |
|
@blowekamp Thanks. I misunderstood. I just don't want this issue to be a distraction from the more important work you are doing. I was afraid it was becoming an unnecessary burden until we have more resources (fingers crossed that we can get some grant support soon). |
ed8e503
into
InsightSoftwareConsortium:main
Seven modules call
CreateGoogleTestDriverwithout declaringITKGoogleTestinTEST_DEPENDS, so enabling one of them alone withBUILD_TESTING=ONfails on an unresolvedGTest::gtest. Second commit adds a guard inCreateGoogleTestDriverthat names the missing declaration.Why the guard is second, and evidence it detects the defect
The guard was written first and the declarations second. That order is a red/green pair but leaves commit 1 unbuildable — with the guard applied to unpatched
main, both a default and a minimal configure fail:Reordered so every commit configures; the tree at the tip is byte-identical to the tree that produced those runs. The guard therefore detects exactly the seven declarations that the first commit adds.
Symptom without the guard
TEST_DEPENDScarries two effects here:ITK_MODULE_<mod>-Test_DEPENDSenablesITKGoogleTest, anditk_module_test()putsITK::ITKGoogleTestModuleon the test kit's interface.The guard keys on
${itk-module}, not theKITargument: five call sites pass a KIT that differs from the module name (Registration/Common,ImageFrequency,BoneEnhancement,SuperPixel,IO/GDCM), and a KIT-keyed check reportsITKIOGDCMas an offender when it is not one.Local validation
macOS arm64,
-DBUILD_TESTING=ON:-DModule_ITKIONRRD=ONonlymainGTest::gtestmainMinimal tree at the tip: build ok,
ctest100% tests passed out of 230.pre-commit run --all-filesclean.AI assistance