Skip to content

Folder structure and RTTR_*DIR config variables

Alexander Grund edited this page Nov 3, 2017 · 3 revisions

Use cases

We want to support the following use cases for running RTTR:

  1. Run from extracted archive downloaded from the website
  2. Run from installed location via CMake (possibly modified by DESTDIR)
  3. Run from build directory (for testing/debugging)
  4. Run from installed package (especially linux)
  5. Allow moving around the installation dir (especially for windows, LAN parties etc)

For this a certain folder structure is used.

CMake variables

CMake defines some variables (except for windows) which are then transferred as defines to the program. These are, with usual defaults in parentheses:

  • RTTR_BINDIR (bin): executables
  • RTTR_DATADIR (share/s25rttr): data for RTTR (language files, maps, resources)
  • RTTR_GAMEDIR (RTTR_DATADIR/S2): original game files (DATA, GFX folders)
  • RTTR_LIBDIR (lib): shared binaries
  • RTTR_DRIVERDIR (RTTR_LIBDIR/driver): audio/video driver libs
  • RTTR_DOCDIR (doc): documentation files

On windows most of them are basically "." so they are all in the same folder. On *Unix they are taken from GNUInstallDirs

Prefix path

Often all of them are relative to a path prefix which is usually the installation directory (e.g. CMAKE_INSTALL_PREFIX possibly with DESTDIR prefixed itself). This prefix path can be found by removing RTTR_BINDIR from the the full path to the executable being run which usually suffices. Optionally it is possible to overwrite this prefix path by setting the environment variable RTTR_PREFIX_DIR before starting the program.
Having found (or set) the prefix path, the program treats all directories (RTTR_*DIR) with a relative path relative to that.

However for package installs or self-build versions you can also set one or all of the variables to an absolute path by defining them. However this results in non-portable builds. Note that the prefix path on linux can also be / or /usr which still allows portable builds. Also for an absolute RTTR_BINDIR the prefix path will (almost) always be /.

Limitations

There are examples (especially involving symlinks) where the detection of the prefix path may fail. In this case one can set the environment variable manually or build with absolute paths.