FindDCMTK
Finds the DICOM ToolKit (DCMTK) libraries and applications:
find_package(DCMTK [...])
DCMTK is a set of libraries and applications implementing large parts of the DICOM Standard (Digital Imaging and Communications in Medicine).
Added in version 3.5: This module is now able to find a version of DCMTK that does or does not export a DCMTKConfig.cmake file.
DCMTK since its version 3.6.1_20140617 supports and installs package configuration file (DCMTKConfig.cmake) for use with the find_package() command in config mode.
This module now applies a two-step process:
- Step 1: Attempts to find DCMTK version providing a
DCMTKConfig.cmakefile and, if found, returns the results without further action. - Step 2: If step 1 failed, this module falls back to module mode (it searches standard locations) and sets the
DCMTK_*result variables.
Until all clients update to the more recent DCMTK, build systems will need to support different versions of DCMTK.
On any given system, the following combinations of DCMTK versions could be considered for the DCMTK installed on the system (for example, via a system package manager), or locally (for example, a custom installation, or through the FetchContent module):
Case | System DCMTK | Local DCMTK | Supported? |
|---|---|---|---|
A | N/A | [ ] DCMTKConfig | YES |
B | N/A | [X] DCMTKConfig | YES |
C | [ ] DCMTKConfig | N/A | YES |
D | [X] DCMTKConfig | N/A | YES |
E | [ ] DCMTKConfig | [ ] DCMTKConfig | YES (*) |
F | [X] DCMTKConfig | [ ] DCMTKConfig | NO |
G | [ ] DCMTKConfig | [X] DCMTKConfig | YES |
H | [X] DCMTKConfig | [X] DCMTKConfig | YES |
Legend:
- (*)
-
See the Troubleshooting section.
- N/A
-
DCMTK is not available.
- [ ] DCMTKConfig
-
DCMTK does NOT export a
DCMTKConfig.cmakefile. - [X] DCMTKConfig
-
DCMTK exports a
DCMTKConfig.cmakefile.
Result Variables
This module defines the following variables:
-
DCMTK_FOUND -
Boolean indicating whether DCMTK was found.
-
DCMTK_INCLUDE_DIRS -
Include directories containing headers needed to use DCMTK.
-
DCMTK_LIBRARIES -
Libraries needed to link against to use DCMTK.
Hints
This module accepts the following variables:
-
DCMTK_DIR -
(optional) Source directory for DCMTK.
Troubleshooting
What to do if project finds a different version of DCMTK?
Remove DCMTK entry from the CMake cache per find_package() documentation, and re-run configuration. To find DCMTK on custom location use variables such as CMAKE_PREFIX_PATH, or DCMTK_DIR.
Examples
Example: Finding DCMTK
Finding DCMTK with this module:
find_package(DCMTK)
Example: Finding DCMTK Without This Module
To explicitly use the DCMTKConfig.cmake package configuration file (recommended when possible) and find DCMTK in config mode without using this module, the NO_MODULE option can be given to find_package():
find_package(DCMTK NO_MODULE)
Example: Creating Imported Target
In the following example, DCMTK is searched with this module and an imported target is conditionally created to provide DCMTK usage requirements which can be easily linked to project targets. For example, if DCMTK is found in config mode, the DCMTK::DCMTK imported target will be available through the found config files instead:
find_package(DCMTK)
# Upstream DCMTKConfig.cmake already provides DCMTK::DCMTK imported target
if(DCMTK_FOUND AND NOT TARGET DCMTK::DCMTK)
add_library(DCMTK::DCMTK INTERFACE IMPORTED)
set_target_properties(
DCMTK:DCMTK
PROPERTIES
INTERFACE_LINK_LIBRARIES "${DCMTK_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${DCMTK_INCLUDE_DIRS}"
)
endif()
target_link_libraries(example PRIVATE DCMTK::DCMTK)
© 2000–2026 Kitware, Inc. and Contributors
Licensed under the BSD 3-clause License.
https://cmake.org/cmake/help/latest/module/FindDCMTK.html