We work on the 'develop' branch.
Get the source code plus the data (which is a git submodule), plus other submodules:
git clone --recurse-submodules https://github.com/MegaGlest/megaglest-source
If you have already cloned the source repository:
git submodule update --init --recursive
Later when you want to update, you can use git pull --recurse-submodules
to
update the repo and all its submodules.
Note
The source code from the latest release (v3.13.0) was issued in 2017 and will not build with gcc >= 10 and may not build on modern systems for other reasons. The code in the git repo has been maintained and should build in most cases. If not, please open an issue.
See the FreeBSD job in the cmake.yml workflow
On Linux and MacOS, dependencies can be downloaded using the 'setupBuildDeps.sh' script (see the mk/linux and mk/macos directories).
On Linux or MacOS, go to mk/linux or mk/macos and run the build script:
./build-mg.sh (add `-h` to see options)
When completed, the game, map editor, and viewer binaries will be output the current directory. You can run them from that location. When built using the script as shown above, the binaries will read the ini files in that directory for information (such as the path to the language files and game data) that is required to run the game.
It is highly recommended to only use the script above. The CMake build
system we use is primarily for packagers. If you build
with CMake and try running the game, it will error when trying to find the ini
files (which contain the paths to the data) unless you install the binaries
and data using -DCMAKE_INSTALL_PREFIX
(see details below).
When building with CMake, you can use standard CMake syntax. It is recommended to create and use an out-of-source build tree. From the repository root:
cmake -B builddir
cd builddir
make -j[n] (where n is the number of processors you wish to use)
All the files generated by CMake and the build artifacts will be output to 'builddir', and can be safely removed if necessary.
To see a list of various configuration options:
cd builddir
cmake -LH
Caution
CMake does not natively generate an 'uninstall'
target
and we have not manually implemented one. This means that make uninstall
will not work after using make install
; you will only be able to uninstall
everything (the binaries and data)by manually removing the files. This is an
important reason why we recommend using the build script, Windows, or other
distribution packages to run the game. However, if another option while
installing using make is to set the installation prefix to an isolated
directory that you can remove later:
cd builddir
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/megaglest
sudo make install -j[n]
The game and data will be installed to '/opt/megaglest' (the binary will be in '/opt/megaglest/bin'). You can also install without superuser privileges by installing to a directory in your own home directory:
cd builddir
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/opt/megaglest