[mojosetup] CMake curses stuff [diff attached]
Chunky Kibbles
chunky at icculus.org
Thu Feb 25 23:52:08 EST 2010
I just checked out from hg, and tried to build. This is a stock ubuntu
9.04 box.
I got an error, the core of which was that <ncursesw/curses.h> doesn't
exist here. Looking at CMakeLists.txt, there was a FIXME to uses
FindCurses. Thus, the attachment.
It's not pretty, as there could be a whole bunch of different includes
that cmake finds, so I've #if defined like crazy. For shame, I'm not sure
if "#if defined(MACRO)" is as portable as a nested charlie foxtrot of
"#ifdef". If it's not, please say so and I can edit the patch
appropriately.
Anyways. Please find attached a diff to make it build using FindCurses,
which causes it to successfully build on this machine now.
Gary (-;
-------------- next part --------------
diff -r d4251dabe79a CMakeLists.txt
--- a/CMakeLists.txt Tue Feb 16 14:05:06 2010 -0500
+++ b/CMakeLists.txt Wed Feb 24 00:36:40 2010 -0800
@@ -374,27 +374,40 @@
ENDIF(MOJOSETUP_GUI_STDIO)
# BINARY SIZE += !!! FIXME: check this.
-IF(UNIX) # !!! FIXME: use FindCurses instead...
+FIND_PACKAGE(Curses)
+IF(CURSES_FOUND)
IF(NOT BEOS)
IF(NOT MACOSX)
IF(NOT SOLARIS) # !!! FIXME: Solaris's curses is really broken, or I'm using it wrong.
OPTION(MOJOSETUP_GUI_NCURSES "Enable ncurses GUI" TRUE)
IF(MOJOSETUP_GUI_NCURSES)
ADD_DEFINITIONS(-DSUPPORT_GUI_NCURSES=1)
+ INCLUDE_DIRECTORIES(CURSES_INCLUDE_DIR)
+
+ IF(CURSES_HAVE_NCURSES_NCURSES_H)
+ ADD_DEFINITIONS(-DHAVE_NCURSES_NCURSES_H)
+ ELSEIF(CURSES_HAVE_NCURSES_CURSES_H)
+ ADD_DEFINITIONS(-DHAVE_NCURSES_CURSES_H)
+ ELSEIF(CURSES_HAVE_NCURSES_H)
+ ADD_DEFINITIONS(-DHAVE_NCURSES_H)
+ ELSEIF(CURSES_HAVE_CURSES_H)
+ ADD_DEFINITIONS(-DHAVE_CURSES_H)
+ ENDIF(CURSES_HAVE_NCURSES_NCURSES_H)
+
OPTION(MOJOSETUP_GUI_NCURSES_STATIC "Statically link ncurses GUI" FALSE)
IF(MOJOSETUP_GUI_NCURSES_STATIC)
ADD_DEFINITIONS(-DGUI_STATIC_LINK_NCURSES=1)
SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} gui_ncurses.c)
- SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} -lncursesw) # !!! FIXME
+ SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} ${CURSES_LIBRARIES})
ELSE(MOJOSETUP_GUI_NCURSES_STATIC)
MOJOSETUP_ADD_LIBRARY(mojosetupgui_ncurses gui_ncurses.c)
- TARGET_LINK_LIBRARIES(mojosetupgui_ncurses "-lncursesw") # !!! FIXME
+ TARGET_LINK_LIBRARIES(mojosetupgui_ncurses ${CURSES_LIBRARIES})
ENDIF(MOJOSETUP_GUI_NCURSES_STATIC)
ENDIF(MOJOSETUP_GUI_NCURSES)
ENDIF(NOT SOLARIS)
ENDIF(NOT MACOSX)
ENDIF(NOT BEOS)
-ENDIF(UNIX)
+ENDIF(CURSES_FOUND)
IF(MACOSX)
OPTION(MOJOSETUP_GUI_COCOA "Enable Cocoa GUI" TRUE)
diff -r d4251dabe79a gui_ncurses.c
--- a/gui_ncurses.c Tue Feb 16 14:05:06 2010 -0500
+++ b/gui_ncurses.c Wed Feb 24 00:36:40 2010 -0800
@@ -21,7 +21,19 @@
#include <unistd.h>
#include <ctype.h>
-#include <ncursesw/curses.h>
+// CMake searches for a whole bunch of different possible curses includes
+#if defined(HAVE_NCURSES_NCURSES_H)
+#include <ncurses/ncurses.h>
+#elif defined(HAVE_NCURSES_CURSES_H)
+#include <ncurses/curses.h>
+#elif defined(HAVE_NCURSES_H)
+#include <ncurses.h>
+#elif defined(HAVE_CURSES_H)
+#include <curses.h>
+#else
+#error ncurses gui enabled, but no known header file found
+#endif
+
#include <locale.h>
// This was built to look roughly like dialog(1), but it's not nearly as
More information about the mojosetup
mailing list