Skip to main content

The missing CMake project initializer

Project description

cmake-init

🚀 Generate modern CMake projects with best practices built-in

Powered by UV - the fast Python package manager.


Quick Start

# 1. Install UV
curl -LsSf https://astral.sh/uv/install.sh | sh

# 2. Clone & Setup
git clone https://github.com/Guo-astro/cmake-start.git
cd cmake-start
./tasks.sh setup

# 3. Create a project
uv run cmake-init my-project

# 4. Build it
cd my-project
cmake --preset=dev
cmake --build --preset=dev

Usage

# C++ executable (default)
uv run cmake-init my-app

# C++ library
uv run cmake-init -s my-lib

# C++ header-only library
uv run cmake-init -h my-headers

# C project
uv run cmake-init --c my-c-app

# C++20 standard
uv run cmake-init --std 20 my-modern-app

# With Conan/vcpkg
uv run cmake-init -p conan my-app

Important: Project names must be lowercase (e.g., my-project, not MyProject)


Installing Code Quality Tools (Optional)

These tools are auto-detected - your project will build fine without them, but they provide extra code checking:

clang-tidy

# macOS
brew install llvm

# Ubuntu/Debian
sudo apt install clang-tidy

# Fedora
sudo dnf install clang-tools-extra

# NixOS
nix-env -iA nixpkgs.clang-tools

# Windows
choco install llvm

cppcheck

# macOS
brew install cppcheck

# Ubuntu/Debian
sudo apt install cppcheck

# Fedora
sudo dnf install cppcheck

# NixOS
nix-env -iA nixpkgs.cppcheck

# Windows
choco install cppcheck

When you run cmake --preset=dev, you'll see:

-- Found clang-tidy: /path/to/clang-tidy
-- Found cppcheck: /path/to/cppcheck
-- Code quality tools status:
--   clang-tidy: ON
--   cppcheck:   ON

If tools aren't found, they're automatically disabled with installation instructions.


Development

Project Structure

cmake-start/
├── cmake-init/              ← Edit these files
│   ├── cmake_init.py       
│   ├── template.py         
│   └── templates/          
│
├── src/cmake_init_lib/     ← Auto-generated (don't edit)
│   ├── cmake_init.py       
│   ├── template.py         
│   └── cmake-init.zip      
│
└── build.py                ← Builds everything

Making Changes

# 1. Edit source files
vim cmake-init/cmake_init.py
vim cmake-init/templates/common/cmake/code-quality.cmake

# 2. Rebuild (copies files + creates template ZIP)
python build.py

# 3. Test
uv run cmake-init test-project

Single source of truth: Always edit files in cmake-init/, then run python build.py


Common Issues

"ModuleNotFoundError"

./fix-editable.sh

"Changes not working"

python build.py  # Run after editing cmake-init/

"Invalid project name"

# Bad:  uv run cmake-init MyProject
# Good: uv run cmake-init my-project

NixOS build errors

export CXX=clang++
cmake --preset=dev

Commands Reference

Command Description
uv run cmake-init my-app Create C++ executable
uv run cmake-init -s my-lib Create C++ library
uv run cmake-init -h my-headers Create header-only library
uv run cmake-init --c my-c-app Create C project
uv run cmake-init --std 20 my-app Use C++20
uv run cmake-init -p conan my-app Use Conan package manager
uv run cmake-init --version Show version
python build.py Build after editing templates
python release.py patch Release new version to PyPI
./tasks.sh setup Initial setup
./fix-editable.sh Fix import errors

Releasing to PyPI

One command release:

# Option 1: Automatic (commits everything first)
./quick-release.sh patch  # 1.0.1 → 1.0.2

# Option 2: Manual (requires clean git)
python release.py patch   # 1.0.1 → 1.0.2

The script automates:

  • ✅ Version bump in pyproject.toml
  • ✅ Template archive build (build.py)
  • ✅ Wheel + source distribution build
  • ✅ Git commit & tag
  • ✅ PyPI upload
  • ✅ GitHub push

First time setup:

# Get PyPI token: https://pypi.org/manage/account/token/
export PYPI_TOKEN='pypi-...'
# OR configure ~/.pypirc (see .pypirc.example)

See RELEASE.md for detailed documentation.


What Makes This Different?

Auto-detects clang-tidy and cppcheck - no build failures
Latest vcpkg - automatically fetches current baseline hash
Fast - powered by UV (10-100x faster than pip)
Modern - CMake presets, FetchContent-ready
Developer-friendly - helpful error messages
Cross-platform - macOS, Linux, Windows, NixOS
Single source - edit cmake-init/, run build.py


Links


Made with ❤️ for developers who hate boilerplate

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmake_start-1.0.4.tar.gz (94.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmake_start-1.0.4-py3-none-any.whl (58.0 kB view details)

Uploaded Python 3

File details

Details for the file cmake_start-1.0.4.tar.gz.

File metadata

  • Download URL: cmake_start-1.0.4.tar.gz
  • Upload date:
  • Size: 94.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for cmake_start-1.0.4.tar.gz
Algorithm Hash digest
SHA256 9e31d2d8d1c43a7d9bb8ec559e44e9f20ffdee02aa029af517e009c606d1dcb3
MD5 fc8896d9192596ee6a370648f2ef6c5c
BLAKE2b-256 d0ef4c3ab5d891a4748411bda7c2d1397b393a1b89fac1b10942cb29a15ed986

See more details on using hashes here.

File details

Details for the file cmake_start-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for cmake_start-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0bbbc7393e9c678946b23b7ab2f19da1966e3a1a617bcb4798113a69bd7c9ff3
MD5 dc3782ee8fb0ee45b54cfa5366758b93
BLAKE2b-256 97509a77923494e44edcdc0716f122ee97cfa11bb479c54a79c1f996c0959757

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page