# Installation

> UStore for C

UStore builds with CMake into two libraries from one source list, each holding the in-memory engine and every engine the build enables through `USTORE_WITH_ROCKSDB`, `USTORE_WITH_LEVELDB` and `USTORE_WITH_NVME`:

- __The archive__, `ustore_static`, linked as `ustore::static` or its alias `ustore::ustore`, carries the objects of the small libraries every build needs: ForkUnion, StringZilla, yyjson and fmt.
  The storage engines' own libraries, RocksDB, LevelDB and liburing, stay archives of their own, installed beside it as `ustore::rocksdb`, `ustore::leveldb` and `ustore::uring`, which `ustore::static` links, so a CMake consumer still names one target.
  A build without CMake links those archives after `libustore_static`, or takes the shared library instead.
- __The shared library__, `ustore_shared`, linked as `ustore::shared`, links them privately and exports only the functions the headers mark `USTORE_EXPORT`, which its consumers import on Windows through the `USTORE_SHARED` definition the target hands them.

Each engine is its own object of the archive, so a program links only the engines it opens.
`USTORE_WITH_NVME` stays off until the NVMe sources are ported to this interface.

```cmake
FetchContent_Declare(
    ustore
    GIT_REPOSITORY https://github.com/unum-cloud/UStore.git
    GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(ustore)
target_link_libraries(your_target PRIVATE ustore::static)
```

Configured with `USTORE_INSTALL`, the install writes both libraries, the headers and a CMake package, which `find_package` reads:

```cmake
find_package(ustore 1.0 REQUIRED)
target_link_libraries(your_target PRIVATE ustore::shared)
```

The preview SDK is the `sdk` component alone: the stripped shared library, the C headers, the C++ wrappers, the package, a `.pc` file and the license.
`cpack --config build_release/CPackConfig.cmake` archives it as `ustore-<version>-<platform>-sdk.tar.gz`, a ZIP on Windows, and a consumer without CMake links it through `pkg-config --cflags --libs ustore`.
`cmake --install build_release --component static` adds `ustore::static` with the engines' archives, and `--component core` the header-only templates.

`c/` and `cpp/` are both include roots, so every header is spelled `<ustore/...>` in the tree and once installed, where the headers of both land side by side in one `ustore/` folder.

`#include <ustore/types.h>`

## ustore_version

Reports the version of the library the program runs against, which may differ from the macros it compiled against.

```c
void ustore_version(int *major, int *minor, int *patch);
```

- `major` (out): Output for the major version.
- `minor` (out): Output for the minor version.
- `patch` (out): Output for the patch version.

## ustore_version_name

The version of the library the program runs against as a static string, like "1.0.0".

```c
char const * ustore_version_name(void);
```

## USTORE_VERSION_MAJOR

Marks every function the library exports, and nothing else.

```c
#define USTORE_VERSION_MAJOR 1
```

On Windows it exports from the shared library, which builds with `USTORE_EXPORTING`, imports where a consumer of that library defines `USTORE_SHARED`, as linking `ustore::shared` does, and expands to nothing for the static library. GCC and Clang give the function default visibility, so it survives `-fvisibility=hidden`. The major version of UStore, which changes when the C ABI breaks.

## USTORE_VERSION_MINOR

The minor version of UStore, which changes when the C ABI gains calls.

```c
#define USTORE_VERSION_MINOR 0
```

## USTORE_VERSION_PATCH

The patch version of UStore, which changes for fixes that keep the C ABI.

```c
#define USTORE_VERSION_PATCH 0
```

