# Integrating the fson Library Into Your Project
The fson project produces two shared libraries — `libfson` and its parsing
core `libcparse` — plus the public headers under `include/fson/` and
`include/cparse/`, a pkg-config file, and the `fson-check` command-line
tool. Your code links **both** libraries: the fson public headers expose
cparse types such as `fedem::parser::ParseError`.
## Building fson from source
Requirements: CMake ≥ 3.20 and a C++23 compiler (GCC 12+ works; the
*public API* of the library only requires C++17 from your side).
GoogleTest is optional and only needed for the test targets.
```sh
git clone --recurse-submodules <repository-url> fson
cd fson
cmake -B build
cmake --build build
ctest --test-dir build # optional
cmake --install build # installs libraries, headers, fson.pc, fson-check
```
`--recurse-submodules` matters: `libs/external/cparse` is a git submodule.
## Consuming an installed fson
### With pkg-config
The installed `fson.pc` carries everything:
```sh
g++ -std=c++17 main.cpp $(pkg-config --cflags --libs fson) -o app
```
`Libs` already contains `-lfson -lcparse`.
### With CMake
```cmake
find_package( PkgConfig REQUIRED )
pkg_check_modules( FSON REQUIRED IMPORTED_TARGET fson )
add_executable( app main.cpp )
target_link_libraries( app PkgConfig::FSON )
```
### Manually
```cmake
target_include_directories( app PRIVATE /usr/local/include )
target_link_libraries( app fson cparse )
```
Include headers with the `fson/` prefix:
```cpp
#include "fson/Fson.hh"
```
## Embedding fson as a subproject
If you vendor the fson tree (e.g. as a git submodule of your own project),
add it and link the target directly:
```cmake
add_subdirectory( third_party/fson )
add_executable( app main.cpp )
target_include_directories( app PRIVATE
third_party/fson/libs/internal/sdk
third_party/fson/libs/external/cparse/src )
target_link_libraries( app fson cparse )
```
## Binary packages
`cpack` run in the build directory produces component-based packages for
7Z, TGZ, ZIP, DEB and RPM:
- **Runtime** — `libfson.so.*`, `libcparse.so.*` and the `fson-check` tool;
what end-user machines need.
- **DEVELOPMENT** — headers, the unversioned `.so` namelinks and `fson.pc`;
what build machines need (depends on Runtime).
```sh
cd build
cpack # all configured generators
cpack -G DEB # just one
```