sourcelume-cmake-module)CMake module for automating generating, validating, and submitting Apache Sourcelume specification records to a Sourcelume Registry for C/C++ projects.
The sourcelume-cmake-module extracts project metadata (coordinates, project name, version, license, git origin, author/vendor), generates canonical Sourcelume 0.0.1 Provenance Records, validates them against the registry schema, and publishes them to the registry.
CMakeLists.txtInclude the module or find package:
cmake_minimum_required(VERSION 3.19) project(my-cpp-project VERSION 1.0.0 LANGUAGES CXX) # Include Sourcelume module list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(Sourcelume) # Enable Sourcelume targets sourcelume_enable( REGISTRY_URL "http://localhost:8082" LICENSE "Apache-2.0" LICENSE_CATEGORY "open-source" LICENSE_NOTE "Apache-2.0 verified C++ project" DATASET_IDENTIFIER "sourcelume://datasets/my-cpp-dataset-v1" DATASET_NAME "My C++ Example Dataset" )
Or, after installing the module (cmake -B build && cmake --install build), load it with find_package:
find_package(Sourcelume 0.0.1 REQUIRED) # add the install prefix to CMAKE_PREFIX_PATH sourcelume_enable(LICENSE "Apache-2.0")
DRY_RUN, FAIL_ON_ERROR and ALLOW_CONFLICT take TRUE or FALSE (for example DRY_RUN TRUE). A keyword with no value means TRUE; an empty value leaves the option unset.
When sourcelume_enable() is configured, the following targets are registered in your build system:
| Target | Description |
|---|---|
sourcelume_generate / sourcelume-generate | Generates provenance-record.json spec file from CMake project metadata. |
sourcelume_validate / sourcelume-validate | Validates the spec against the registry's /records/validate endpoint. |
sourcelume_publish / sourcelume-publish | Submits the generated spec to the registry (POST /records). |
To execute targets using CMake:
# 1. Configure build directory cmake -B build # 2. Generate Provenance Record cmake --build build --target sourcelume_generate # 3. Validate against Sourcelume Registry cmake --build build --target sourcelume_validate # 4. Publish to Registry cmake --build build --target sourcelume_publish
To build and run tests for the sourcelume-cmake-module itself:
# Configure with testing enabled cmake -B build -DBUILD_TESTING=ON # Generate module provenance record cmake --build build --target sourcelume_generate # Execute module test suite ctest --test-dir build --output-on-failure
You can pass options via CMake cache flags or environment variables:
# Dry run without network calls cmake --build build --target sourcelume_publish -- -Dsourcelume.dryRun=true # Or with environment variable SOURCELUME_DRY_RUN=1 cmake --build build --target sourcelume_publish # Override registry endpoint and credentials SOURCELUME_REGISTRY_URL="https://registry.example.org" \ SOURCELUME_REGISTRY_TOKEN="<token>" \ cmake --build build --target sourcelume_publish
You can also run the module standalone via cmake -P:
cmake -DSOURCELUME_ACTION=generate \ -DSOURCELUME_PROJECT_NAME=my-project \ -DSOURCELUME_VERSION=1.0.0 \ -DSOURCELUME_LICENSE=MIT \ -DSOURCELUME_OUTPUT_FILE=build/sourcelume/provenance-record.json \ -P cmake/Sourcelume.cmake
| Parameter | Environment Variable | Default Value | Description |
|---|---|---|---|
REGISTRY_URL | SOURCELUME_REGISTRY_URL | http://localhost:8082 | URL of the Sourcelume Registry. |
USERNAME | SOURCELUME_REGISTRY_USERNAME | - | Registry username for HTTP Basic Auth. |
PASSWORD | SOURCELUME_REGISTRY_PASSWORD | - | Registry password for HTTP Basic Auth. |
TOKEN | SOURCELUME_REGISTRY_TOKEN | - | Bearer token for authentication. |
DRY_RUN | SOURCELUME_DRY_RUN | FALSE | If true, logs payloads without sending to the registry. |
FAIL_ON_ERROR | SOURCELUME_FAIL_ON_ERROR | TRUE | If true, failures abort the build. |
OUTPUT_FILE | SOURCELUME_OUTPUT_FILE | ${CMAKE_CURRENT_BINARY_DIR}/sourcelume/provenance-record.json | Path to generated JSON-LD spec. |
RECORD_ID | SOURCELUME_RECORD_ID | urn:sourcelume:cmake:${PROJECT_NAME}:${PROJECT_VERSION} | Provenance Record ID. |
DATASET_IDENTIFIER | SOURCELUME_DATASET_IDENTIFIER | sourcelume://cmake/${PROJECT_NAME} | Persistent dataset identifier. |
DATASET_NAME | SOURCELUME_DATASET_NAME | ${PROJECT_DESCRIPTION} / ${PROJECT_NAME} | Dataset title or name. |
LICENSE | SOURCELUME_LICENSE | Apache-2.0 | License name, URL, or SPDX IRI. |
LICENSE_CATEGORY | SOURCELUME_LICENSE_CATEGORY | open-source | License category. |
LICENSE_NOTE | SOURCELUME_LICENSE_NOTE | - | Note or description regarding dataset licensing. |
ORIGIN | SOURCELUME_ORIGIN | Derived from git / PROJECT_HOMEPAGE_URL | Dataset or codebase origin URI. |
Licensed under the Apache License, Version 2.0.