Procedure for creating a command-line tool in C or C++ that includes all recommended packaging for all platforms

One reason I might want to create a command line tool in NodeJs is because I can follow simple procedure such as this:

And then I can tell people “go do npm install -g cooltool” and my cool tool is on their computer ready to be used from the command line, such as git or 7zip, place in the path and everything. And it’ll work on any computer NodeJS is on.

But I’d rather do this in C/C++. Is there a guide to do this such that one can write a simple console place application (with no dependencies), that will work on any platform. It’s okay if it’s limited to gcc and/or cmake for instance.

But what I would also like is have all the packaging “just work”, including publishing the packages in the places expected by users of the given platform. would that be apt-get? chocolatey? can it auto-create an msi or setup.exe? how about a dmg for osx?

I feel like this is a solved problem that someone must have already spent the time addressing. A programmer should be able to write a C file, compile it, and if it works, press a button and all the rest of the stuff just happens, packaging, etc.

This can perhaps even be a cloud service (I wouldn’t paying for it)