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:
ggml target already exists (e.g., from parent project like whisper.cpp)find_package()ggml/ subdirectory (if exists)../ggml (if exists)GGML_DIR variableClone 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=ON
Or use sibling directory:
cd ..
git clone https://github.com/ggerganov/ggml.git
cd BSRoformer.cpp
cmake -B build -DGGML_CUDA=ON
When 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/ggml
cmake -B build -DGGML_DIR=/custom/path/to/ggml
Option 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