Build from source#

Please install the build dependencies you want to compile DLite against before compiling from source.

The source code can be cloned from GitHub

git clone https://github.com/SINTEF/DLite.git

Please see the separate instructions if you want to build with Visual Studio.

Configuration#

DLite uses CMake as build system and supports many platforms. Create a build directory and configure CMake

mkdir build
cd build
cmake [CONFIG_OPTIONS] ..

where [CONFIG_OPTIONS] are CMake configuration options. Configuring CMake is normally done with the -D CMake option to specify configuration variables.

For example, to build against Python 3.10 with HDF5 support, configure with

cmake -DWITH_PYTHON=YES -DPYTHON_VERSION=3.10 -DWITH_HDF5=YES ..

Please refer to the CMake documentation for more options.

Configure for Python environment#

See build against Python environment for how to configure against a Python virtualenv.

Build & install#

After configuring cmake, DLite can be built and installed with:

cmake --build .
cmake --install .

Testing#

To test DLite, install the test dependencies and run:

ctest

If you have valgrind installed, you can run the tests with memory checking turned on:

cmake --build . --target memcheck

For more info about checking and debugging memory issues, see Memory debugging.

Build documentation#

In order to reduce build dependencies for the causal user, DLite does not build documentation by default. Provide the -DWITH_DOC=YES option to cmake to build the documentation.

DLite uses Sphinx to generate documentation from Python source code. Ensure the correct virtual environment is set up and install the requirements

pip install -r requirements_doc.txt

If you have Doxygen installed, the HTML documentation of the C API should be generated as a part of the build process. It can be browsed by opening the following file in your browser:

<build>/doc/html/index.html

where <build> is your build folder.

To only build the documentation, you can do:

cd build
cmake --build . --target doc

If you have LaTeX and make installed, you can also the latex documentation with

cd build
cmake --build . --target latex

which will produce the file

<build>/doc/latex/refman.pdf

Quick start with Visual Studio Code and Docker#

Using Visual Studio Code (VS Code) it is possible to do development on the system defined in Dockerfile.

  1. Download and install Visual Studio Code.

  2. Install the extension Remote Development.

  3. Clone DLite

  4. Open the DLite folder with VS Code.

  5. Start VS Code, run the Remote-Containers: Open Folder in Container… command from the Command Palette (F1) or quick actions Status bar item. This will build the container and restart VS Code in it. This may take some time the first time as the Docker image must be built. See Quick start: Open an existing folder in a container for more information and instructions.

  6. In the container terminal, perform the first build and tests with

    mkdir /workspace/build
    cd /workspace/build
    cmake ../DLite
    cmake --build .
    ctest