Documentation/4.1/Developers/Build Module

From Slicer Wiki
Revision as of 09:00, 20 June 2012 by JChris.FillionR (talk | contribs) (Created page with 'The different [[Documentation/{{documentation/version}}/Developers/Modules|type of modules]] supported by Slicer can easily be build outside of the Slicer source tree. The follo…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Home < Documentation < 4.1 < Developers < Build Module

The different type of modules supported by Slicer can easily be build outside of the Slicer source tree.

The following examples are specific to unix-like platforms and can easily be adapted for Windows.

Externally building modules could be achieved doing:

$ cd MyModule-build
$ cmake -DSlicer_DIR:PATH=/path/to/Slicer-Superbuild/Slicer-build .
$ make

For this to work, in addition to invoke cmake_minimum_required at the top of the CMakeLists.txt, it's important to make sure the following line are added after setting MODULE_NAME:

#-----------------------------------------------------------------------------
if(NOT Slicer_SOURCE_DIR)
  find_package(Slicer REQUIRED)
  include(${Slicer_USE_FILE})
endif()

For example:

cmake_minimum_required(VERSION 2.8.7)

#-----------------------------------------------------------------------------
set(MODULE_NAME MyModule)
set(MODULE_TITLE ${MODULE_NAME})

string(TOUPPER ${MODULE_NAME} MODULE_NAME_UPPER)

#-----------------------------------------------------------------------------
if(NOT Slicer_SOURCE_DIR)
  find_package(Slicer REQUIRED)
  include(${Slicer_USE_FILE})
endif()

#-----------------------------------------------------------------------------
add_subdirectory(Logic)

#-----------------------------------------------------------------------------
set(MODULE_EXPORT_DIRECTIVE "Q_SLICER_QTMODULES_${MODULE_NAME_UPPER}_EXPORT")

[...]