Skip to content

Commit f64dafd

Browse files
committed
feat: supports building with MinGW
1 parent ed4c548 commit f64dafd

5 files changed

Lines changed: 11 additions & 6 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ target_link_libraries(
6060
PRIVATE
6161
Iconv::Iconv
6262
Threads::Threads
63-
$<$<PLATFORM_ID:Windows>:Ws2_32>
64-
$<$<PLATFORM_ID:Windows>:Iphlpapi>
65-
$<$<PLATFORM_ID:Windows>:Synchronization>
63+
$<$<PLATFORM_ID:Windows>:ws2_32>
64+
$<$<PLATFORM_ID:Windows>:iphlpapi>
65+
$<$<PLATFORM_ID:Windows>:synchronization>
6666
PUBLIC
6767
fmt::fmt
6868
$<$<CXX_COMPILER_ID:GNU>:stdc++exp>

src/os/os.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
#include <array>
44

55
#ifdef _WIN32
6+
#include <atomic>
67
#include <windows.h>
7-
#include <Lmcons.h>
8+
#include <lmcons.h>
89
#include <zero/os/windows/error.h>
910
#include <zero/strings/strings.h>
1011
#elif defined(__linux__)

src/os/process.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ zero::os::process::ID zero::os::process::currentProcessID() {
1818
#include <zero/defer.h>
1919
#include <zero/env.h>
2020
#include <fmt/ranges.h>
21+
#include <algorithm>
2122
#include <cassert>
2223
#include <ranges>
2324
#include <future>
@@ -28,7 +29,6 @@ zero::os::process::ID zero::os::process::currentProcessID() {
2829
#include <zero/os/windows/error.h>
2930
#else
3031
#include <csignal>
31-
#include <algorithm>
3232
#include <fcntl.h>
3333
#include <spawn.h>
3434
#include <sys/wait.h>

src/os/windows/process.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ std::expected<DWORD, std::error_code> zero::os::windows::process::Process::ppid(
9393
));
9494
}));
9595

96+
#ifdef __MINGW32__
97+
return static_cast<DWORD>(reinterpret_cast<std::uintptr_t>(info.InheritedFromUniqueProcessId));
98+
#else
9699
return static_cast<DWORD>(reinterpret_cast<std::uintptr_t>(info.Reserved3));
100+
#endif
97101
}
98102

99103
std::expected<std::string, std::error_code> zero::os::windows::process::Process::name() const {

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ target_link_libraries(
4949
Threads::Threads
5050
Catch2::Catch2WithMain
5151
FakeIt::FakeIt-catch
52-
$<$<PLATFORM_ID:Windows>:Iphlpapi>
52+
$<$<PLATFORM_ID:Windows>:iphlpapi>
5353
)
5454

5555
include(Catch)

0 commit comments

Comments
 (0)