- Author(s) of this documentation:
- David Coeurjolly - Martial Tola
This part of the manual describes how to build DGtal on Linux, Mac OS X and Windows.
Introduction and first build
The DGtal library uses cmake to manage the project build on various systems.
To build DGtal in is minimal configuration, you need at least these dependencies:
- c++ compiler (g++, clang++, ...) with C++20 features
- [cmake](http://cmake.org) (>3.20, optionally cmake-gui),
- zlib (already available in most OS)
To build DGtal in is full configuration, you may need these dependencies too:
If you want to generate the documentation, you would need:
- doxygen >= 1.8.0,
- graphviz.
- Note
- Since 1.4, some dependencies could be installed using conan.io. Just install the conan 2 binary and cmake will install all libraries (which may take some time for the first build). For instance:
conan profile detect --force ##Conan profile
cd build
conan install .. --build=missing -s:a compiler.cppstd=20
cmake .. -G "Visual Studio 15 2017" -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" -DCMAKE_POLICY_DEFAULT_CMP0091=NEW
Build on Linux-based distributions
To build DGtal from the source archive, we use the CMake tool to generate a Makefile or a project file for various IDE (KDevelop, Xcode, Codeblock...). In most linux distributions, all mandatory and optional dependencies are available as packages (debian, ubuntu, ...). Please refer to your package manager to find the appropriate package name and versions.
An important feature of cmake is the "out-of-source" build process. Let us suppose that DGtal sources are in the DGTALSOURCES folder. Hence, in a terminal you can create a build folder:
cd DGTALSOURCES
mkdir build
cd build
Next, use the cmake command to generate your Unix Makefile project (default generator on Unix/Linux) like below for the minimal DGtal configuration:
Many options can be specified to add functionnalities or control the build of DGtal. A full list is available below. As an example, you can activate the use of 3D viewer and parallelization by adding the following options:
cmake .. -DDGTAL_WITH_POLYSCOPE_VIEWER=
ON -DDGTAL_WITH_OPENMP=
ON
If no error occurs, you can build the DGtal lib and install it:
Build on Mac OS X
Then, since recent Mac OS systems are unix-like operating systems, the easiest way to compile DGtal with cmake/make is to follow Linux-based instructions from source code archive.
Build on Windows / Visual Studio
DGtal core library compiles on Windows using Visual Studio 2015 or newer (note that building DGtal on cygwin or MinGW environments is trivial using linux based build). Since DGtal requires C++11 features since release 0.9.1, compiling the library with older Visual Studio compilers is not supported.
To generate the Visual Studio project, use the cmake (or cmake-gui) tools with recent Visual Studio target. During the project generation, you would have to specify the path to boost headers (or paths needed for any optional dependency such as CGAL, Cairo...).
- Note
- Do not forget to set DGTAL_BUILD_SHARED_LIBS cmake to false (static DGtal lib target, default).
- Advanced:
- When working on DGtal within github, we have set up a Windows container for continuous integration.
Main DGtal cmake options
In DGtal CMakeLists.txt, several options can be specified to custom the library build. First, cmake has predefined build options (CMAKE_BUILD_TYPE) such as:
- CMAKE_BUILD_TYPE
- Debug: debug mode (e.g. C++ debug flags, DEBUG variable, ...)
- Release: release build (e.g. optimized C++ compiler options, NDEBUG variable, ...)
- CMAKE_INSTALL_PREFIX: a string containing the DGtal install path (e.g. by default on some linux: "/usr/local/").
Beside these options, user can also specify these options:
- DGTAL_BUILD_EXAMPLES (ON/OFF): to build DGtal examples (default: OFF)
- DGTAL_BUILD_TESTS (ON/OFF): to build the test suite (default: OFF)
- VERBOSE (ON/OFF): to define the VERBOSE variable (default: OFF). If set to ON, verbose messages are traced out.
- DEBUG_VERBOSE (ON/OFF): to define the DEBUG_VERBOSE variable (default: OFF). If set to ON, verbose debug messages are traced out.
- DGTAL_BUILD_SHARED_LIBS (ON/OFF): to build the lib as a shared library (default: OFF) but must be OFF actually on Windows
DGtal Optionnal Dependencies
When building DGtal only mandatory dependencies are fetched and setup. However, some functionnalities may require additionnal dependencies as specified in their documentation. We list here options to build DGtal accordingly:
- DGTAL_WITH_OPENMP (ON/OFF): build DGtal with openmp (requires compiler supports)
- DGTAL_WITH_CGAL (ON/OFF): links DGtal with CGAL library (requires manual installation)
- DGTAL_WITH_ITK (ON/OFF): links DGtal with ITK library (requires manual installation)
- DGTAL_WITH_CAIRO (ON/OFF): links DGtal with cairo library (requires manual installation))
- DGTAL_WITH_HDF5 (ON/OFF): links DGtal with HDF5 library (requires manual installation)
- DGTAL_WITH_POLYSCOPE_VIEWER (ON/OFF): links DGtal with polyscope library (fetched automatically).
- DGTAL_WITH_PONCA (ON/OFF): links DGtal with Ponca library (fetched automatically).
- DGTAL_WITH_FFTW3 (ON/OFF): links DGtal with FFTW (requires manual installation)
- DGTAL_WITH_LIBIGL (ON/OFF): links DGtal with libigl (fetched automatically)