Difference between revisions of "Documentation/Nightly/Developers/Tutorials/BundleModulesIntoExtension"

From Slicer Wiki
Jump to: navigation, search
m
m (Text replacement - "\[http:\/\/www\.slicer\.org\/slicerWiki\/images\/([^ ]+) ([^]]+)]" to "[http://www.slicer.org/w/img_auth.php/$1 $2]")
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
<noinclude>{{documentation/versioncheck}}</noinclude>
 
= Overview =
 
= Overview =
  
 
Extensions are packaged against a specific version of Slicer, to be distributed and available for a revision X of Slicer, extensions have to be build against that same revision of Slicer. Otherwise, an extension will be considered as [[Documentation/{{documentation/version}}/SlicerApplication/ExtensionsManager#Incompatible_extensions|incompatible]].
 
Extensions are packaged against a specific version of Slicer, to be distributed and available for a revision X of Slicer, extensions have to be build against that same revision of Slicer. Otherwise, an extension will be considered as [[Documentation/{{documentation/version}}/SlicerApplication/ExtensionsManager#Incompatible_extensions|incompatible]].
  
= Extension bundles N modules =
+
<ol style="list-style-type:none; border-left:thick solid darkgreen; padding-left:1em;"> 
 +
  <li>If you are not familiar with the extension creation and contribution process, consider reading [[Documentation/{{documentation/version}}/Developers/Tutorials/BuildTestPackageDistributeExtensions|Step-by-step: How to create, publish and distribute an extension]].</li>
 +
</ol>
  
== CMake variables ==
+
= CMake variables =
  
In case an extension is expected to bundle more than one module, the following CMake variables could be defined:
+
To create an extension, the following CMake variables should be defined:
  
 
{|class="wikitable alternance" style="text-align:left; width:70%; border:1px solid black;"
 
{|class="wikitable alternance" style="text-align:left; width:70%; border:1px solid black;"
Line 60: Line 63:
 
|}
 
|}
  
== Project layout ==
+
= Project layout =
  
 
The code should be organized as illustrated below:
 
The code should be organized as illustrated below:
Line 93: Line 96:
 
</pre>
 
</pre>
  
== Top-level CMakeLists.txt ==
+
= Top-level CMakeLists.txt =
  
 
The top-level <code>CMakeLists.txt</code> could be organized as reported below:
 
The top-level <code>CMakeLists.txt</code> could be organized as reported below:
  
 
<pre>
 
<pre>
cmake_minimum_required(VERSION 2.8.8)
+
cmake_minimum_required(VERSION 2.8.9)
  
 
#-----------------------------------------------------------------------------
 
#-----------------------------------------------------------------------------
if(NOT Slicer_SOURCE_DIR)  <- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
+
# Extension meta-information <- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
  set(EXTENSION_NAME MyExtension)  <- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
+
set(EXTENSION_NAME MyExtension)  <- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
  set(EXTENSION_HOMEPAGE "http://www.slicer.org/slicerWiki/index.php/Documentation/4.1/Extensions/${EXTENSION_NAME}")  <- - - - EXTENSION SPECIFIC
+
set(EXTENSION_HOMEPAGE "http://www.slicer.org/slicerWiki/index.php/Documentation/4.1/Extensions/${EXTENSION_NAME}")  <- - - - EXTENSION SPECIFIC
  set(EXTENSION_CATEGORY "Examples")  <- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  EXTENSION SPECIFIC
+
set(EXTENSION_CATEGORY "Examples")  <- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  EXTENSION SPECIFIC
  set(EXTENSION_CONTRIBUTORS "Jean-Christophe Fillion-Robin (Kitware)")  <- - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
+
set(EXTENSION_CONTRIBUTORS "Jean-Christophe Fillion-Robin (Kitware)")  <- - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
  set(EXTENSION_DESCRIPTION "This is an example of extension bundling a CLI, a loadable and a scripted module")  <- - - - - - - EXTENSION SPECIFIC
+
set(EXTENSION_DESCRIPTION "This is an example of extension bundling a CLI, a loadable and a scripted module")  <- - - - - - - EXTENSION SPECIFIC
  set(EXTENSION_ICONURL "http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Extensions/Testing/LoadableExtensionTemplate/Resources/Icons/LoadableExtensionTemplate.png?revision=19437&view=co")
+
set(EXTENSION_ICONURL "http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Extensions/Testing/LoadableExtensionTemplate/Resources/Icons/LoadableExtensionTemplate.png?revision=19437&view=co")
endif()  <- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
 
  
 
#-----------------------------------------------------------------------------
 
#-----------------------------------------------------------------------------
if(NOT Slicer_SOURCE_DIR)
+
find_package(Slicer REQUIRED)
  find_package(Slicer REQUIRED)
+
include(${Slicer_USE_FILE})
  include(${Slicer_USE_FILE})
 
endif()
 
  
 
#-----------------------------------------------------------------------------
 
#-----------------------------------------------------------------------------
Line 122: Line 122:
  
 
#-----------------------------------------------------------------------------
 
#-----------------------------------------------------------------------------
if(NOT Slicer_SOURCE_DIR)  <- - - - - - - - - - - EXTENSION SPECIFIC
+
include(${Slicer_EXTENSION_CPACK})  <- - - - -  EXTENSION SPECIFIC
  include(${Slicer_EXTENSION_CPACK})  <- - - - -  EXTENSION SPECIFIC
 
endif()  <- - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
 
  
 
</pre>
 
</pre>
  
== Possible tweak of Module level CMakeLists.txt ==
+
= Possible tweak of Module level CMakeLists.txt =
  
 
During the development process, it could be useful to be able to build each module against a given slicer build tree without having to build the complete extensions, to do so the <code>CMakeLists.txt</code> of each module could include <code>find_package(Slicer REQUIRED)</code>.
 
During the development process, it could be useful to be able to build each module against a given slicer build tree without having to build the complete extensions, to do so the <code>CMakeLists.txt</code> of each module could include <code>find_package(Slicer REQUIRED)</code>.
Line 135: Line 133:
  
 
<pre>
 
<pre>
cmake_minimum_required(VERSION 2.8.8)
+
cmake_minimum_required(VERSION 2.8.9)
  
 
#-----------------------------------------------------------------------------
 
#-----------------------------------------------------------------------------
Line 141: Line 139:
  
 
#-----------------------------------------------------------------------------
 
#-----------------------------------------------------------------------------
if(NOT Slicer_SOURCE_DIR)
+
find_package(Slicer REQUIRED)
  find_package(Slicer REQUIRED)
+
include(${Slicer_USE_FILE})
  include(${Slicer_USE_FILE})
 
endif()
 
  
 
[...]
 
[...]
 
</pre>
 
</pre>
  
 +
<!--
 
= Extension bundles 1 module =
 
= Extension bundles 1 module =
  
Line 180: Line 177:
  
 
<pre>
 
<pre>
cmake_minimum_required(VERSION 2.8.8)
+
cmake_minimum_required(VERSION 2.8.9)
  
 
#-----------------------------------------------------------------------------
 
#-----------------------------------------------------------------------------
if(NOT Slicer_SOURCE_DIR)  <- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
+
# Extension meta-information <- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
  set(EXTENSION_NAME MyLoadableModuleExtension)  <- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
+
set(EXTENSION_NAME MyLoadableModuleExtension)  <- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
  set(EXTENSION_HOMEPAGE "http://www.slicer.org/slicerWiki/index.php/Documentation/4.1/Extensions/${MODULE_NAME}")  <- - - - -  EXTENSION SPECIFIC
+
set(EXTENSION_HOMEPAGE "http://www.slicer.org/slicerWiki/index.php/Documentation/4.1/Extensions/${MODULE_NAME}")  <- - - - -  EXTENSION SPECIFIC
  set(EXTENSION_CATEGORY "Examples")  <- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  EXTENSION SPECIFIC
+
set(EXTENSION_CATEGORY "Examples")  <- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  EXTENSION SPECIFIC
  set(EXTENSION_CONTRIBUTORS "Jean-Christophe Fillion-Robin (Kitware)")  <- - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
+
set(EXTENSION_CONTRIBUTORS "Jean-Christophe Fillion-Robin (Kitware)")  <- - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
  set(EXTENSION_DESCRIPTION "This is an example of Qt loadable module built as an extension")  <- - - - - - - - - - - - - - - - EXTENSION SPECIFIC
+
set(EXTENSION_DESCRIPTION "This is an example of Qt loadable module built as an extension")  <- - - - - - - - - - - - - - - - EXTENSION SPECIFIC
  set(EXTENSION_ICONURL "http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Extensions/Testing/LoadableExtensionTemplate/Resources/Icons/LoadableExtensionTemplate.png?revision=19437&view=co")
+
set(EXTENSION_ICONURL "http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Extensions/Testing/LoadableExtensionTemplate/Resources/Icons/LoadableExtensionTemplate.png?revision=19437&view=co")
endif()<- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
 
  
 
#-----------------------------------------------------------------------------
 
#-----------------------------------------------------------------------------
Line 199: Line 195:
  
 
#-----------------------------------------------------------------------------
 
#-----------------------------------------------------------------------------
if(NOT Slicer_SOURCE_DIR)
+
find_package(Slicer REQUIRED)
  find_package(Slicer REQUIRED)
+
include(${Slicer_USE_FILE})
  include(${Slicer_USE_FILE})
 
endif()
 
  
 
#-----------------------------------------------------------------------------
 
#-----------------------------------------------------------------------------
Line 231: Line 225:
  
 
#-----------------------------------------------------------------------------
 
#-----------------------------------------------------------------------------
if(NOT Slicer_SOURCE_DIR)  <- - - - - - - - - - - EXTENSION SPECIFIC
+
include(${Slicer_EXTENSION_CPACK})  <- - - - -  EXTENSION SPECIFIC
  include(${Slicer_EXTENSION_CPACK})  <- - - - -  EXTENSION SPECIFIC
 
endif()  <- - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
 
 
</pre>
 
</pre>
 +
-->
  
 
= Additional documentation =
 
= Additional documentation =
  
* [http://www.slicer.org/slicerWiki/images/a/a1/AHM-2011-SlicerExtensions-final.ppt AHM 2011 SlicerExtensions presentation]
+
* [[Documentation/{{documentation/version}}/Developers/Tutorials/BuildTestPackageDistributeExtensions|Step-by-step: How to create, publish and distribute an extension]]
 
+
* [http://www.slicer.org/w/img_auth.php/a/a1/AHM-2011-SlicerExtensions-final.ppt AHM 2011 SlicerExtensions presentation]
{{:Documentation/{{documentation/version}}/Developers/FAQ/Extensions|Extensions}}
+
* Read [[Documentation/{{documentation/version}}/FAQ|FAQ]]

Latest revision as of 12:39, 27 November 2019

Home < Documentation < Nightly < Developers < Tutorials < BundleModulesIntoExtension


For the latest Slicer documentation, visit the read-the-docs.


Overview

Extensions are packaged against a specific version of Slicer, to be distributed and available for a revision X of Slicer, extensions have to be build against that same revision of Slicer. Otherwise, an extension will be considered as incompatible.

  1. If you are not familiar with the extension creation and contribution process, consider reading Step-by-step: How to create, publish and distribute an extension.

CMake variables

To create an extension, the following CMake variables should be defined:

CMake variable Description Mandatory
EXTENSION_NAME Name of the extension Check.svg
EXTENSION_HOMEPAGE Url of the web page describing the extension Check.svg
EXTENSION_CATEGORY Extension category Check.svg
EXTENSION_CONTRIBUTORS Extension contributor specified as Firstname1 Lastname1 ([SubOrg1, ]Org1), Firstname2 Lastname2 ([SubOrg2, ]Org2)
EXTENSION_DESCRIPTION One line describing what is the purpose of the extension
EXTENSION_ICONURL Url to an icon (png, size 128x128 pixels)
EXTENSION_SCREENSHOTURLS Space separated list of urls to images
EXTENSION_DEPENDS List of extensions required to build this extension. Specify "NA" if there are no dependency.


List of partially supported CMake variables:

CMake variable Description
EXTENSION_STATUS Give people an idea what to expect from this code

Project layout

The code should be organized as illustrated below:


  MyExtension  <- - - - - - - - - - - - - - - - - - - - - - Top-level folder of the extension project
       |
       |-- CMakeLists.txt
       |
       |-- MyExtension.png
       |
       |-- MyCLIModule
       |        |
       |        |-- CMakeLists.txt
       |        |
       |        |-- MyCLIModule.cxx
       |        |
       |        |-- MyCLIModule.xml
       .        .
       .        .
       |
       |-- MyLoadableModule
                |
                |-- CMakeLists.txt
                |
                |-- qSlicerMyLoadableModuleModule.cxx
                |
                |-- qSlicerMyLoadableModuleModule.h
                .
                .

Top-level CMakeLists.txt

The top-level CMakeLists.txt could be organized as reported below:

cmake_minimum_required(VERSION 2.8.9)

#-----------------------------------------------------------------------------
# Extension meta-information <- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
set(EXTENSION_NAME MyExtension)  <- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
set(EXTENSION_HOMEPAGE "http://www.slicer.org/slicerWiki/index.php/Documentation/4.1/Extensions/${EXTENSION_NAME}")  <- - - - EXTENSION SPECIFIC
set(EXTENSION_CATEGORY "Examples")  <- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  EXTENSION SPECIFIC
set(EXTENSION_CONTRIBUTORS "Jean-Christophe Fillion-Robin (Kitware)")  <- - - - - - - - - - - - - - - - - - - - - - - - - - - EXTENSION SPECIFIC
set(EXTENSION_DESCRIPTION "This is an example of extension bundling a CLI, a loadable and a scripted module")  <- - - - - - - EXTENSION SPECIFIC
set(EXTENSION_ICONURL "http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Extensions/Testing/LoadableExtensionTemplate/Resources/Icons/LoadableExtensionTemplate.png?revision=19437&view=co")

#-----------------------------------------------------------------------------
find_package(Slicer REQUIRED)
include(${Slicer_USE_FILE})

#-----------------------------------------------------------------------------
add_subdirectory(MyCLIModule)
add_subdirectory(MyLoadableModule)
[...]

#-----------------------------------------------------------------------------
include(${Slicer_EXTENSION_CPACK})  <- - - - -  EXTENSION SPECIFIC

Possible tweak of Module level CMakeLists.txt

During the development process, it could be useful to be able to build each module against a given slicer build tree without having to build the complete extensions, to do so the CMakeLists.txt of each module could include find_package(Slicer REQUIRED).

For example, the CMakeLists.txt of MyCLIModule module that would be bundled into MyExtension could include the following code:

cmake_minimum_required(VERSION 2.8.9)

#-----------------------------------------------------------------------------
set(MODULE_NAME MyCLIModule) # Do not use 'project()'

#-----------------------------------------------------------------------------
find_package(Slicer REQUIRED)
include(${Slicer_USE_FILE})

[...]


Additional documentation