From 4c5115d74284c111dfb52e40296552e51e7727df Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Tue, 24 Oct 2017 01:22:17 +0200 Subject: [PATCH] Add toolchain files for MinGW 32- and 64-bit cross-compilation Tested on Arch Linux. Fixes #807. --- README.md | 11 ++++++++++- cmake/toolchains/mingw32.toolchain | 10 ++++++++++ cmake/toolchains/mingw64.toolchain | 10 ++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 cmake/toolchains/mingw32.toolchain create mode 100644 cmake/toolchains/mingw64.toolchain diff --git a/README.md b/README.md index 35986b459..52d70c201 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ MySQL (or MariaDB) support in the server is not included in the binary releases Note that the bundled MySQL libraries might not work properly on your system. If you run into connection problems with the MySQL server, for example that it connects as root while you chose another user, make sure to install your system libraries for the MySQL client and C++ connector. Make sure that the CMake configuration summary says that it found MySQL libs that were not bundled (no "using bundled libs"). Running tests (Debian/Ubuntu) -------------- +----------------------------- In order to run the tests, you need to install the following library `libgtest-dev`. @@ -77,6 +77,15 @@ Download and install some version of [Microsoft Visual Studio](https://www.visua Start CMake and select the source code folder (where DDNet resides, the directory with `CMakeLists.txt`). Additionally select a build folder, e.g. create a build subdirectory in the source code directory. Click "Configure" and select the Visual Studio generator (it should be pre-selected, so pressing "Finish" will suffice). After configuration finishes and the "Generate" reactivates, click it. When that finishes, click "Open Project". Visual Studio should open. You can compile the DDNet client by right-clicking the DDNet project (not the solution) and select "Select as StartUp project". Now you should be able to compile DDNet by clicking the green, triangular "Run" button. +Cross-compiling to Windows x86/x86\_64 +-------------------------------------- + +Install MinGW cross-compilers of the form `i686-w64-mingw32-gcc` (32 bit) or +`x86_64-w64-mingw32-gcc` (64 bit). This is probably the hard part. ;) + +Then add `-DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/mingw64.toolchain` to the +**initial** CMake command line. + Importing the official DDNet Database ------------------------------------- diff --git a/cmake/toolchains/mingw32.toolchain b/cmake/toolchains/mingw32.toolchain new file mode 100644 index 000000000..c4c065b7e --- /dev/null +++ b/cmake/toolchains/mingw32.toolchain @@ -0,0 +1,10 @@ +set(CMAKE_SYSTEM_NAME Windows) + +set(CMAKE_C_COMPILER i686-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++) +set(CMAKE_RC_COMPILER i686-w64-mingw32-windres) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/cmake/toolchains/mingw64.toolchain b/cmake/toolchains/mingw64.toolchain new file mode 100644 index 000000000..bec41e944 --- /dev/null +++ b/cmake/toolchains/mingw64.toolchain @@ -0,0 +1,10 @@ +set(CMAKE_SYSTEM_NAME Windows) + +set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) +set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)