Build

Build the project

Step: Build with Visual Studio

Open the OGS.sln (in the build directory) either by double-clicking it in the file browser or opening in Visual Studio via File / Open / Project.

On the project explorer right-click on ogs or ogs-gui and choose Set as startup project. Then press F5 or click the green arrow to build and start the project.

About Visual Studio startup projects

The reason for this is that you can have only one sub-project of your Visual Studio Solution activated for debugging (e.g. by pressing F5). Per default this is the first sub-project (in the case of a CMake-generated project this is ALL_BUILD). This must be manually set to a sub-project which generates an executable (a library sub-project cannot be started). And because this setting is stored in user specific project file it cannot be set via CMake.

How to work with CMake and Visual Studio

You can work normally in Visual Studio but remember that you have to make project changes in the CMakeLists.txt-file and not inside Visual Studio. You can add a new source file within Visual Studios File menu but you have to add that file also to the CMake file. Every time you change a CMakeLists.txt and you build the project a new CMake run is automatically invoked. After that Visual Studio informs you that the project files were changed and it reloads them.

Building from the command line

You can also build from the command line:

cd build-directory
cmake --build . --config Release

Please that with Visual Studio you have to provide the --config-parameter as Visual Studio is a multi-configuration generator in CMake.

If you build with the help of a CMake preset then you can omit the --config-parameter, e.g.:

cd source-directory
cmake --build --preset msvc-release

With ninja

To build with the ninja tool on the shell go to your previously configured build directory and type ninja:

cd ../build/release
ninja

Exceeding memory consumption during compilation

By default, ninja uses maximum parallelism which may lead to a memory consumption exceeding the available memory (especially when compiling the processes).

Therefore, we recommend restricting the number of parallel compilations to be used to one per 8 GB RAM, e.g., if your machine has 16 GB RAM type ninja -j 2 for a maximum of two parallel compilations.

Another option is to build just the process you are interested in by configuring with the CMake option OGS_BUILD_PROCESSES, e.g.: cmake -DOGS_BUILD_PROCESSES=HT ..... In this case you should be able to compile with full parallelization.

Build with CMake presets

Similar to the configure presets there are build presets, e.g. in your source-directory:

cmake --build --preset release             # equivalent to running ninja above
cmake --build --preset release -j 2 -t ogs # build the ogs-target with 2 threads

See Linux-tab!

Waiting

Now the build process is running… This can take some time because maybe there are external libraries which get automatically downloaded and compiled. This step is only done once per build directory, so subsequent builds will be much faster. See this for more.

Finished

Congratulations you have finished the Getting Started-section!

Have a look at the other sections of this guide. Check out Development Workflows if you are interested in actively contributing to the project. The Configuration Options-page shows you all available build customizations. Go ahead!


This article was written by Lars Bilke. If you are missing something or you find an error please let us know.
Generated with Hugo 0.122.0 in CI job 418530 | Last revision: February 1, 2024
Commit: [cmake] Set runtime parameter on larger benchmarks. 86f23e2  | Edit this page on