|
| 1 | +--- |
| 2 | +name: build-cmake |
| 3 | +description: Build an iPlug2 plugin project using CMake (Ninja or Xcode generator) |
| 4 | +--- |
| 5 | + |
| 6 | +# Build iPlug2 Plugin with CMake |
| 7 | + |
| 8 | +Use this skill when the user wants to build their plugin project using CMake. |
| 9 | + |
| 10 | +## Workflow |
| 11 | + |
| 12 | +1. **Identify the project:** |
| 13 | + - Look for `CMakeLists.txt` in project directories |
| 14 | + |
| 15 | +2. **Choose a preset** based on platform and build requirements |
| 16 | + |
| 17 | +## Using CMake Presets |
| 18 | + |
| 19 | +The project uses CMake presets for standardized builds. Prefer `--preset` instead of manual `-G` flags. |
| 20 | + |
| 21 | +### List Available Presets |
| 22 | + |
| 23 | +```bash |
| 24 | +cmake --list-presets |
| 25 | +``` |
| 26 | + |
| 27 | +### macOS Builds |
| 28 | + |
| 29 | +```bash |
| 30 | +# Configure with Ninja (fast builds) |
| 31 | +cmake --preset macos-ninja -S [ProjectName] |
| 32 | + |
| 33 | +# Build |
| 34 | +cmake --build build/macos-ninja --target [ProjectName]-app |
| 35 | + |
| 36 | +# Or with Xcode (for debugging) |
| 37 | +cmake --preset macos-xcode -S [ProjectName] |
| 38 | +cmake --build build/macos-xcode --config Release --target [ProjectName]-app |
| 39 | + |
| 40 | +# Universal binary (arm64 + x86_64) |
| 41 | +cmake --preset macos-xcode-universal -S [ProjectName] |
| 42 | +cmake --build build/macos-xcode-universal --config Release |
| 43 | +``` |
| 44 | + |
| 45 | +### iOS Builds |
| 46 | + |
| 47 | +```bash |
| 48 | +# iOS Device |
| 49 | +cmake --preset ios-xcode -S [ProjectName] |
| 50 | +cmake --build build/ios-xcode --config Release |
| 51 | + |
| 52 | +# iOS Simulator |
| 53 | +cmake --preset ios-sim-xcode -S [ProjectName] |
| 54 | +cmake --build build/ios-sim-xcode --config Release |
| 55 | +``` |
| 56 | + |
| 57 | +For running in Simulator, use the `run-ios-simulator` skill. |
| 58 | + |
| 59 | +### visionOS Builds |
| 60 | + |
| 61 | +```bash |
| 62 | +# visionOS Device |
| 63 | +cmake --preset visionos-xcode -S [ProjectName] |
| 64 | +cmake --build build/visionos-xcode --config Release |
| 65 | + |
| 66 | +# visionOS Simulator |
| 67 | +cmake --preset visionos-sim-xcode -S [ProjectName] |
| 68 | +cmake --build build/visionos-sim-xcode --config Release |
| 69 | +``` |
| 70 | + |
| 71 | +### Windows Builds |
| 72 | + |
| 73 | +```bash |
| 74 | +# Visual Studio 2022 (x64) |
| 75 | +cmake --preset windows-vs2022 -S [ProjectName] |
| 76 | +cmake --build build/windows-vs2022 --config Release |
| 77 | + |
| 78 | +# ARM64EC |
| 79 | +cmake --preset windows-vs2022-arm64ec -S [ProjectName] |
| 80 | +cmake --build build/windows-vs2022-arm64ec --config Release |
| 81 | +``` |
| 82 | + |
| 83 | +### Web/WAM Build (Emscripten) |
| 84 | + |
| 85 | +```bash |
| 86 | +# Configure (requires EMSDK environment) |
| 87 | +cmake --preset wam -S [ProjectName] |
| 88 | + |
| 89 | +# Build |
| 90 | +cmake --build build/wam --target [ProjectName]-wam |
| 91 | + |
| 92 | +# Create distribution |
| 93 | +cmake --build build/wam --target [ProjectName]-wam-dist |
| 94 | +``` |
| 95 | + |
| 96 | +Output in `build/wam/out/[ProjectName]-wam/` |
| 97 | + |
| 98 | +## Available Configure Presets |
| 99 | + |
| 100 | +| Preset | Platform | Generator | Description | |
| 101 | +|--------|----------|-----------|-------------| |
| 102 | +| `macos-ninja` | macOS | Ninja | Fast command-line builds (NanoVG/Metal) | |
| 103 | +| `macos-make` | macOS | Make | Unix Makefiles (NanoVG/Metal) | |
| 104 | +| `macos-xcode` | macOS | Xcode | IDE builds with debugging | |
| 105 | +| `macos-xcode-universal` | macOS | Xcode | Universal binary (arm64+x86_64) | |
| 106 | +| `ios-xcode` | iOS | Xcode | iOS device builds | |
| 107 | +| `ios-sim-xcode` | iOS | Xcode | iOS Simulator builds | |
| 108 | +| `visionos-xcode` | visionOS | Xcode | visionOS device builds | |
| 109 | +| `visionos-sim-xcode` | visionOS | Xcode | visionOS Simulator builds | |
| 110 | +| `windows-ninja` | Windows | Ninja | Fast Windows command-line builds | |
| 111 | +| `windows-vs2022` | Windows | VS2022 | Windows x64 builds | |
| 112 | +| `windows-vs2022-arm64ec` | Windows | VS2022 | Windows ARM64EC builds | |
| 113 | +| `wam` | Web | Ninja | Emscripten/WebAssembly builds | |
| 114 | + |
| 115 | +## Available Targets |
| 116 | + |
| 117 | +- `[ProjectName]-app` - Standalone application |
| 118 | +- `[ProjectName]-vst3` - VST3 plugin |
| 119 | +- `[ProjectName]-au` - Audio Unit (AUv2) |
| 120 | +- `[ProjectName]-clap` - CLAP plugin |
| 121 | +- `[ProjectName]AU-framework` - AUv3 framework |
| 122 | +- `[ProjectName]AUv3-appex` - AUv3 app extension |
| 123 | +- `[ProjectName]-ios-app` - iOS standalone app |
| 124 | +- `[ProjectName]-wam` - Web Audio Module |
| 125 | + |
| 126 | +## Graphics Backend and Renderer |
| 127 | + |
| 128 | +Default configuration uses NanoVG with Metal (macOS/iOS) or GL2 (Windows). |
| 129 | + |
| 130 | +To use Skia backend, add cache variables: |
| 131 | + |
| 132 | +```bash |
| 133 | +cmake --preset macos-ninja -S [ProjectName] \ |
| 134 | + -DIGRAPHICS_BACKEND=SKIA \ |
| 135 | + -DIGRAPHICS_RENDERER=METAL |
| 136 | +``` |
| 137 | + |
| 138 | +Valid combinations: |
| 139 | +- **NanoVG**: GL2, GL3, METAL |
| 140 | +- **Skia**: GL3, METAL, CPU |
| 141 | + |
| 142 | +**Note:** Skia requires prebuilt libraries: |
| 143 | +```bash |
| 144 | +./iPlug2/Dependencies/download-prebuilt-libs.sh mac |
| 145 | +``` |
| 146 | + |
| 147 | +## Build Locations (symlinked on macOS) |
| 148 | + |
| 149 | +- APP: `~/Applications/[ProjectName].app` |
| 150 | +- VST3: `~/Library/Audio/Plug-Ins/VST3/` |
| 151 | +- AU: `~/Library/Audio/Plug-Ins/Components/` |
| 152 | +- CLAP: `~/Library/Audio/Plug-Ins/CLAP/` |
| 153 | + |
| 154 | +## Clean Build |
| 155 | + |
| 156 | +```bash |
| 157 | +# Remove build directory and reconfigure |
| 158 | +rm -rf build/macos-ninja |
| 159 | +cmake --preset macos-ninja -S [ProjectName] |
| 160 | +``` |
| 161 | + |
| 162 | +## Example |
| 163 | + |
| 164 | +```bash |
| 165 | +# Quick build of standalone app |
| 166 | +cmake --preset macos-ninja -S MySynth |
| 167 | +cmake --build build/macos-ninja --target MySynth-app |
| 168 | + |
| 169 | +# Open the built app |
| 170 | +open ~/Applications/MySynth.app |
| 171 | + |
| 172 | +# Build for iOS Simulator |
| 173 | +cmake --preset ios-sim-xcode -S MySynth |
| 174 | +cmake --build build/ios-sim-xcode --config Release |
| 175 | +``` |
0 commit comments