Modern C++ project generator with CMake, package managers, IDE configurations and development tools.
- About
- Installation
- Usage
- What is generated
- Options and flags
- Project structure
- Development
- Internal architecture
- License
cpp-gen is a CLI tool written in Go that automates the creation of modern C++ projects,
eliminating the time spent on the initial configuration of:
- CMake hierarchical with best practices (CMake 3.20+, CMakePresets.json)
- Package managers: VCPKG (manifest mode) or native FetchContent
- IDEs: Visual Studio Code, CLion or Neovim with complete configurations
- Quality tools: Clangd LSP, Clang-Format, warning flags
- Git: initialized repository, comprehensive
.gitignoreand README
# With yay
yay -S cpp-gen-bin
# With paru
paru -S cpp-gen-binbrew tap matpdev/tap
brew install cpp-genDownload the latest pre-compiled binary from GitHub Releases:
# Linux x86_64
curl -LO https://github.com/matpdev/cpp-gen/releases/latest/download/cpp-gen_linux_amd64.tar.gz
tar -xzf cpp-gen_linux_amd64.tar.gz
install -m755 cpp-gen ~/.local/bin/
# Verify checksum
sha256sum -c checksums.txtgo install github.com/matpdev/cpp-gen@latestgit clone https://github.com/matpdev/cpp-gen.git
cd cpp-gen
go mod tidy
go build -o cpp-gen .# Opens the step-by-step TUI form
cpp-gen new
# With pre-filled name
cpp-gen new meu-projetoThe form guides you through all the options:
β‘ cpp-gen v0.1.0
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Modern CMake project structure (3.20+)
β Package managers: VCPKG or FetchContent
β Configurations for VSCode, CLion and Neovim
β Git, .gitignore and README ready
β Clangd and Clang-Format pre-configured
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
Usage: cpp-gen new [project-name]
cpp-gen new meu-projeto \
--no-interactive \
--description "My C++ application" \
--author "John Doe" \
--std 20 \
--type executable \
--pkg vcpkg \
--ide vscode# Display version
cpp-gen version
# General help
cpp-gen --help
# Help for the new subcommand
cpp-gen new --helpmeu-projeto/
βββ CMakeLists.txt β Main CMake configuration
βββ CMakePresets.json β debug/release/sanitize/vcpkg presets
βββ vcpkg.json β VCPKG dependencies (manifest mode)
βββ vcpkg-configuration.json β Version baseline (reproducible builds)
βββ README.md β Generated project README
βββ .gitignore β Comprehensive C++/CMake/IDE patterns
βββ .clangd β LSP configuration (compile_commands.json)
βββ .clang-format β Formatting rules (LLVM-based)
β
βββ cmake/
β βββ CompilerWarnings.cmake β Warning flags (GCC/Clang/MSVC)
β βββ Vcpkg.cmake β VCPKG integration helper module
β βββ Dependencies.cmake β (if FetchContent) declared dependencies
β
βββ src/
β βββ CMakeLists.txt β add_executable() or add_library() target
β βββ main.cpp β Initial source code
β
βββ include/
β βββ meu-projeto/ β Public headers (include namespace)
β
βββ tests/
β βββ CMakeLists.txt β Test target with CTest
β βββ test_main.cpp β Initial tests with CHECK() macro
β
βββ docs/ β Documentation (empty, ready for Doxygen)
β
βββ .vscode/
βββ tasks.json β Configure, Build, Clean, Test, Format
βββ launch.json β Debug with CodeLLDB and cppdbg/GDB
βββ settings.json β Clangd, CMake Tools, automatic formatting
βββ extensions.json β Recommended extensions
βββ c_cpp_properties.json β IntelliSense fallback
| Configure Preset | Description |
|---|---|
debug |
Debug with full symbols |
release |
Release with optimizations, no tests |
release-with-debug |
RelWithDebInfo (profiling) |
sanitize |
Debug + AddressSanitizer + UBSanitizer |
vcpkg-debug |
Debug with VCPKG toolchain (if VCPKG selected) |
vcpkg-release |
Release with VCPKG (if VCPKG selected) |
# List all presets
cmake --list-presets
# Quick build
cmake --preset debug
cmake --build --preset build-debug
ctest --preset test-debug --output-on-failure| Flag | Default | Description |
|---|---|---|
--output, -o |
. |
Directory where the project folder will be created |
--no-interactive, -n |
false |
Disables the TUI; uses only the flags below |
--name |
β | Project name (alternative to the positional argument) |
--description |
β | Brief project description |
--author |
β | Author or organization name |
--version |
1.0.0 |
Initial version (SemVer) |
--std |
20 |
C++ standard: 17 | 20 | 23 |
--type |
executable |
executable | static-lib | header-only |
--pkg |
none |
none | vcpkg | fetchcontent |
--ide |
none |
none | vscode | clion | nvim |
--no-git |
false |
Do not initialize a Git repository |
--no-clangd |
false |
Do not generate .clangd |
--no-clang-format |
false |
Do not generate .clang-format |
| Flag | Description |
|---|---|
--verbose, -v |
Displays each file generated during the process |
--help, -h |
Displays command help |
cpp-gen/
βββ main.go β Entry point
βββ go.mod β Go module and dependencies
β
βββ cmd/
β βββ root.go β Root command (banner, version)
β βββ new.go β `new` subcommand (flags, handler, TUI)
β
βββ internal/
βββ config/
β βββ config.go β Enumerated types and ProjectConfig
β
βββ tui/
β βββ form.go β Interactive form (charmbracelet/huh)
β βββ styles.go β lipgloss styles (colors, layout)
β
βββ generator/
βββ generator.go β Orchestrator, TemplateData, utilities
βββ structure.go β Folder structure and initial C++ files
βββ cmake.go β CMakeLists.txt, CMakePresets.json, helpers
βββ git.go β Git init, .gitignore, README.md
βββ clang.go β .clangd, .clang-format
β
βββ ide/
β βββ ide.go β Data interface, public functions, utilities
β βββ vscode.go β tasks.json, launch.json, settings, extensions
β βββ clion.go β .idea/, cmake.xml, run configs, .nvim.lua
β
βββ packages/
βββ vcpkg.go β vcpkg.json, vcpkg-configuration.json, Vcpkg.cmake
βββ fetchcontent.go β cmake/Dependencies.cmake with commented examples
main()
βββ cmd.Execute()
βββ newCmd.RunE (cmd/new.go)
βββ tui.RunForm() β interactive form
βββ cfg.Validate()
βββ printProjectSummary()
βββ generator.New(cfg).Generate()
βββ generateStructure() β src/, include/, tests/, docs/
βββ generateCMake() β CMakeLists.txt, presets, helpers
βββ runPackages() β vcpkg.json | Dependencies.cmake
βββ runIDE() β .vscode/ | .idea/ | .nvim.lua
βββ generateClang() β .clangd | .clang-format
βββ generateGit() β .gitignore | README.md | git init
git clone https://github.com/matpdev/cpp-gen.git
cd cpp-gen
go mod tidygo run . new meu-projetogo build -o cpp-gen .
./cpp-gen new --helpgo test ./...
go test ./... -v # verbose
go test ./... -count=1 # disable test cachego vet ./...
# With golangci-lint installed:
golangci-lint run| Package | Version | Usage |
|---|---|---|
github.com/spf13/cobra |
v1.8.1 | CLI framework (commands and flags) |
github.com/charmbracelet/huh |
v0.6.0 | Interactive TUI forms |
github.com/charmbracelet/lipgloss |
v1.0.0 | Terminal styles and colors |
| Package | Responsibility |
|---|---|
cmd |
CLI interface: flag parsing, validation, orchestration |
internal/config |
Pure data types, no I/O logic |
internal/tui |
Interactive user interface (no generation logic) |
internal/generator |
All file generation logic |
internal/generator/ide |
IDE-specific configurations (isolated per IDE) |
internal/generator/packages |
Package manager configurations (isolated per pkg) |
- Create
internal/generator/ide/myide.gowith thegenerateMyIDE()function - Add the
IDEMyIDEconstant ininternal/config/config.go - Add the option in the TUI form in
internal/tui/form.go - Add the case in
generator.runIDE()ininternal/generator/generator.go - Add the parser in
cmd/new.goinparseIDE()
- Create
internal/generator/packages/mypkg.gowithGenerateMyPkg() - Add the
PkgMyPkgconstant ininternal/config/config.go - Add the case in the TUI form and in
generator.runPackages()
- Fork the repository
- Create a branch:
git checkout -b feature/my-feature - Commit:
git commit -m 'feat: add support for XYZ' - Push:
git push origin feature/my-feature - Open a Pull Request
feat:β new featurefix:β bug fixdocs:β documentationrefactor:β refactoring without behavior changetest:β adding or fixing testschore:β maintenance tasks
MIT Β© 2025 β See LICENSE for details.
Made with β€οΈ and Go.