|
| 1 | +# Building ld-decode |
| 2 | + |
| 3 | +This project uses CMake and enforces out-of-source builds. All build artifacts are kept in a separate `build/` directory, keeping the source tree clean. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +```bash |
| 8 | +mkdir build |
| 9 | +cd build |
| 10 | +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. |
| 11 | +make -j8 |
| 12 | +ctest --output-on-failure |
| 13 | +``` |
| 14 | + |
| 15 | +## Step-by-Step Instructions |
| 16 | + |
| 17 | +### 1. Create a Build Directory |
| 18 | + |
| 19 | +```bash |
| 20 | +mkdir build |
| 21 | +cd build |
| 22 | +``` |
| 23 | + |
| 24 | +Keep the build directory separate from the source tree. This is a CMake best practice. |
| 25 | + |
| 26 | +### 2. Configure the Build |
| 27 | + |
| 28 | +```bash |
| 29 | +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. |
| 30 | +``` |
| 31 | + |
| 32 | +This configures the build with: |
| 33 | +- **RelWithDebInfo**: Release build with debug symbols for better profiling and debugging |
| 34 | +- **..**: Points to the source directory (parent directory) |
| 35 | + |
| 36 | +The cmake step will: |
| 37 | +- Detect your system's compiler and libraries |
| 38 | +- Find Qt6 libraries |
| 39 | +- Configure build files for your platform |
| 40 | + |
| 41 | +### 3. Build the Project |
| 42 | + |
| 43 | +```bash |
| 44 | +make -j8 |
| 45 | +``` |
| 46 | + |
| 47 | +Builds all targets using 8 parallel jobs. Adjust the number based on your CPU core count. |
| 48 | + |
| 49 | +**Single-threaded build** (if parallel builds cause issues): |
| 50 | +```bash |
| 51 | +make |
| 52 | +``` |
| 53 | + |
| 54 | +### 4. Run Tests |
| 55 | + |
| 56 | +```bash |
| 57 | +ctest --output-on-failure |
| 58 | +``` |
| 59 | + |
| 60 | +Runs all tests sequentially. Tests must run sequentially due to shared testout directory. |
| 61 | + |
| 62 | +**Run specific test**: |
| 63 | +```bash |
| 64 | +ctest -R chroma --output-on-failure |
| 65 | +``` |
| 66 | + |
| 67 | +### 5. Install (Optional) |
| 68 | + |
| 69 | +```bash |
| 70 | +make install DESTDIR=/tmp/staging |
| 71 | +``` |
| 72 | + |
| 73 | +Installs built binaries and libraries to the staging directory. |
| 74 | + |
| 75 | +## Building Individual Tools |
| 76 | + |
| 77 | +You can build specific tools or libraries without building the entire project: |
| 78 | + |
| 79 | +```bash |
| 80 | +# Build a single tool |
| 81 | +make ld-analyse |
| 82 | +make ld-chroma-decoder |
| 83 | +make ld-json-converter |
| 84 | +``` |
| 85 | + |
| 86 | +**Common tool targets:** |
| 87 | +- `ld-analyse` - GUI analysis tool |
| 88 | +- `ld-chroma-decoder` - Chroma decoder |
| 89 | +- `ld-chroma-encoder` - Chroma encoder |
| 90 | +- `ld-json-converter` - JSON to SQLite converter |
| 91 | +- `ld-process-vbi` - VBI processor |
| 92 | +- `ld-process-vits` - VITS processor |
| 93 | +- `ld-cut` - Cut/segment tool |
| 94 | +- `ld-ldf-reader` - LDF file reader |
| 95 | +- `ld-discmap` - Disc mapper |
| 96 | +- `ld-dropout-correct` - Dropout corrector |
| 97 | + |
| 98 | +**Library targets:** |
| 99 | +- `lddecode-library` - Core library |
| 100 | +- `lddecode-chroma` - Chroma decoder library |
| 101 | + |
| 102 | +**Test targets:** |
| 103 | +- `testfilter` - Filter tests |
| 104 | +- `testlinenumber` - Line number tests |
| 105 | +- `testmetadata` - Metadata tests |
| 106 | +- `testvbidecoder` - VBI decoder tests |
| 107 | +- `testvitcdecoder` - VITC decoder tests |
| 108 | + |
| 109 | +**View all available targets:** |
| 110 | +```bash |
| 111 | +make help | grep "^ [a-z]" |
| 112 | +``` |
| 113 | + |
| 114 | +## Build Options |
| 115 | + |
| 116 | +You can customize the build with additional CMake variables: |
| 117 | + |
| 118 | +```bash |
| 119 | +cmake -DCMAKE_BUILD_TYPE=Release .. |
| 120 | +``` |
| 121 | + |
| 122 | +**Available build types:** |
| 123 | +- `Debug` - Debug symbols, no optimization |
| 124 | +- `Release` - Optimized, no debug symbols |
| 125 | +- `RelWithDebInfo` - Optimized with debug symbols (recommended) |
| 126 | +- `MinSizeRel` - Minimized size |
| 127 | + |
| 128 | +### Qt Debug Symbols |
| 129 | + |
| 130 | +To include Qt debug symbols for debugging Qt-related issues: |
| 131 | + |
| 132 | +**Option 1: Debug build (full debug, no optimization)** |
| 133 | +```bash |
| 134 | +cd build |
| 135 | +cmake -DCMAKE_BUILD_TYPE=Debug .. |
| 136 | +make -j8 |
| 137 | +``` |
| 138 | + |
| 139 | +**Option 2: Optimized build with Qt debug symbols** |
| 140 | +```bash |
| 141 | +cd build |
| 142 | +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DQT_DEBUG=ON .. |
| 143 | +make -j8 |
| 144 | +``` |
| 145 | + |
| 146 | +**Option 3: Reconfigure existing build** |
| 147 | +If you already have a build directory, you can reconfigure: |
| 148 | +```bash |
| 149 | +cd build |
| 150 | +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DQT_DEBUG=ON .. |
| 151 | +make -j8 |
| 152 | +``` |
| 153 | + |
| 154 | +Debug builds will be larger and slower but provide better debugging information for stepping through code and inspecting Qt internals. |
| 155 | + |
| 156 | +## Troubleshooting |
| 157 | + |
| 158 | +### Rebuilding After Source Changes |
| 159 | + |
| 160 | +If you make changes to `CMakeLists.txt`, cmake will automatically reconfigure during the next `make` invocation. |
| 161 | + |
| 162 | +### Clean Build |
| 163 | + |
| 164 | +To perform a clean build: |
| 165 | + |
| 166 | +```bash |
| 167 | +rm -rf build |
| 168 | +mkdir build |
| 169 | +cd build |
| 170 | +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. |
| 171 | +make -j8 |
| 172 | +``` |
| 173 | + |
| 174 | +### In-Source Build Error |
| 175 | + |
| 176 | +If you accidentally run cmake in the source directory, you'll see: |
| 177 | + |
| 178 | +``` |
| 179 | +In-source builds are not allowed. Please create a build directory and run: |
| 180 | + mkdir build |
| 181 | + cd build |
| 182 | + cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. |
| 183 | +``` |
| 184 | + |
| 185 | +Simply follow those instructions to fix it. |
| 186 | + |
| 187 | +## Dependencies |
| 188 | + |
| 189 | +The project requires: |
| 190 | +- CMake 3.16 or later |
| 191 | +- Qt6 (Core, Gui, Widgets, Sql) |
| 192 | +- C++17 compatible compiler (GCC 7+, Clang 5+, MSVC 2019+) |
| 193 | +- FFTW3 |
| 194 | +- FFmpeg (libavcodec, libavformat, libavutil) |
| 195 | +- Python 3.6+ |
| 196 | +- SQLite3 |
| 197 | + |
| 198 | +### Ubuntu/Debian |
| 199 | + |
| 200 | +```bash |
| 201 | +sudo apt-get install cmake qt6-base-dev libgl-dev libfftw3-dev libavformat-dev \ |
| 202 | + libavcodec-dev libavutil-dev ffmpeg libsqlite3-dev libqt6sql6-sqlite |
| 203 | +``` |
| 204 | + |
| 205 | +### macOS (Homebrew) |
| 206 | + |
| 207 | +```bash |
| 208 | +brew install cmake qt6 fftw ffmpeg sqlite3 |
| 209 | +``` |
| 210 | + |
| 211 | +## Build Output |
| 212 | + |
| 213 | +All build artifacts are placed in the `build/` directory: |
| 214 | +- `build/` - All CMake files, object files, and executables |
| 215 | +- Source tree remains clean |
| 216 | + |
| 217 | +The root directory only contains: |
| 218 | +- Source code (`lddecode/`, `tools/`, `scripts/`, etc.) |
| 219 | +- Configuration files (`CMakeLists.txt`, `setup.py`, etc.) |
| 220 | +- Documentation |
| 221 | + |
| 222 | +## For CI/CD |
| 223 | + |
| 224 | +The GitHub Actions workflow uses: |
| 225 | + |
| 226 | +```yaml |
| 227 | +- name: Configure |
| 228 | + run: cd build && cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. |
| 229 | + |
| 230 | +- name: Build |
| 231 | + run: make -C build VERBOSE=1 |
| 232 | + |
| 233 | +- name: Run tests |
| 234 | + run: cd build && ctest --output-on-failure |
| 235 | +``` |
| 236 | +
|
| 237 | +Tests run sequentially (no `-j` flag) to avoid race conditions in the shared testout directory. |
0 commit comments