StephanTLavavej / mingw-distro

MinGW distro build scripts.
499 stars 55 forks source link

FreeType needs to upstream a CMakeLists.txt patch for the MSYS environment #97

Open StephanTLavavej opened 9 months ago

StephanTLavavej commented 9 months ago

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.

StephanTLavavej commented 9 months ago

Aside: This issue also affects SDL2, although I'm not yet using CMake for it.

apodtele commented 9 months ago

If we switch order of WIN32 and UNIX checks, would it work too?

StephanTLavavej commented 8 months ago

I believe so; that's what I said originally:

(and for the second location selecting ftsystem.c, simply checking WIN32 before UNIX)

apodtele commented 8 months ago

@lemzwerg @madig This seems necessary for CMake to work with mingw. Ok?

lemzwerg commented 8 months ago

I've never worked with MSYS, so I can't tell whether it works. So please proceed as you think it's best.

StephanTLavavej commented 8 months ago

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.

apodtele commented 8 months ago

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?

apodtele commented 8 months ago

Committed.

StephanTLavavej commented 8 months ago

Thank you! :heart_eyes_cat: