From c41f7983838a654c830edc94470be4defd0f1686 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Mon, 27 Aug 2007 09:01:14 -0400 Subject: [PATCH] COMP: make it build on NetBSD, which has separate curses and ncurses, so it has to be detected that curses isn't good enough, but ncurses is, and that ncurses.h instead of curses.h is included Alex --- Modules/FindCurses.cmake | 19 +++++++++++--- Source/CursesDialog/CMakeLists.txt | 7 +++-- Source/CursesDialog/ccmake.cxx | 2 +- .../CursesDialog/cmCursesStandardIncludes.h | 14 +++++++++- Source/CursesDialog/form/CMakeLists.txt | 4 ++- Source/CursesDialog/form/cmFormConfigure.h.in | 26 +++++++++++++++++++ Source/CursesDialog/form/form.h | 14 +++++++++- 7 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 Source/CursesDialog/form/cmFormConfigure.h.in diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake index e4ca1407d..fffe188c9 100644 --- a/Modules/FindCurses.cmake +++ b/Modules/FindCurses.cmake @@ -3,6 +3,10 @@ # CURSES_FOUND - system has Curses # CURSES_INCLUDE_DIR - the Curses include directory # CURSES_LIBRARIES - The libraries needed to use Curses +# CURSES_HAVE_CURSES_H - true if curses.h is available +# CURSES_HAVE_NCURSES_H - true if ncurses.h is available +# CURSES_HAVE_NCURSES_NCURSES_H - true if ncurses/ncurses.h is available +# CURSES_HAVE_NCURSES_CURSES_H - true if ncurses/curses.h is available # # Set CURSES_NEED_NCURSES to TRUE before the FIND_PACKAGE() command if NCurses # functionality is required. @@ -44,16 +48,25 @@ ENDIF(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES) IF(NOT CURSES_USE_NCURSES) - FIND_PATH(CURSES_CURSES_INCLUDE_PATH curses.h ) - SET(CURSES_INCLUDE_PATH "${CURSES_CURSES_INCLUDE_PATH}") + FIND_FILE(CURSES_HAVE_CURSES_H curses.h ) + FIND_PATH(CURSES_CURSES_H_PATH curses.h ) + SET(CURSES_INCLUDE_PATH "${CURSES_CURSES_H_PATH}") + SET(CURSES_LIBRARY "${CURSES_CURSES_LIBRARY}") GET_FILENAME_COMPONENT(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH) GET_FILENAME_COMPONENT(_cursesParentDir "${_cursesLibDir}" PATH) ELSE(NOT CURSES_USE_NCURSES) # we need to find ncurses - FIND_PATH(CURSES_NCURSES_INCLUDE_PATH ncurses.h ncurses/ncurses.h ncurses/curses.h) GET_FILENAME_COMPONENT(_cursesLibDir "${CURSES_NCURSES_LIBRARY}" PATH) GET_FILENAME_COMPONENT(_cursesParentDir "${_cursesLibDir}" PATH) + + FIND_FILE(CURSES_HAVE_NCURSES_H ncurses.h) + FIND_FILE(CURSES_HAVE_NCURSES_NCURSES_H ncurses/ncurses.h) + FIND_FILE(CURSES_HAVE_NCURSES_CURSES_H ncurses/curses.h) + FIND_FILE(CURSES_HAVE_CURSES_H curses.h PATHS "${_cursesParentDir}/include" NO_DEFAULT_PATH) + FIND_FILE(CURSES_HAVE_CURSES_H curses.h) + + FIND_PATH(CURSES_NCURSES_INCLUDE_PATH ncurses.h ncurses/ncurses.h ncurses/curses.h) FIND_PATH(CURSES_NCURSES_INCLUDE_PATH curses.h PATHS "${_cursesParentDir}/include" NO_DEFAULT_PATH) FIND_PATH(CURSES_NCURSES_INCLUDE_PATH curses.h) diff --git a/Source/CursesDialog/CMakeLists.txt b/Source/CursesDialog/CMakeLists.txt index bf86e1f63..58a1c684f 100644 --- a/Source/CursesDialog/CMakeLists.txt +++ b/Source/CursesDialog/CMakeLists.txt @@ -14,15 +14,14 @@ SET( CURSES_SRCS CursesDialog/ccmake ) -INCLUDE_DIRECTORIES(${CMake_SOURCE_DIR}/Source/CursesDialog/form) +INCLUDE_DIRECTORIES(${CMake_SOURCE_DIR}/Source/CursesDialog/form + ${CMake_BINARY_DIR}/Source/CursesDialog/form) LINK_DIRECTORIES(${CMake_BINARY_DIR}/Source/CursesDialog/form) INCLUDE_DIRECTORIES(${CURSES_INCLUDE_PATH}) - - ADD_EXECUTABLE(ccmake ${CURSES_SRCS} ) TARGET_LINK_LIBRARIES(ccmake CMakeLib) TARGET_LINK_LIBRARIES(ccmake cmForm) -INSTALL_TARGETS(/bin ccmake) \ No newline at end of file +INSTALL_TARGETS(/bin ccmake) diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index 2d5cea0ae..1e26b79b3 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -23,8 +23,8 @@ #include #include "cmCursesMainForm.h" +#include "cmCursesStandardIncludes.h" -#include #include //---------------------------------------------------------------------------- diff --git a/Source/CursesDialog/cmCursesStandardIncludes.h b/Source/CursesDialog/cmCursesStandardIncludes.h index 456d4a69a..a5b229c7b 100644 --- a/Source/CursesDialog/cmCursesStandardIncludes.h +++ b/Source/CursesDialog/cmCursesStandardIncludes.h @@ -20,6 +20,8 @@ #define _MSE_INT_H #endif +#include + #if defined(__hpux) # define _BOOL_DEFINED # include @@ -28,7 +30,17 @@ # include # undef _XOPEN_SOURCE_EXTENDED #else -# include +/* figure out which curses.h to include */ +# if defined(CURSES_HAVE_NCURSES_H) +# include +# elif defined(CURSES_HAVE_NCURSES_NCURSES_H) +# include +# elif defined(CURSES_HAVE_NCURSES_CURSES_H) +# include +# else +# include +# endif + # include #endif diff --git a/Source/CursesDialog/form/CMakeLists.txt b/Source/CursesDialog/form/CMakeLists.txt index e5c8ca22b..a3d99777a 100644 --- a/Source/CursesDialog/form/CMakeLists.txt +++ b/Source/CursesDialog/form/CMakeLists.txt @@ -1,7 +1,9 @@ PROJECT(CMAKE_FORM) INCLUDE_REGULAR_EXPRESSION("^.*$") -INCLUDE_DIRECTORIES(${CURSES_INCLUDE_PATH}) +INCLUDE_DIRECTORIES(${CURSES_INCLUDE_PATH} "${CMAKE_CURRENT_BINARY_DIR}") + +CONFIGURE_FILE(cmFormConfigure.h.in "${CMAKE_CURRENT_BINARY_DIR}/cmFormConfigure.h") SET( FORM_SRCS fld_arg.c diff --git a/Source/CursesDialog/form/cmFormConfigure.h.in b/Source/CursesDialog/form/cmFormConfigure.h.in new file mode 100644 index 000000000..8f7609214 --- /dev/null +++ b/Source/CursesDialog/form/cmFormConfigure.h.in @@ -0,0 +1,26 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef CMFORMCONFIGURE_H +#define CMFORMCONFIGURE_H + +#cmakedefine CURSES_HAVE_CURSES_H +#cmakedefine CURSES_HAVE_NCURSES_H +#cmakedefine CURSES_HAVE_NCURSES_NCURSES_H +#cmakedefine CURSES_HAVE_NCURSES_CURSES_H + +#endif diff --git a/Source/CursesDialog/form/form.h b/Source/CursesDialog/form/form.h index cb291c48e..94f05af8a 100644 --- a/Source/CursesDialog/form/form.h +++ b/Source/CursesDialog/form/form.h @@ -37,7 +37,19 @@ #define _MSE_INT_H #endif -#include +#include + +/* figure out which curses.h to include */ +# if defined(CURSES_HAVE_NCURSES_H) +# include +# elif defined(CURSES_HAVE_NCURSES_NCURSES_H) +# include +# elif defined(CURSES_HAVE_NCURSES_CURSES_H) +# include +# else +# include +# endif + #include #include