Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Patch for compile both CMake and PDCurses with MSVC
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a2fcf2e372..9d2a8f20da 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -656,15 +656,10 @@ macro (CMAKE_BUILD_UTILITIES)
endif()
#---------------------------------------------------------------------
- # Use curses?
- if (UNIX)
- if(NOT DEFINED BUILD_CursesDialog)
- include(${CMake_SOURCE_DIR}/Source/Checks/Curses.cmake)
- option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" "${CMakeCheckCurses_COMPILED}")
- endif()
- else ()
- set(BUILD_CursesDialog 0)
- endif ()
+ set(CURSES_INCLUDE_PATH "D:/Data/Projects/externals/PDCurses")
+ set(CURSES_LIBRARY "D:/Data/Projects/externals/PDCurses/wincon/pdcurses.lib")
+
+ set(BUILD_CursesDialog 1)
if(BUILD_CursesDialog)
set(CURSES_NEED_NCURSES TRUE)
find_package(Curses)
diff --git a/Source/Checks/Curses/CMakeLists.txt b/Source/Checks/Curses/CMakeLists.txt
index 17318a33b2..44c6b162a1 100644
--- a/Source/Checks/Curses/CMakeLists.txt
+++ b/Source/Checks/Curses/CMakeLists.txt
@@ -5,6 +5,9 @@ endif()
project(CheckCurses C)
set(CURSES_NEED_NCURSES TRUE)
+set(CURSES_INCLUDE_PATH "D:/Data/Projects/externals/PDCurses")
+set(CURSES_LIBRARY "D:/Data/Projects/externals/PDCurses/wincon/pdcurses.lib")
+
find_package(Curses)
if(NOT CURSES_FOUND)
return()
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index 85e256b8bc..cd486db66c 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -9,7 +9,7 @@
#include <string>
#include <vector>
-#include <unistd.h>
+#include <io.h>
#include "cmsys/Encoding.hxx"
@@ -60,7 +60,7 @@ void onsig(int /*unused*/)
endwin();
if (initscr() == nullptr) {
static const char errmsg[] = "Error: ncurses initialization failed\n";
- auto r = write(STDERR_FILENO, errmsg, sizeof(errmsg) - 1);
+ auto r = _write(_fileno(stderr), errmsg, sizeof(errmsg) - 1);
static_cast<void>(r);
exit(1);
}
@@ -74,7 +74,7 @@ void onsig(int /*unused*/)
cmCursesForm::CurrentForm->Render(1, 1, x, y);
cmCursesForm::CurrentForm->UpdateStatusBar();
}
- signal(SIGWINCH, onsig);
+ signal(28, onsig);
}
}
@@ -142,7 +142,7 @@ int main(int argc, char const* const* argv)
keypad(stdscr, true); /* Use key symbols as KEY_DOWN */
cmCursesColor::InitColors();
- signal(SIGWINCH, onsig);
+ signal(28, onsig);
int x;
int y;
diff --git a/curses.h b/curses.h
index b5b91fda..0978a286 100644
--- a/curses.h
+++ b/curses.h
@@ -621,10 +621,10 @@ indicator.
#define KEY_CODE_YES 0x100 /* If get_wch() gives a key code */
#define KEY_BREAK 0x101 /* Not on PC KBD */
-#define KEY_DOWN 0x102 /* Down arrow key */
-#define KEY_UP 0x103 /* Up arrow key */
-#define KEY_LEFT 0x104 /* Left arrow key */
-#define KEY_RIGHT 0x105 /* Right arrow key */
+#define KEY_DOWN 0x1C8 /* Down arrow key */
+#define KEY_UP 0x1C2 /* Up arrow key */
+#define KEY_LEFT 0x1C4 /* Left arrow key */
+#define KEY_RIGHT 0x1C6 /* Right arrow key */
#define KEY_HOME 0x106 /* home key */
#define KEY_BACKSPACE 0x107 /* not on pc */
#define KEY_F0 0x108 /* function keys; 64 reserved */
diff --git a/wincon/Makefile b/wincon/Makefile
index b7d7c90b..e0b22af9 100644
--- a/wincon/Makefile
+++ b/wincon/Makefile
@@ -26,11 +26,11 @@ include $(common)/libobjs.mif
PDCURSES_WIN_H = $(osdir)/pdcwin.h
-CC = gcc
-AR = ar
-STRIP = strip
-LINK = gcc
-WINDRES = windres
+CC = /usr/bin/x86_64-w64-mingw32-gcc
+AR = /usr/bin/x86_64-w64-mingw32-ar
+STRIP = /usr/bin/x86_64-w64-mingw32-strip
+LINK = /usr/bin/x86_64-w64-mingw32-gcc
+WINDRES = /usr/bin/x86_64-w64-mingw32-windres
ifeq ($(DEBUG),Y)
CFLAGS = -g -Wall -DPDCDEBUG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment