Difference between revisions of "Documentation/4.0/Developers/Build system"

From Slicer Wiki
Jump to: navigation, search
(Add link to Slicer versioning doc)
(Move QtPlugins to its own page)
Line 1: Line 1:
 
Back to [[Documentation/{{documentation/version}}/Developers|Developers Information]]←
 
Back to [[Documentation/{{documentation/version}}/Developers|Developers Information]]←
  
;[[Documentation/Versioning]]
+
;[[Documentation/Versioning|Versioning]]
 
: Convention to name Slicer packages.
 
: Convention to name Slicer packages.
 
   
 
   
= Qt Plugins =
+
;[[Documentation/{{documentation/version}}/Developers/QtPlugins|Qt Plugins]]
Plugins for Qt (e.g. designer, iconengines, image formats)  are automatically discovered and loaded by Qt based on the directory plugins are into. There are [http://doc.qt.nokia.com/4.6/plugins-howto.html#locating-plugins multiple ways] to tell Qt where to scan directories containing plugins. <code>addLibraryPath</code> would probably be the easiest, but because plugins (e.g. designer) must be localized by Qt Designer when designing UIs, the solution is to have the environment variable <code>QT_PLUGIN_PATH</code> set by the [[Documentation/{{documentation/version}}/Developers/Launcher|Slicer launcher]] (or using a ''qt.conf'' file when no launcher is available (e.g. MacOsX Slicer installs)).
+
: How to build and load Qt plugins.
A limitation of qt.conf is that it only handles 1 plugin path, this is why Slicer installs must have their plugins in a unique top directory.
 
 
 
== Compile ==
 
To compile a plugin, use one of the macros in [https://github.com/commontk/CTK/blob/master/CMake/ctkMacroBuildQtPlugin.cmake ctkMacroBuildQtPlugin.cmake]:
 
*<code>ctkMacroBuildQtDesignerPlugin</code> to build a Qt Designer plugin.
 
*<code>ctkMacroBuildQtIconEnginesPlugin</code> to build an Icon Engine plugin.
 
*...
 
They are built in the ''bin/PLUGIN_TYPE'' directory where ''PLUGIN_TYPE'' is designer, imageformats... Only on Visual Studio they are also automatically in XXX-build/bin/PLUGIN_TYPE/BUILD_TYPE  where BUILD_TYPE is Debug, Release...
 
Refer to 
 
== Mac Bundle ==
 
Because Qt plugins are not ''direct'' dependency of Slicer (discovered and dynamically loaded at run time), Qt plugins need to be compiled as [http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:add_library MODULE] and need to be manually bundled at package time (see [http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Utilities/LastConfigureStep/SlicerCompleteBundles.cmake.in?view=markup SlicerCompleteBundles.cmake.in]).
 
 
 
== Build ==
 
<code>QT_PLUGIN_PATH</code> must points to 2 paths: ''Slicer-Superbuild/CTK-build/CTK-build/bin'' and <code>Slicer_QtPlugins_DIR</code>=''Slicer-Superbuild/Slicer-build/bin''.
 
 
 
The default Qt plugins (such as svg image format or sqldriver plugins) are in the Qtdir plugin path. 
 
 
 
Plugins locations for built Slicer:
 
* ''Slicer-Superbuild/CTK-build/CTK-build/bin/designer/CTK??????WidgetsPlugins.{so|dll}''
 
* ''Slicer-Superbuild/Slicer-build/bin/designer/qSlicer??????WidgetsPlugins.{so|dll}''
 
* ''Slicer-Superbuild/Slicer-build/bin/iconengines/qSlicer??????Plugin.{so|dll}''
 
* ''QtDir/plugins/imageformats/*.{so|dll|dylib}''
 
 
 
On Windows, they also are in the following paths but are ignored by Qt:
 
* ''Slicer-Superbuild/CTK-build/CTK-build/bin/designer/Release/CTK??????WidgetsPlugins.{so|dll}''
 
* ''Slicer-Superbuild/Slicer-build/bin/designer/Release/qSlicer??????WidgetsPlugins.{so|dll}''
 
* ''Slicer-Superbuild/Slicer-build/bin/iconengines/Release/qSlicer??????Plugin.{so|dll}''
 
 
 
== Install ==
 
<code>QT_PLUGIN_PATH</code> points to a unique path: <code>Slicer_INSTALL_QtPlugins_DIR</code>=''Slicer/lib/QtPlugins''. However, on MacOSX, there is no launcher, so environment variables can't be set prior to launching Slicer. A ''qt.conf'' containing the ''Slicer/lib/QtPlugins'' path is used for the mac bundle.
 
In order for the plugins to be installed at the right location, <code>CTK_INSTALL_QTPLUGIN_DIR</code> must be passed to CTK (see [http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/SuperBuild/External_CTK.cmake?view=markup External_CTK.cmake], this is internally used by ''ctkMacroBuildQtPlugin.cmake'')
 
Because Qt is packaged within Slicer, the plugins must also be packaged (see [http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/CMake/SlicerBlockInstallQtPlugins.cmake?view=markup SlicerBlockInstallQtPlugins.cmake])
 
Plugins locations for installed Slicer:
 
* Slicer/lib/QtPlugins/designer/CTK??????WidgetsPlugins.{so|dll}
 
* Slicer/lib/QtPlugins/iconengines/qSlicer??????WidgetsPlugins.{so|dll}
 
* Slicer/lib/QtPlugins/imageformats/*.{so|dll|dylib}
 
* Slicer/lib/QtPlugins/sqldrivers/*.{so|dll|dylib}
 
 
 
== Extensions ==
 
Extensions need to provide their plugin paths to the Slicer launcher.
 

Revision as of 20:55, 7 January 2012

Home < Documentation < 4.0 < Developers < Build system

Back to Developers Information

Versioning
Convention to name Slicer packages.
Qt Plugins
How to build and load Qt plugins.