diff -Naur libkml-1.3.0-orig/CMakeLists.txt libkml-1.3.0/CMakeLists.txt
--- libkml-1.3.0-orig/CMakeLists.txt	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/CMakeLists.txt	2018-10-05 09:11:14.278815800 +0300
@@ -69,7 +69,7 @@
   set(PKGCONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/pkgconfig")
 endif(NOT DEFINED PKGCONFIG_INSTALL_DIR)
 
-if(WIN32 AND NOT CYGWIN)
+if(WIN32 AND NOT CYGWIN AND NOT MINGW)
   set(DEF_INSTALL_CMAKE_DIR cmake)
 else()
   set(DEF_INSTALL_CMAKE_DIR lib/cmake/libkml)
diff -Naur libkml-1.3.0-orig/examples/hellonet/CMakeLists.txt libkml-1.3.0/examples/hellonet/CMakeLists.txt
--- libkml-1.3.0-orig/examples/hellonet/CMakeLists.txt	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/examples/hellonet/CMakeLists.txt	2018-10-05 09:11:14.288815800 +0300
@@ -1,78 +1,77 @@
-
-add_library(curlfetch curlfetch.cc)
+add_library(curlfetch STATIC curlfetch.cc)
 target_link_libraries(curlfetch ${CURL_LIBRARIES})
 
 build_example(
   NAME csvurl2gmap
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME getgmapkml
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME getgsheetcsv
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME getgsheetkml
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME gsheet2gmap
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME kmlwalk
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME kmzfetch
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME listfeed
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME listgdocs
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME listgmaps
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME listgphotos
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME resolvestyle
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME searchgmap
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME uploadgmap
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME uploadgmapcsv
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME uploadgmapkml
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME uploadgsheet
-  DEPENDS kmlconvenience curlfetch)
+  DEPENDS curlfetch kmlconvenience)
 
 build_example(
   NAME xsdprint
-  DEPENDS kmlconvenience kmlxsd curlfetch)
+  DEPENDS curlfetch kmlconvenience kmlxsd)
 
 if(INSTALL_EXAMPLES)
 file(GLOB eg_files "${CMAKE_CURRENT_SOURCE_DIR}/*.cc")
diff -Naur libkml-1.3.0-orig/examples/hellonet/csvurl2gmap.cc libkml-1.3.0/examples/hellonet/csvurl2gmap.cc
--- libkml-1.3.0-orig/examples/hellonet/csvurl2gmap.cc	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/examples/hellonet/csvurl2gmap.cc	2018-10-05 09:11:14.288815800 +0300
@@ -23,13 +23,11 @@
 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#include <termios.h>
 #include <time.h>
 #include <iostream>
 #include <string>
 #include "boost/scoped_ptr.hpp"
 #include "curlfetch.h"
-#include "prompt.h"
 #include "kml/base/file.h"
 #include "kml/dom.h"
 #include "kml/engine.h"
@@ -37,6 +35,7 @@
 #include "kml/convenience/convenience.h"
 #include "kml/convenience/google_maps_data.h"
 #include "kml/convenience/http_client.h"
+#include "prompt.h"
 
 using kmlconvenience::GoogleMapsData;
 
diff -Naur libkml-1.3.0-orig/examples/hellonet/prompt.h libkml-1.3.0/examples/hellonet/prompt.h
--- libkml-1.3.0-orig/examples/hellonet/prompt.h	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/examples/hellonet/prompt.h	2018-10-05 09:11:14.298815900 +0300
@@ -28,10 +28,38 @@
 #ifndef EXAMPLES_HELLONET_PROMPT_H__
 #define EXAMPLES_HELLONET_PROMPT_H__
 
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#else
 #include <termios.h>
+#endif
 #include <iostream>
 #include <string>
 
