|
| 1 | +Crow has the ability to generate a SBOM (Software Bill of Materials) at build using [`cmake-sbom`](https://github.com/DEMCON/cmake-sbom) in SPDX format. |
| 2 | + |
| 3 | +## Prerequisites |
| 4 | + |
| 5 | +The CMake module `cmake-sbom` expects the `spdx-tools`, `reuse`, and `ntia-conformance-checker` Python packages as external prerequisites. |
| 6 | + |
| 7 | +## Example Steps |
| 8 | + |
| 9 | +Below you'll find the steps to add SBOM generation. |
| 10 | + |
| 11 | +### Install Python Packages |
| 12 | + |
| 13 | +Create a Python virtual environment first so you're not installing Python packages globally: |
| 14 | + |
| 15 | +1. Create and navigate to the build directory:<br> `mkdir build && cd build` |
| 16 | +2. Create the venv:<br> `python3 -m venv .venv` |
| 17 | +3. Activate the venv (macOS/Linux):<br> `source .venv/bin/activate` |
| 18 | +4. Install the required Python packages:<br> `pip install spdx-tools reuse ntia-conformance-checker` |
| 19 | + |
| 20 | +### Build Crow with cmake-sbom |
| 21 | + |
| 22 | +Steps to generate a `.spdx` file using CMake for your project: |
| 23 | + |
| 24 | +1. If you didn't create the `build` directory, create and navigate to the build directory:<br> `mkdir build && cd build` |
| 25 | +2. Enable the build option:<br> `cmake .. -DCROW_GENERATE_SBOM=ON -DPython3_EXECUTABLE=$(which python3)` |
| 26 | +3. Then run:<br> `cmake --build .` |
| 27 | +4. Run the install:<br> `cmake --install . --prefix /tmp/crow-install` |
| 28 | + |
| 29 | +Check for the generated .spdx file in the `build/` directory. The file name follows this pattern:<br> `crow-<version>-<date>.spdx` |
| 30 | + |
| 31 | +!!! note |
| 32 | + You must pass `-DPython3_EXECUTABLE=$(which python3)` so CMake uses the venv's Python instead of the system Python. Without it, |
| 33 | + the SBOM verification step will fail because the system Python won't have the required packages installed. |
| 34 | + |
| 35 | +!!! note |
| 36 | + The .spdx file is generated when you run the `cmake --install . --prefix /tmp/crow-install` |
| 37 | + |
| 38 | +!!! note |
| 39 | + You can also combine `-DCROW_GENERATE_SBOM=ON` with conditional dependencies:<br> `cmake .. -DCROW_GENERATE_SBOM=ON -DCROW_ENABLE_SSL=ON -DCROW_ENABLE_COMPRESSION=ON` |
0 commit comments