@@ -441,6 +441,69 @@ \subsection{Advanced Module Configuration}
441441displayed (Figure \ref {fig:ConfigITKDefault }); these messages are sorted in
442442alphabetical order by module names.
443443
444+ Those who prefer to build ITK using the command line are referred to the online
445+ cmake command-line tool
446+ documentation\footnote {\url {https://cmake.org/cmake/help/latest/manual/cmake.1.html}}.
447+ Only some typical use cases are shown here for reference.
448+
449+ \begin {itemize }
450+ \item \textbf {Example 1 }: Build all default modules.
451+ \small
452+ \begin {minted }[baselinestretch=1,fontsize=\footnotesize ,linenos=false,bgcolor=ltgray]{bash}
453+ cmake [-DITK_BUILD_DEFAULT_MODULES:BOOL=ON]
454+ ../ITK-build
455+ \end {minted }
456+ \normalsize
457+
458+ As \code {ITK\_ BUILD\_ DEFAULT\_ MODULES} is \code {ON} by default, the above can
459+ also be accomplished by
460+ \begin {minted }[baselinestretch=1,fontsize=\footnotesize ,linenos=false,bgcolor=ltgray]{bash}
461+ cmake ../ITK-build
462+ \end {minted }
463+
464+ \item \textbf {Example 2 }: Enable specific group(s) of modules.
465+ \small
466+ \begin {minted }[baselinestretch=1,fontsize=\footnotesize ,linenos=false,bgcolor=ltgray]{bash}
467+ cmake -DITK_BUILD_DEFAULT_MODULES:BOOL=OFF
468+ -DBUILD_EXAMPLES:BOOL=OFF
469+ -DITKGroup_{Group1}:BOOL=ON
470+ [-DITKGroup_{Group2}:BOOL=ON]
471+ ../ITK-build
472+ \end {minted }
473+ \normalsize
474+
475+ where \code {ITKGroup\_ {GroupN}} could be, for example,
476+ \code {ITKGroup\_ Filtering} or \code {ITKGroup\_ Registration} for the
477+ \code {Filtering} and \code {Registration} groups, respectively.
478+
479+ \item \textbf {Example 3 }: Enable specific modules.
480+ \small
481+ \begin {minted }[baselinestretch=1,fontsize=\footnotesize ,linenos=false,bgcolor=ltgray]{bash}
482+ cmake -DITK_BUILD_DEFAULT_MODULES:BOOL=OFF
483+ -DBUILD_EXAMPLES:BOOL=OFF
484+ -DModule_{Module1}:BOOL=ON
485+ [-DModule_{Module2}:BOOL=ON]
486+ ../ITK-build
487+ \end {minted }
488+ \normalsize
489+
490+ where \code {Module\_ {Module1}} could be, for example, \code {Module\_ ITKFEM} for
491+ the non-default, built-in \code {FEM} module, or \code {Module\_ Cuberille} for
492+ the \code {Cuberille} remote module.
493+
494+ \item \textbf {Example 4 }: Enable examples.
495+ \small
496+ \begin {minted }[baselinestretch=1,fontsize=\footnotesize ,linenos=false,bgcolor=ltgray]{bash}
497+ cmake -DITK_BUILD_DEFAULT_MODULES:BOOL=ON
498+ -DBUILD_EXAMPLES:BOOL=ON
499+ ../ITK-build
500+ \end {minted }
501+ \normalsize
502+
503+ Note that \code {BUILD\_ EXAMPLES} is \code {OFF} by default, and
504+ \code {BUILD\_ EXAMPLES=ON} requires \code {ITK\_ BUILD\_ DEFAULT\_ MODULES=ON}.
505+
506+ \end {itemize }
444507
445508\subsection {Static and Shared Libraries }
446509\label {sec:StaticSharedLibraries }
@@ -592,6 +655,72 @@ \section{Getting Started With ITK}
592655to see the output. It is therefore preferable to run the executable from the DOS
593656command line by starting the \code {cmd.exe} shell first.
594657
658+ \section {Using ITK as an External Library }
659+ \label {sec:UsingITKAsExternalLibrary }
660+
661+ For a project that uses ITK as an external library, it is recommended to
662+ specify the individual ITK modules in the \code {COMPONENTS} argument in the
663+ \code {find_package} CMake command:
664+
665+ \small
666+ \begin {minted }[baselinestretch=1,fontsize=\footnotesize ,linenos=false,bgcolor=ltgray]{bash}
667+ find_package(ITK REQUIRED COMPONENTS Module1 Module2)
668+ include(\$ {ITK_USE_FILE})
669+ \end {minted }
670+ \normalsize
671+
672+ e.g.
673+
674+ \small
675+ \begin {minted }[baselinestretch=1,fontsize=\footnotesize ,linenos=false,bgcolor=ltgray]{bash}
676+ find_package(ITK REQUIRED
677+ COMPONENTS
678+ MorphologicalContourInterpolation
679+ ITKSmoothing
680+ ITKIOImageBase
681+ ITKIONRRD
682+ )
683+ include(\$ {ITK_USE_FILE})
684+ \end {minted }
685+ \normalsize
686+
687+ If you would like to use the CMake ExternalProject
688+ Module\footnote {url{https://cmake.org/cmake/help/latest/module/ExternalProject.html}}
689+ to download ITK source code when building your ITK application (a.k.a.
690+ Superbuild ITK), here is a basic CMake snippet for setting up a Superbuild in
691+ an ITK application project using CMake:
692+
693+ \small
694+ \begin {minted }[baselinestretch=1,fontsize=\footnotesize ,linenos=false,bgcolor=ltgray]{bash}
695+ ExternalProject_Add(ITK
696+ GIT_REPOSITORY \$ {git_protocol}://github.com/InsightSoftwareConsortium/ITK.git"
697+ GIT_TAG "< tag id>" # specify the commit id or the tag id
698+ SOURCE_DIR <ITK source tree path>
699+ BINARY_DIR <ITK build tree path>
700+ CMAKE_GENERATOR $ {gen}
701+ CMAKE_ARGS
702+ $ {ep_common_args}
703+ -DBUILD_SHARED_LIBS:BOOL=OFF
704+ -DBUILD_EXAMPLES:BOOL=OFF
705+ -DBUILD_TESTING:BOOL=OFF
706+ -DITK_BUILD_DEFAULT_MODULES:BOOL=ON
707+ [-DModule_LevelSetv4Visualization:BOOL=ON]
708+ INSTALL_COMMAND ""
709+ DEPENDS
710+ [VTK] [DCMTK] # if some of the modules requested require extra third party libraries
711+ )
712+ \end {minted}
713+ \normalsize
714+
715+ More exemplary configurations for superbuild ITK projects can be found in:
716+ Slicer\footnote {url{https://github.com/Slicer/Slicer},
717+ BrainsTools\footnote {url{https://github.com/BRAINSia/BRAINSTools}, ITK Wiki
718+ Examples\footnote {url{https://github.com/InsightSoftwareConsortium/ITKWikiExamples},
719+ ITK Sphinx
720+ Examples\footnote {url{https://github.com/InsightSoftwareConsortium/ITKExamples},
721+ and ITK Software
722+ Guide\footnote {url{https://github.com/InsightSoftwareConsortium/ITKSoftwareGuide}.
723+
595724\subsection {Hello World! }
596725\label {sec:HelloWorldITK }
597726
0 commit comments