chore(cmake): add CMake presets (#5655)

* chore(cmake): add CMake presets

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* Update .github/workflows/ci.yml

* fix: don't autodetect `.venv` if inside a VIRTUALENV already

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* Update CMakeLists.txt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Henry Schreiner
2025-05-14 01:29:24 -04:00
committed by GitHub
parent 853bafa0a2
commit 05a6a03e7d
4 changed files with 149 additions and 32 deletions

View File

@@ -220,25 +220,20 @@ jobs:
with:
fetch-depth: 0
- name: Prepare venv
run: python3.13t -m venv .venv
- name: Prepare uv's path
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install Python deps
run: .venv/bin/pip install -r tests/requirements.txt
- name: Install ninja
run: uv tool install ninja
- name: Configure C++11
run: >
cmake -S. -Bbuild
-DPYBIND11_WERROR=ON
-DDOWNLOAD_CATCH=ON
-DDOWNLOAD_EIGEN=ON
-DPython_ROOT_DIR=.venv
- name: Configure via preset
run: cmake --preset venv -DPYBIND11_CREATE_WITH_UV=python3.13t
- name: Build C++11
run: cmake --build build -j2
run: cmake --build --preset venv
- name: Python tests C++11
run: cmake --build build --target pytest -j2
run: cmake --build --preset testsvenv -t pytest
deadsnakes:
strategy:
@@ -292,33 +287,27 @@ jobs:
run: |
sudo make install
sudo apt-get update
sudo apt-get install libc6-dbg # Needed by Valgrind
sudo apt-get install ninja-build libc6-dbg
- name: Prepare env
run: |
python -m pip install -r tests/requirements.txt
- name: Configure
run: >
cmake -S . -B build
-DCMAKE_BUILD_TYPE=Debug
-DPYBIND11_WERROR=ON
-DDOWNLOAD_CATCH=ON
-DDOWNLOAD_EIGEN=ON
-DCMAKE_CXX_STANDARD=17
run: cmake --preset default -DCMAKE_CXX_STANDARD=17
- name: Build
run: cmake --build build -j 2
run: cmake --build --preset default
- name: Python tests
run: cmake --build build --target pytest
run: cmake --build --preset default --target pytest
- name: C++ tests
run: cmake --build build --target cpptest
run: cmake --build --preset default --target cpptest
- name: Run Valgrind on Python tests
if: matrix.valgrind
run: cmake --build build --target memcheck
run: cmake --build --preset default --target memcheck
# Testing on clang using the excellent silkeh clang docker images