@@ -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 }
@@ -469,7 +532,7 @@ \subsection{Static and Shared Libraries}
469532an application. This reduces binary size and ensures that singleton
470533variables are unique across the application.
471534
472- A very advanced CMake configuration variable,
535+ An advanced CMake configuration variable,
473536\code {ITK\_ TEMPLATE\_ VISIBILITY\_ DEFAULT} defines the symbol visibility
474537attribute on template classes to \textit {default } on systems that require it
475538to perform \code {dynamic\_ cast}'s on pointers passed across binaries. The
@@ -491,7 +554,7 @@ \subsection{Compiling ITK}
491554and selecting the `` Build'' context menu item.
492555
493556The build process can take anywhere from 15 minutes to a couple of hours,
494- depending on the the build configuration and the performance of your
557+ depending on the build configuration and the performance of your
495558system. If testing is enabled as part of the normal build process,
496559about 2400 test programs will be compiled. In this case, you will then need
497560to run \code {ctest} to verify that all the components of ITK have been correctly built
@@ -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