Skip to content

A lightweight scaffolding tool designed to quickly generate a modern, standard C++ project structure. Available in both Bash (Linux/macOS) and Python (Cross-platform/Windows) versions, this tool automatically configures the CMake build system and prepares the environment for Neovim (LSP) development out of the box.

Notifications You must be signed in to change notification settings

csuhqf/C-Project-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ Project Generator

A lightweight scaffolding tool designed to quickly generate a modern, standard C++ project structure.

Available in both Bash (Linux/macOS) and Python (Cross-platform/Windows) versions, this tool automatically configures the CMake build system and prepares the environment for Neovim (LSP) development out of the box.

✨ Key Features

  • Standard Directory Structure: Automatically creates src, include, build, and data directories.
  • Modern CMake Configuration:
    • Defaults to C++17 standard.
    • Auto-discovery: Automatically scans src for all .cpp files (no need to manually edit CMakeLists.txt when adding files).
    • Correctly configures header file paths (target_include_directories).
  • LSP/Neovim Ready:
    • Automatically generates compile_commands.json.
    • Creates a symbolic link to the project root, ensuring clangd or ccls works immediately.
  • Code Formatting: Generates a pre-configured .clang-format file (LLVM style).

🚀 Quick Start

Choose the script that best fits your operating system.

Option 1: Bash Script (Recommended for Linux / macOS)

Fast and dependency-free for Unix-like systems.

  1. Make executable:

    chmod +x creat_c_project.sh
  2. Run the script:

    ./creat_c_project.sh MyAwesomeProject

Option 2: Python Script (Cross-platform / Windows)

Ideal for Windows users or those requiring cross-platform compatibility. It handles Windows symlink permissions gracefully (falling back to file copying if necessary).

  1. Run the script:
    python creat_c_project.py MyAwesomeProject

📂 Generated Structure

The script generates the following file tree:

MyAwesomeProject/
├── build/                  # CMake intermediate build files
├── data/                   # Data files storage
├── include/                # Header files (.h / .hpp)
├── src/                    # Source files (.cpp)
│   └── main.cpp            # Automatically generated entry point
├── .clang-format           # Code formatting rules
├── CMakeLists.txt          # Modern CMake configuration
└── compile_commands.json   # (Symlink) For LSP navigation/completion

⚙️ Detailed Features

1. Automated CMake Configuration

The generated CMakeLists.txt uses GLOB_RECURSE with CONFIGURE_DEPENDS. This means when you add new .cpp files to the src/ directory, CMake will detect them automatically during the next build—no manual file listing required.

2. LSP (Language Server Protocol) Support

Immediately after creating the directories, the script runs cmake .. in the build folder to generate compile_commands.json. It then symlinks (or copies on restricted Windows environments) this file to the project root.

This ensures that Neovim (via coc.nvim, nvim-lspconfig, etc.) or VSCode provides code completion and definition jumping immediately upon opening the project.

3. Build & Run

Once generated, you can start developing right away:

cd MyAwesomeProject

# Build
cmake --build build

# Run
./build/MyAwesomeProject             # Linux/macOS
# .\build\Debug\MyAwesomeProject.exe # Windows

📝 Requirements

  • CMake: 3.10 or higher.
  • C++ Compiler: GCC, Clang, or MSVC.
  • Python: (Only if using the Python script) Python 3.6+.

License

MIT License

About

A lightweight scaffolding tool designed to quickly generate a modern, standard C++ project structure. Available in both Bash (Linux/macOS) and Python (Cross-platform/Windows) versions, this tool automatically configures the CMake build system and prepares the environment for Neovim (LSP) development out of the box.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published