This project uses a flexible GGML dependency resolution strategy that supports both standalone builds and integration into larger projects.
The CMake configuration resolves GGML dependencies in the following priority order:
- Existing Target - If
ggmltarget already exists (e.g., from parent project likewhisper.cpp) - Installed Package - Search for GGML via
find_package() - Submodule - Use
ggml/subdirectory (if exists) - Sibling Directory - Use
../ggml(if exists) - Explicit Path - Use path specified by
GGML_DIRvariable
Clone GGML as submodule:
cd BSRoformer.cpp
git submodule add https://github.com/ggerganov/ggml.git
git submodule update --init --recursive
cmake -B build -DGGML_CUDA=ONOr use sibling directory:
cd ..
git clone https://github.com/ggerganov/ggml.git
cd BSRoformer.cpp
cmake -B build -DGGML_CUDA=ONWhen both projects need GGML, let whisper.cpp provide it:
# Parent Project CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(MyParentProject)
# Build whisper.cpp first (includes ggml)
add_subdirectory(whisper.cpp)
# Build BSRoformer - it will reuse whisper.cpp's ggml target
add_subdirectory(BSRoformer.cpp)Or use explicit path:
cmake -B build -DGGML_DIR=/path/to/shared/ggmlcmake -B build -DGGML_DIR=/custom/path/to/ggmlOption A: Submodule (Recommended)
BSRoformer.cpp/
├── ggml/ # Git submodule
├── src/
├── tests/
└── CMakeLists.txt
Option B: Sibling Directory
parent/
├── ggml/ # Shared GGML
├── BSRoformer.cpp/
└── whisper.cpp/ # Also uses ../ggml
Option C: Parent Project
MyProject/
├── external/
│ └── ggml/
├── whisper.cpp/
├── BSRoformer.cpp/
└── CMakeLists.txt # Defines ggml target
- ✅ Standalone: Works independently without parent project
- ✅ Reusable: Shares GGML across multiple projects
- ✅ Flexible: Supports multiple directory layouts
- ✅ Build Time: Avoids duplicate GGML compilation
- ✅ Disk Space: Single GGML copy for multiple projects