--- z3-z3-4.7.1/src/CMakeLists.txt.orig	2018-06-05 22:40:21.646153600 +0300
+++ z3-z3-4.7.1/src/CMakeLists.txt	2018-06-05 23:18:27.979924400 +0300
@@ -110,6 +110,9 @@
 foreach (component ${Z3_LIBZ3_COMPONENTS_LIST})
   list(APPEND object_files $<TARGET_OBJECTS:${component}>)
 endforeach()
+if (MINGW)
+  list(APPEND object_files "${CMAKE_CURRENT_BINARY_DIR}/api_dll.def")
+endif()
 if (Z3_BUILD_LIBZ3_SHARED)
   set(lib_type "SHARED")
 else()
@@ -181,7 +184,7 @@
   PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
 )
 
-if (MSVC)
+if (WIN32)
   # Handle settings dll exports when using MSVC
   # FIXME: This seems unnecessarily complicated but I'm doing
   # this because this is what the python build system does.
@@ -207,7 +210,9 @@
     DEPENDS "${dll_module_exports_file}"
   )
   add_dependencies(libz3 libz3_extra_depends)
-  z3_append_linker_flag_list_to_target(libz3 "/DEF:${dll_module_exports_file}")
+  if(MSVC)
+    z3_append_linker_flag_list_to_target(libz3 "/DEF:${dll_module_exports_file}")
+  endif()
 endif()
 
 ################################################################################
