Install binary distribution to /usr

Is there a way to install the binary distributions from https://cmake.org/download/ to /usr?

I understand that the directory structure of the binary distributions is significant and e.g. the cmake binary should not be moved from the bin folder to /usr/bin or anywhere else, as this will break all the relative paths.

So in practice this means that after extracting the binary distribution, I need to either a) use the absolute path to cmake, or b) add the extracted bin folder to my PATH.

What I would like to do is to extract the binary distribution to /usr so that it can be picked up from the default system PATH without breaking all the relative paths. Is this possible? If so, how?

I never actually recommend it, but yes, you can just extract the archive into /usr (there’s probably a top-level directory that you should skip though).

Thanks Jakub. Any reason you wouldn’t recommend it?

If I download the sources from https://cmake.org/download/ and run ./boostrap && make && sudo make install then everything gets installed system-wide (actually into /usr/local, not directly under /usr but still on the default PATH).

What I’m trying to do is to end up in the same place as make install but using the pre-built binary distributions instead of building myself. Is there something I should be aware of for why that’s not a good idea?

Simple - the system-wide directories are typically managed by your package manager. If you change something there, the package manager sometimes gets confused. It leads to file conflicts, that are resolved in different ways by different package managers… It’s a mess.

On my systems, I typically have a dedicated secondary “root” directory (/opt/root). It’s added (prepended) to PATH in /etc/profile, and this is where I install 3-party stuff for all users. I also have ~/local with the same purpose but per-user. Maybe it’s a bit paranoid, maybe not, but with this arrangement there’s much less that can break.

I agree that putting stuff in /usr can conflict with the package manager, so I suppose make install installing in /usr/local by default is a better choice, but either way, let me go back to the original question - is it supported to extract the binary distributions to a system-wide location to arrive at the same outcome as make install?

If so, I think it would be helpful to add instructions to https://cmake.org/download/ for how to do this. Or even better, add a script that extracts the binary distribution to the same location as make install. Has anyone requested this before?

AFAIK the CMake binary distribution is rather thought as “standalone” - so extract wherever you want and use.
As there’s no magic involved, there’s also no need for any scripts to do the extraction.
But… For linux there is an “installer” - use the *.sh files instead of *.tar.gz

Ok, looks like running the .sh installer in /usr/local and answering “No” to “Do you want to include the subdirectory cmake-3.24.2-linux-x86_64?” results in more or less the same outcome as make install. Some things are subtly different, for example the location of the man folder, but not sure if that makes a difference.

I still think it would be helpful to have instructions for how to install the binary distribution on the default PATH like make install.

I really don’t think that guiding people through not recommended (and potentially harmful) approach is a good idea. If you want something like that you should already be sure what you’re doing and how that may affect your system. make install (as you call it) is already something considered advanced because it involves building the software from scratch, and it’s typically recommended to use --prefix / DESTDIR and no blindly install to system directories.

I may be biased though.

Ok, thank you for the helpful info!