@@ -574,28 +574,75 @@ \section{Using ITK as an External Library}%
574574
575575\small
576576\begin {minted }[baselinestretch=1,fontsize=\footnotesize ,linenos=false,bgcolor=ltgray]{cmake}
577- set(MINIMUM_ITK_VERSION 5.4 )
577+ set(MINIMUM_ITK_VERSION 6.0 )
578578find_package(ITK $ {MINIMUM_ITK_VERSION} REQUIRED COMPONENTS Module1 Module2 )
579- include($ {ITK_USE_FILE})
579+
580+ add_executable(Example Example.cxx)
581+ target_link_libraries(Example ITK::Module1 ITK::Module2 )
580582\end {minted}
581583\normalsize
582584
583585e.g.
584586
585587\small
586588\begin {minted}[baselinestretch=1 ,fontsize=\footnotesize ,linenos=false,bgcolor=ltgray]{cmake}
587- set(MINIMUM_ITK_VERSION 5.4 )
589+ set(MINIMUM_ITK_VERSION 6.0 )
588590find_package(ITK $ {MINIMUM_ITK_VERSION} REQUIRED
589591 COMPONENTS
590592 MorphologicalContourInterpolation
591593 ITKSmoothing
592594 ITKIOImageBase
593595 ITKIONRRD
594596 )
595- include($ {ITK_USE_FILE})
597+
598+ add_executable(Example Example.cxx)
599+ target_link_libraries(Example
600+ ITK::MorphologicalContourInterpolation
601+ ITK::ITKSmoothing
602+ ITK::ITKIOImageBase
603+ ITK::ITKIONRRD
604+ )
605+ # or
606+ target_link_libraries(Example $ {ITK_INTERFACE_LIBRARIES})
596607\end {minted}
597608\normalsize
598609
610+ ITK uses factory registration to load IO formats and pluggable components at runtime.
611+ ITK 6 uses meta-modules that simplify factory registration by grouping related modules together.
612+
613+ Factory meta-modules include:
614+
615+ \begin {description}
616+ \item [ITKImageIO] All image IO modules (JPEG, PNG, NIFTI, DICOM, etc.).
617+ \item [ITKMeshIO] All mesh IO modules.
618+ \item [ITKTransformIO] Transform IO modules.
619+ \item [ITKFFTImageFilterInit] FFT implementations.
620+ \end {description}
621+
622+ To register all factories:
623+
624+ \small
625+ \begin {minted}[baselinestretch=1 ,fontsize=\footnotesize ,linenos=false,bgcolor=ltgray]{cmake}
626+ set(MINIMUM_ITK_VERSION 6.0 )
627+ find_package(ITK $ {MINIMUM_ITK_VERSION} REQUIRED
628+ COMPONENTS
629+ MorphologicalContourInterpolation
630+ ITKSmoothing
631+ ITKIOImageBase
632+ ITKIONRRD
633+ )
634+ itk_generate_factory_registration()
635+
636+ add_executable(Example Example.cxx)
637+ target_link_libraries(Example $ {ITK_INTERFACE_LIBRARIES} ITK::ITKImageIO)
638+ \end {minted}
639+ \normalsize
640+
641+ The \code {itk\_ generate\_ factory\_ registration()} macro must be called before adding executables.
642+ The CMake macro generates registration code for the IO modules and factory-enabled components from
643+ the modules loaded in \code {find\_ package()}. The meta-module must be linked to the target to
644+ include and enable the generated registration code.
645+
599646If you would like to use the CMake ExternalProject
600647Module\footnote {\url {https://cmake.org/cmake/help/latest/module/ExternalProject.html}}
601648to download ITK source code when building your ITK application (a.k.a.
0 commit comments