Building Metrix simulator

This page will get you through the building of the executable metrix-simulator for your preferred operating system.

Requirements

To build metrix-simulator, you need:

  • A C++ compiler that supports C++11 (clang 3.3 or higher, g++ 5.0 or higher)

  • CMake (3.12 or higher)

  • Make

  • Boost development packages (1.66 or higher)

Use the following commands to install them on your OS:

Ubuntu 20.04 and later

$> apt install -y cmake g++ git libboost-all-dev libxml2-dev make

Ubuntu 18.04

$> apt install -y g++ git libboost-all-dev libxml2-dev make wget

Note: Under Ubuntu 18.04, the default CMake package is too old (3.10), so you have to install it manually:

$> wget https://cmake.org/files/v3.12/cmake-3.12.0-Linux-x86_64.tar.gz
$> tar xzf cmake-3.12.0-Linux-x86_64.tar.gz
$> export PATH=$PWD/cmake-3.12.0-Linux-x86_64/bin:$PATH

CentOS 8

$> yum install -y boost-devel gcc-c++ git libxml2-devel make wget

Note: Under CentOS 8, the default CMake package is too old (3.11.4), so you have to install it manually:

$> wget https://cmake.org/files/v3.12/cmake-3.12.0-Linux-x86_64.tar.gz
$> tar xzf cmake-3.12.0-Linux-x86_64.tar.gz
$> export PATH=$PWD/cmake-3.12.0-Linux-x86_64/bin:$PATH

Build sources

Next, you can build the executable from the sources

1. Clone the project

$> git clone https://github.com/powsybl/powsybl-metrix.git
$> cd powsybl-metrix/metrix-simulator

2. Build the third parties

$> mkdir build
$> mkdir build/external
$> cd build/external
$> cmake ../../external -DCMAKE_BUILD_TYPE=<BUILD_TYPE_3PARTIES>
$> cmake --build .

3. Build the project executable

$> cd ..
$> cmake .. -DCMAKE_INSTALL_PREFIX=<PREFIX> -DCMAKE_BUILD_TYPE=<BUILD_TYPE>
$> cmake --build . --target install

The following CMAKE options can be set for the executable configuration:

  • USE_SIRIUS_SHARED (default = OFF): If active, the project will link using the shared library of sirius solver instead of the static library

  • METRIX_RUN_ALL_TESTS (default = ON): If inactive, the project will execute a reduced scope of tests

Extras

Checkstyle

This project uses clang-tidy to verify the code style. This tool is provided with the clang extra tools. To enable the code style checking, add the -DCMAKE_CXX_CLANG_TIDY=clang-tidy flag to the configure command.

A clang-format file is also provided to format the code by using clang-format. Most IDEs have an option to format files using clang-format automatically.

Code coverage

This project uses either gcov or llvm-cov to compute the code coverage. We also use gcovr (4.2 or higher) to generate both sonar and HTML reports. To compute the code coverage, add the -DCODE_COVERAGE=TRUE flag to the configure command.