Look for shlwapi.h also in case of MinGW.
diff --git a/CMakeLists.txt b/CMakeLists.txt
old mode 100644
new mode 100755
index ae24799..fa456ea
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -82,11 +82,11 @@
   set (HAVE_INTTYPES_H  0)
   set (HAVE_UNISTD_H    0)
   set (HAVE_SYS_STAT_H  1)
-  check_include_file_cxx ("shlwapi.h" HAVE_SHLWAPI_H)
+  set (HAVE_SHLWAPI_H   1)
 else ()
   foreach (fname IN ITEMS unistd stdint inttypes sys/types sys/stat fnmatch)
     string (TOUPPER "${fname}" FNAME)
-    string (REGEX REPLACE "/" "_" FNAME "${FNAME}")
+    string (REPLACE "/" "_" FNAME "${FNAME}")
     if (NOT HAVE_${FNAME}_H)
       check_include_file_cxx ("${fname}.h" HAVE_${FNAME}_H)
     endif ()
@@ -95,6 +95,9 @@
   bool_to_int (HAVE_STDINT_H)
   bool_to_int (HAVE_SYS_TYPES_H)
   bool_to_int (HAVE_INTTYPES_H)
+  if (NOT HAVE_FNMATCH_H AND OS_WINDOWS)
+    check_include_file_cxx ("shlwapi.h" HAVE_SHLWAPI_H)
+  endif ()
 endif ()
 
 set (GFLAGS_INTTYPES_FORMAT "" CACHE STRING "Format of integer types: \"C99\" (uint32_t), \"BSD\" (u_int32_t), \"VC7\" (__int32)")