Top
Best
New

Posted by randerson_112 6 hours ago

Show HN: I built a Cargo-like build tool for C/C++(github.com)
I love C and C++, but setting up projects can sometimes be a pain.

Every time I wanted to start something new I'd spend the first hour writing CMakeLists.txt, figuring out find_package, copying boilerplate from my last project, and googling why my library isn't linking. By the time the project was actually set up I'd lost all momentum.

So, I built Craft - a lightweight build and workflow tool for C and C++. Instead of writing CMake, your project configuration goes in a simple craft.toml:

  [project]
  name = "my_app"
  version = "0.1.0"
  language = "c"
  c_standard = 99

  [build]
  type = "executable"
Run craft build and Craft generates the CMakeLists.txt automatically and builds your project. Want to add dependencies? That's just a simple command:

  craft add --git https://github.com/raysan5/raylib --links raylib
  craft add --path ../my_library
  craft add sfml
Craft will clone the dependency, regenerate the CMake, and rebuild your project for you.

Other Craft features: craft init - adopt an existing C/C++ project into Craft or initialize an empty directory. craft template - save any project structure as a template to be initialized later. craft gen - generate header and source files with starter boilerplate code. craft upgrade - keeps itself up to date.

CMakeLists.extra.cmake for anything that Craft does not yet handle.

Cross platform - macOS, Linux, Windows.

It is still early (I just got it to v1.0.0) but I am excited to be able to share it and keep improving it.

Would love feedback. Please also feel free to make pull requests if you want to help with development!

97 points | 86 commentspage 3
forrestthewoods 3 hours ago|
Cmake is infamously not a build system. It is a build system generator.

This is now a build system generator generator. This is the wrong solution imho. The right solution is to just build a build system that doesn’t suck. Cmake sucks. Generating suck is the wrong angle imho.

mutkach 5 hours ago||
Please consider adding `cargo watch` - that would be a killer feature!
randerson_112 4 hours ago|
Yes! This is definitely on the list of features to add. Thank you for the feedback!
duped 6 hours ago||
FWIW: there is something fundamentally wrong with a meta-meta build system. I don't think you should bother generating or wrapping CMake, you should be replacing it.
flohofwoe 6 hours ago||
Cmake is doing a lot of underappreciated work under the hood that would be very hard to replicate in another tool, tons of accumulated workarounds for all the different host operating systems, compiler toolchains and IDEs, it's also one of few build tools which properly support Windows and Visual Studio.

Just alone reverse engineering the Xcode and Visual Studio project file formats for each IDE version isn't fun, but this "boring" grunt work is what makes cmake so valuable.

The core ideas of cmake are sound, it's only the scripting language that sucks.

SleepyMyroslav 5 hours ago|||
Another fresh example of what you don't like: https://www.youtube.com/watch?v=ExSlx0vBMXo Building C++: It Doesn't Have to be Painful! - Nicole Mazzuca - Meeting C++ 2025

Build systems don't plan to converge in the future =)

SpaceNoodled 6 hours ago||
My thoughts exactly. I thought this was going to be some new thing, but it's just yet another reason that I'll stick with Makefiles.
flohofwoe 5 hours ago||
Do your Makefiles work across Linux, macOS and Windows (without WSL or MingW), GCC, Clang and MSVC, or allow loading the project into an IDE like Xcode or Visual Studio though? That's why meta-build-systems like cmake were created, not to be a better GNU Make.
uecker 5 hours ago||
There is something fundamentally wrong with Windows or Visual Studio that it requires ugly solutions.
delta_p_delta_x 5 hours ago|||
Windows and Visual Studio solutions are perfectly fine. MSBuild is a declarative build syntax in XML, it's not very different from a makefile.
uecker 5 hours ago||
XML is already terrible. But the main problem seems to be that they created something similar but incompatible to make.
flohofwoe 4 hours ago|||
Ok, then just cl.exe instead of gcc or clang. Completely different set of command line options from gcc and clang, but that's fine. C/C++ build tooling needs to be able to deal with different toolchains. The diversity of C/C++ toolchains is a strength, not a weakness :)

One nice feature of MSVC is that you can describe the linker dependencies in the source files (via #pragma comment(lib, ...)), this enables building fairly complex single-file tools trivially without a build system like this:

   cl mytool.c
...without having to specify system dependencies like kernel32 etc... on the cmdline.
einpoklum 3 hours ago||
Impression before actually trying this:

CMake is a combination of a warthog of a specification language, and mechanisms for handling a zillion idiosyncracies and corners cases of everything.

I doubt than < 10,000 lines of C code can cover much of that.

I am also doubtful that developers are able to express the exact relations and semantic nuances they want to, as opposed to some default that may make sense for many projects, but not all.

Still - if it helps people get started on simpler or more straightforward projects - that's neat :-)

spwa4 6 hours ago||
Just switch to bazel, copy my hermetic build config and just use it ... yes, you can hate me know.
mc-serious 6 hours ago||
[dead]
shevy-java 5 hours ago||
Will take C only 51 years to adopt.
kjksf 5 hours ago|
In the age of AI tools like this are pointless. Especially new ones, given existence of make, cmake, premake and a bunch of others.

C++ build system, at the core, boils down to calling gcc foo.c -o foo.obj / link foo.obj foo.exe (please forgive if I got they syntax wrong).

Sure, you have more .c files, and you pass some flags but that's the core.

I've recently started a new C++ program from scratch.

What build system did I write?

I didn't. I told Claude:

"Write a bun typescript script build.ts that compiles the .cpp files with cl and creates foo.exe. Create release and debug builds, trigger release build with -release cmd-line flag".

And it did it in minutes and it worked. And I can expand it with similar instructions. I can ask for release build with all the sanitize flags and claude will add it.

The particulars don't matter. I could have asked for a makefile, or cmake file or ninja or a script written in python or in ruby or in Go or in rust. I just like using bun for scripting.

The point is that in the past I tried to learn cmake and good lord, it's days spent learning something that I'll spent 1 hr using.

It just doesn't make sense to learn any of those tools given that claude can give me working any build system in minutes.

It makes even less sense to create new build tools. Even if you create the most amazing tool, I would still choose spending a minute asking claude than spending days learning arbitrary syntax of a new tool.

randerson_112 4 hours ago||
This is a fair and valid point. However, why leave your workflow to write a prompt to an AI when you can run simple commands in your workspace. Also you are most likely paying to use the AI while Craft is free and open source and will only continue to improve. I respect your feedback though, thank you!
duped 5 hours ago||
You're missing finding library/include paths, build configuration (`-D` flags for conditional compilation), fetching these from remote repositories, and versioning.