Skip to content

Commit 7f051c5

Browse files
committed
Fix OpenJPEG target handling in DCMTKConfig.cmake
When DCMTK is built with OpenJPEG support, DCMTKTargets.cmake contains INTERFACE_LINK_LIBRARIES entries that reference the imported target openjp2. If a consuming project includes DCMTKConfig.cmake without previously finding OpenJPEG, CMake errors out because the openjp2 target does not exist. Fix by calling find_package(OpenJPEG) in DCMTKConfig.cmake before the DCMTK targets are imported, but only when DCMTK was built with OpenJPEG support and the openjp2 target has not already been defined. This ensures the openjp2 target is available when DCMTKTargets.cmake is processed, without forcing projects that already found OpenJPEG themselves to find it again.
1 parent 969c4b6 commit 7f051c5

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

CMake/DCMTKConfig.cmake.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ SET_AND_CHECK(DCMTK_TARGETS "@PACKAGE_DCMTK_CMKDIR_CONFIG@/DCMTKTargets.cmake")
109109
# Compatibility: This variable is deprecated
110110
set(DCMTK_INCLUDE_DIR ${DCMTK_INCLUDE_DIRS})
111111

112+
if(DCMTK_WITH_OPENJPEG AND NOT TARGET openjp2)
113+
find_package(OpenJPEG CONFIG QUIET)
114+
endif()
115+
112116
if(NOT DCMTK_TARGETS_IMPORTED)
113117
set(DCMTK_TARGETS_IMPORTED 1)
114118
include(${DCMTK_TARGETS})

0 commit comments

Comments
 (0)