r/cpp • u/000nan000 • May 20 '26
I wrote a dumb bash script to scaffold C++23 Modules + CMake + LSP (SDL/Raylib) in 2 seconds
Got tired of writing CMake boilerplates and fighting clangd every time I wanted to test a C++23 module or pop a Raylib window. So I wrote startcpp.
It’s just a single bash script. No Python, no vcpkg/conan bloat, no 50-file template structures.
What it actually sets up:
- Generates a CMake config with
FILE_SET CXX_MODULESand drops<iostream>for<print>. - Forces
CMAKE_EXPORT_COMPILE_COMMANDSand symlinks it to root. Neovim/clangd picks it up instantly. - Dependency pipeline for
--raylib,--sdl2or--sdl3: triesfind_packagefirst for system binaries. Silently falls back to CPM (FetchContent) to pull the github tag if you don't have it installed locally. - Injects
ccacheand defaults to Ninja.
Usage: startcpp test_proj --raylib ninja -C build
There's a quick video in the README showing the setup.
11
Upvotes
11
u/No-Dentist-1645 May 21 '26
Since you're already using modules, you should consider using
import std;instead of including all stdlib headersThat being said, if I wanted to "bootstrap" a simple C++ project, I would much rather just have a "template" git repository that I can just
git cloneto somewhere and start from there7
u/Supadoplex May 21 '26
Nice. So, now you have a script to generate a config for cmake to generate a config for the build system to generate the compile commands to compile the sources to assemble them into an executable to run the program.
1
u/enl1l May 28 '26
c++ modules is dead simple with xmake, this is all you need to get a simple raylib project up and running with clang.
xmake.lua
src/main.cpp
Then just add whatever modules/cpp files under src/**, and off you go..
1
u/simplex5d May 21 '26
Hi! It would be cool if you could optionally generate a pcons build script (I'm the author, so AMA). I just added full module support including
import std;. I know cmake is popular but IMHO pcons is nicer, simpler and more maintainable.