This commit adds support for building with the MinGW toolchain.
This is useful as it allows Windows builds of the CTS to be
built on Linux or other platforms.
This can then either be used on Windows natively, or under the Wine
translation layer.
It can be used by either specifying a MinGW toolchain in CMake
or using the x86_64-w64-mingw32-cmake wrapper.
Fixes: #125
Signed-off-by: Joshua Ashton <joshua@froggi.es>
# define VKAPI_ATTR
#endif
-#if (DE_OS == DE_OS_WIN32) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
+#if (DE_OS == DE_OS_WIN32) && ((defined(_MSC_VER) && _MSC_VER >= 800) || defined(__MINGW32__) || defined(_STDCALL_SUPPORTED))
# define VKAPI_CALL __stdcall
# define VKAPI_PTR VKAPI_CALL
#else
# define VKAPI_ATTR
#endif
-#if (DE_OS == DE_OS_WIN32) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
+#if (DE_OS == DE_OS_WIN32) && ((defined(_MSC_VER) && _MSC_VER >= 800) || defined(__MINGW32__) || defined(_STDCALL_SUPPORTED))
# define VKAPI_CALL __stdcall
#else
# define VKAPI_CALL
#if (DE_OS == DE_OS_WIN32)
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
-# include <Dxgi1_2.h>
+# include <dxgi1_2.h>
#endif
using tcu::TestLog;
# define NOMINMAX
# include <windows.h>
# include <aclapi.h>
-# include "VersionHelpers.h"
-# include "d3d11_2.h"
-# include "d3dcompiler.h"
+# include <versionhelpers.h>
+# include <d3d11_2.h>
+# include <d3dcompiler.h>
typedef HRESULT (WINAPI * LPD3DX11COMPILEFROMMEMORY)(LPCSTR,
SIZE_T,
else ()
message(FATAL_ERROR "DE_COMPILER is not valid")
endif ()
+
+if (DE_MINGW AND DE_PTR_SIZE EQUAL 8)
+ # Pass -mbig-obj to mingw gas on Win64. COFF has a 2**16 section limit, and
+ # on Win64, every COMDAT function creates at least 3 sections: .text, .pdata,
+ # and .xdata.
+ # Enable static libgcc and libstdc++ also to avoid needing to have
+ # Windows builds of the standard libraries distributed.
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wa,-mbig-obj -static -static-libgcc")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj -static -static-libgcc -static-libstdc++")
+endif()
set(DE_ANDROID_API 5)
endif ()
+# MinGW
+if (CMAKE_CXX_COMPILER MATCHES ".*-mingw32-.*")
+ set(DE_MINGW 1)
+ set(BUILD_SHARED_LIBS OFF)
+else()
+ set(DE_MINGW 0)
+endif()
+
message(STATUS "DE_OS = ${DE_OS}")
message(STATUS "DE_COMPILER = ${DE_COMPILER}")
message(STATUS "DE_CPU = ${DE_CPU}")
if (DE_OS_IS_ANDROID)
message(STATUS "DE_ANDROID_API = ${DE_ANDROID_API}")
endif ()
+message(STATUS "DE_MINGW = ${DE_MINGW}")
# Expose definitions
if (DE_DEBUG)
add_definitions("-DDE_COMPILER=${DE_COMPILER}")
add_definitions("-DDE_CPU=${DE_CPU}")
add_definitions("-DDE_PTR_SIZE=${DE_PTR_SIZE}")
+add_definitions("-DDE_MINGW=${DE_MINGW}")
if (DE_OS_IS_ANDROID)
add_definitions("-DDE_ANDROID_API=${DE_ANDROID_API}")
assert(wreason);
# endif
}
-#elif ((DE_OS == DE_OS_WIN32) && (DE_COMPILER == DE_COMPILER_CLANG))
+#elif ((DE_OS == DE_OS_WIN32) && (DE_COMPILER == DE_COMPILER_CLANG || DE_COMPILER == DE_COMPILER_GCC))
_assert(reason, file, line);
#elif (DE_OS == DE_OS_OSX) || (DE_OS == DE_OS_IOS) || defined(__FreeBSD__)
fprintf(stderr, "Assertion '%s' failed at %s:%d\n", reason, file, line);
#if (DE_OS == DE_OS_WIN32 && DE_COMPILER == DE_COMPILER_MSC)
# define DE_DIRITER DE_DIRITER_WIN32
-#elif (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_OSX) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_SYMBIAN) || (DE_OS == DE_OS_IOS) || (DE_OS == DE_OS_QNX) || (DE_OS == DE_OS_WIN32 && DE_COMPILER == DE_COMPILER_CLANG)
+#elif (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_OSX) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_SYMBIAN) || (DE_OS == DE_OS_IOS) || (DE_OS == DE_OS_QNX) || (DE_OS == DE_OS_WIN32 && (DE_COMPILER == DE_COMPILER_CLANG || DE_COMPILER == DE_COMPILER_GCC))
# define DE_DIRITER DE_DIRITER_POSIX
#endif
endif ()
if (DE_OS_IS_WIN32)
- set(DEUTIL_LIBS WS2_32)
+ set(DEUTIL_LIBS ${DEUTIL_LIBS} ws2_32)
endif ()
if (DE_OS_IS_UNIX OR DE_OS_IS_QNX)
#if defined(DE_USE_WINSOCK)
/* WinSock spesific. */
-# include <WinSock2.h>
-# include <WS2tcpip.h>
-# include <WinDef.h>
+# include <winsock2.h>
+# include <ws2tcpip.h>
+# include <windef.h>
static deBool initWinsock (void)
{
add_definitions(-DDEQP_SUPPORT_WAYLAND=1)
endif ()
endif ()
+
+if (DE_OS_IS_WIN32)
+ target_link_libraries(tcutil-platform "version")
+endif()
#include <iterator>
#include <set>
-#include <WinGDI.h>
+#include <wingdi.h>
// WGL_ARB_pixel_format
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
#include "tcuWin32EGLNativeDisplayFactory.hpp"
#include "egluGLContextFactory.hpp"
+// MinGW doesn't define this in its headers, but
+// still has the export in the libs.
+extern "C" WINUSERAPI WINBOOL WINAPI SetProcessDPIAware(VOID);
+
namespace tcu
{
namespace win32
#include "deUniquePtr.hpp"
#include "deMemory.h"
-#pragma comment(lib, "version.lib")
-
namespace tcu
{
namespace win32