Skip to content

Commit 4a98d0c

Browse files
author
Jon Haitz Legarreta
committed
DOC: Add documentation about command-line CMake and Remote Modules.
Add documentation to - Show how to use CMake command-line tool. - Show how to use ITK as an external library. - How to contribute with a remote module. In the latter case, many ITK wiki contents were re-used: https://itk.org/Wiki/ITK/Policy_and_Procedures_for_Adding_Remote_Modules Addresses: https://insightsoftwareconsortium.atlassian.net/projects/ITK/issues/ITK-3211?filter=myopenissues
1 parent b9fb1a8 commit 4a98d0c

File tree

2 files changed

+234
-0
lines changed

2 files changed

+234
-0
lines changed

SoftwareGuide/Latex/DevelopmentGuidelines/CreateAModule.tex

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ \chapter{How To Create A Module}
88
dependencies on other modules, which it declares. A module is defined with
99
CMake scripts that inform the build system of its contents and dependencies.
1010

11+
The modularization effort significantly improves the extensibility of the
12+
toolkit and lowers the barrier to contribution.
13+
1114
Modules are organized into:
1215

1316
\begin{itemize}
@@ -969,3 +972,105 @@ \subsection{CMakeList.txt}
969972
set(ITKVideoBridgeOpenCV_SYSTEM_INCLUDE_DIRS ${OpenCV_INCLUDE_DIRS})
970973
set(ITKVideoBridgeOpenCV_SYSTEM_LIBRARY_DIRS ${OpenCV_LIB_DIR})
971974
\end{minted}
975+
976+
\section{Contributing with a Remote Module}
977+
\label{sec:ContributingRemoteModules}
978+
979+
For most ITK community members, the modularization of the toolkit is relatively
980+
transparent. The default configuration includes all the (default) modules into
981+
the ITK library, which is used to build their own ITK applications.
982+
983+
For ITK developers and code contributors, the modular structure imposes rules
984+
for organizing the source code, building the library and contributing to the
985+
ITK source code repository.
986+
987+
A Module may be developed outside the main ITK repository, but it may be
988+
made available in the ITK repository as a Remote Module. The Remote Module
989+
infrastructure enables fast dissemination of research code through ITK without
990+
increasing the size of the main repository. The Insight Journal
991+
(\url{http://www.insight-journal.org/}) adds support for ITK module submissions
992+
with automatic dashboard testing (see Section~\ref{sec:CDash} on
993+
page~\pageref{sec:CDash} for further details).
994+
995+
The source code of a Remote Module can be downloaded by CMake (with a CMake
996+
variable switch) at ITK CMake configuration time, making it a convenient way to
997+
distribute modular source code.
998+
999+
\subsection{Policy for Adding and Removing Remote Modules}
1000+
\label{subsec:RemoteModuleAddRemovePolicy}
1001+
1002+
A module can be added to the list of remotes if it satisfies the following
1003+
criteria:
1004+
\begin{itemize}
1005+
\item There is a peer-reviewed article in an online, open access journal (such
1006+
as the Insight Journal) describing the theory behind and usage of the module.
1007+
\item There is a nightly build against ITK master on the CDash dashboard that
1008+
builds and passes tests successfully.
1009+
\item A name and contact email exists for the dashboard build. The maintainer
1010+
of the dashboard build does not necessarily need to be the original author of
1011+
the Insight Journal article.
1012+
\item The license should be compatible with the rest of the toolkit. That is
1013+
it should be an Open Source Initiative-approved
1014+
license\footnote{\url{https://opensource.org/licenses}} without copyleft or
1015+
non-commercial restrictions. Ideally, it should be an Apache 2.0 license
1016+
assigned to the Insight Software Consortium as found in the rest of the
1017+
toolkit. Note that the module should contain neither patented code, nor
1018+
algorithms, nor methods.
1019+
\end{itemize}
1020+
1021+
At the beginning of the release candidate phase of a release, maintainers of
1022+
failing module dashboard builds will be contacted. If a module's dashboard
1023+
submission is still failing at the last release candidate tagging, it will be
1024+
removed before the final release.
1025+
1026+
Module names must be \textbf{unique}.
1027+
1028+
At no time in the future should a module in the main repository depend on a
1029+
Remote Module.
1030+
1031+
\subsection{Procedure for Adding a Remote Module}
1032+
\label{subsec:ProcedureAddingRemoteModules}
1033+
1034+
The repository
1035+
\begin{center}
1036+
\url{https://github.com/InsightSoftwareConsortium/ITKModuleTemplate}
1037+
\end{center}
1038+
1039+
provides a useful template to be used as a starting point for a new ITK module.
1040+
1041+
The procedure to publish a new module in ITK is summarized as follows:
1042+
\begin{enumerate}
1043+
\item Publish an open access article describing the module in an online, open
1044+
access journal like The Insight Journal.
1045+
\item Submit a Gerrit patch (see Section~\ref{sec:GitRepository} on
1046+
page~\pageref{sec:GitRepository) that adds a file named
1047+
\code{Modules/Remote/<module name>.remote.cmake}. This file must have the
1048+
following:
1049+
\begin{enumerate}
1050+
\item Dashboard maintainer name and email in the comments.
1051+
\item A call to the \code{itk_fetch_module} CMake function (documented in
1052+
\code{CMake/ITKModuleRemote.cmake}) whose arguments are:
1053+
\begin{enumerate}
1054+
\item The name of the remote module. Note that in each
1055+
\code{<remote module name>.remote.cmake}, the first argument of the function
1056+
\code{itk_fetch_module()} is the name of the remote module, and it has to be
1057+
consistent with the module name defined in the corresponding
1058+
\code{<remote module name>.remote.cmake}. To better distinguish the remote
1059+
modules from the internal ITK modules, the names of the remote modules should
1060+
\textbf{NOT} contain the ``ITK'' string prefix.
1061+
\item A short description of the module with the handle to the open access
1062+
article.
1063+
\item URLs describing the location and version of the code to download. The
1064+
version should be a specific hash.
1065+
\end{enumerate}
1066+
\end{enumerate}
1067+
\end{enumerate}
1068+
1069+
After the Remote Module has experienced sufficient testing, and community
1070+
members express broad interests in the contribution, the submitter can then move
1071+
the contribution into the ITK repository via Gerrit code review.
1072+
1073+
It is possible but not recommended to directly submit a module to Gerrit for
1074+
review without submitting to Insight Journal first. There are no established
1075+
rules on whether a module should be directly merged into the main repository or
1076+
not.

SoftwareGuide/Latex/Introduction/Installation.tex

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,69 @@ \subsection{Advanced Module Configuration}
441441
displayed (Figure \ref{fig:ConfigITKDefault}); these messages are sorted in
442442
alphabetical 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}
592655
to see the output. It is therefore preferable to run the executable from the DOS
593656
command 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

Comments
 (0)