Allow to cross-compile Windows build under Linux using MinGW.

It works fine on Ubuntu. You only need to use:
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw.cmake
This commit is contained in:
Deve 2015-01-08 21:46:59 +01:00
parent d2c8f2b225
commit d0f96a7673
5 changed files with 26 additions and 9 deletions

View File

@ -0,0 +1,17 @@
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)
# which compilers to use for C and C++
SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc-posix)
SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++-posix)
SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32 ${PROJECT_SOURCE_DIR}/dependencies)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View File

@ -22,7 +22,7 @@ add_library(enet STATIC
)
if(MINGW)
target_link_libraries(enet wsock32 ws2_32 Winmm)
target_link_libraries(enet wsock32 ws2_32 winmm)
endif()
#if(WIN32)

View File

@ -82,7 +82,7 @@
using namespace irr;
#ifdef WIN32
#include <Windows.h>
#include <windows.h>
#endif
#if defined(__linux__) && !defined(ANDROID)
#include <X11/Xlib.h>

View File

@ -38,11 +38,11 @@
#include <iostream>
#include <string>
namespace irr {
namespace io
{
IFileSystem* createFileSystem();
}
namespace irr {
namespace io
{
IFileSystem* createFileSystem();
}
}
// For mkdir
@ -53,7 +53,7 @@ namespace irr {
# include <unistd.h>
#else
# include <direct.h>
# include <Windows.h>
# include <windows.h>
# include <stdio.h>
# if !defined(__CYGWIN__ ) && !defined(__MINGW32__)
/*Needed by the remove directory function */

View File

@ -26,7 +26,7 @@
#include <string.h>
#if defined(WIN32)
# include "Ws2tcpip.h"
# include "ws2tcpip.h"
# define inet_ntop InetNtop
#else
# include <arpa/inet.h>