How to construct an ITK module

Description

  • Modularized ITK v4
  • Modularization are done by CMake magics
  • Key CMake code to construct an ITK module
More details about modularization, please refer to the wiki page:
http://www.itk.org/Wiki/ITK_Release_4/Modularization

Module template

Here is a template module to download (thanks to Bradley Lowekamp):
git clone https://github.com/blowekamp/itkExternalTemplate.git

Code

CMakeLists.txt

project(ITKExternalTemplate)
itk_module_impl()

itk-module.cmake:

set(DOCUMENTATION "This module is for showing ITK module structure purposes.")

# itk_module() defines the module dependencies in ITKExternalTemplate;
# ITKExternalTemplate depends on ITKCommon;
# The testing module in ITKExternalTemplate depends on ITKTestKernel,
# and ITKMetaIO for image IO (besides ITKExternalTemplate itself)

itk_module(ITKExternalTemplate
  DEPENDS
    ITKCommon
  TEST_DEPENDS
    ITKTestKernel
    ITKMetaIO
  DESCRIPTION
    "${DOCUMENTATION}"
)

src/CMakeLists.txt

#${itk-module} will be the name of this module and will not need to be
#changed when this module is renamed.

set(${itk-module}_SRC
itkSomeFile.cxx
)

add_library(${itk-module} ${${itk-module}_SRC})
target_link_libraries(${itk-module}  ${${itk-module}_LIBRARIES})
itk_module_target(${itk-module})

test/CMakeLists.txt

itk_module_test()

#${itk-module} will be the name of this module and will not need to be
#changed when this module is renamed.

set(ITK${itk-module}Tests
  itkEmptyTest.cxx
)

CreateTestDriver(${itk-module}  "${${itk-module}-Test_LIBRARIES}" "${ITK${itk-module}Tests}")

itk_add_test(NAME itkDeleteMeEmptyTest
  COMMAND ${itk-module}TestDriver itkEmptyTest "argument1" "..." )

Video

Table Of Contents

Previous topic

Video Processing Using ITKVideoBridgeOpenCV module

Next topic

Wanted Sessions

This Page