feat: Introduce warning suppression option and update CMake presets

- Added YAZE_SUPPRESS_WARNINGS option to suppress compiler warnings for cleaner build output.
- Updated CMakeLists.txt to apply warning suppression based on the new option.
- Reorganized CMakePresets.json to simplify preset names and enhance clarity, including new presets for quiet and verbose builds.
- Created documentation for the new CMake preset system, detailing usage and features.
This commit is contained in:
scawful
2025-10-04 21:53:51 -04:00
parent a057d0707a
commit a3c756272d
4 changed files with 572 additions and 523 deletions

View File

@@ -79,6 +79,9 @@ option(YAZE_WITH_JSON "Enable JSON support for AI integrations" ON)
# YAZE_WITH_GRPC: gRPC for GUI automation (auto-enables JSON) # YAZE_WITH_GRPC: gRPC for GUI automation (auto-enables JSON)
option(YAZE_WITH_GRPC "Enable gRPC-based ImGuiTestHarness for automated GUI testing (experimental)" OFF) option(YAZE_WITH_GRPC "Enable gRPC-based ImGuiTestHarness for automated GUI testing (experimental)" OFF)
# YAZE_SUPPRESS_WARNINGS: Suppress compiler warnings for cleaner build output
option(YAZE_SUPPRESS_WARNINGS "Suppress compiler warnings (use -v preset suffix for verbose)" ON)
# Dependency resolution # Dependency resolution
if(Z3ED_AI) if(Z3ED_AI)
message(STATUS "Z3ED_AI enabled: Activating AI agent dependencies (JSON, YAML, httplib)") message(STATUS "Z3ED_AI enabled: Activating AI agent dependencies (JSON, YAML, httplib)")
@@ -107,6 +110,18 @@ set(YAZE_TEST_ROM_PATH "${CMAKE_BINARY_DIR}/bin/zelda3.sfc" CACHE STRING "Path t
set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
# Apply warning suppression if requested
if(YAZE_SUPPRESS_WARNINGS)
if(MSVC)
add_compile_options(/w)
else()
add_compile_options(-w)
endif()
message(STATUS "✓ Warnings suppressed (use -v preset suffix for verbose builds)")
else()
message(STATUS "○ Verbose warnings enabled")
endif()
set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD_REQUIRED ON)

File diff suppressed because it is too large Load Diff

207
docs/CMAKE_PRESETS.md Normal file
View File

