|
| 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 | + - If not specified, find projects excluding TemplateProject |
| 15 | + |
| 16 | +2. **Choose build method:** |
| 17 | + - **Ninja** (fast, command-line): Best for quick iteration |
| 18 | + - **Xcode** (IDE): Best for debugging |
| 19 | + |
| 20 | +## macOS Build with Ninja |
| 21 | + |
| 22 | +```bash |
| 23 | +# Configure (from repo root) |
| 24 | +cmake -B build -G Ninja -S [ProjectName] |
| 25 | + |
| 26 | +# Build specific target |
| 27 | +ninja -C build [ProjectName]-app |
| 28 | +ninja -C build [ProjectName]-vst3 |
| 29 | +ninja -C build [ProjectName]-au |
| 30 | +ninja -C build [ProjectName]-clap |
| 31 | +``` |
| 32 | + |
| 33 | +### Available Targets |
| 34 | +- `[ProjectName]-app` - Standalone application |
| 35 | +- `[ProjectName]-vst3` - VST3 plugin |
| 36 | +- `[ProjectName]-au` - Audio Unit (AUv2) |
| 37 | +- `[ProjectName]-clap` - CLAP plugin |
| 38 | +- `[ProjectName]AU-framework` - AUv3 framework |
| 39 | +- `[ProjectName]AUv3-appex` - AUv3 app extension |
| 40 | + |
| 41 | +### Graphics Backend and Renderer Selection |
| 42 | + |
| 43 | +Two options control the graphics system: |
| 44 | +- `IGRAPHICS_BACKEND`: `NANOVG` (default) or `SKIA` |
| 45 | +- `IGRAPHICS_RENDERER`: `METAL` (default), `GL2`, `GL3`, or `CPU` |
| 46 | + |
| 47 | +Valid combinations: |
| 48 | +- **NanoVG**: GL2, GL3, METAL |
| 49 | +- **Skia**: GL3, METAL, CPU |
| 50 | + |
| 51 | +```bash |
| 52 | +# NanoVG + Metal (default) |
| 53 | +cmake -B build -G Ninja -S [ProjectName] |
| 54 | + |
| 55 | +# NanoVG + OpenGL 3 |
| 56 | +cmake -B build -G Ninja -S [ProjectName] -DIGRAPHICS_RENDERER=GL3 |
| 57 | + |
| 58 | +# Skia + Metal (higher quality rendering) |
| 59 | +cmake -B build -G Ninja -S [ProjectName] -DIGRAPHICS_BACKEND=SKIA |
| 60 | + |
| 61 | +# Skia + CPU (software rendering, no GPU required) |
| 62 | +cmake -B build -G Ninja -S [ProjectName] -DIGRAPHICS_BACKEND=SKIA -DIGRAPHICS_RENDERER=CPU |
| 63 | +``` |
| 64 | + |
| 65 | +**Note:** Skia requires prebuilt libraries. Run first: |
| 66 | +```bash |
| 67 | +./iPlug2/Dependencies/download-prebuilt-libs.sh mac |
| 68 | +``` |
| 69 | + |
| 70 | +### Build Locations (symlinked) |
| 71 | +- APP: `~/Applications/[ProjectName].app` |
| 72 | +- VST3: `~/Library/Audio/Plug-Ins/VST3/` |
| 73 | +- AU: `~/Library/Audio/Plug-Ins/Components/` |
| 74 | +- CLAP: `~/Library/Audio/Plug-Ins/CLAP/` |
| 75 | + |
| 76 | +## macOS Build with Xcode Generator |
| 77 | + |
| 78 | +```bash |
| 79 | +# Generate Xcode project |
| 80 | +cmake -B build-xcode -G Xcode -S [ProjectName] |
| 81 | + |
| 82 | +# Open in Xcode |
| 83 | +open build-xcode/[ProjectName].xcodeproj |
| 84 | +``` |
| 85 | + |
| 86 | +Or build from command line: |
| 87 | +```bash |
| 88 | +cmake --build build-xcode --target [ProjectName]-app --config Debug |
| 89 | +``` |
| 90 | + |
| 91 | +## iOS Build |
| 92 | + |
| 93 | +```bash |
| 94 | +# Configure for iOS |
| 95 | +cmake -B build-ios -G Ninja -S [ProjectName] \ |
| 96 | + -DCMAKE_SYSTEM_NAME=iOS \ |
| 97 | + -DCMAKE_OSX_DEPLOYMENT_TARGET=15.0 |
| 98 | + |
| 99 | +# Build iOS app with embedded AUv3 |
| 100 | +ninja -C build-ios [ProjectName]-ios-app |
| 101 | +``` |
| 102 | + |
| 103 | +### iOS Targets |
| 104 | +- `[ProjectName]-ios-app` - iOS standalone app |
| 105 | +- `[ProjectName]AU-ios-framework` - iOS AUv3 framework |
| 106 | +- `[ProjectName]AUv3-ios-appex` - iOS AUv3 app extension |
| 107 | + |
| 108 | +For running in Simulator, use the `run-ios-simulator` skill. |
| 109 | + |
| 110 | +## Web/WAM Build (Emscripten) |
| 111 | + |
| 112 | +```bash |
| 113 | +# Configure with Emscripten |
| 114 | +emcmake cmake -B build-web -G Ninja -S [ProjectName] |
| 115 | + |
| 116 | +# Build WAM targets |
| 117 | +ninja -C build-web [ProjectName]-wam |
| 118 | +ninja -C build-web [ProjectName]-web |
| 119 | + |
| 120 | +# Create distribution |
| 121 | +ninja -C build-web [ProjectName]-wam-dist |
| 122 | +``` |
| 123 | + |
| 124 | +Output in `build-web/out/[ProjectName]-wam/` |
| 125 | + |
| 126 | +## Clean Build |
| 127 | + |
| 128 | +```bash |
| 129 | +# Remove build directory and reconfigure |
| 130 | +rm -rf build && cmake -B build -G Ninja -S [ProjectName] |
| 131 | +``` |
| 132 | + |
| 133 | +## Tips |
| 134 | + |
| 135 | +- Use `ninja -C build` without target to build everything |
| 136 | +- Add `-j4` to limit parallel jobs if needed |
| 137 | +- Check `CMakeCache.txt` in build dir to verify settings |
| 138 | +- Use `ccmake -B build` for interactive configuration |
| 139 | + |
| 140 | +## Example |
| 141 | + |
| 142 | +```bash |
| 143 | +# Quick build of standalone app |
| 144 | +cmake -B build -G Ninja -S MySynth |
| 145 | +ninja -C build MySynth-app |
| 146 | + |
| 147 | +# Open the built app |
| 148 | +open ~/Applications/MySynth.app |
| 149 | + |
| 150 | +# Rebuild with Skia backend |
| 151 | +rm -rf build |
| 152 | +cmake -B build -G Ninja -S MySynth -DIGRAPHICS_BACKEND=SKIA |
| 153 | +ninja -C build MySynth-app |
| 154 | +``` |
0 commit comments