You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/advanced_documentation/build-guide.md
+28-14Lines changed: 28 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,12 +11,12 @@ repository there are three builds:
11
11
12
12
* A `power-grid-model`[pip](https://pypi.org/project/power-grid-model/) Python package with C++ extension as the calculation core.
13
13
* 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)
15
16
* Native C++ unit tests
16
17
* C API tests
17
18
* A performance benchmark program
18
19
* An example C program to call the shared library
19
-
* An install target that installs a package that contains the dynamic library
20
20
* A separate example [CMake](https://cmake.org/) project with a small C++ program that shows how to find and use the installable
21
21
package.
22
22
@@ -65,7 +65,7 @@ You can define the environment variable `CXX` to for example `clang++` to specif
65
65
66
66
### Build System for CMake Project
67
67
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.
69
69
70
70
### Build Dependencies
71
71
@@ -97,43 +97,57 @@ The table below shows the Python dependencies
97
97
## Build Python Package
98
98
99
99
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.
101
101
Go to the root folder of the repository.
102
102
103
-
```
103
+
```shell
104
104
pip install -e .[dev]
105
105
```
106
106
107
107
Then you can run the tests.
108
108
109
-
```
109
+
```shell
110
110
pytest
111
111
```
112
112
113
113
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.
114
114
115
-
```
115
+
```python
116
116
from power_grid_model.utils import self_test
117
117
self_test()
118
118
```
119
119
120
120
## Build CMake Project
121
121
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:
125
142
126
143
*`power_grid_model_c`: a dynamic library (`.dll` or `.so`) with stable pure C API/ABI which can be used by any application
127
144
*`tests/cpp_unit_tests`: the unit test target for the C++ core using the `doctest` framework.
128
145
*`tests/cpp_integration_tests`: the integration test target for the C++ core using the `doctest` framework.
129
146
*`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
131
148
*`tests/benchmark_cpp`: the C++ benchmark target for performance measure.
132
149
*`power_grid_model_c_example`: an example C program to call the dynamic library
133
150
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`.
137
151
138
152
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.
0 commit comments