Created by: OPNA2608
Fixes #786 (closed).
Problems:
- CMake supports setting an installation prefix, but the convenience resource linking ignores it and hardcodes
/usr/share
instead - The resource linking uses
lstat
to determine if a link already exists.lstat
gives details about the link itself, not what it links to -stat
will follow symlinks to give details about their targets. It can happen that the link target stops existing at some point (e.g. reinstallation to new directory) which leads to invalid symlinks. These can produce cryptic errors for users.
Solutions:
- Hardcode the CMake data prefix's (
CMAKE_INSTALL_DATAROOTDIR
) absolute path variant instead of/usr/share
. Its default value isshare
relative toCMAKE_INSTALL_PREFIX
, so it should evaluate to the same path with the default prefix of OpenXRay. - Use
stat
instead oflstat
to determine if a link is needed. Ifstat
fails, start preparing the resource linking. We then checklstat
next to determine if an invalid link already exists (link path exists, but what it links to doesn't) - unlink it if it does. Lastly we make a new link to the resource.