Skip to content

Commit

Permalink
Fix: update the README stating what changed with CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueBrain committed Apr 13, 2019
1 parent d114a71 commit 2440a6e
Showing 1 changed file with 62 additions and 76 deletions.
138 changes: 62 additions & 76 deletions README.md
Expand Up @@ -513,46 +513,40 @@ create one after closing.

## 7.0) Compiling

### Windows:
### Windows

You need Microsoft Visual Studio 2015 Update 3 or more recent. Open the project file
and it should build automatically. In case you want to build with SDL support
you need to add WITH_SDL to the project settings.
You need Microsoft Visual Studio 2017 or more recent. You can open the folder
(as a CMake project). CMake will be detected, and you can compile from there.

PNG (WITH_PNG), ZLIB (WITH_ZLIB), LZO (WITH_LZO), Freetype (WITH_FREETYPE) and
libLZMA (WITH_LIBLZMA) support is enabled by default. For these to work you need their
development files. To get them just use vcpkg from https://github.com/Microsoft/vcpkg
using x86-windows-static and x64-windows-static triplets.
For more help with VS see docs/Readme_Windows_MSVC.md.

You can also build it using the Makefile with MSYS/MinGW or Cygwin/MinGW.
Please read the Makefile for more information.

### Solaris, FreeBSD, OpenBSD:

Use '`gmake`', but do a '`./configure`' before the first build.

### Linux/Unix:

OpenTTD can be built with GNU '`make`'. On non-GNU systems it is called '`gmake`'.
However, for the first build one has to do a '`./configure`' first.

### macOS:

Use '`make`' or Xcode (which will then call make for you)
This will give you a binary for your CPU type (PPC/Intel)
However, for the first build one has to do a '`./configure`' first.
To make a universal binary type '`./configure --enabled-universal`'
instead of '`./configure`'.

### Haiku:

Use '`make`', but do a '`./configure`' before the first build.

### OS/2:

A comprehensive GNU build environment is required to build the OS/2 version.
See the docs/Readme_OS2.txt file for more information.
libLZMA (WITH_LIBLZMA) support is enabled by default. For these to work you
need their development files. To get them just use vcpkg from
https://github.com/Microsoft/vcpkg using x86-windows-static and
x64-windows-static triplets. For more help with VS see
docs/Readme_Windows_MSVC.md.

Alternatively, you can create a MSVC project file via CMake. For this
either download CMake from https://cmake.org/download/ or use the version
that comes with vcpkg. After that, you can run something similar to this:

```powershell
mkdir build
cd build
cmake.exe .. -G'Visual Studio 16 2019' -DCMAKE_TOOLCHAIN_FILE="<location of vcpkg>\vcpkg\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="x64-windows-static"
```

Change `<location of vcpkg>` to where you have installed vcpkg. After this
in the build folder are MSVC project files. MSVC can rebuild the project
files himself via the `ZERO_CHECK` project.

### All other platforms

```bash
mkdir build
cd build
cmake ..
make
```

### 7.1) Required/optional libraries

Expand All @@ -577,50 +571,42 @@ no graphical user interface; you would be building a dedicated server.

### 7.2) Supported compilers

The following compilers are known to compile OpenTTD:

- Microsoft Visual C++ (MSVC) 2015, 2017 and 2019.
- GNU Compiler Collection (GCC) 3.3 - 4.4, 4.6 - 4.8.
- Versions 4.1 and earlier give bogus warnings about uninitialised variables.
- Versions 4.4, 4.6 give bogus warnings about freeing non-heap objects.
- Versions 4.6 and later give invalid warnings when lto is enabled.
- Intel C++ Compiler (ICC) 12.0.
- Clang/LLVM 2.9 - 3.0
Version 2.9 gives bogus warnings about code nonconformity.

The following compilers are known not to compile OpenTTD:

- Microsoft Visual C++ (MSVC) 2013 and earlier.
These old versions do not support modern C++ language features.
- GNU Compiler Collection (GCC) 3.2 and earlier.
These old versions fail due to OpenTTD's template usage.
- GNU Compiler Collection (GCC) 4.5. It optimizes enums too aggressively.
See https://github.com/OpenTTD/OpenTTD/issues/5513 and references therein.
- Intel C++ Compiler (ICC) 11.1 and earlier.
- Version 10.0 and earlier fail a configure check and fail with recent
system headers.
- Version 10.1 fails to compile station_gui.cpp.
- Version 11.1 fails with an internal error when compiling network.cpp.
- Clang/LLVM 2.8 and earlier.
- (Open) Watcom.

If any of these compilers can compile OpenTTD again, please let us know.
Patches to support more compilers are welcome.
Every compiler that is supported by CMake and supports C++11, should be
able to compile OpenTTD. As the exact list of compilers changes constantly,
we refer to the compiler manual to see if it supports C++11, and to CMake
to see if it supports your compiler.

### 7.3) Compilation of base sets

To recompile the extra graphics needed to play with the original Transport
Tycoon Deluxe graphics you need GRFCodec (which includes NFORenum) as well.
GRFCodec can be found at https://www.openttd.org/download-grfcodec.
The compilation of these extra graphics does generally not happen, unless
you remove the graphics file using '`make maintainer-clean`'.

Re-compilation of the base sets, thus also use of '`--maintainer-clean`' can
leave the repository in a modified state as different grfcodec versions can
cause binary differences in the resulting grf. Also translations might have
been added for the base sets which are not yet included in the base set
information files. Use the configure option '`--without-grfcodec`' to avoid
modification of the base set files by the build process.
GRFCodec can be found at
https://www.openttd.org/downloads/grfcodec-releases/latest.html.

Having GRFCodec installed can cause regeneration of the `.grf` files, which
are written in the source directory. This can leave your repository in a
modified state, as different GRFCodec versions can cause binary differences
in the resulting `.grf` files. Also translations might have been added for
the base sets which are not yet included in the base set information files.
To avoid this behaviour, disable GRFCodec (and NFORenum) in CMake cache
(`GRFCODEC_EXECUTABLE` and `NFORENUM_EXECUTABLE`).

### 7.4) Developers settings

You can control some flags directly via `CXXFLAGS` (any combination
of these flags will work fine too):

- `-DRANDOM_DEBUG`: this helps with debugging desyncs.
- `-fno-inline`: this avoids creating inline functions; this can make
debugging a lot easier.
- `-O0`: this disables all optimizations; this can make debugging a
lot easier.
- `-p`: this enables profiling.

Always use a clean buildfolder if you changing `CXXFLAGS`, as this
value is otherwise cached. Example use:

`CXXFLAGS="-fno-inline" cmake ..`

## 8.0) Translating

Expand Down

0 comments on commit 2440a6e

Please sign in to comment.