Skip to content

y-scope/ystdlib-cpp

Repository files navigation

ystdlib

An open-source C++ library developed and used at YScope.

Usage

First, build and install ystdlib onto your system. Then, in your project's CMakeLists.txt, add the following:

find_package(ystdlib REQUIRED)
target_link_libraries(<target_name>
    [<link-options>]
    ystdlib::<lib_1>
    [ystdlib::<lib_2> ... ystdlib::<lib_N>]
)

Where

  • <target_name> is the name of your target.
  • <link-options> are the link options for your target.
  • lib_1, lib_2, ..., lib_N are the names of the ystdlib libraries you wish to link with your target.

Note

If BUILD_TESTING is ON, set ystdlib_BUILD_TESTING to OFF to skip building ystdlib's unit tests.

Tip

If ystdlib is not installed to a path that is searched by default, set ystdlib_ROOT to manually specify the location:

set(ystdlib_ROOT "<PATH_TO_INSTALLATION>")

Contributing

Follow the steps below to develop and contribute to the project.

Requirements

  • CMake 3.23 or higher
  • Python 3.10 or higher
  • Task 3.40.0 or higher

Set up

Initialize and update submodules:

git submodule update --init --recursive

If you want to open the project in an IDE, run the following command to install any necessary dependencies from source:

task deps:install-all

Building

The library can be built directly using CMake or indirectly using Task.

Using Task

To build all targets:

task build:all

To build an executable containing all unit tests:

task build:unit-test-all

To build an executable containing a single library's unit tests:

task build:unit-test-<lib_name>

Using CMake

To build all libraries, run:

cmake -S . -B ./build
cmake --build ./build

To build a subset of libraries, set the variable ystdlib_LIBRARIES to a semicolon-separated (;) list of library names. The library names match their directory name in src/. For example:

cmake -S . -B ./build -Dystdlib_LIBRARIES="containers;io_interface"
cmake --build ./build

Note

Internal dependencies of the libraries you choose will be automatically built, even if you don't explicitly specify them. In the example, specifying io_interface automatically adds wrapped_facade_headers to the build.

Installing

After building, install with:

cmake --install "./build" --prefix "$HOME/.local"

Testing

To build and run all unit tests:

task test-all

To build and run unit tests for a specific library:

task test-<lib_name>

When generating a testing target, the CMake variable BUILD_TESTING is followed (unless overruled by setting ystdlib_BUILD_TESTING to false). By default, if built as a top-level project, BUILD_TESTING is set to true and unit tests are built.

Linting

Before submitting a pull request, ensure you’ve run the linting commands below and have fixed all violations and suppressed all warnings.

To run all linting checks:

task lint:check

To run all linting checks AND fix some violations:

task lint:fix

To see how to run a subset of linters for a specific file type:

task -a

Look for all tasks under the lint namespace (identified by the lint: prefix).

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6