BUG: Use TIFF::TIFF target instead of TIFF_LIBRARIES variable#6531
Merged
hjmjohnson merged 1 commit intoJun 29, 2026
Merged
Conversation
FindTIFF.cmake populates TIFF_LIBRARIES using legacy optimized/debug keywords when LOCATION_RELEASE and LOCATION_DEBUG both resolve to the same fallback path. ITK then incorrectly prepends its namespace, producing ITK::optimized and ITK::debug which are not valid targets. Use the TIFF::TIFF imported target directly and add export code so downstream find_package(ITK) calls invoke find_package(TIFF).
dzenanz
approved these changes
Jun 29, 2026
Contributor
hjmjohnson
approved these changes
Jun 29, 2026
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.
Use the modern
TIFF::TIFFimported target instead of${TIFF_LIBRARIES}whenITK_USE_SYSTEM_TIFF=ON. Closes #6529.Root cause
CMake's
FindTIFF.cmakepopulates the legacyTIFF_LIBRARIESvariable forbackward compatibility by querying
LOCATION_RELEASEandLOCATION_DEBUGonthe
TIFF::tiffimported target. When libtiff is built withCMAKE_BUILD_TYPE=None(Arch Linux packaging convention), the targets fileonly registers
IMPORTED_LOCATION_NONE. CMake falls back to that path forboth
LOCATION_RELEASEandLOCATION_DEBUGqueries, returning the samepath twice.
FindTIFF.cmakelacks aNOT STREQUALguard (unlikeSelectLibraryConfigurations.cmake) and emits:ITK's
itk_module_impl()loop inITKModuleMacros.cmakethen prepends theITK::namespace to any token that is not a file path or already namespaced,turning
optimized→ITK::optimizedanddebug→ITK::debug.REMOVE_DUPLICATESstrips the second copy of the path, leaving:target_link_librariesthen fails becauseITK::optimizedis not a target.The upstream CMake bug (missing
STREQUALguard inFindTIFF.cmake) wasintroduced in Sep 2023 and remains unfixed as of CMake master (Dec 2025).
Fix
Modules/ThirdParty/TIFF/CMakeLists.txt: replace"${TIFF_LIBRARIES}"with"TIFF::TIFF". TheTIFF::TIFFimported target is always created byFindTIFF.cmakewhen TIFF is found (since CMake 3.5), contains::so itpasses through
itk_module_impl()'s namespace loop unchanged, and correctlyencapsulates all per-configuration link details internally.
Export code (
ITKTIFF_EXPORT_CODE_INSTALL/ITKTIFF_EXPORT_CODE_BUILD) isadded so that downstream
find_package(ITK)calls re-invokefind_package(TIFF)and recreate theTIFF::TIFFtarget.AI assistance
archlinux:latest) with PKGBUILDdependencies, mounting the ITK source read-only, running cmake configure
only — confirmed
ITK::optimizedin generatedITKTIFF.cmake.