From e28a2c09840415d3b3c1436fda1e42ad7face23a Mon Sep 17 00:00:00 2001 From: carlzhc <356889@gmail.com> Date: Tue, 9 Apr 2024 08:06:42 +0800 Subject: [PATCH] Fix build errors on MSYS platform --- CMakeLists.txt | 6 ++++++ GNUmakefile | 3 +++ ttyio.c | 3 +++ 3 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0c9dca0..6dae2f85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,12 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux") string (REPLACE ";" " " LIBBSD_FLAGS "${BSD_CFLAGS}") target_link_libraries (mg ${BSD_LIBRARIES}) set (CMAKE_C_FLAGS "-Wall -DREGEX -D_GNU_SOURCE ${LIBBSD_FLAGS} ${NCURSES_FLAGS} -L${NCURSES_LIBRARY_DIRS}") +elseif(CMAKE_SYSTEM_NAME MATCHES "MSYS") + pkg_check_modules (BSD REQUIRED libbsd-overlay) + link_directories (${BSD_LIBRARY_DIRS}) + string (REPLACE ";" " " LIBBSD_FLAGS "${BSD_CFLAGS}") + target_link_libraries (mg ${BSD_LIBRARIES}) + set (CMAKE_C_FLAGS "-Wall -DREGEX -isystem /usr/include -D_GNU_SOURCE ${LIBBSD_FLAGS} ${NCURSES_FLAGS}") else() set (CMAKE_C_FLAGS "-Wall -DREGEX ${LIBBSD_FLAGS} ${NCURSES_FLAGS} -L${NCURSES_LIBRARY_DIRS}") endif() diff --git a/GNUmakefile b/GNUmakefile index 9afa1b8e..d8945d03 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -40,6 +40,9 @@ endif ifdef STATIC LDFLAGS=-static -static-libgcc + ifneq ($(MSYSTEM),) + CURSES_LIBS:= $(CURSES_LIBS).dll + endif endif CC?= gcc diff --git a/ttyio.c b/ttyio.c index d4ede36c..c3f91dfa 100644 --- a/ttyio.c +++ b/ttyio.c @@ -14,6 +14,9 @@ #include #include #include +#if defined(__MSYS__) +#include +#endif #include #include #include