+// This function modifies the echo property of standard input
+void SetStdinEcho(bool enable)
+{
+#ifdef _WIN32
+    HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); 
+    DWORD mode;
+    GetConsoleMode(hStdin, &mode);
+    if (!enable)
+        mode &= ~ENABLE_ECHO_INPUT;
+    else
+        mode |= ENABLE_ECHO_INPUT;
+    SetConsoleMode(hStdin, mode);
+#else
+    struct termios tty;
+    tcgetattr(STDIN_FILENO, &tty);
+    if (!enable)
+        tty.c_lflag &= ~ECHO;
+    else
+        tty.c_lflag |= ECHO;
+    (void)tcsetattr(STDIN_FILENO, TCSANOW, &tty);
+#endif
+}
+
 // This class provides some static methods useful for prompting on a terminal.
 class Prompt {
  public:
@@ -39,18 +67,13 @@
     std::cin.get();
     std::cout << prompt;
     std::cout << std::flush;
-    // Get the current state of the input terminal.
-    struct termios t;
-    tcgetattr(0, &t);
     // Flip off the ECHO bit.
-    t.c_lflag &= ~ECHO;
-    tcsetattr(0, TCSANOW, &t);
+    SetStdinEcho(false);
     // User can now type password safely.
     std::string input;
     std::getline(std::cin, input);
     // Flip ECHO back on.
-    t.c_lflag |= ECHO;
-    tcsetattr(0, TCSANOW, &t);
+    SetStdinEcho(true);
     std::cout << std::endl;
     return input;
   }
diff -Naur libkml-1.3.0-orig/examples/hellonet/uploadgmap.cc libkml-1.3.0/examples/hellonet/uploadgmap.cc
--- libkml-1.3.0-orig/examples/hellonet/uploadgmap.cc	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/examples/hellonet/uploadgmap.cc	2018-10-05 09:11:14.298815900 +0300
@@ -27,12 +27,10 @@
 // Maps Data API.  The URI of feed to the new map is printed on output.
 // The created map has only the Placemarks from the original file.
 
-#include <termios.h>
 #include <iostream>
 #include <string>
 #include "boost/scoped_ptr.hpp"
 #include "curlfetch.h"
-#include "prompt.h"
 #include "kml/base/file.h"
 #include "kml/dom.h"
 #include "kml/engine.h"
@@ -40,6 +38,7 @@
 #include "kml/convenience/convenience.h"
 #include "kml/convenience/google_maps_data.h"
 #include "kml/convenience/http_client.h"
+#include "prompt.h"
 
 using kmlconvenience::GoogleMapsData;
 
diff -Naur libkml-1.3.0-orig/examples/hellonet/uploadgmapkml.cc libkml-1.3.0/examples/hellonet/uploadgmapkml.cc
--- libkml-1.3.0-orig/examples/hellonet/uploadgmapkml.cc	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/examples/hellonet/uploadgmapkml.cc	2018-10-05 09:11:14.308815900 +0300
@@ -23,12 +23,10 @@
 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#include <termios.h>
 #include <iostream>
 #include <string>
 #include "boost/scoped_ptr.hpp"
 #include "curlfetch.h"
-#include "prompt.h"
 #include "kml/base/file.h"
 #include "kml/dom.h"
 #include "kml/engine.h"
@@ -36,6 +34,7 @@
 #include "kml/convenience/convenience.h"
 #include "kml/convenience/google_maps_data.h"
 #include "kml/convenience/http_client.h"
+#include "prompt.h"
 
 using kmlconvenience::GoogleMapsData;
 
diff -Naur libkml-1.3.0-orig/examples/hellonet/uploadgsheet.cc libkml-1.3.0/examples/hellonet/uploadgsheet.cc
--- libkml-1.3.0-orig/examples/hellonet/uploadgsheet.cc	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/examples/hellonet/uploadgsheet.cc	2018-10-05 09:11:14.308815900 +0300
@@ -23,12 +23,10 @@
 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#include <termios.h>
 #include <iostream>
 #include <string>
 #include "boost/scoped_ptr.hpp"
 #include "curlfetch.h"
