jrl-umi3218 / jrl-cmakemodules

CMake utility toolbox
https://jrl-cmakemodules.readthedocs.io/en/master/
Other
59 stars 46 forks source link

Remove empty folders when doing make uninstall #292

Open gabrielebndn opened 4 years ago

gabrielebndn commented 4 years ago

When doing make uninstall only the files are removed, but the folders are left there, even if they are empty. This leaves the system with a lot of empty folders. I think this should be changed and the empty folders should be removed. A test should be performed to check whether the folder is empty: if it is empty, it is silently removed; if it is not, a warning should be issued saying "cannot remove folder blah blah blah because it is not empty". This is analogous to what apt does. Ideally, make install followed by make uninstall should leave the system in the exact same state as it was before

jcarpent commented 4 years ago

You're partially right I would say. This indeed annoying to have remaining empty folders left when uninstalling applications. BUT, some applications (e.g. CppAD and CppADCodeGen) use the same installation folder (cppad) for the installation. In other words, we cannot remove some folders when some other applications are still in place. Normally, the uninstallation of a package is taken in charge by the package manager (such as apt, brew, etc.), which does the job in your back.

gabrielebndn commented 4 years ago

@jcarpent exactly. That is why I say make uninstall should check whether the folder is empty. If it is not, clearly it will be left there; but if it is not, I see no reason not to remove it. This is exactly what APT does. In other words, the workflow should be: