From eb57b07adf436fdaf6ffc55f2e23aa1f75414958 Mon Sep 17 00:00:00 2001 From: Volodymyr Shymanskyy Date: Wed, 3 Jun 2020 01:31:18 +0300 Subject: [PATCH] Support MinGW. Fix #146 --- CMakeLists.txt | 7 ++++++- source/m3_config_platforms.h | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index efaf984..56b914a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,11 @@ if(DEFINED ENV{WASI_CC}) set(WASIENV 1) endif() +# Detect MinGW +if(WIN32 AND CMAKE_C_COMPILER_ID MATCHES "GNU") + set(MINGW 1) +endif() + if(BUILD_32BIT) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") endif() @@ -107,7 +112,7 @@ elseif(WASIENV) #-flto -Wl,--lto-O3 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,stack-size=8388608") -elseif(WIN32) +elseif(WIN32 AND NOT MINGW) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dd_m3HasTracer -D_CRT_SECURE_NO_WARNINGS /WX- /diagnostics:column") diff --git a/source/m3_config_platforms.h b/source/m3_config_platforms.h index 0faede3..fd7b5d2 100644 --- a/source/m3_config_platforms.h +++ b/source/m3_config_platforms.h @@ -310,7 +310,9 @@ # if defined(M3_COMPILER_MSVC) -# define M3_WEAK +# define M3_WEAK //__declspec(selectany) +# elif defined(__MINGW32__) +# define M3_WEAK //__attribute__((selectany)) # else # define M3_WEAK __attribute__((weak)) # endif