Building and Using bpt in Another Build System

One of bpt’s primary goals is to inter-operate with other build systems cleanly. One of bpt’s primary outputs is machine-readable JSON summary of its build results. bpt also supports emitting a include()-able CMake module for consumption by older CMake versions that cannot parse the JSON natively.

Generating a Build for Importing

In order to import and link against libraries built by bpt, one needs to first run a build and generate the appropriate build results manifest. This manifest is not generated globally: It is generated on a per-build basis as part of the build process. The manifest will describe in build-system-agnostic terms how to include and link against as set of libraries generated by a build.

bpt has first-class support for generating this file. The build-deps subcommand of bpt will download and build a set of dependencies, and places a JSON file that can be used to import the built results.

Note

Alternatively, for CMake projects, one can use the --cmake option to write a CMake script that defines the needed IMPORTED targets. Refer: Using bpt in a CMake Project

The build-deps command accepts a list of dependency specifiers as positional command-line arguments. bpt will attempt to generate a dependency solution using that set of dependencies and will then obtain and build their sources.

Declaring Dependencies in a File

bpt build-deps accepts a list of dependency specifiers as command line arguments, but it may be useful to specify those requirements in a file.

bpt build-deps accepts a YAML file describing the dependencies of a project as well. The only required property in the file is the dependencies key. (The presence of any other key is an error.)

Here is a simple dependencies file that declares a single requirement:

dependencies.yaml
dependencies: [
  'neo-sqlite3^0.2.0'
]

See also

The dependencies array is an array of dependency specifier strings, the same as those that would be used in a bpt.yaml project file.

Building Dependencies and the Manifest

We can invoke bpt build-deps and give it the path to this file:

$ bpt build-deps --deps-file dependencies.yaml

When finished, bpt will write the build results into a subdirectory called _deps and generate a file named _built.json. This file is ready to be imported into any build system that can understand its simple schema.

Note

The output directory and manifest filepath can be controlled with the --out and --built-json flags, respectively.

CMake Integration

See also

Using bpt libraries in CMake is a significant enough use case to warrant a dedicated page. Refer: Using bpt in a CMake Project