Skip to content

deform-labs/cppkg

Repository files navigation

cppkg

CMake on multiple platforms CMake Hate Uses Your Compiler Self-Hosting

Cargo-inspired package manager for C++ with absolutely no dependencies! Because manually creating src/, CMakeLists.txt, and build/ for every project is hell. also because i hate cmake.

Cross-platform, self-hosting, and with Git out of the box.

ALL COMMENTS IN THE FILES ARE ALL WRITTEN BY HUMANS!

Features

  • cppkg init — scaffold a new C++ project in seconds
  • cppkg add author/repo@version — fetch dependencies directly from GitHub
  • cppkg build — fetches dependencies,creates lock file and compiles.
  • cppkg clean — remove build artifacts and cloned dependencies
  • Workspace support — manage multiple packages under one root
  • SSH with HTTPS fallback for dependency cloning
  • Cross-platform — Windows (MSVC), Linux (GCC, Clang)

NOTE cppkg has cmakelists generation support for all cmake freaks out there

Installation

From release

Download the latest binary from Releases and add it to your PATH.

From source

git clone https://github.com/deform-labs/cppkg
cd cppkg
cmake -B build -S cppkg
cmake --build build

Add the output directory to your PATH.

Note: cppkg is self-hosting — once you have a binary, you can use cppkg build cppkg to rebuild itself.

Usage

Create a project

cppkg init my-project
cd my-project

Creates:

my-project/
├── src/
│   └── main.cpp
├── .gitignore
└── cppkg.toml

Add a dependency

cppkg add fmtlib/fmt@10.1.0
cppkg add gabime/spdlog@v1.12.0
cppkg add nlohmann/json@v3.11.2 --https
  • Format: author/repo@version
  • Validates the remote repo exists before writing to cppkg.toml
  • SSH by default, HTTPS fallback automatic (or force with --https)

Build

cppkg build          # build current directory
cppkg build my-project
  • Reads cppkg.toml for project metadata
  • Clones any missing dependencies into target/deps/
  • Compiles with your own compiler! no cmake and nothing extra is needed. use your pre-existing compiler on your computer!
  • Automatically parallel (uses all CPU cores) and cached (fast rebuilds)

Remove a dependency

cppkg remove fmtlib/fmt

Clean

cppkg clean
cppkg clean my-project

Removes target/deps/ and build artifacts.

Package manifest

[package]
name = "my-project"
version = "0.1.0"
cpp_std = "c++20"
 
[dependencies]
fmtlib/fmt = "10.1.0"
gabime/spdlog = "v1.12.0"

The key under [dependencies] is author/repo, the value is the tag or branch to clone.

Workspaces

Group multiple packages under one root.

cppkg workspace init my-workspace
cd my-workspace
cppkg init my-lib
cppkg init my-app

my-workspace/cppkg.toml:

[workspace]
members = [
    "my-lib",
    "my-app",
]

Packages initialized inside a workspace are automatically registered as members.

Project layout

please look at the source files to understand the layout.

Limitations

  • No conflict resolution for transitive dependencies

License

MIT

About

a package manager for C++ inspired by cargo!

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages