|
| 1 | +# ------------------------- |
| 2 | +# Config |
| 3 | +# ------------------------- |
| 4 | +# Override on the CLI like: just BUILD_TYPE=Release build |
| 5 | +BUILD_DIR := "cmake-build" |
| 6 | +BUILD_TYPE := "Release" # Debug | Release | RelWithDebInfo | MinSizeRel |
| 7 | +GENERATOR := "" # e.g., -G Ninja |
| 8 | +CMAKE_FLAGS := "-DCMAKE_BUILD_TYPE={{BUILD_TYPE}} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON" |
| 9 | + |
| 10 | +# If you set an install prefix, uncomment the next line (useful for pybind11 modules): |
| 11 | +# INSTALL_PREFIX ?= "{{pwd()}}/.local" |
| 12 | +# INSTALL_FLAG := "-DCMAKE_INSTALL_PREFIX={{INSTALL_PREFIX}}" |
| 13 | + |
| 14 | +# ------------------------- |
| 15 | +# Default |
| 16 | +# ------------------------- |
| 17 | +default: configure build test |
| 18 | + |
| 19 | +# ------------------------- |
| 20 | +# CMake lifecycle |
| 21 | +# ------------------------- |
| 22 | +configure: |
| 23 | + cmake -S . -B {{BUILD_DIR}} {{GENERATOR}} {{CMAKE_FLAGS}} |
| 24 | + |
| 25 | +build: configure |
| 26 | + cmake --build {{BUILD_DIR}} -j |
| 27 | + |
| 28 | +install: build |
| 29 | + cmake --install {{BUILD_DIR}} |
| 30 | + |
| 31 | +test: build |
| 32 | + ctest --test-dir {{BUILD_DIR}} --output-on-failure |
| 33 | + |
| 34 | +clean: |
| 35 | + rm -rf {{BUILD_DIR}} |
| 36 | + |
| 37 | +# ------------------------- |
| 38 | +# Run binaries (examples) |
| 39 | +# ------------------------- |
| 40 | +# Add more run-* recipes as we add crates |
| 41 | +run-kalman: |
| 42 | + {{BUILD_DIR}}/crates/kf_linear/kf_demo |
| 43 | + |
| 44 | +# ------------------------- |
| 45 | +# Linting & formatting |
| 46 | +# ------------------------- |
| 47 | +lint: build |
| 48 | + clang-tidy crates/*/src/*.cpp -p {{BUILD_DIR}} -- -std=c++17 |
| 49 | + |
| 50 | +fmt: |
| 51 | + find crates -type f \( -name '*.cpp' -o -name '*.hpp' \) -exec clang-format -i {} + |
| 52 | + |
| 53 | +fmt-check: |
| 54 | + find crates -type f \( -name '*.cpp' -o -name '*.hpp' \) -exec clang-format --dry-run --Werror {} + |
| 55 | + |
0 commit comments