Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create CMake preset #44

Merged
merged 9 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ on:
- cron: '30 15 * * *'

jobs:
preset-test:
runs-on: ubuntu-latest
strategy:
matrix:
preset: ["gcc-debug", "gcc-release"]
steps:
- uses: actions/checkout@v4
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.25.x'
- uses: seanmiddleditch/gha-setup-ninja@v5
- name: Run preset
run: cmake --workflow --preset ${{ matrix.preset }}

test:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -72,7 +87,7 @@ jobs:

create-issue-when-fault:
runs-on: ubuntu-latest
needs: [test]
needs: [preset-test, test]
if: failure() && github.event_name == 'schedule'
steps:
# See https://github.com/cli/cli/issues/5075
Expand Down
121 changes: 121 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"version": 6,
"configurePresets": [
{
"name": "_root-config",
"hidden": true,
"generator": "Ninja",
wusatosi marked this conversation as resolved.
Show resolved Hide resolved
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_CXX_STANDARD": "20"
}
},
{
"name": "_debug-base",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_FLAGS": "-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=leak -fsanitize=undefined"
}
},
{
"name": "_release-base",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_CXX_FLAGS": "-O3"
}
},
{
"name": "gcc-debug",
"displayName": "GCC Debug Build",
"inherits": [
"_root-config",
"_debug-base"
],
"cacheVariables": {
"CMAKE_CXX_COMPILER": "g++"
}
},
{
"name": "gcc-release",
"displayName": "GCC Release Build",
"inherits": [
"_root-config",
"_release-base"
],
"cacheVariables": {
"CMAKE_CXX_COMPILER": "g++"
}
}
],
"buildPresets": [
{
"name": "gcc-debug",
"configurePreset": "gcc-debug"
},
{
"name": "gcc-release",
"configurePreset": "gcc-release"
}
],
"testPresets": [
{
"name": "_test_base",
"hidden": true,
"output": {
"outputOnFailure": true
},
"execution": {
"noTestsAction": "error",
"stopOnFailure": true
}
},
{
"name": "gcc-debug",
"inherits": "_test_base",
"configurePreset": "gcc-debug"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR, but it just occurred to me that we might leverage the ninja-multiconfig generator to keep the list of configurePresets small? That is have one that configures Debug, Release, and possibly various sanitizer flavors? This might help keep the combinatorics down.

},
{
"name": "gcc-release",
"inherits": "_test_base",
"configurePreset": "gcc-release"
}
],
"workflowPresets": [
{
"name": "gcc-debug",
"steps": [
{
"type": "configure",
"name": "gcc-debug"
},
{
"type": "build",
"name": "gcc-debug"
},
{
"type": "test",
"name": "gcc-debug"
}
]
},
{
"name": "gcc-release",
"steps": [
{
"type": "configure",
"name": "gcc-release"
},
{
"type": "build",
"name": "gcc-release"
},
{
"type": "test",
"name": "gcc-release"
}
]
}
]
}
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ apt-get install \
This project strives to be as normal and simple a CMake project as possible. This build workflow in particular will work, producing a static `libbeman.exemplar.a` library, ready to package with its headers:

```shell
cmake -B build -S . -DCMAKE_CXX_STANDARD=20
cmake --build build
ctest --test-dir build
cmake --workflow --preset gcc-debug
cmake --install build --prefix /opt/beman.exemplar
wusatosi marked this conversation as resolved.
Show resolved Hide resolved
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the "verbose logs" sections below need to be updated as well.

On the other hand, I'd be happier to see them removed entirely. I've used beman.exemplar for a few different projects now and it's a pain to have to update those sections.

The "Disable tests build" section also needs to be updated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for double checking! Sorry I missed those sections. I will have them updated later today. !!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated cmake command and output in 8430517 .

Expand Down