Difference between revisions of "Documentation/Nightly/Developers/Build Instructions/Configure"

From Slicer Wiki
Jump to: navigation, search
(Prepend documentation/versioncheck template. See http://na-mic.org/Mantis/view.php?id=2887)
(→‎Unix-like: Update unix-like build instructions)
 
(41 intermediate revisions by 8 users not shown)
Line 1: Line 1:
 
<noinclude>{{documentation/versioncheck}}</noinclude>
 
<noinclude>{{documentation/versioncheck}}</noinclude>
== CONFIGURE and generate Slicer solution files ==
 
You can configure and generate Slicer solution files using either <code>ccmake</code> or <code>cmake-gui</code>.
 
  
=== Per-platform instructions===
+
==CONFIGURE and generate Slicer solution files==
==== Windows ====
+
There are many ways of customizing Slicer's user interface or feature set. This section describes how a custom Slicer build can be configured at build-time. See an overview of various other options in [http://www.na-mic.org/Wiki/images/b/b0/Slicelets2016.pdf this presentation].
*'''Recommended''': <code>cmake-gui</code>
 
** Configure using default options.
 
** Set the build directory. For example: <code>C:\Slicer-SuperBuild-Debug</code> or <code>C:\Slicer-SuperBuild-Release</code>
 
* '''Remarks''':
 
#If you downloaded the Qt binary then <code>qmake</code> will be detected and all paths will be set automatically.
 
#If you built your own Qt (e.g. in Debug mode for use with the designer) set the <code>QT_QMAKE_EXECUTABLE</code> in <code>cmake-gui</code>.<code>QT_QMAKE_EXECUTABLE</code> should be set to the path of the qmake.exe file, which is inside the bin directory (for example, <code>\path\to\qt-everywhere-opensource-build-4.7.4\bin\qmake.exe</code>).
 
#Windows doesn't support path longer than 260 characters, please make sure that the total path name of your <code>Slicer-build</code> directory is no longer than 50 characters ( for example <code>c:\work\Slicer\Slicer-Superbuild</code> (32 characters) is fine)
 
#If you are making a release build, set your CMAKE_CONFIGURATION_TYPES to Release. Otherwise Visual Studio will select Debug by default and your build tree can end up with a mix of release and debug libraries.
 
  
==== Unix-like ====
+
You can configure and generate Slicer solution files using either <code>ccmake</code> or <code>cmake-gui</code>. To streamline this process, you can also use the [https://github.com/KitwareMedical/SlicerCustomAppTemplate SlicerCustomAppTemplate] project maintained by Kitware.
*'''Recommended''': <code>ccmake</code>
+
 
** Configure using the following commands. By default '''CMAKE_BUILD_TYPE''' is set to '''Debug'''.
+
<!--
 +
<ol style="list-style-type:none; border-left:thick solid red; padding-left:1em;">
 +
  <li>While it is not enforced, we strongly recommend you to '''AVOID''' the use of '''SPACES''' for both the <code>source directory</code> and the <code>build directory</code>. We mean it.
 +
  </li>
 +
</ol>
 +
-->
 +
===Customizing application build===
 +
Customized editions of Slicer can be generated without changing Slicer source code, just by modifying CMake variables:
 +
 
 +
*SlicerApp_APPLICATION_NAME: Custom application name to be used, instead of default "Slicer". The name is used in installation package name, window title bar, etc.
 +
*Slicer_DISCLAIMER_AT_STARTUP: String that is displayed to the user after first startup of Slicer after installation (disclaimer, welcome message, etc).
 +
*Slicer_DEFAULT_HOME_MODULE: Module name that is activated automatically on application start.
 +
*Slicer_DEFAULT_FAVORITE_MODULES: Modules that will be added to the toolbar by default for easy access. List contains module names, separated by space character.
 +
*Slicer_CLIMODULES_DISABLED: Built-in CLI modules that will be removed from the application. List contains module names, separated by semicolon character.
 +
*Slicer_QTLOADABLEMODULES_DISABLED: Built-in Qt loadable modules that will be removed from the application. List contains module names, separated by semicolon character.
 +
*Slicer_QTSCRIPTEDMODULES_DISABLED: Built-in scripted loadable modules that will be removed from the application. List contains module names, separated by semicolon character.
 +
*Slicer_USE_PYTHONQT_WITH_OPENSSL: enable/disable building the application with SSL support (ON/OFF)
 +
*Slicer_USE_SimpleITK: enable/disable SimpleITK support (ON/OFF)
 +
*Slicer_BUILD_SimpleFilters: enable/disable building SimpleFilters. Requires SimpleITK. (ON/OFF)
 +
*Slicer_BUILD_EMSegment: enable/disable building EM segmenter (ON/OFF)
 +
*Slicer_USE_PYTHONQT_WITH_TCL: TCL support (ON/OFF)
 +
*Slicer_EXTENSION_SOURCE_DIRS: Defines additional extensions that will be included in the application package as built-in modules. Full paths of extension source directories has to be specified, separated by semicolons.
 +
 
 +
===Per-platform instructions===
 +
====Windows====
 +
 
 +
'''Recommended''': run ''CMake (cmake-gui)'' from the Windows Start menu
 +
 
 +
*Set the build directory. Use a very short path, for example: <code>C:\D\S4</code> for source code and for <code>C:\D\S4D</code> build directory are known to work.
 +
**Because Windows [http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx#maxpath doesn't support file path longer than 260 characters] and has a [http://massmail.spl.harvard.edu/public-archives/slicer-devel/2014/016113.html maximum command line length], it is strongly recommended to choose a build directory that is no longer than 10 characters. If a longer path is used then build may or may not succeed.
 +
**You cannot use the same build tree for both release or debug mode builds. If both build types are needed, then the same source directory can be used, but a separate build directory should be created and configured for each build type.
 +
*Select your compiler: Visual Studio 16 2019 Win64
 +
*<b>Do not configure yet.</b>
 +
*Add <code>Qt5_DIR</code> variable pointing to Qt5 folder such as <code>C:\Qt\5.15.0\msvc2019_64\lib\cmake\Qt5</code>: click ''Add entry'' button, set ''Name'' to ''Qt5_DIR'', ''Type'' to ''PATH'', and ''Value'' to the Qt5 folder.
 +
*Configure
 +
*Click generate then close cmake-gui.
 +
*If building in release mode:
 +
**Open the top-level Slicer.sln file in the build directory in Visual Studio
 +
**Set active configuration to Release. Visual Studio will select Debug build configuration by default when you first open the solution in the Visual Studio GUI. If you build Slicer in release mode and accidentally forget to switch the build configuration to Release then the build will fail. Note: you can avoid this manual configuration mode selection by setting <code>CMAKE_CONFIGURATION_TYPES</code> to <code>Release</code> in cmake-gui.
 +
*If building in debug mode:
 +
**Start Visual Studio using the Slicer launcher as described in [[Documentation/{{documentation/version}}/Developers/Tutorials/Debug_Instructions|Step-by-step debug instuctions]]
 +
*Build the ALL_BUILD project
 +
 
 +
'''Alternative option''': Configure and build using command-line or batch file
 +
 
 +
Instead of using ''CMake (cmake-gui)'', it is also possible to configure by creating a .bat file that contains command-line instructions and run this .bat file each time a Slicer needs to be re-built. The examples below assume Slicer source code is in <code>C:\D\S4</code> folder and Qt-5.10 is installed in default location.
 +
 
 +
Visual Studio 2015 in Release mode:
 +
<pre>
 +
mkdir C:\D\S4R
 +
cd /d C:\D\S4R
 +
"C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 16 2019 Win64" -DQt5_DIR:PATH=C:\Qt\5.15.0\msvc2019_64\lib\cmake\Qt5 C:\D\S4
 +
"C:\Program Files\CMake\bin\cmake.exe" --build . --config Release
 +
</pre>
 +
 
 +
Visual Studio 2015 in Debug mode:
 +
<pre>
 +
mkdir C:\D\S4D
 +
cd /d C:\D\S4D
 +
"C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 16 2019 Win64" -DQt5_DIR:PATH=C:\Qt\5.15.0\msvc2019_64\lib\cmake\Qt5 C:\D\S4
 +
"C:\Program Files\CMake\bin\cmake.exe" --build . --config Debug
 +
</pre>
 +
 
 +
Visual Studio 2019 with VS2015 toolset in Release mode:
 +
<pre>
 +
mkdir C:\D\S4R
 +
cd /d C:\D\S4R
 +
"C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 16 2019 Win64" -T "v140" -DQt5_DIR:PATH=C:\Qt\5.10.0\msvc2015_64\lib\cmake\Qt5 C:\D\S4
 +
"C:\Program Files\CMake\bin\cmake.exe" --build . --config Release
 +
</pre>
 +
 
 +
====Unix-like====
 +
 
 +
*'''Recommended''':
 +
**Configure using the following commands. By default '''CMAKE_BUILD_TYPE''' is set to '''Debug'''.
 
<pre>
 
<pre>
 
mkdir Slicer-SuperBuild-Debug
 
mkdir Slicer-SuperBuild-Debug
 
cd Slicer-SuperBuild-Debug
 
cd Slicer-SuperBuild-Debug
cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DQT_QMAKE_EXECUTABLE:FILEPATH=/path/to/QtSDK-1.2/Desktop/Qt/474/gcc/bin/qmake ../Slicer
+
cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DQt5_DIR:PATH=/path/to/Qt5.15.0/5.15.0/gcc_64/lib/cmake/Qt5 ../Slicer
 +
</pre>
 +
where you replace ''/path/to/QtSDK'' with the real path on your machine where QtSDK is located
 +
 
 +
If '''using Qt from the system''', do not forget to add the following CMake variable to your configuration command line:
 +
<pre>-DSlicer_USE_SYSTEM_QT:BOOL=1
 
</pre>
 
</pre>
where you replace ''/path/to'' with the real path on your machine where QtSDK-1.2 is located
 
* '''Remarks''':
 
# Using top-level directory name like <code>Slicer-Superbuild-Release</code> or <code>Slicer-Superbuild-Debug</code> is recommended.
 
  
=== General information ===
+
*'''Remarks''':
 +
 
 +
#Instead of <code>cmake</code>, you can use <code>ccmake</code> or <code>cmake-gui</code> to visually inspect and edit configure options.
 +
#Using top-level directory name like <code>Slicer-SuperBuild-Release</code> or <code>Slicer-SuperBuild-Debug</code> is recommended.
 +
#[[Documentation/{{documentation/version}}/Developers/Tutorials/Debug_Instructions|Step-by-step debug instuctions]]
 +
 
 +
*On Mac OS X 10.9 (Mavericks) / 10.10 (Yosemite) / 10.11 (El Capitan), also set the following variables (see [http://massmail.spl.harvard.edu/public-archives/slicer-devel/2014/thread.html#16440 discussion]):
 +
 
 +
{| border="0" cellpadding="4" cellspacing="4"
 +
|-
 +
| bgcolor="#abcdef" height="8" |'''Variable'''
 +
| bgcolor="#abcdef" height="8" |'''Description'''
 +
|-
 +
|Slicer_USE_PYTHONQT_WITH_TCL||OFF
 +
|-
 +
|CMAKE_OSX_DEPLOYMENT_TARGET||10.9 or 10.10 or 10.11
 +
|-
 +
|}
 +
 
 +
===General information===
  
 
Two projects are generated by either <code>cmake</code>, <code>ccmake</code> or <code>cmake-gui</code>.  
 
Two projects are generated by either <code>cmake</code>, <code>ccmake</code> or <code>cmake-gui</code>.  
  
One of them is in the top-level bin directory <code>Slicer-Superbuild</code> and the other one is in the subdirectory <code>Slicer-build</code>:
+
One of them is in the top-level bin directory <code>Slicer-SuperBuild</code> and the other one is in the subdirectory <code>Slicer-build</code>:
  
<pre>Slicer-Superbuild/Slicer-build</pre>
+
<pre>Slicer-SuperBuild/Slicer-build</pre>
  
# The first project in <code>Slicer-Superbuild</code> manages all the external dependencies of Slicer (VTK, ITK, Python, ...). To build Slicer for the first time, run make (or build the solution file in Visual Studio) in <code>Slicer-Superbuild</code>, which will update and build the external libraries and if successful will then build the subproject Slicer-build.<br>
+
#The first project in <code>Slicer-SuperBuild</code> manages all the external dependencies of Slicer (VTK, ITK, Python, ...). To build Slicer for the first time, run make (or build the solution file in Visual Studio) in <code>Slicer-SuperBuild</code>, which will update and build the external libraries and if successful will then build the subproject Slicer-build.<br>
# The second project in <code>Slicer-Superbuild/Slicer-build</code> is the "traditional" build directory of Slicer.  After local changes in Slicer (or after an svn update on the source directory of Slicer), only running make (or building the solution file in Visual Studio) in <code>Slicer-Superbuild/Slicer-build</code> is necessary (the external libraries are considered built and up to date). <br>
+
#The second project in <code>Slicer-SuperBuild/Slicer-build</code> is the "traditional" build directory of Slicer.  After local changes in Slicer (or after an svn update on the source directory of Slicer), only running make (or building the solution file in Visual Studio) in <code>Slicer-SuperBuild/Slicer-build</code> is necessary (the external libraries are considered built and up to date). <br>
 
#'''Warning''': An significant amount of disk space is required to compile Slicer in Debug (>10GB on Windows)
 
#'''Warning''': An significant amount of disk space is required to compile Slicer in Debug (>10GB on Windows)
  
=== Workaround firewall blocking git protocol ===
+
===Workaround for if the firewall is blocking git protocol===
* Some firewall will be blocking the git protocol, a possible workaround is to configure Slicer disabling the option <code>Slicer_USE_GIT_PROTOCOL</code>. Then http protocol will be used instead. Consider also reading https://github.com/commontk/CTK/issues/33
 
  
=== Notes for advanced users ===
+
*Some firewalls will block the git protocol. A possible workaround is to configure Slicer by disabling the option <code>Slicer_USE_GIT_PROTOCOL</code>. Then the http protocol will be used instead. Consider also reading https://github.com/commontk/CTK/issues/33
* By default, if CMake finds Java on your machine, it automatically builds Java CLIs. If you don't want any Java in your Slicer (or if you don't want to install Java on your Mac Os X), you can pass <code>-DCMAKE_DISABLE_FIND_PACKAGE_Java:BOOL=TRUE</code> when configuring Slicer.
 
* Same applies for OpenSSL: <code>CMAKE_DISABLE_FIND_PACKAGE_OpenSSL:BOOL=TRUE</code> can be passed when building Slicer for packaging.
 

Latest revision as of 14:29, 1 June 2020

Home < Documentation < Nightly < Developers < Build Instructions < Configure


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


CONFIGURE and generate Slicer solution files

There are many ways of customizing Slicer's user interface or feature set. This section describes how a custom Slicer build can be configured at build-time. See an overview of various other options in this presentation.

You can configure and generate Slicer solution files using either ccmake or cmake-gui. To streamline this process, you can also use the SlicerCustomAppTemplate project maintained by Kitware.

Customizing application build

Customized editions of Slicer can be generated without changing Slicer source code, just by modifying CMake variables:

  • SlicerApp_APPLICATION_NAME: Custom application name to be used, instead of default "Slicer". The name is used in installation package name, window title bar, etc.
  • Slicer_DISCLAIMER_AT_STARTUP: String that is displayed to the user after first startup of Slicer after installation (disclaimer, welcome message, etc).
  • Slicer_DEFAULT_HOME_MODULE: Module name that is activated automatically on application start.
  • Slicer_DEFAULT_FAVORITE_MODULES: Modules that will be added to the toolbar by default for easy access. List contains module names, separated by space character.
  • Slicer_CLIMODULES_DISABLED: Built-in CLI modules that will be removed from the application. List contains module names, separated by semicolon character.
  • Slicer_QTLOADABLEMODULES_DISABLED: Built-in Qt loadable modules that will be removed from the application. List contains module names, separated by semicolon character.
  • Slicer_QTSCRIPTEDMODULES_DISABLED: Built-in scripted loadable modules that will be removed from the application. List contains module names, separated by semicolon character.
  • Slicer_USE_PYTHONQT_WITH_OPENSSL: enable/disable building the application with SSL support (ON/OFF)
  • Slicer_USE_SimpleITK: enable/disable SimpleITK support (ON/OFF)
  • Slicer_BUILD_SimpleFilters: enable/disable building SimpleFilters. Requires SimpleITK. (ON/OFF)
  • Slicer_BUILD_EMSegment: enable/disable building EM segmenter (ON/OFF)
  • Slicer_USE_PYTHONQT_WITH_TCL: TCL support (ON/OFF)
  • Slicer_EXTENSION_SOURCE_DIRS: Defines additional extensions that will be included in the application package as built-in modules. Full paths of extension source directories has to be specified, separated by semicolons.

Per-platform instructions

Windows

Recommended: run CMake (cmake-gui) from the Windows Start menu

  • Set the build directory. Use a very short path, for example: C:\D\S4 for source code and for C:\D\S4D build directory are known to work.
    • Because Windows doesn't support file path longer than 260 characters and has a maximum command line length, it is strongly recommended to choose a build directory that is no longer than 10 characters. If a longer path is used then build may or may not succeed.
    • You cannot use the same build tree for both release or debug mode builds. If both build types are needed, then the same source directory can be used, but a separate build directory should be created and configured for each build type.
  • Select your compiler: Visual Studio 16 2019 Win64
  • Do not configure yet.
  • Add Qt5_DIR variable pointing to Qt5 folder such as C:\Qt\5.15.0\msvc2019_64\lib\cmake\Qt5: click Add entry button, set Name to Qt5_DIR, Type to PATH, and Value to the Qt5 folder.
  • Configure
  • Click generate then close cmake-gui.
  • If building in release mode:
    • Open the top-level Slicer.sln file in the build directory in Visual Studio
    • Set active configuration to Release. Visual Studio will select Debug build configuration by default when you first open the solution in the Visual Studio GUI. If you build Slicer in release mode and accidentally forget to switch the build configuration to Release then the build will fail. Note: you can avoid this manual configuration mode selection by setting CMAKE_CONFIGURATION_TYPES to Release in cmake-gui.
  • If building in debug mode:
  • Build the ALL_BUILD project

Alternative option: Configure and build using command-line or batch file

Instead of using CMake (cmake-gui), it is also possible to configure by creating a .bat file that contains command-line instructions and run this .bat file each time a Slicer needs to be re-built. The examples below assume Slicer source code is in C:\D\S4 folder and Qt-5.10 is installed in default location.

Visual Studio 2015 in Release mode:

mkdir C:\D\S4R
cd /d C:\D\S4R
"C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 16 2019 Win64" -DQt5_DIR:PATH=C:\Qt\5.15.0\msvc2019_64\lib\cmake\Qt5 C:\D\S4
"C:\Program Files\CMake\bin\cmake.exe" --build . --config Release

Visual Studio 2015 in Debug mode:

mkdir C:\D\S4D
cd /d C:\D\S4D
"C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 16 2019 Win64" -DQt5_DIR:PATH=C:\Qt\5.15.0\msvc2019_64\lib\cmake\Qt5 C:\D\S4
"C:\Program Files\CMake\bin\cmake.exe" --build . --config Debug

Visual Studio 2019 with VS2015 toolset in Release mode:

mkdir C:\D\S4R
cd /d C:\D\S4R
"C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 16 2019 Win64" -T "v140" -DQt5_DIR:PATH=C:\Qt\5.10.0\msvc2015_64\lib\cmake\Qt5 C:\D\S4
"C:\Program Files\CMake\bin\cmake.exe" --build . --config Release

Unix-like

  • Recommended:
    • Configure using the following commands. By default CMAKE_BUILD_TYPE is set to Debug.
mkdir Slicer-SuperBuild-Debug
cd Slicer-SuperBuild-Debug
cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DQt5_DIR:PATH=/path/to/Qt5.15.0/5.15.0/gcc_64/lib/cmake/Qt5 ../Slicer

where you replace /path/to/QtSDK with the real path on your machine where QtSDK is located

If using Qt from the system, do not forget to add the following CMake variable to your configuration command line:

-DSlicer_USE_SYSTEM_QT:BOOL=1
  • Remarks:
  1. Instead of cmake, you can use ccmake or cmake-gui to visually inspect and edit configure options.
  2. Using top-level directory name like Slicer-SuperBuild-Release or Slicer-SuperBuild-Debug is recommended.
  3. Step-by-step debug instuctions
  • On Mac OS X 10.9 (Mavericks) / 10.10 (Yosemite) / 10.11 (El Capitan), also set the following variables (see discussion):
Variable Description
Slicer_USE_PYTHONQT_WITH_TCL OFF
CMAKE_OSX_DEPLOYMENT_TARGET 10.9 or 10.10 or 10.11

General information

Two projects are generated by either cmake, ccmake or cmake-gui.

One of them is in the top-level bin directory Slicer-SuperBuild and the other one is in the subdirectory Slicer-build:

Slicer-SuperBuild/Slicer-build
  1. The first project in Slicer-SuperBuild manages all the external dependencies of Slicer (VTK, ITK, Python, ...). To build Slicer for the first time, run make (or build the solution file in Visual Studio) in Slicer-SuperBuild, which will update and build the external libraries and if successful will then build the subproject Slicer-build.
  2. The second project in Slicer-SuperBuild/Slicer-build is the "traditional" build directory of Slicer. After local changes in Slicer (or after an svn update on the source directory of Slicer), only running make (or building the solution file in Visual Studio) in Slicer-SuperBuild/Slicer-build is necessary (the external libraries are considered built and up to date).
  3. Warning: An significant amount of disk space is required to compile Slicer in Debug (>10GB on Windows)

Workaround for if the firewall is blocking git protocol

  • Some firewalls will block the git protocol. A possible workaround is to configure Slicer by disabling the option Slicer_USE_GIT_PROTOCOL. Then the http protocol will be used instead. Consider also reading https://github.com/commontk/CTK/issues/33