summaryrefslogtreecommitdiff
path: root/COMPILING.md
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2019-04-07 12:02:34 +0200
committerglx22 <glx22@users.noreply.github.com>2020-06-05 19:36:05 +0200
commit945508b8549505482fd186cc185a93f3fb3e3726 (patch)
treeee248404bcadc800ed63184603d6abeed3c0390c /COMPILING.md
parent4d04009d12932270da0e492b155cb2e699389c30 (diff)
downloadopenttd-945508b8549505482fd186cc185a93f3fb3e3726.tar.xz
Fix: update COMPILING.md stating what changed with CMake
Diffstat (limited to 'COMPILING.md')
-rw-r--r--COMPILING.md118
1 files changed, 49 insertions, 69 deletions
diff --git a/COMPILING.md b/COMPILING.md
index 46de5e09e..64f25f9c2 100644
--- a/COMPILING.md
+++ b/COMPILING.md
@@ -23,7 +23,7 @@ no graphical user interface; you would be building a dedicated server.
## 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
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
```
-Open the relevant project file and it should build automatically.
-- VS 2015: projects/openttd_vs140.sln
-- VS 2017: projects/openttd_vs141.sln
-- VS 2019: projects/openttd_vs142.sln
+You can open the folder (as a CMake project). CMake will be detected, and you can compile from there.
-Set the build mode to `Release` in
-`Build > Configuration manager > Active solution configuration`.
-You can now compile.
+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:
-If everything works well the binary should be in `objs\Win[32|64]\Release\openttd.exe`
-and in `bin\openttd.exe`
-
-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).
-
-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)
-
-## Linux, Unix, Solaris:
-
-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.
-
-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).
+```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"
+```
-## OS/2:
+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.
-A comprehensive GNU build environment is required to build the OS/2 version.
+## All other platforms
-The OpenTTD wiki may provide additional help with [compiling for OS/2](https://wiki.openttd.org/Compiling_on_OS/2).
+```bash
+mkdir build
+cd build
+cmake ..
+make
+```
## 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,
+we refer to the compiler manual to see if it supports C++11, and to CMake
+to see if it supports your compiler.
-- Microsoft Visual C++ (MSVC) 2015, 2017 and 2019.
-- GNU Compiler Collection (GCC) 4.8 - 9.
-- Clang/LLVM 3.9 - 8
+## Compilation of base sets
-The following compilers are known not to compile OpenTTD:
+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/downloads/grfcodec-releases/latest.html.
-In general, this is because these old versions do not (fully) support modern
-C++11 language features.
+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`).
-- Microsoft Visual C++ (MSVC) 2013 and earlier.
-- GNU Compiler Collection (GCC) 4.7 and earlier.
-- Clang/LLVM 3.8 and earlier.
+## Developers settings
-If any of these, or any other, compilers can compile OpenTTD, let us know.
-Pull requests to support more compilers are welcome.
+You can control some flags directly via `CXXFLAGS` (any combination
+of these flags will work fine too):
-## Compilation of base sets
+- `-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.
-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.
+Always use a clean buildfolder if you changing `CXXFLAGS`, as this
+value is otherwise cached. Example use:
+
+`CXXFLAGS="-fno-inline" cmake ..`