Skip to content

Commit

Permalink
Add CMakePresets.json
Browse files Browse the repository at this point in the history
  • Loading branch information
mlund committed Jul 23, 2024
1 parent e50b196 commit 019252d
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .clangd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CompileFlags:
CompilationDatabase: "build/"
CompilationDatabase: "build/debug"

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ sids/
docs/html/
unittests.log
a.out
.clangd
.zed/settings.json

# VisualStudioCode
.vscode/settings.json
Expand Down Expand Up @@ -113,6 +115,7 @@ out.cereal

# CMake
cmake-build-*/
build/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml
Expand Down
66 changes: 66 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 24,
"patch": 0
},
"configurePresets": [
{
"name": "config-base",
"hidden": true,
"displayName": "Base Configuration",
"description": "Default build using unix makefile generator",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "on"
}
},
{
"name": "debug",
"displayName": "Config Debug",
"description": "Sets debug build type",
"inherits": "config-base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"ENABLE_PYTHON": "off",
"ENABLE_CACHE": "off"
}
},
{
"name": "relwithdebinfo",
"displayName": "Config Release with Debug Info",
"description": "Sets release with debug info build type",
"inherits": "debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "release",
"displayName": "Config Release",
"description": "Sets release build type",
"inherits": "debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
],
"buildPresets": [
{
"name": "faunus-debug",
"displayName": "Faunus Debug Build",
"configurePreset": "debug",
"configuration": "Debug",
"targets": ["faunus"]
},
{
"name": "faunus-release",
"displayName": "Faunus Release Build",
"configurePreset": "release",
"configuration": "Release",
"targets": ["faunus"]
}
]
}
15 changes: 10 additions & 5 deletions docs/_docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ make clean
rm -fR CMakeCache.txt CMakeFiles _deps
~~~

### CMake Presets

CMake presets are provided and can be used e.g. like this:
~~~ bash
cmake --preset debug # populates build/debug/
cmake --build --preset faunus-debug
~~~

### Intel Threading Building Blocks (TBB)

To use C++ parallel algorithms, some compilers require linkage with TBB.
Expand Down Expand Up @@ -189,12 +197,9 @@ code .
## Clangd

For editors with `clangd` support, we provide a `.clangd` configuration file.
This looks for a CMake generated `build` path that should contain
This looks for a CMake generated `build/debug` path that should contain
`compile_commands.json`.
If you use a custom build directory, simply create a symlink called `build`
in the project root.
If your build directory doesn't contain `compile_commands.json`, you can create
one with the CMake argument `-DCMAKE_EXPORT_COMPILE_COMMANDS=on`.
Use `cmake . --preset debug` to generate.

## Code Style

Expand Down

0 comments on commit 019252d

Please sign in to comment.