@@ -0,0 +1,207 @@
# CMake Presets Quick Reference
This document explains the reorganized CMake preset system for Yaze.
## Design Principles
1. **Short, memorable names** - No more `macos-dev-z3ed-ai`, just `mac-ai`
2. **Warnings off by default** - Add `-v` suffix for verbose (e.g., `mac-dbg-v`)
3. **Clear architecture support** - Explicit ARM64 and x86_64 presets
4. **Platform prefixes** - `mac-`, `win-`, `lin-` for easy identification
## Quick Start
### macOS Development
```bash
# Most common: AI-enabled development
cmake --preset mac-ai
cmake --build --preset mac-ai
# Basic debug build (no AI)
cmake --preset mac-dbg
cmake --build --preset mac-dbg
# Verbose warnings for debugging
cmake --preset mac-dbg-v
cmake --build --preset mac-dbg-v
# Release build
cmake --preset mac-rel
cmake --build --preset mac-rel
```
### Windows Development
```bash
# Debug build (x64)
cmake --preset win-dbg
cmake --build --preset win-dbg
# AI-enabled development
cmake --preset win-ai
cmake --build --preset win-ai
# ARM64 support
cmake --preset win-arm
cmake --build --preset win-arm
```
## All Presets
### macOS Presets
| Preset | Description | Arch | Warnings | Features |
|--------|-------------|------|----------|----------|
| `mac-dbg` | Debug build | ARM64 | Off | Basic |
| `mac-dbg-v` | Debug verbose | ARM64 | On | Basic |
| `mac-rel` | Release | ARM64 | Off | Basic |
| `mac-x64` | Debug x86_64 | x86_64 | Off | Basic |
| `mac-uni` | Universal binary | Both | Off | Basic |
| `mac-dev` | Development | ARM64 | Off | ROM tests |
| `mac-ai` | AI development | ARM64 | Off | z3ed, JSON, gRPC, ROM tests |
| `mac-z3ed` | z3ed CLI | ARM64 | Off | AI agent support |
| `mac-rooms` | Dungeon editor | ARM64 | Off | Minimal build for room editing |
### Windows Presets
| Preset | Description | Arch | Warnings | Features |
|--------|-------------|------|----------|----------|
| `win-dbg` | Debug build | x64 | Off | Basic |
| `win-dbg-v` | Debug verbose | x64 | On | Basic |
| `win-rel` | Release | x64 | Off | Basic |
| `win-arm` | Debug ARM64 | ARM64 | Off | Basic |
| `win-arm-rel` | Release ARM64 | ARM64 | Off | Basic |
| `win-dev` | Development | x64 | Off | ROM tests |
| `win-ai` | AI development | x64 | Off | z3ed, JSON, gRPC, ROM tests |
| `win-z3ed` | z3ed CLI | x64 | Off | AI agent support |
### Linux Presets
| Preset | Description | Compiler | Warnings |
|--------|-------------|----------|----------|
| `lin-dbg` | Debug | GCC | Off |
| `lin-clang` | Debug | Clang | Off |
### Special Purpose
| Preset | Description |
|--------|-------------|
| `ci` | Continuous integration (no ROM tests) |
| `asan` | AddressSanitizer build |
| `coverage` | Code coverage build |
## Warning Control
By default, all presets suppress compiler warnings with `-w` for a cleaner build experience.
### To Enable Verbose Warnings:
1. Use a preset with `-v` suffix (e.g., `mac-dbg-v`, `win-dbg-v`)
2. Or set `YAZE_SUPPRESS_WARNINGS=OFF` manually:
```bash
cmake --preset mac-dbg -DYAZE_SUPPRESS_WARNINGS=OFF
```
## Architecture Support
### macOS
- **ARM64 (Apple Silicon)**: `mac-dbg`, `mac-rel`, `mac-ai`, etc.
- **x86_64 (Intel)**: `mac-x64`
- **Universal Binary**: `mac-uni` (both ARM64 + x86_64)
### Windows
- **x64**: `win-dbg`, `win-rel`, `win-ai`, etc.
- **ARM64**: `win-arm`, `win-arm-rel`
## Build Directories
Most presets use `build/` directory. Exceptions:
- `mac-rooms`: Uses `build_rooms/` to avoid conflicts
## Feature Flags
Common CMake options you can override:
```bash
# Enable/disable components
-DYAZE_BUILD_TESTS=ON/OFF
-DYAZE_BUILD_Z3ED=ON/OFF
-DYAZE_BUILD_EMU=ON/OFF
-DYAZE_BUILD_APP=ON/OFF
# AI features
-DZ3ED_AI=ON/OFF
-DYAZE_WITH_JSON=ON/OFF
-DYAZE_WITH_GRPC=ON/OFF
# Testing
-DYAZE_ENABLE_ROM_TESTS=ON/OFF
-DYAZE_TEST_ROM_PATH=/path/to/zelda3.sfc
# Build optimization
-DYAZE_MINIMAL_BUILD=ON/OFF
-DYAZE_USE_MODULAR_BUILD=ON/OFF
```
## Examples
### Development with AI features and verbose warnings
```bash
cmake --preset mac-dbg-v -DZ3ED_AI=ON -DYAZE_WITH_GRPC=ON
cmake --build --preset mac-dbg-v
```
### Release build for distribution (macOS Universal)
```bash
cmake --preset mac-uni
cmake --build --preset mac-uni
cpack --preset mac-uni
```
### Quick minimal build for testing
```bash
cmake --preset mac-dbg -DYAZE_MINIMAL_BUILD=ON
cmake --build --preset mac-dbg -j12
```
## Updating compile_commands.json
After configuring with a new preset, copy the compile commands for IDE support:
```bash
cp build/compile_commands.json .
```
This ensures clangd and other LSP servers can find headers and understand build flags.
## Migration from Old Presets
Old preset names have been simplified:
| Old Name | New Name |
|----------|----------|
| `macos-dev-z3ed-ai` | `mac-ai` |
| `macos-debug` | `mac-dbg` |
| `macos-release` | `mac-rel` |
| `macos-debug-universal` | `mac-uni` |
| `macos-dungeon-dev` | `mac-rooms` |
| `windows-debug` | `win-dbg` |
| `windows-release` | `win-rel` |
| `windows-arm64-debug` | `win-arm` |
| `linux-debug` | `lin-dbg` |
| `linux-clang` | `lin-clang` |
## Troubleshooting
### Warnings are still showing
- Make sure you're using a preset without `-v` suffix
- Check `cmake` output for `✓ Warnings suppressed` message
- Reconfigure and rebuild: `rm -rf build && cmake --preset mac-dbg`
### clangd can't find nlohmann/json
- Run `cmake --preset <your-preset>` to regenerate compile_commands.json
- Copy to root: `cp build/compile_commands.json .`
- Restart your IDE or LSP server
### Build fails with missing dependencies
- Ensure submodules are initialized: `git submodule update --init --recursive`
- For AI features, make sure you have OpenSSL: `brew install openssl` (macOS)

View File

@@ -47,11 +47,13 @@ target_link_libraries(yaze_canvas PUBLIC
SDL2::SDL2 SDL2::SDL2
) )
# Compiler-specific options # Compiler-specific options (respect global warning settings)
if(MSVC) if(NOT YAZE_SUPPRESS_WARNINGS)
target_compile_options(yaze_canvas PRIVATE /W4) if(MSVC)
else() target_compile_options(yaze_canvas PRIVATE /W4)
target_compile_options(yaze_canvas PRIVATE -Wall -Wextra -Wpedantic) else()
target_compile_options(yaze_canvas PRIVATE -Wall -Wextra -Wpedantic)
endif()
endif() endif()
# Add canvas to parent GUI library # Add canvas to parent GUI library