Skip to main content

Workspaces

Workspaces

Workspaces allow you to manage multiple related CForge projects together, sharing dependencies and enabling cross-project references.

Creating a Workspace

# Initialize a workspace with projects
cforge init --workspace my_workspace --projects core gui

# Or create an empty workspace
cforge init --workspace my_workspace

This generates a cforge-workspace.toml:

[workspace]
name = "my_workspace"
projects = ["core", "gui"]
default_startup_project = "core"

Workspace Structure

my_workspace/
├── cforge-workspace.toml # Workspace configuration
├── core/
│ ├── cforge.toml # Core project config
│ ├── src/
│ └── include/
└── gui/
├── cforge.toml # GUI project config
├── src/
└── include/

Workspace Commands

# Build all projects
cforge build

# Build specific project
cforge build -p gui

# List workspace projects
cforge list projects

# Show build order
cforge list build-order

# Visualize dependencies
cforge tree

Project Dependencies

Projects in a workspace can depend on each other:

# gui/cforge.toml
[dependencies.project.core]
include_dirs = ["include"]
link = true
link_type = "PRIVATE"

Dependency Options

OptionDescription
include_dirsInclude directories to expose
linkWhether to link the project library
link_typeLink visibility: PUBLIC, PRIVATE, or INTERFACE
target_nameOverride the CMake target name

Build Order

CForge automatically determines the correct build order based on project dependencies:

$ cforge list build-order

Build order for workspace 'my_workspace':
1. core
2. gui (depends on: core)

Workspace Configuration Options

[workspace]
name = "my_workspace"
projects = ["core", "gui", "tools"]
default_startup_project = "gui"

# Shared build settings
[workspace.build]
build_type = "Debug"
directory = "build"

# Shared dependencies for all projects
[workspace.dependencies.git.fmt]
url = "https://github.com/fmtlib/fmt.git"
tag = "11.1.4"

Running Projects

# Run the default startup project
cforge run

# Run a specific project
cforge run -p gui

# Set default startup project
cforge startup gui

Cleaning

# Clean all projects
cforge clean

# Clean specific project
cforge clean -p core

# Clean all build artifacts
cforge clean --all

IDE Integration

Generate IDE project files for the workspace:

# Visual Studio Code
cforge ide vscode

# CLion
cforge ide clion

# Visual Studio 2022
cforge ide vs2022