--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -286,7 +286,21 @@
 
   # Add the "lib" prefix for generated .lib outputs.
   set(LIB_PREFIX lib)
-else (MSVC)
+elseif (MINGW)
+  # Allow big object
+  add_definitions("-Wa,-mbig-obj")
+  string(REPLACE "/" "\\" PROTOBUF_SOURCE_WIN32_PATH ${protobuf_SOURCE_DIR})
+  string(REPLACE "/" "\\" PROTOBUF_BINARY_WIN32_PATH ${protobuf_BINARY_DIR})
+  string(REPLACE "." ","  protobuf_RC_FILEVERSION "${protobuf_VERSION}")
+  # Configure Resource Compiler
+  set(CMAKE_RC_COMPILER_INIT windres)
+  enable_language(RC)
+  # fix rc.exe invocations because of usage of add_definitions()
+  set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff -i <SOURCE> -o <OBJECT>")
+
+  configure_file(${protobuf_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
+  set(protobuf_version_rc_file ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
+else ()
   # No version.rc file.
   set(protobuf_version_rc_file)
 
