Installation Guide
This guide explains how to install the cargs library in different environments.
Quick Reference
| Method | Command | Best For |
|---|---|---|
| Package Managers | conan install libcargs/1.0.1@ |
Production use |
| From Source | meson setup .build && meson compile -C .build |
Development |
| With Just | just build |
Development workflow |
Prerequisites
cargs has only one optional dependency:
PCRE2 Dependency
PCRE2: Required only for regex validation support.
Installation Methods
Package Managers (Recommended)
Conan
# Install from Conan Center
conan install libcargs/1.0.1@
# With specific options
conan install libcargs/1.0.1@ -o libcargs:disable_regex=true
In your project's conanfile.txt:
vcpkg
# Install from vcpkg registry
vcpkg install libcargs
# Without regex support
vcpkg install libcargs[core]
In your project's vcpkg.json:
Building From Source
Using Meson
# Clone the repository
git clone https://github.com/lucocozz/cargs.git
cd cargs
# Build
meson setup .build
meson compile -C .build
# Install (requires permissions)
meson install -C .build
Using Just (Development Workflow)
Just
Just is a command runner that simplifies common tasks.
# Clone the repository
git clone https://github.com/lucocozz/cargs.git
cd cargs
# Build static and shared libraries
just build
# Install
just install
Using as a Static Library
If you prefer not to install system-wide:
- Build the project using any method above
- Copy
libcargs.ato your project - Copy the
includes/directory to your project - Link with the static library:
As a Meson Dependency
# In your meson.build
cargs_dep = dependency('cargs', version: '>=1.0.1', required: false)
# Fallback to subproject if not found system-wide
if not cargs_dep.found()
cargs_proj = subproject('cargs')
cargs_dep = cargs_proj.get_variable('cargs_dep')
endif
Configuration Options
Disabling Regex Support
If you don't need regex validation, you can build without the PCRE2 dependency:
When regex support is disabled:
- No PCRE2 dependency is required
- The REGEX() validator becomes a non-functional stub
- All predefined patterns in cargs/regex.h are defined but won't work
- The CARGS_NO_REGEX macro is defined for conditional compilation
Performance Optimization
For production deployments, enable release mode to skip validation during initialization: