Open StephanTLavavej opened 10 months ago
Aside: This issue also affects SDL2, although I'm not yet using CMake for it.
If we switch order of WIN32 and UNIX checks, would it work too?
I believe so; that's what I said originally:
(and for the second location selecting ftsystem.c, simply checking WIN32 before UNIX)
@lemzwerg @madig This seems necessary for CMake to work with mingw. Ok?
I've never worked with MSYS, so I can't tell whether it works. So please proceed as you think it's best.
Note that I don't fully understand the CMake build environment - I suspect that UNIX AND NOT MINGW AND NOT MSYS
may be a more proper fix. It should be low-risk either way.
Elsewhere we check WIN32 before UNIX to make sure that Windows native calls have priority under MinGW. This is robust, also works with MSVC and does not confuse unixes. Please use WIN32 instead of MSYS/MINGW because CMake is supposed to work with MSVC too. Secondly, is it possible to consolidate both code segments?
Committed.
Thank you! :heart_eyes_cat:
With CMake 3.28.1 in MSYS2/mingw-w64, I need to patch a couple of lines in FreeType's CMakeLists.txt:
https://github.com/StephanTLavavej/mingw-distro/blob/f74a2a8c7eeb7b9a21763553e06c0cf77434098d/freetype-fix-cmake-mingw.patch#L1-L21
This is because this environment identifies itself as both UNIX and WIN32, but it lacks unistd.h and fcntl.h, and builds/unix/ftsystem.c is completely inappropriate for it.
Checking
UNIX AND NOT MSYS
is my current minimally-invasive approach.UNIX AND NOT WIN32
would also work (and for the second location selecting ftsystem.c, simply checking WIN32 before UNIX), but I'm not sure if that would negatively impact Cygwin.This (or some similar fix) should be upstreamed to FreeType.