fix: enable Windows 7 compatibility for static build
This commit is contained in:
parent
003b9306e7
commit
20ce7caaa8
@ -21,6 +21,10 @@ include(cmake/deps_occ.cmake)
|
|||||||
# Add an option to enable static builds
|
# Add an option to enable static builds
|
||||||
OPTION(BUILD_STATIC "Build STP2GLB as a static executable." OFF)
|
OPTION(BUILD_STATIC "Build STP2GLB as a static executable." OFF)
|
||||||
|
|
||||||
|
if (WIN32 AND DEFINED WIN32_WINNT)
|
||||||
|
add_compile_definitions(_WIN32_WINNT=${WIN32_WINNT})
|
||||||
|
endif ()
|
||||||
|
|
||||||
if (BUILD_STATIC)
|
if (BUILD_STATIC)
|
||||||
message(STATUS "Building STP2GLB as a static executable.")
|
message(STATUS "Building STP2GLB as a static executable.")
|
||||||
|
|
||||||
|
|||||||
31
src/third_party/httplib.h
vendored
31
src/third_party/httplib.h
vendored
@ -32,9 +32,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0A00
|
#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0601
|
||||||
#error \
|
#error \
|
||||||
"cpp-httplib doesn't support Windows 8 or lower. Please use Windows 10 or later."
|
"cpp-httplib doesn't support platforms older than Windows 7 SP1."
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -3083,8 +3083,14 @@ inline bool mmap::open(const char *path) {
|
|||||||
auto wpath = u8string_to_wstring(path);
|
auto wpath = u8string_to_wstring(path);
|
||||||
if (wpath.empty()) { return false; }
|
if (wpath.empty()) { return false; }
|
||||||
|
|
||||||
hFile_ = ::CreateFile2(wpath.c_str(), GENERIC_READ, FILE_SHARE_READ,
|
hFile_ =
|
||||||
OPEN_EXISTING, NULL);
|
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0602
|
||||||
|
::CreateFile2(wpath.c_str(), GENERIC_READ, FILE_SHARE_READ,
|
||||||
|
OPEN_EXISTING, NULL);
|
||||||
|
#else
|
||||||
|
::CreateFileW(wpath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||||
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (hFile_ == INVALID_HANDLE_VALUE) { return false; }
|
if (hFile_ == INVALID_HANDLE_VALUE) { return false; }
|
||||||
|
|
||||||
@ -3101,7 +3107,17 @@ inline bool mmap::open(const char *path) {
|
|||||||
size_ = static_cast<size_t>(size.QuadPart);
|
size_ = static_cast<size_t>(size.QuadPart);
|
||||||
|
|
||||||
hMapping_ =
|
hMapping_ =
|
||||||
|
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0602
|
||||||
::CreateFileMappingFromApp(hFile_, NULL, PAGE_READONLY, size_, NULL);
|
::CreateFileMappingFromApp(hFile_, NULL, PAGE_READONLY, size_, NULL);
|
||||||
|
#else
|
||||||
|
::CreateFileMappingW(
|
||||||
|
hFile_, NULL, PAGE_READONLY,
|
||||||
|
static_cast<DWORD>((static_cast<unsigned long long>(size_) >> 32) &
|
||||||
|
0xffffffffULL),
|
||||||
|
static_cast<DWORD>(static_cast<unsigned long long>(size_) &
|
||||||
|
0xffffffffULL),
|
||||||
|
NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Special treatment for an empty file...
|
// Special treatment for an empty file...
|
||||||
if (hMapping_ == NULL && size_ == 0) {
|
if (hMapping_ == NULL && size_ == 0) {
|
||||||
@ -3115,7 +3131,12 @@ inline bool mmap::open(const char *path) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
addr_ = ::MapViewOfFileFromApp(hMapping_, FILE_MAP_READ, 0, 0);
|
addr_ =
|
||||||
|
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0602
|
||||||
|
::MapViewOfFileFromApp(hMapping_, FILE_MAP_READ, 0, 0);
|
||||||
|
#else
|
||||||
|
::MapViewOfFile(hMapping_, FILE_MAP_READ, 0, 0, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (addr_ == nullptr) {
|
if (addr_ == nullptr) {
|
||||||
close();
|
close();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user