-#include "prompt.h"
 #include "kml/base/file.h"
 #include "kml/dom.h"
 #include "kml/engine.h"
@@ -36,6 +34,7 @@
 #include "kml/convenience/convenience.h"
 #include "kml/convenience/google_doc_list.h"
 #include "kml/convenience/http_client.h"
+#include "prompt.h"
 
 using kmlconvenience::GoogleDocList;
 
diff -Naur libkml-1.3.0-orig/examples/helloworld/CMakeLists.txt libkml-1.3.0/examples/helloworld/CMakeLists.txt
--- libkml-1.3.0-orig/examples/helloworld/CMakeLists.txt	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/examples/helloworld/CMakeLists.txt	2018-10-05 09:11:14.308815900 +0300
@@ -1,6 +1,11 @@
-add_library(helloutil print.cc)
+add_library(helloutil STATIC print.cc)
 target_link_libraries(helloutil ${MINIZIP_LIBRARY})
 
+if(MINGW)
+  #supress ignored-qualifiers warning for mingw
+  set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/simplifylines.cc COMPILE_FLAGS "-Wno-ignored-qualifiers")
+endif()
+
 build_example(
   NAME createkml
   DEPENDS kmldom kmlbase)
@@ -27,7 +32,7 @@
 
 build_example(
   NAME hellofeatures
-  DEPENDS kmldom kmlbase helloutil)
+  DEPENDS helloutil kmldom kmlbase)
 
 build_example(
   NAME hellofolder
@@ -39,7 +44,7 @@
 
 build_example(
   NAME hellohref
-  DEPENDS kmldom kmlbase helloutil)
+  DEPENDS helloutil kmldom kmlbase)
 
 build_example(
   NAME hellokmz
@@ -47,7 +52,7 @@
 
 build_example(
   NAME helloregion
-  DEPENDS kmldom kmlbase helloutil)
+  DEPENDS helloutil kmldom kmlbase)
 
 build_example(
   NAME helloworld
diff -Naur libkml-1.3.0-orig/src/kml/base/CMakeLists.txt libkml-1.3.0/src/kml/base/CMakeLists.txt
--- libkml-1.3.0-orig/src/kml/base/CMakeLists.txt	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/src/kml/base/CMakeLists.txt	2018-10-05 09:11:14.318815900 +0300
@@ -7,10 +7,15 @@
 
 file(GLOB SRCS "*.cc"
   contrib/minizip/unzip.c
-  contrib/minizip/iomem_simple.c)
+  contrib/minizip/iomem_simple.c
+  contrib/strptime.c)
 
 if(WIN32)
   list(REMOVE_ITEM SRCS "${CMAKE_CURRENT_SOURCE_DIR}/file_posix.cc")
+  if(MINGW)
+      #supress long-long warning for mingw
+      set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/time_util.cc COMPILE_FLAGS "-Wno-long-long")
+  endif()
 else()
   list(REMOVE_ITEM SRCS "${CMAKE_CURRENT_SOURCE_DIR}/file_win32.cc")
   #supress long-long warning for linux
diff -Naur libkml-1.3.0-orig/src/kml/base/contrib/minizip/unzip.c libkml-1.3.0/src/kml/base/contrib/minizip/unzip.c
--- libkml-1.3.0-orig/src/kml/base/contrib/minizip/unzip.c	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/src/kml/base/contrib/minizip/unzip.c	2018-10-05 09:11:14.318815900 +0300
@@ -35,6 +35,9 @@
  */
 
 
+#ifdef __MINGW32__
+#define Z_U4 unsigned long
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>
diff -Naur libkml-1.3.0-orig/src/kml/base/date_time.cc libkml-1.3.0/src/kml/base/date_time.cc
--- libkml-1.3.0-orig/src/kml/base/date_time.cc	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/src/kml/base/date_time.cc	2018-10-05 09:11:14.328815900 +0300
@@ -29,12 +29,8 @@
 #include "boost/scoped_ptr.hpp"
 #include <stdlib.h>
 
