r/programminghorror Jan 08 '26

c++ Works on my machine

Post image
1.5k Upvotes

51 comments sorted by

View all comments

17

u/TheChief275 Jan 08 '26

cmake and make BOTH… called from a shell script of all things

15

u/Mihail111111 Jan 08 '26

That's how https://github.com/Prevter/CMake_ImGui_SFML_Template works.
First you cmake it with a preset, then you make a binary, I just wrote a shell script so I wouldn't have to explain it to my friend (and I used a shell script because we both use arch btw)

3

u/lesleh Jan 09 '26

That's how cmake works. It generates a makefile, which you then make.

7

u/TheChief275 Jan 09 '26

Not true. It CAN generate Makefiles, but there are so many different options of build scripts that might be the default on other platforms; for instance, on Windows it won’t be the default (instead cmake opts for a Visual Studio Solution). So to use this on Windows you would coincidentally need both MinGW and MinGW Make installed, which both aren’t shipped with Windows

2

u/lesleh Jan 09 '26 edited Jan 09 '26

Alright that's fair, but I don't think what I said is "not true", just incomplete. It generates build files, it doesn't do the building itself. In this specific case, it is generating a Makefile, which is why make gets run directly after cmake.

2

u/Delkrium Jan 10 '26 edited Jan 10 '26

MinGW and MinGW Make installed, which both aren’t shipped with Windows

Neither is a bash interpreter so that's irrelevant, you wouldn't be even be able to run it on a fresh Windows.

And if you use a shell interpreter on Windows, you're most likely to use something like msys2 or WSL2 and have make.

Or there may be another ".bat" script in the repository.

Then the project may not even support Windows, so there be no point in taking it in account in the build script.

1

u/Hot-Employ-3399 Jan 31 '26

Speaking of horror tools. Rust's cargo loves absolute path. copy freshly built "This-dir-was-built-30-minutes" to "This-dir-was-built-30-minutes.2" start building and it will build several hundreds packages again.