Skip to content

Commit bc88792

Browse files
Merge pull request #725 from PowerGridModel/fix/build-guide
Renew build guide
2 parents 3912591 + 64ed0bc commit bc88792

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

docs/advanced_documentation/build-guide.md

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ repository there are three builds:
1111

1212
* A `power-grid-model` [pip](https://pypi.org/project/power-grid-model/) Python package with C++ extension as the calculation core.
1313
* A [CMake](https://cmake.org/) project consisting of the C++ header-only calculation core, and the following build targets:
14-
* A dynamic library (`.dll` or `.so`) with stable pure C API/ABI which can be used by any application
14+
* A dynamic library (`.dll` or `.so`) with stable pure C API/ABI which can be used by any application (enabled by default)
15+
* An install target that installs the package containing the dynamic library (enabled by default)
1516
* Native C++ unit tests
1617
* C API tests
1718
* A performance benchmark program
1819
* An example C program to call the shared library
19-
* An install target that installs a package that contains the dynamic library
2020
* A separate example [CMake](https://cmake.org/) project with a small C++ program that shows how to find and use the installable
2121
package.
2222

@@ -65,7 +65,7 @@ You can define the environment variable `CXX` to for example `clang++` to specif
6565

6666
### Build System for CMake Project
6767

68-
This repository uses [CMake](https://cmake.org/) (version 3.23 or later) and [Ninja](https://ninja-build.org/) as C++ build system.
68+
This repository uses [CMake](https://cmake.org/) (version 3.23 or later) as C++ build system.
6969

7070
### Build Dependencies
7171

@@ -97,43 +97,57 @@ The table below shows the Python dependencies
9797
## Build Python Package
9898

9999
Once you have prepared the build dependencies,
100-
you can install the library from source in develop mode with the development dependency.
100+
you can install the library from source in editable mode with the development dependency.
101101
Go to the root folder of the repository.
102102

103-
```
103+
```shell
104104
pip install -e .[dev]
105105
```
106106

107107
Then you can run the tests.
108108

109-
```
109+
```shell
110110
pytest
111111
```
112112

113113
A basic `self_test` function is provided to check if the installation was successful and ensures there are no build errors, segmentation violations, undefined symbols, etc. It performs multiple C API calls, runs through the main data flow, and verifies the integrity of serialization and deserialization.
114114

115-
```
115+
```python
116116
from power_grid_model.utils import self_test
117117
self_test()
118118
```
119119

120120
## Build CMake Project
121121

122-
There is a root cmake file in the root folder of the repo `CMakeLists.txt`. It specifies
123-
dependencies and the build options for the project. The core algorithm is implemented in the header-only
124-
library `power_grid_model`. There are four sub-projects defined in the root cmake file:
122+
### User build
123+
124+
If you are a C-API user of the library, you can build the CMake using all the default settings.
125+
You can specifiy a standard [CMAKE_BUILD_TYPE](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html).
126+
This will only build the core C-API dynamic library.
127+
128+
```shell
129+
cmake -DCMAKE_BUILD_TYPE=Release -B build
130+
cmake --build build --config Release
131+
```
132+
133+
### Developer build
134+
135+
If you opt for a developer build of Power Grid Model,
136+
you can use the pre-defined CMake presets to enable developer build, including all the tests, warnings, examples, and benchmark. In the presets the [Ninja](https://ninja-build.org/) generator is used.
137+
In principle, you can use any C++ IDE with cmake and ninja support to develop the C++ project.
138+
It is also possible to use the bare CMake CLI to set up the project.
139+
Supported presets for your development platform can be listed using `cmake --list-presets`.
140+
141+
In the developer build the following build targets (directories) are enabled:
125142

126143
* `power_grid_model_c`: a dynamic library (`.dll` or `.so`) with stable pure C API/ABI which can be used by any application
127144
* `tests/cpp_unit_tests`: the unit test target for the C++ core using the `doctest` framework.
128145
* `tests/cpp_integration_tests`: the integration test target for the C++ core using the `doctest` framework.
129146
* `tests/cpp_validation_tests`: the validation test target using the `doctest` framework
130-
* `tests/c_api_tests`: the C API test target using the `doctest` framework
147+
* `tests/native_api_tests`: the C API test target using the `doctest` framework
131148
* `tests/benchmark_cpp`: the C++ benchmark target for performance measure.
132149
* `power_grid_model_c_example`: an example C program to call the dynamic library
133150

134-
In principle, you can use any C++ IDE with cmake and ninja support to develop the C++ project. It is also possible to use
135-
the bare CMake CLI to set up the project. For ease of use, several presets are available (CMake 3.23+). Supported presets
136-
for your development platform can be listed using `cmake --list-presets`.
137151

138152
On Linux/macOS, the presets will use command `clang`/`clang++` or `gcc`/`g++` to find the relevant `clang` or `gcc` compiler. It is the developer's reponsiblity to properly define symbolic links (which should be discoverable through `PATH` environment variable) of `clang` or `gcc` compiler in your system. If you want to build with `clang-tidy`, you also need to define symbolic link of `clang-tidy` to point to the actual `clang-tidy` executable of your system.
139153

0 commit comments

Comments
 (0)