A simple CLI tool that sets up a modern C++ project with CMake, similar to how cargo new
works for Rust projects.
I get confused when I open an IDE, simple as. I just want to be able to create a C++ project quickly and get going, but I'm also terrible at remembering all the commands, arguments and flags to create things like .clang-format, compile-commands.json and others in order to have a pleasant experience in [your favorite terminal text editor].
- Creates a basic C++ project structure with src/, include/, and lib/ directories
- Generates CMake configuration with modern C++23 defaults
- Automatically detects and uses CMake version and preferred generator (Ninja if available)
- Includes debug and release build presets
- Sets up clangd support via compile_commands.json
- Configures .clang-format for consistent code style
- Provides platform-specific run scripts (run.ps1/run.sh)
- Initializes git repository with sensible .gitignore
git clone https://github.com/definitelynico/mfs-cpp-starter.git
cd mfs-cpp-starter
dotnet publish -c Release -r win-x64
The compiled executable will be in bin/Release/net9.0/win-x64/publish/
.
There are two ways to create a new project:
mfs-cpp-starter init [project-name]
If project name is not provided, the current directory name will be used.
mfs-cpp-starter <project-path> [project-name]
If project name is not provided, the directory name will be used.
# Initialize in current directory
mfs-cpp-starter init my-project
# Create new project in a new directory
mfs-cpp-starter path/to/new-project
# Create new project with custom name
mfs-cpp-starter path/to/directory custom-name
my-project/
├── src/
│ └── main.cpp
├── include/
├── lib/
├── build/
├── CMakeLists.txt
├── CMakePresets.json
├── .clang-format
├── .clangd
├── .gitignore
└── run.ps1/run.sh # Platform-specific run script
After creating a project, you can build and run it using the provided script:
# On Windows
./run.ps1
# On Linux/macOS
./run.sh
These scripts will:
- Configure CMake if not already done
- Build the project using the debug preset
- Run the executable
Alternatively, you can manually build using:
# Debug build (outputs compile_commands.json)
cmake --preset debug
cmake --build --preset debug
# Release build
cmake --preset release
cmake --build --preset release
- .NET 6.0 or later
- CMake 3.20 or later
- A C++ compiler (GCC, Clang, or MSVC)
- Git
- Ninja (optional, but recommended)