Skip to main content

Quick Start

Get up and running with CForge in minutes.

Creating a New Project

# Create a new project in the current directory
cforge init my_project
cd my_project

# Or create in current directory
mkdir my_project && cd my_project
cforge init

Project Templates

# Executable (default)
cforge init --template exe

# Static or shared library
cforge init --template lib

# Header-only library
cforge init --template header-only

# With tests enabled
cforge init --with-tests

# Specific C++ standard
cforge init --cpp=20

Project Structure

After cforge init, you'll have:

my_project/
├── cforge.toml # Project configuration
├── src/
│ └── main.cpp # Main source file
├── include/ # Header files
└── build/ # Build output (generated)

Configuration File

cforge.toml:

[project]
name = "my_project"
version = "1.0.0"
type = "executable"
cpp_standard = "17"

[build]
source_dir = "src"
include_dir = "include"

Build & Run

# Build in Debug mode (default)
cforge build

# Build in Release mode
cforge build --config Release

Output:

   Compiling my_project v1.0.0
Compiling src/main.cpp
Finished Debug target(s) in 0.84s
# Run the executable
cforge run

Output:

     Running my_project
Hello, cforge!

Adding Dependencies

Edit cforge.toml to add dependencies:

[dependencies]
fmt = { version = "10.1.0", source = "vcpkg" }
spdlog = { version = "1.12.0", source = "vcpkg" }

Or use the CLI:

cforge add fmt
cforge add spdlog

Then rebuild:

cforge build

CForge will automatically install dependencies via vcpkg.

Running Tests

# Run all tests
cforge test

# Run with filter
cforge test --filter "Unit*"

Developer Workflow

Watch Mode

Auto-rebuild on file changes:

# Watch and rebuild
cforge watch

# Watch, rebuild, and run
cforge watch --run

Code Formatting

# Format all source files
cforge fmt

# Check formatting without modifying
cforge fmt --check

Static Analysis

# Run clang-tidy
cforge lint

# Auto-fix issues
cforge lint --fix

IDE Setup

Generate IDE project files:

# VS Code
cforge ide vscode

# CLion
cforge ide clion

# Visual Studio
cforge ide vs

Next Steps