How to properly strip release binaries


I would like that my application binaries were stripped in the release builds. My application currently builds for Linux, Windows, MacOS and Android. What’s the proper CMake way of doing this?

The Unix Makefiles and Ninja generators provide install/strip targets to do this. I don’t think there’s a general mechanism though.

But is it possible to do it without installing?

The only way I found so far was kinda specific to gcc I think. I wanted some way that simply was set and forget for everything possible.

No, CMake provides no “strip binaries” abstraction other than through the install on those generators. The closest you can get is to use the Release build otherwise.

What does “stripping binaries” even mean?

It is usually a process which removes debug info and symbols from binaries to make them smaller. Other details may also be tweaked, but it’s largely a “cleanse debugging info” process.