-// TODO: fix this for real.
 #ifdef _WIN32
-char* strptime(const char* buf, const char* format, struct tm* tm) {
-  // Not yet implemented on this platform.
-  return NULL;
-}
+extern "C" char* strptime(const char* buf, const char* format, struct tm* tm);
 #endif
 
 namespace kmlbase {
diff -Naur libkml-1.3.0-orig/src/kml/base/date_time.h libkml-1.3.0/src/kml/base/date_time.h
--- libkml-1.3.0-orig/src/kml/base/date_time.h	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/src/kml/base/date_time.h	2018-10-05 09:11:14.328815900 +0300
@@ -31,12 +31,6 @@
 #include <time.h>
 #include "kml/base/util.h"
 
-// TODO: fix this for real.
-#ifdef _WIN32
-time_t timegm(struct tm* tm);
-char* strptime(const char* buf, const char* format, struct tm* tm);
-#endif
-
 namespace kmlbase {
 
 class DateTime {
diff -Naur libkml-1.3.0-orig/src/kml/base/file_win32.cc libkml-1.3.0/src/kml/base/file_win32.cc
--- libkml-1.3.0-orig/src/kml/base/file_win32.cc	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/src/kml/base/file_win32.cc	2018-10-05 09:11:14.338815900 +0300
@@ -34,11 +34,14 @@
 #include "kml/base/file.h"
 #include <windows.h>
 #include <tchar.h>
+#ifndef __MINGW32__
 #include <xstring>
+#endif
 #include <algorithm>
 
 namespace kmlbase {
 
+#ifndef __MINGW32__
 // Internal to the win32 file class. We need a conversion from string to
 // LPCWSTR.
 static std::wstring Str2Wstr(const string& str) {
@@ -56,13 +59,18 @@
                       static_cast<int>(s), NULL, NULL);
   return str;
 }
+#endif
 
 bool File::Exists(const string& full_path) {
   if (full_path.empty()) {
     return false;
   }
+#ifndef __MINGW32__
   std::wstring wstr = Str2Wstr(full_path);
   DWORD attrs = ::GetFileAttributes(wstr.c_str());
+#else
+  DWORD attrs = ::GetFileAttributes(full_path.c_str());
+#endif
   return (attrs != INVALID_FILE_ATTRIBUTES) &&
     ((attrs & FILE_ATTRIBUTE_DIRECTORY) == 0);
 }
@@ -71,8 +79,12 @@
   if (filepath.empty()) {
     return false;
   }
+#ifndef __MINGW32__
   std::wstring wstr = Str2Wstr(filepath);
   return ::DeleteFile(wstr.c_str()) ? true : false;
+#else
+  return ::DeleteFile(filepath.c_str()) ? true : false;
+#endif
 }
 
 static const unsigned int BUFSIZE = 1024;
@@ -97,8 +109,12 @@
   if (uRetVal == 0) {
     return false;
   }
+#ifndef __MINGW32__
   string str = Wstr2Str(szTempName);
   path->assign(str.c_str(), strlen(str.c_str()));
+#else
+  path->assign(szTempName, strlen(szTempName));
+#endif
   return true;
 }
 
diff -Naur libkml-1.3.0-orig/src/kml/base/uri_parser.cc libkml-1.3.0/src/kml/base/uri_parser.cc
--- libkml-1.3.0-orig/src/kml/base/uri_parser.cc	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/src/kml/base/uri_parser.cc	2018-10-05 09:11:14.338815900 +0300
@@ -187,11 +187,10 @@
 
 bool UriParser::FilenameToUri(const string& filename,
                               string* output) {
-#ifdef WIN32
-  return WindowsFilenameToUri(filename, output);
-#else
-  return UnixFilenameToUri(filename, output);
-#endif
+ if (filename.find('\\') != string::npos)
+   return WindowsFilenameToUri(filename, output);
+ else
+   return UnixFilenameToUri(filename, output);
 }
 
 bool UriParser::UnixFilenameToUri(const string& filename,
diff -Naur libkml-1.3.0-orig/src/kml/dom/CMakeLists.txt libkml-1.3.0/src/kml/dom/CMakeLists.txt
--- libkml-1.3.0-orig/src/kml/dom/CMakeLists.txt	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/src/kml/dom/CMakeLists.txt	2018-10-05 09:11:14.338815900 +0300
@@ -50,6 +50,11 @@
   visitor.h
   visitor_driver.h)
 
+if(MINGW)
+  #supress unused-variable warning for mingw
+  set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/kml22.cc COMPILE_FLAGS "-Wno-unused-variable")
+endif()
+
 build_target(
   NAME kmldom
   SRCS ${SRCS}
diff -Naur libkml-1.3.0-orig/src/swig/CMakeLists.txt libkml-1.3.0/src/swig/CMakeLists.txt
--- libkml-1.3.0-orig/src/swig/CMakeLists.txt	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/src/swig/CMakeLists.txt	2018-10-05 09:11:14.348815900 +0300
@@ -1,42 +1,52 @@
 if(WITH_PYTHON)
-  find_package(PythonLibs REQUIRED)
+  find_package(PythonLibs 2.7 REQUIRED)
   if(NOT PYTHONLIBS_FOUND)
     message(FATAL_ERROR "Python Libraries not found.")
   endif()
 
-  find_package(PythonInterp REQUIRED)
+  find_package(PythonInterp 2.7 REQUIRED)
 
   include_directories(${PYTHON_INCLUDE_PATH})
 
-  if(NOT DEFINED PYTHON_INSTALL_DIR)
+  if(MINGW)
+    set(PYTHON_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/python2.7/site-packages")
+  elseif(NOT DEFINED PYTHON_INSTALL_DIR)
     execute_process(COMMAND
       ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(True)"
       OUTPUT_VARIABLE PYTHON_INSTALL_DIR
       OUTPUT_STRIP_TRAILING_WHITESPACE )
-  endif(NOT DEFINED PYTHON_INSTALL_DIR)
+  endif()
+
+  if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
+    add_definitions("-DMS_WIN64")
+  endif()
+
+  set(CMAKE_SWIG_OUTDIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 
   file(GLOB IFILES "kml*.i")
   foreach(INTERFACE_FILE ${IFILES})
     get_filename_component(MODULE_NAME ${INTERFACE_FILE} NAME_WE)
     set_source_files_properties(${INTERFACE_FILE} PROPERTIES CPLUSPLUS ON )
     set_source_files_properties(${INTERFACE_FILE} PROPERTIES CMAKE_SWIG_FLAGS "-includeall -DSWIGPYTHON")
-    set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}PYTHON_wrap.cxx COMPILE_FLAGS "-Wno-long-long" )
+    set_source_files_properties(${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MODULE_NAME}PYTHON_wrap.cxx COMPILE_FLAGS "-Wno-long-long")
     swig_add_module(${MODULE_NAME} python ${INTERFACE_FILE})
     swig_link_libraries(${MODULE_NAME} kmlbase kmlengine kmldom ${PYTHON_LIBRARIES})
+    set_target_properties(_${MODULE_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
     add_custom_command(
       TARGET _${MODULE_NAME}
       POST_BUILD
       COMMAND ${CMAKE_COMMAND} -E echo "Byte-compiling ${MODULE_NAME}.py"
-      COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/cmake/pycompile.py ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}.py
+      COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/cmake/pycompile.py ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MODULE_NAME}.py
       DEPENDS kmlbase kmlengine kmldom)
 
     install(TARGETS
       _${MODULE_NAME}
+      LIBRARY DESTINATION ${PYTHON_INSTALL_DIR}
       DESTINATION ${PYTHON_INSTALL_DIR})
 
     install(FILES
-      ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}.py
-      ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}.pyc
+      ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MODULE_NAME}.py
+      ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MODULE_NAME}.pyc
       DESTINATION ${PYTHON_INSTALL_DIR})
 
   endforeach()
