From dcdb2704bb4336f9feb4529a83718a31a6c46a1e Mon Sep 17 00:00:00 2001
From: Naveen M K <naveen521kk@gmail.com>
Date: Sun, 14 Mar 2021 02:28:21 +0530
Subject: [PATCH] Add MINGW support

---
 CMakeLists.txt | 2 +-
 setup.py       | 7 +++----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 64375ca..9f75ea8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(mapbox_earcut)
 
-add_subdirectory(pybind11)
+find_package(pybind11 CONFIG)
     
 pybind11_add_module(mapbox_earcut src/main.cpp)
 target_include_directories(mapbox_earcut PUBLIC include)
diff --git a/setup.py b/setup.py
index 84cc14e..128a0ec 100644
--- a/setup.py
+++ b/setup.py
@@ -39,8 +39,10 @@ class CMakeBuild(build_ext):
         extdir = os.path.abspath(
             os.path.dirname(self.get_ext_fullpath(ext.name)))
         cmake_args = [
+            '-GMSYS Makefiles',
             '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
-            '-DPYTHON_EXECUTABLE=' + sys.executable
+            '-DPYTHON_EXECUTABLE=' + sys.executable,
+            '-DCMAKE_INSTALL_PREFIX='+os.getenv('MINGW_PREFIX')
         ]
 
         cfg = 'Debug' if self.debug else 'Release'
@@ -51,9 +53,6 @@ class CMakeBuild(build_ext):
                 '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(
                     cfg.upper(), extdir)
             ]
-            if sys.maxsize > 2**32:
-                cmake_args += ['-A', 'x64']
-            build_args += ['--', '/m']
         else:
             cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
             build_args += ['--', '-j8']
-- 
2.30.2.windows.1

