fix-mingw.diff 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index d39958a..ba21f3c 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -117,8 +117,14 @@ if(BUILD_SHARED_LIBS AND WIN32 AND HTTPLIB_COMPILE)
  6. set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
  7. endif()
  8. -if(CMAKE_SYSTEM_NAME MATCHES "Windows" AND ${CMAKE_SYSTEM_VERSION} VERSION_LESS "10.0.0")
  9. - message(SEND_ERROR "Windows ${CMAKE_SYSTEM_VERSION} or lower is not supported. Please use Windows 10 or later.")
  10. +if(CMAKE_SYSTEM_NAME MATCHES "Windows")
  11. + if(CMAKE_SYSTEM_VERSION)
  12. + if(${CMAKE_SYSTEM_VERSION} VERSION_LESS "10.0.0")
  13. + message(SEND_ERROR "Windows ${CMAKE_SYSTEM_VERSION} or lower is not supported. Please use Windows 10 or later.")
  14. + endif()
  15. + else()
  16. + message(WARNING "Cross-compiling for Windows, but CMAKE_SYSTEM_VERSION is not specified. Assuming target is Windows 10 or later.")
  17. + endif()
  18. endif()
  19. if(CMAKE_SIZEOF_VOID_P LESS 8)
  20. message(WARNING "Pointer size ${CMAKE_SIZEOF_VOID_P} is not supported. Please use a 64-bit compiler.")
  21. diff --git a/httplib.h b/httplib.h
  22. index e15ba44..728504a 100644
  23. --- a/httplib.h
  24. +++ b/httplib.h
  25. @@ -3083,8 +3083,13 @@ inline bool mmap::open(const char *path) {
  26. auto wpath = u8string_to_wstring(path);
  27. if (wpath.empty()) { return false; }
  28. +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM | WINAPI_PARTITION_GAMES) && (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
  29. hFile_ = ::CreateFile2(wpath.c_str(), GENERIC_READ, FILE_SHARE_READ,
  30. OPEN_EXISTING, NULL);
  31. +#else
  32. + hFile_ = ::CreateFileW(wpath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL,
  33. + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  34. +#endif
  35. if (hFile_ == INVALID_HANDLE_VALUE) { return false; }