diff -Naur libkml-1.3.0-orig/tests/kml/base/CMakeLists.txt libkml-1.3.0/tests/kml/base/CMakeLists.txt
--- libkml-1.3.0-orig/tests/kml/base/CMakeLists.txt	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/tests/kml/base/CMakeLists.txt	2018-10-05 09:11:14.348815900 +0300
@@ -18,6 +18,11 @@
 xml_namespaces
 xmlns)
 
+if(MINGW)
+  #supress overflow warning for mingw
+  set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/expat_parser_test.cc COMPILE_FLAGS "-Wno-overflow")
+endif()
+
 foreach(TEST ${TESTS})
   build_test(
     GROUP base
diff -Naur libkml-1.3.0-orig/tests/kml/convenience/CMakeLists.txt libkml-1.3.0/tests/kml/convenience/CMakeLists.txt
--- libkml-1.3.0-orig/tests/kml/convenience/CMakeLists.txt	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/tests/kml/convenience/CMakeLists.txt	2018-10-05 09:11:14.358815900 +0300
@@ -13,7 +13,7 @@
 
 foreach(TEST ${TESTS})
   build_test(
-    GROUP regionator
+    GROUP convenience
     NAME ${TEST}
     DEPENDS kmlbase;kmlengine;kmldom;kmlconvenience)
 endforeach()
diff -Naur libkml-1.3.0-orig/tests/kml/convenience/google_maps_data_test.cc libkml-1.3.0/tests/kml/convenience/google_maps_data_test.cc
--- libkml-1.3.0-orig/tests/kml/convenience/google_maps_data_test.cc	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/tests/kml/convenience/google_maps_data_test.cc	2018-10-05 09:11:14.358815900 +0300
@@ -36,6 +36,13 @@
 #include "kml/convenience/http_client_test_util.h"
 #include "kml/engine.h"
 
+#if defined(_WIN32) && !defined(setenv)
+// This code is safe, as the temporary string object will be destructed at the
+// end of the full expression
+#define setenv(name, value, overwrite) \
+    (putenv((string(name) + "=" + string(value)).c_str()))
+#endif
+
 // The following define is a convenience for testing inside Google.
 #ifdef GOOGLE_INTERNAL
 #include "kml/base/google_internal_test.h"
diff -Naur libkml-1.3.0-orig/tests/kml/engine/feature_view_test.cc libkml-1.3.0/tests/kml/engine/feature_view_test.cc
--- libkml-1.3.0-orig/tests/kml/engine/feature_view_test.cc	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/tests/kml/engine/feature_view_test.cc	2018-10-05 09:11:14.358815900 +0300
@@ -144,7 +144,11 @@
   // These fields are expected to be set to these values.
   ASSERT_DOUBLE_EQ(-86.032775, lookat->get_longitude());
   ASSERT_DOUBLE_EQ(35.78925, lookat->get_latitude());
+#ifdef _WIN64
   ASSERT_DOUBLE_EQ(712928.68603440293, lookat->get_range());
+#else
+  ASSERT_DOUBLE_EQ(712928.68603440106, lookat->get_range());
+#endif
   // These fields are not set by ComputeBboxLookAt.
   ASSERT_FALSE(lookat->has_altitude());
   ASSERT_FALSE(lookat->has_heading());
diff -Naur libkml-1.3.0-orig/tests/kml/engine/kmz_file_test.cc libkml-1.3.0/tests/kml/engine/kmz_file_test.cc
--- libkml-1.3.0-orig/tests/kml/engine/kmz_file_test.cc	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/tests/kml/engine/kmz_file_test.cc	2018-10-05 09:11:14.368816000 +0300
@@ -347,7 +347,11 @@
   created->List(&list);
   ASSERT_EQ(static_cast<size_t>(2), list.size());
   ASSERT_EQ(string("dummy.png"), list[0]);
+#ifndef __MINGW32__
   ASSERT_EQ(string("kmzfiles/dummy.kml"), list[1]);
+#else
+  ASSERT_EQ(string("kmzfiles\\dummy.kml"), list[1]);
+#endif
 }
 
 TEST_F(KmzTest, TestCreateFromElement) {
@@ -370,7 +374,11 @@
   ASSERT_EQ(static_cast<size_t>(3), list.size());
   ASSERT_EQ(string("doc.kml"), list[0]);
   ASSERT_EQ(string("dummy.png"), list[1]);
+#ifndef __MINGW32__
   ASSERT_EQ(string("kmzfiles/dummy.kml"), list[2]);
+#else
+  ASSERT_EQ(string("kmzfiles\\dummy.kml"), list[2]);
+#endif
 }
 
 TEST_F(KmzTest, TestCreateFromKmlFilePath) {
@@ -388,7 +396,11 @@
   ASSERT_EQ(static_cast<size_t>(3), list.size());
   ASSERT_EQ(string("doc.kml"), list[0]);
   ASSERT_EQ(string("dummy.png"), list[1]);
+#ifndef __MINGW32__
   ASSERT_EQ(string("kmzfiles/dummy.kml"), list[2]);
+#else
+  ASSERT_EQ(string("kmzfiles\\dummy.kml"), list[2]);
+#endif
 }
 
 TEST_F(KmzTest, TestCreateFromKmlFile) {
@@ -410,7 +422,11 @@
   ASSERT_EQ(static_cast<size_t>(3), list.size());
   ASSERT_EQ(string("doc.kml"), list[0]);
   ASSERT_EQ(string("dummy.png"), list[1]);
+#ifndef __MINGW32__
   ASSERT_EQ(string("kmzfiles/dummy.kml"), list[2]);
+#else
+  ASSERT_EQ(string("kmzfiles\\dummy.kml"), list[2]);
+#endif
 }
 
 TEST_F(KmzTest, TestCreateFromGoogleEarthFile) {
@@ -431,10 +447,17 @@
   created->List(&list);
   ASSERT_EQ(static_cast<size_t>(5), list.size());
   ASSERT_EQ(string("doc.kml"), list[0]);
+#ifndef __MINGW32__
   ASSERT_EQ(string("files/camelbrown200.png"), list[1]);
   ASSERT_EQ(string("files/camelblack200.png"), list[2]);
   ASSERT_EQ(string("files/camera_mode.png"), list[3]);
   ASSERT_EQ(string("files/camelcolor200.png"), list[4]);
+#else
+  ASSERT_EQ(string("files\\camelbrown200.png"), list[1]);
+  ASSERT_EQ(string("files\\camelblack200.png"), list[2]);
+  ASSERT_EQ(string("files\\camera_mode.png"), list[3]);
+  ASSERT_EQ(string("files\\camelcolor200.png"), list[4]);
+#endif
 }
 
 TEST_F(KmzTest, TestSaveToString) {
diff -Naur libkml-1.3.0-orig/tests/swig/CMakeLists.txt libkml-1.3.0/tests/swig/CMakeLists.txt
--- libkml-1.3.0-orig/tests/swig/CMakeLists.txt	2015-12-21 20:23:05.000000000 +0300
+++ libkml-1.3.0/tests/swig/CMakeLists.txt	2018-10-05 09:11:14.368816000 +0300
@@ -1,12 +1,18 @@
 if(WITH_PYTHON)
+file(COPY kmlbase_test.py DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 add_test(NAME test_python_kmlbase
-  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/kmlbase_test.py)
+  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/kmlbase_test.py
+  WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 
+file(COPY kmldom_test.py DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 add_test(NAME test_python_kmldom
-  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/kmldom_test.py)
+  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/kmldom_test.py
+  WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 
+file(COPY kmlengine_test.py DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 add_test(NAME test_python_kmlengine
-  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/kmlengine_test.py)
+  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/kmlengine_test.py
+  WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 endif()
 
 if(WITH_JAVA)
