==============================
Installing Freeciv with Meson:
==============================

This file describes how to compile and install Freeciv with the experimental
Meson build system support. Meson support is still work-in-progress. Fully
supported official way to compile and install Freeciv is still using
autotools as described in INSTALL.


Prerequisites:
==============

Freeciv has mostly the same prerequisites no matter if it's built
with autotools or meson and ninja. The only difference is the requirement
of the build system itself. Meson build does not need autotools, nor does
autotools build need meson. See main (autotools) INSTALL file for the
common prerequisites.

For the meson based build minimum version of meson is 0.57.0.


Overview:
=========

There's two parts in building freeciv. First one needs to configure the
build, and then execute it.

Build directory is configured with the 'meson' command. This is equivalent
of running './configure' in autotools based system. Meson does not allow
configuring the source directory. It always requires separate build directory.
Just create an empty directory, cd in to it, and run meson with path to
source directory as parameter. You can also give configure options in this
phase.

> mkdir build ; cd build
> meson setup ../freeciv-3.1.0

You need to configure the build directory just once. As source files get
updated, you can just execute incremental builds in the build directory.
You can have multiple build directories configured to use the same source
directory, typically set up with different configure options. You can
for example have separate build directories for different kinds of clients.

The build is executed with 'ninja' command. This is equivalent of running
'make' in autotools based system. It's also used to install freeciv

> ninja
> ninja install


Configure options:
==================

Configure options are given as '-D<option>=<value>'.
For example to set freeciv installation prefix as
'/home/cazfi/freeciv-install':

> meson setup ../src -Dprefix=/home/cazfi/freeciv-install

You can give configure options when you first set up the build directory
(like in example above), or you can change configure options for the
build directory later by 'meson configure' subcommand like this:

> meson configure -Dprefix=/home/cazfi/freeciv-install

You get full list of configure options by running 'meson configure'
subcommand without any configure options to set

> meson configure

Some of the configure options are implemented by meson itself for
all meson-based projects. Some options are implemented in freeciv build
system, and they are specific to freeciv.


Notable generic configure options:
----------------------------------

prefix (string):
  The directory where Freeciv will be installed. You can install multiple
  versions of Freeciv in parallel by using different prefix for each.
  It's also a good idea to use prefix to avoid messing your system directories

debug (boolean):
  Whether debug version of Freeciv should be built. While this is generic
  option, some functionality in Freeciv depends on this setting.

werror (boolean):
  Turn compiler warnings to hard errors. This is recommended for
  any development builds of freeciv, to make sure that newly introduced
  warnings get noticed.

default_library ('shared'/'static'/'both')
  In case of freeciv, this affects build of common libfreeciv library.
  The default is to build shared library, and as the binaries then
  need to find the shared library at their run time, setting
  system up for that may require some extra work. If one uses
  this setting to build static library instead, it's going to be
  included in the binaries themselves, so they don't need to find it.


Freeciv specific configure options:
-----------------------------------

ack_experimental (boolean):
  As the official build system for freeciv is still autotools, user
  has to acknowledge that they are using experimental build system when
  using meson. This configure options must be set to 'true', or build
  refuses to start

clients (array):
  List of clients to build. To disable client build completely, give an
  empty array ('-Dclients=[]'). Currently gtk3.22-, sdl2-, qt-,
  and gtk4-client builds are supported.
  By default builds just gtk3.22-client.

fcmp (array):
  List of freeciv modpack installer UIs to build. To disable their build
  completely, give an empty array ('-Dfcmp=[]'). Currently gtk3, qt, gtk4,
  and cli are supported. By default builds just gtk3 UI.

cacert-path (string):
  Custom path to CA cert bundle. If this is empty, default path will be used.
  This affects mostly downloading custom modpacks with modpack installer from
  an 'https' URL.

followtag (string):
  Custom followtag name. If this is empty, default follow tag is used.
  That's the version tag that the client checks from the metaserver to
  see if there's newer freeciv versions of the kind available.

json-protocol (boolean):
  Build json-protocol support in. Json-protocol is an alternative to the default
  raw-protocol between freeciv server and client.

syslua ('try'/'true'/'false')
  Whether to use lua from the system, or to build lua included in freeciv
  source tree. The default is 'try' to use lua from the system if possible,
  but fallback to using freeciv's included one if not found from system.

sys-tolua-cmd (boolean):
  Whether to use tolua command from the system, or to build one
  included in the freeciv source tree. For native build
  the default is false, i.e., to use freeciv's own tolua.
  When cross-compiling, this setting is ignored, and tolua is
  always used from the build system.

mwand ('try'/'true'/'false')
  Whether to build against MagickWand to have support for additional
  mapimg formats. The default is 'try' to enable the support if possible.

readline ('try'/'true'/'false')
  Whether to enable readline functionality on server.
  The default is 'try' to enable it if suitable readline found.

audio (boolean):
  Build sound support to the clients. Defaults to true.

ruledit (boolean):
  Build ruleset editor. Defaults to false.

nls (boolean):
  Build in Native Language Support. Defaults to true.

gitrev (boolean):
  Include git commit id to the version string.

server ('disabled'/'enabled'/'freeciv-web'):
  Whether to build server, or not. Special value 'freeciv-web'
  means that freeciv-web version will be built instead of
  the regular server.

appimage (boolean):
  Make build suitable for AppImage packaging. This affects paths from
  which various resources are looked from, and produces build that
  doesn't work outside AppImage.

qtver ('qt5'/'qt6'):
  Whether to build Qt5 or Qt6 versions of the binaries.

min-win-ver (string):
  Minimum Windows version the build should support. Versions listed on
  https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170

localeprefix (string):
  If non-empty, will be used instead of default prefix when constructing locale path.
  Default prefix is the regular prefix on most systems,
  but current directory ('.') in Windows.
  Unlike regular prefix, this can also be a relative path.


run.sh
------

One of the build results is script named 'run.sh' in the build directory -
it does not get installed to the installation directory. This script can
be used to run freeciv executables from the build directory.
Give the executable name and parameters as parameters to ./run.sh, e.g.,
./run.sh freeciv-server --help
