Difference between revisions of "Documentation/4.1/Developers/Build Module"
From Slicer Wiki
m |
(Prepend documentation/versioncheck template. See http://na-mic.org/Mantis/view.php?id=2887) |
||
(3 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | The different [[Documentation/{{documentation/version}}/Developers/Modules|type of modules]] supported by Slicer can easily be | + | <noinclude>{{documentation/versioncheck}}</noinclude> |
+ | The different [[Documentation/{{documentation/version}}/Developers/Modules|type of modules]] supported by Slicer can easily be built outside of the Slicer source tree. | ||
The following examples are specific to unix-like platforms and can easily be adapted for Windows. | The following examples are specific to unix-like platforms and can easily be adapted for Windows. | ||
+ | |||
+ | |||
Assuming the source code of your module is located in folder <code>MyModule</code>, externally building modules could be achieved doing: | Assuming the source code of your module is located in folder <code>MyModule</code>, externally building modules could be achieved doing: | ||
Line 10: | Line 13: | ||
$ make | $ make | ||
</pre> | </pre> | ||
+ | |||
+ | |||
For this to work, in addition to invoke <code>cmake_minimum_required</code> at the top of the top-level <code>CMakeLists.txt</code>, it's important to make sure the following line are added after setting <code>MODULE_NAME</code>: | For this to work, in addition to invoke <code>cmake_minimum_required</code> at the top of the top-level <code>CMakeLists.txt</code>, it's important to make sure the following line are added after setting <code>MODULE_NAME</code>: | ||
Line 19: | Line 24: | ||
endif() | endif() | ||
</pre> | </pre> | ||
+ | |||
For example: | For example: | ||
+ | |||
<pre> | <pre> | ||
− | cmake_minimum_required(VERSION 2.8. | + | cmake_minimum_required(VERSION 2.8.8) <- - - - ADD THIS |
#----------------------------------------------------------------------------- | #----------------------------------------------------------------------------- | ||
Line 31: | Line 38: | ||
#----------------------------------------------------------------------------- | #----------------------------------------------------------------------------- | ||
− | if(NOT Slicer_SOURCE_DIR) | + | if(NOT Slicer_SOURCE_DIR) <- - - - - - - - - - ADD THIS |
− | find_package(Slicer REQUIRED) | + | find_package(Slicer REQUIRED) <- - - - - - - ADD THIS |
− | include(${Slicer_USE_FILE}) | + | include(${Slicer_USE_FILE}) <- - - - - - - - ADD THIS |
endif() | endif() | ||
Latest revision as of 07:22, 14 June 2013
Home < Documentation < 4.1 < Developers < Build Module
For the latest Slicer documentation, visit the read-the-docs. |
The different type of modules supported by Slicer can easily be built outside of the Slicer source tree.
The following examples are specific to unix-like platforms and can easily be adapted for Windows.
Assuming the source code of your module is located in folder MyModule
, externally building modules could be achieved doing:
$ mkdir MyModule-build $ cd MyModule-build $ cmake -DSlicer_DIR:PATH=/path/to/Slicer-Superbuild/Slicer-build ../MyModule $ make
For this to work, in addition to invoke cmake_minimum_required
at the top of the top-level 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.8) <- - - - ADD THIS #----------------------------------------------------------------------------- set(MODULE_NAME MyModule) set(MODULE_TITLE ${MODULE_NAME}) string(TOUPPER ${MODULE_NAME} MODULE_NAME_UPPER) #----------------------------------------------------------------------------- if(NOT Slicer_SOURCE_DIR) <- - - - - - - - - - ADD THIS find_package(Slicer REQUIRED) <- - - - - - - ADD THIS include(${Slicer_USE_FILE}) <- - - - - - - - ADD THIS endif() #----------------------------------------------------------------------------- add_subdirectory(Logic) #----------------------------------------------------------------------------- set(MODULE_EXPORT_DIRECTIVE "Q_SLICER_QTMODULES_${MODULE_NAME_UPPER}_EXPORT") [...]