Address namespace issue with GoogleTest libraries#5789
Address namespace issue with GoogleTest libraries#5789blowekamp wants to merge 3 commits intoInsightSoftwareConsortium:mainfrom
Conversation
blowekamp
commented
Feb 10, 2026
- Add depreciation warning for the removed GTest::GTest and GTest::Main targets.
- Correct the namespace to GTest in ITKTargets.
f54d8de to
9e28fc7
Compare
| mark_as_advanced(GTEST_HAS_ABSL) | ||
| if (NOT ITK_LEGACY_REMOVE) | ||
| add_library(GTest::GTest INTERFACE IMPORTED) | ||
| add_library(GTest::Main INTERFACE IMPORTED) |
There was a problem hiding this comment.
This would not work for the elastix ITK6 build, at least for now, because elastix always builds with ITK_LEGACY_REMOVE 🤔
Do you propose all those changes, just to make elastix happy? I hope not 😇 If it's just for elastix, we might as well simply adjust elastix with some dedicated CMake code, if ITK6 ...
There was a problem hiding this comment.
Just the first commit: ec08359 was needed for your request.
The condition could be changed to ITK_FUTURE_LEGACY_REMOVE if that is prefered.
The rest is needed to fix "ITK::gtest" to be "GTest::gtest" ( and similar to gtest_main) in the ITKTargets.cmake file for exporting in the build directory.
There was a problem hiding this comment.
As noted in the PR #5791, this alias was marked deprecated in CMake 3.20, and remove in 4.1.0. Given that I think the "ITK_LEGACY_REMOVE" is appropriate. Please let me know your preference for this code block
The ITK specific alias were removed, this change restores them with a deprecated warning.
Change to a function to avoid side effects during call. Use cmake_parse_arguments to parse additional NAMESPACE argument. Add detection of existing alias before setting.
Use added NAMESPACE option to itk_module_target to keep GTest namespace, fixing it being overridden to ITK.
9e28fc7 to
815e9bd
Compare