1
0
Fork 0

Fix: update COMPILING.md stating what changed with CMake

pull/8191/head
Patric Stout 2019-04-07 12:02:34 +02:00 committed by glx22
parent 4d04009d12
commit 945508b854
1 changed files with 50 additions and 70 deletions

View File

@ -23,7 +23,7 @@ no graphical user interface; you would be building a dedicated server.
## Windows: ## Windows:
You need Microsoft Visual Studio 2015 Update 3 or newer. You need Microsoft Visual Studio 2017 or more recent.
You can download the free Visual Studio Community Edition from Microsoft at You can download the free Visual Studio Community Edition from Microsoft at
https://visualstudio.microsoft.com/vs/community/. https://visualstudio.microsoft.com/vs/community/.
@ -56,86 +56,66 @@ To install both the x64 (64bit) and x86 (32bit) variants (though only one is nec
.\vcpkg install liblzma:x86-windows-static libpng:x86-windows-static lzo:x86-windows-static zlib:x86-windows-static .\vcpkg install liblzma:x86-windows-static libpng:x86-windows-static lzo:x86-windows-static zlib:x86-windows-static
``` ```
Open the relevant project file and it should build automatically. You can open the folder (as a CMake project). CMake will be detected, and you can compile from there.
- VS 2015: projects/openttd_vs140.sln
- VS 2017: projects/openttd_vs141.sln
- VS 2019: projects/openttd_vs142.sln
Set the build mode to `Release` in Alternatively, you can create a MSVC project file via CMake. For this
`Build > Configuration manager > Active solution configuration`. either download CMake from https://cmake.org/download/ or use the version
You can now compile. that comes with vcpkg. After that, you can run something similar to this:
If everything works well the binary should be in `objs\Win[32|64]\Release\openttd.exe` ```powershell
and in `bin\openttd.exe` 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"
```
The OpenTTD wiki may provide additional help with [compiling for Windows](https://wiki.openttd.org/Compiling_on_Windows_using_Microsoft_Visual_C%2B%2B_2015). 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.
You can also build OpenTTD with MSYS2/MinGW-w64 or Cygwin/MinGW using the Makefile. The OpenTTD wiki may provide additional help with [MSYS2](https://wiki.openttd.org/Compiling_on_Windows_using_MSYS2) ## All other platforms
## Linux, Unix, Solaris: ```bash
mkdir build
OpenTTD can be built with GNU '`make`'. On non-GNU systems it is called '`gmake`'. cd build
However, for the first build one has to do a '`./configure`' first. cmake ..
make
The OpenTTD wiki may provide additional help with: ```
- [compiling for Linux and *BSD](https://wiki.openttd.org/Compiling_on_%28GNU/%29Linux_and_*BSD)
- [compiling for Solaris](https://wiki.openttd.org/Compiling_on_Solaris)
## 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 --enable-universal`'
instead of '`./configure`'.
The OpenTTD wiki may provide additional help with [compiling for macOS](https://wiki.openttd.org/Compiling_on_Mac_OS_X).
## Haiku:
Use '`make`', but do a '`./configure`' before the first build.
The OpenTTD wiki may provide additional help with [compiling for Haiku](https://wiki.openttd.org/Compiling_on_Haiku).
## OS/2:
A comprehensive GNU build environment is required to build the OS/2 version.
The OpenTTD wiki may provide additional help with [compiling for OS/2](https://wiki.openttd.org/Compiling_on_OS/2).
## Supported compilers ## Supported compilers
The following compilers are tested with and known to compile OpenTTD: 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,
- Microsoft Visual C++ (MSVC) 2015, 2017 and 2019. we refer to the compiler manual to see if it supports C++11, and to CMake
- GNU Compiler Collection (GCC) 4.8 - 9. to see if it supports your compiler.
- Clang/LLVM 3.9 - 8
The following compilers are known not to compile OpenTTD:
In general, this is because these old versions do not (fully) support modern
C++11 language features.
- Microsoft Visual C++ (MSVC) 2013 and earlier.
- GNU Compiler Collection (GCC) 4.7 and earlier.
- Clang/LLVM 3.8 and earlier.
If any of these, or any other, compilers can compile OpenTTD, let us know.
Pull requests to support more compilers are welcome.
## Compilation of base sets ## Compilation of base sets
To recompile the extra graphics needed to play with the original Transport To recompile the extra graphics needed to play with the original Transport
Tycoon Deluxe graphics you need GRFCodec (which includes NFORenum) as well. Tycoon Deluxe graphics you need GRFCodec (which includes NFORenum) as well.
GRFCodec can be found at https://www.openttd.org/download-grfcodec. GRFCodec can be found at
The compilation of these extra graphics does generally not happen, unless https://www.openttd.org/downloads/grfcodec-releases/latest.html.
you remove the graphics file using '`make maintainer-clean`'.
Re-compilation of the base sets, thus also use of '`--maintainer-clean`' can Having GRFCodec installed can cause regeneration of the `.grf` files, which
leave the repository in a modified state as different grfcodec versions can are written in the source directory. This can leave your repository in a
cause binary differences in the resulting grf. Also translations might have modified state, as different GRFCodec versions can cause binary differences
been added for the base sets which are not yet included in the base set in the resulting `.grf` files. Also translations might have been added for
information files. Use the configure option '`--without-grfcodec`' to avoid the base sets which are not yet included in the base set information files.
modification of the base set files by the build process. To avoid this behaviour, disable GRFCodec (and NFORenum) in CMake cache
(`GRFCODEC_EXECUTABLE` and `NFORENUM_EXECUTABLE`).
## 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 ..`