From 35a852ba53ca7c16463fbb72b5288ac70febae8f Mon Sep 17 00:00:00 2001 From: James Rowe Date: Mon, 1 Aug 2016 15:13:35 -0600 Subject: [PATCH] Add mingw compile support --- CMakeLists.txt | 12 ++++++++++-- externals/microprofile/microprofile.h | 4 ++-- src/citra_qt/main.cpp | 4 ++++ src/common/string_util.cpp | 4 ++-- src/core/gdbstub/gdbstub.cpp | 2 +- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ac3df0e0..e103c9901 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,15 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) if (NOT MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + + if (MINGW) + add_definitions(-DMINGW_HAS_SECURE_API) + if (MINGW_STATIC_BUILD) + add_definitions(-DQT_STATICPLUGIN) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") + endif() + endif() else() # Silence "deprecation" warnings add_definitions(/D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /D_SCL_SECURE_NO_WARNINGS) @@ -166,9 +175,8 @@ IF (APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++") ELSEIF(MINGW) - # GCC does not support codecvt, so use iconv instead # PSAPI is the Process Status API - set(PLATFORM_LIBRARIES winmm ws2_32 psapi iconv) + set(PLATFORM_LIBRARIES winmm ws2_32 psapi imm32 version) # WSAPoll functionality doesn't exist before WinNT 6.x (Vista and up) add_definitions(-D_WIN32_WINNT=0x0600) diff --git a/externals/microprofile/microprofile.h b/externals/microprofile/microprofile.h index d1ae0c1c2..d838e31a5 100644 --- a/externals/microprofile/microprofile.h +++ b/externals/microprofile/microprofile.h @@ -512,7 +512,7 @@ typedef int MpSocket; #if defined(__APPLE__) || defined(__linux__) typedef pthread_t MicroProfileThread; -#elif defined(_WIN32) +#elif defined(_MSC_VER) typedef HANDLE MicroProfileThread; #else typedef std::thread* MicroProfileThread; @@ -921,7 +921,7 @@ void MicroProfileThreadJoin(MicroProfileThread* pThread) int r = pthread_join(*pThread, 0); MP_ASSERT(r == 0); } -#elif defined(_WIN32) +#elif defined(_MSC_VER) typedef HANDLE MicroProfileThread; DWORD _stdcall ThreadTrampoline(void* pFunc) { diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 9fd4482f6..c486326cd 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -55,6 +55,10 @@ #include "video_core/video_core.h" +#ifdef QT_STATICPLUGIN +Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin); +#endif + GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { Pica::g_debug_context = Pica::DebugContext::Construct(); diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index f0aa072db..7cf19dfaf 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -13,7 +13,7 @@ #include "common/logging/log.h" #include "common/string_util.h" -#ifdef _MSC_VER +#ifdef _WIN32 #include #include #include "common/common_funcs.h" @@ -292,7 +292,7 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st return result; } -#ifdef _MSC_VER +#ifdef _WIN32 std::string UTF16ToUTF8(const std::u16string& input) { diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index 28d403158..85e8a4024 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp @@ -14,7 +14,7 @@ #include #include -#ifdef _MSC_VER +#ifdef _WIN32 #include #include #include