From 5cb3764fc555d685200f7f45a75e175ead1aea6c Mon Sep 17 00:00:00 2001 From: Syoyo Fujita Date: Thu, 28 May 2020 21:38:16 +0900 Subject: [PATCH 1/4] Fix build on MinGW cross compiling environment. --- loader/CMakeLists.txt | 4 +++- loader/loader.c | 13 +++++++++++++ loader/loader.rc | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index e01c97375..219b99bd5 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -158,7 +158,7 @@ if(WIN32) if (USE_MASM) enable_language(ASM_MASM) endif () - if(CMAKE_ASM_MASM_COMPILER_WORKS OR JWASM_FOUND) + if((CMAKE_ASM_MASM_COMPILER_WORKS AND NOT CMAKE_CROSSCOMPILING) OR JWASM_FOUND) if(MINGW) set(CMAKE_ASM_MASM_FLAGS ${CMAKE_ASM_MASM_FLAGS} ${JWASM_FLAGS}) elseif(NOT CMAKE_CL_64 AND NOT JWASM_FOUND) @@ -178,6 +178,8 @@ if(WIN32) add_library(loader-unknown-chain OBJECT unknown_ext_chain.c) set_target_properties(loader-unknown-chain PROPERTIES CMAKE_C_FLAGS_DEBUG "${MODIFIED_C_FLAGS_DEBUG}") target_compile_options(loader-unknown-chain PUBLIC ${MSVC_LOADER_COMPILE_OPTIONS}) + + target_include_directories(loader-unknown-chain PRIVATE "$") endif() elseif(APPLE) # For MacOS, use the C code and force the compiler's tail-call optimization instead of using assembly code. diff --git a/loader/loader.c b/loader/loader.c index c3f482b41..4fe42de73 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -83,6 +83,19 @@ typedef HRESULT (APIENTRY *PFN_CreateDXGIFactory1)(REFIID riid, void **ppFactory); static PFN_CreateDXGIFactory1 fpCreateDXGIFactory1; + +#if defined(__MINGW32__) +// MinGW header may not have some definitions(cfgmgr32.h). +#if !defined(CM_GETIDLIST_FILTER_CLASS) +#define CM_GETIDLIST_FILTER_CLASS (0x200) +#endif + +#if !defined(CM_GETIDLIST_FILTER_PRESENT) +#define CM_GETIDLIST_FILTER_PRESENT (0x100) +#endif + +#endif // __MINGW32__ + #endif // This is a CMake generated file with #defines for any functions/includes diff --git a/loader/loader.rc b/loader/loader.rc index 18eb5e6c1..2a9988d00 100755 --- a/loader/loader.rc +++ b/loader/loader.rc @@ -43,7 +43,11 @@ /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// +#if defined(__MINGW32__) +#include +#else #include "winres.h" +#endif #define VER_FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_BUILDNO -- 2.25.1