A fast, cross-platform backwards compatible CMake build tool for C and C++
A fast, cross-platform backwards compatible CMake build tool for C and C++
A modern C/C++ build tool with Cargo-like simplicity. cforge simplifies C/C++ project management with a clean TOML configuration, automatic dependency resolution, and cross-platform builds. It generates CMake under the hood while providing a much simpler interface.
# Install cforge
curl -fsSL https://raw.githubusercontent.com/ChaseSunstrom/cforge/master/scripts/install.sh | bash
# Create a new project (interactive prompts guide you through setup)
cforge init myapp
cd myapp
# Build and run
cforge build
cforge run
# Or skip prompts with flags
cforge init myapp --template executable --cpp 17 --with-tests --license MIT -ycforge deps add cforge migratecurl -fsSL https://raw.githubusercontent.com/ChaseSunstrom/cforge/master/scripts/install.sh | bashirm https://raw.githubusercontent.com/ChaseSunstrom/cforge/master/scripts/install.ps1 | iexgit clone https://github.com/ChaseSunstrom/cforge.git
cd cforge
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
cmake --install buildcforge completions bash >> ~/.bashrc
cforge completions zsh >> ~/.zshrc
cforge completions fish > ~/.config/fish/completions/cforge.fish
cforge completions powershell >> $PROFILEProjects are configured with a cforge.toml file:
…| Command | Description |
|---|---|
cforge init [name] |
Initialize a new project (interactive if no args given) |
cforge migrate [path] |
Import CMakeLists.txt into cforge.toml |
cforge new |
Create files from templates (class, header, interface, test) |
cforge build |
Build the project |
cforge run |
Build and run the project |
cforge clean |
Clean build artifacts |
cforge install |
Install project to system |
cforge flash |
Flash firmware to embedded target |
cforge circular |
Check for circular dependencies |
| Command | Description |
|---|---|
cforge deps add |
Add a dependency |
cforge deps remove |
Remove a dependency |
cforge deps search |
Search package registry |
cforge deps info |
Show package details |
cforge deps list |
List current dependencies |
cforge deps tree |
Visualize dependency tree (with conflict detection) |
cforge deps lock |
Manage lock file for reproducible builds |
cforge deps update |
Update package registry |
cforge deps outdated |
Show dependencies with newer versions |
| Command | Description |
|---|---|
cforge test |
Run tests |
cforge bench |
Run benchmarks |
cforge fmt |
Format code with clang-format |
cforge lint |
Static analysis with clang-tidy |
cforge doc |
Generate documentation with Doxygen |
| Command | Description |
|---|---|
cforge ide |
Generate IDE project files |
cforge watch |
Watch for changes and auto-rebuild |
cforge hot |
Hot reload session (shared library live-swapping) |
cforge package |
Create distributable packages |
cforge cache |
Manage binary cache |
cforge completions |
Generate shell completions |
| Command | Description |
|---|---|
cforge version |
Show version information |
cforge upgrade |
Upgrade cforge to the latest version |
cforge doctor |
Diagnose environment and check for required tools |
cforge help |
Show help for a command |
Running cforge init without arguments starts an interactive setup wizard with arrow-key selection:
cforge init # Interactive mode (prompts for template, standard, etc.)
cforge init myapp # Interactive, project name pre-filled
cforge init myapp -y # Accept all defaults (no prompts)
cforge init myapp --template shared-library --cpp 20 --with-tests --license Apache-2.0All flags skip their corresponding prompt. Available flags:
| Flag | Description |
|---|---|
--template |
executable, static-lib, shared-library, header-only, embedded |
--cpp |
C++ standard: 11, 14, 17, 20, 23 |
--with-tests / -t |
Include test infrastructure |
--with-git / -g |
Initialize git repository |
--license |
MIT, Apache-2.0, GPL-3.0, BSD-2-Clause, None |
-y / --yes |
Accept all defaults without prompting |
cforge init --workspace myws # Create empty workspace
cforge init --workspace myws --projects app lib # Workspace with projectscforge new class MyClass # Create MyClass.hpp and MyClass.cpp
cforge new class MyClass -n myproj # With namespace
cforge new header utils # Create utils.hpp
cforge new interface IService # Create abstract interface
cforge new test MyClass # Create test file
cforge new struct Config # Create struct header…cforge build # Build main project
cforge build -p mylib # Build specific project
cforge build --gen-workspace-cmake # Generate workspace CMakeLists.txtcforge run # Build and run
cforge run -c Release # Run release build
cforge run --no-build # Run without rebuilding
cforge run -- arg1 arg2 # Pass arguments to executable
cforge run -p myapp -- --config file # Run specific project with args[dependencies]
fmt = "11.1.4"
spdlog = "*" # Latest version
json = "3.11.2"cforge deps add fmt # Add from registry
cforge deps add fmt@11.1.4 # Specific version
cforge deps add spdlog --features async # With features
cforge deps search json # Search packages
cforge deps info nlohmann_json # Package details
cforge deps outdated # Check for updates[dependencies.git.imgui]
url = "https://github.com/ocornut/imgui.git"
tag = "v1.89.9"cforge deps add mylib --git https://github.com/user/mylib --tag v1.0[dependencies.vcpkg]
curl = { version = "7.80.0", features = ["ssl"] }cforge deps add boost --vcpkg[dependencies.system.OpenGL]
method = "find_package"
components = ["GL", "GLU"]
[dependencies.system.gtk3]
method = "pkg_config"
package = "gtk+-3.0"cforge deps lock # Generate/update lock file
cforge deps lock --verify # Verify deps match lock
cforge deps lock --force # Force regeneration
cforge deps lock --clean # Remove lock fileCommit cforge.lock to version control for reproducible builds.
cforge deps tree # Show dependency tree
cforge deps tree -a # Include all details
cforge deps tree -d 2 # Limit depth
cforge deps tree --check # Detect version conflicts (exit code 1 if found)
cforge deps tree --format dot # Graphviz DOT output
cforge deps tree --format dot | dot -Tpng -o deps.png # Generate graph imageIn workspaces, cforge deps tree also shows the inter-project dependency graph and warns about version conflicts across projects.
cforge provides portable build options that automatically translate to the correct flags for each compiler:
| Option | Values | Description |
|---|---|---|
optimize |
"none", "debug", "size", "speed", "aggressive" |
Optimization level |
warnings |
"none", "default", "all", "strict", "pedantic" |
Warning level |
debug_info |
true / false |
Include debug symbols |
sanitizers |
["address", "undefined", "thread", "leak"] |
Runtime sanitizers |
lto |
true / false |
Link-time optimization |
exceptions |
true / false |
C++ exceptions |
rtti |
true / false |
Runtime type info |
hardening |
"none", "basic", "full" |
Security hardening |
stdlib |
"default", "libc++", "libstdc++" |
Standard library |
visibility |
"default", "hidden" |
Symbol visibility |
| Portable | MSVC | GCC/Clang |
|---|---|---|
optimize = "speed" |
/O2 |
-O2 |
optimize = "size" |
/O1 /Os |
-Os |
optimize = "aggressive" |
/Ox |
-O3 |
warnings = "all" |
/W4 |
-Wall -Wextra |
warnings = "strict" |
/W4 /WX |
-Wall -Wextra -Werror |
lto = true |
/GL + /LTCG |
-flto |
debug_info = true |
/Zi |
-g |
sanitizers = ["address"] |
/fsanitize=address |
-fsanitize=address |
# Platform-specific settings
[platform.windows]
hardening = "full"
defines = ["WIN32"]
links = ["ws2_32"]
[platform.linux]
hardening = "basic"
links = ["pthread"]
[platform.macos]
stdlib = "libc++"
frameworks = ["Cocoa"]
# Compiler-specific settings
[compiler.msvc]
warnings = "strict"
defines = ["_CRT_SECURE_NO_WARNINGS"]
[compiler.gcc]
warnings = "pedantic"
[compiler.clang]
flags = ["-fcolor-diagnostics"]For multi-project repositories:
# workspace.toml or cforge.toml
[workspace]
name = "my-workspace"
projects = ["app", "lib", "tests"]
main_project = "app"cforge build # Build main project
cforge build -p lib # Build specific project
cforge build --gen-workspace-cmake # Generate workspace CMake[test]
enabled = true
framework = "catch2" # or "gtest", "doctest", "boost"cforge test # Run all tests
cforge test -c Release # Test release build
cforge test Math # Run tests in Math category
cforge test -c Release -- Math Add # Specific tests
cforge test -v # Verbose output[benchmark]
directory = "bench"
framework = "google" # google, nanobench, catch2
auto_link_project = true # Link project librarycforge bench # Run all benchmarks
cforge bench --filter 'BM_Sort' # Run matching benchmarks
cforge bench --no-build # Skip rebuild
cforge bench --json > rNo open issues yet, or sync has not completed.