Skip to content

Add CMake Presets#3805

Open
med-ayssar wants to merge 1 commit into
nest:mainfrom
med-ayssar:add-cmake-presets
Open

Add CMake Presets#3805
med-ayssar wants to merge 1 commit into
nest:mainfrom
med-ayssar:add-cmake-presets

Conversation

@med-ayssar
Copy link
Copy Markdown
Contributor

@med-ayssar med-ayssar commented Apr 16, 2026

NEST has no CMakePresets.json, forcing every developer to manually remember and type the same long -D flag chains every time they configure a build. This adds friction for new contributors and makes it easy to misconfigure.

This PR adds CMakePresets.json with 7 presets covering the most common build scenarios (default, debug, release, mpi, mpi-debug, minimal, docs), so developers can replace verbose cmake -Dwith-mpi=ON -Dwith-optimize=ON ... invocations with a single cmake --preset <name>.

CMake Presets

Preset Description Key flags
default Standard dev build -O2, OpenMP, Python, GSL, Boost
debug Debug build -g, no optimization
release Optimized release -O3
mpi MPI + OpenMP -O2, MPI enabled
mpi-debug MPI debug -g, MPI enabled
minimal No optional deps No Python/MPI/Boost/GSL
docs With user docs Requires Sphinx + Pandoc

Each preset puts its binary dir under build/<preset-name>/ to avoid conflicts.

List all presets

cmake --list-presets

Configure

cmake --preset default
cmake --preset debug
cmake --preset release
cmake --preset mpi
cmake --preset mpi-debug
cmake --preset minimal
cmake --preset docs

Build

cmake --build --preset default
cmake --build --preset debug

Install

cmake --build --preset default --target install

Note: you need to run the configure stage first, so that it creates the buildDir!

Example

cmake --preset debug
cd build/debug
make install -j7

@med-ayssar
Copy link
Copy Markdown
Contributor Author

@heplesser, @terhorstd and @gtrensch: could you maybe give it a try and approve it if you see it fit.

@gtrensch gtrensch added S: Normal Handle this with default priority T: Maintenance Work to keep up the quality of the code and documentation. I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) labels Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: Normal Handle this with default priority T: Maintenance Work to keep up the quality of the code and documentation.

Projects

Status: To do
Status: To do

Development

Successfully merging this pull request may close these issues.

2 participants