mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 14:08:35 +08:00
FindCurses: Add option for ncursesw detection
This is a remake of the patch from issue #10347 but based on current master. Works for me on Lubuntu 17.04. Fixes: #10347
This commit is contained in:

committed by
Brad King

parent
10edb0c7d5
commit
4b02afc0ca
@@ -29,6 +29,8 @@
|
|||||||
#
|
#
|
||||||
# Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the
|
# Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the
|
||||||
# ``find_package(Curses)`` call if NCurses functionality is required.
|
# ``find_package(Curses)`` call if NCurses functionality is required.
|
||||||
|
# Set ``CURSES_NEED_WIDE`` to ``TRUE`` before the
|
||||||
|
# ``find_package(Curses)`` call if unicode functionality is required.
|
||||||
#
|
#
|
||||||
# Backward Compatibility
|
# Backward Compatibility
|
||||||
# ^^^^^^^^^^^^^^^^^^^^^^
|
# ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
@@ -42,9 +44,20 @@
|
|||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
|
||||||
|
|
||||||
|
# we don't know anything about cursesw, so only ncurses
|
||||||
|
# may be ncursesw
|
||||||
|
if(NOT CURSES_NEED_WIDE)
|
||||||
|
set(NCURSES_LIBRARY_NAME "ncurses")
|
||||||
|
else()
|
||||||
|
set(NCURSES_LIBRARY_NAME "ncursesw")
|
||||||
|
# Also, if we are searchig fo wide curses - we are actually searching
|
||||||
|
# for ncurses, we don't know about any other unicode version.
|
||||||
|
set(CURSES_NEED_NCURSES TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_library(CURSES_CURSES_LIBRARY NAMES curses )
|
find_library(CURSES_CURSES_LIBRARY NAMES curses )
|
||||||
|
|
||||||
find_library(CURSES_NCURSES_LIBRARY NAMES ncurses )
|
find_library(CURSES_NCURSES_LIBRARY NAMES "${NCURSES_LIBRARY_NAME}" )
|
||||||
set(CURSES_USE_NCURSES FALSE)
|
set(CURSES_USE_NCURSES FALSE)
|
||||||
|
|
||||||
if(CURSES_NCURSES_LIBRARY AND ((NOT CURSES_CURSES_LIBRARY) OR CURSES_NEED_NCURSES))
|
if(CURSES_NCURSES_LIBRARY AND ((NOT CURSES_CURSES_LIBRARY) OR CURSES_NEED_NCURSES))
|
||||||
@@ -55,9 +68,15 @@ endif()
|
|||||||
# message. Cygwin is an ncurses package, so force ncurses on
|
# message. Cygwin is an ncurses package, so force ncurses on
|
||||||
# cygwin if the curses.h is missing
|
# cygwin if the curses.h is missing
|
||||||
if(CYGWIN)
|
if(CYGWIN)
|
||||||
|
if (CURSES_NEED_WIDE)
|
||||||
|
if(NOT EXISTS /usr/include/ncursesw/curses.h)
|
||||||
|
set(CURSES_USE_NCURSES TRUE)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
if(NOT EXISTS /usr/include/curses.h)
|
if(NOT EXISTS /usr/include/curses.h)
|
||||||
set(CURSES_USE_NCURSES TRUE)
|
set(CURSES_USE_NCURSES TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
@@ -96,17 +115,32 @@ if(CURSES_USE_NCURSES)
|
|||||||
|
|
||||||
# Use CURSES_NCURSES_INCLUDE_PATH if set, for compatibility.
|
# Use CURSES_NCURSES_INCLUDE_PATH if set, for compatibility.
|
||||||
if(CURSES_NCURSES_INCLUDE_PATH)
|
if(CURSES_NCURSES_INCLUDE_PATH)
|
||||||
|
if (CURSES_NEED_WIDE)
|
||||||
|
find_path(CURSES_INCLUDE_PATH
|
||||||
|
NAMES ncursesw/ncurses.h ncursesw/curses.h
|
||||||
|
PATHS ${CURSES_NCURSES_INCLUDE_PATH}
|
||||||
|
NO_DEFAULT_PATH
|
||||||
|
)
|
||||||
|
else()
|
||||||
find_path(CURSES_INCLUDE_PATH
|
find_path(CURSES_INCLUDE_PATH
|
||||||
NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h
|
NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h
|
||||||
PATHS ${CURSES_NCURSES_INCLUDE_PATH}
|
PATHS ${CURSES_NCURSES_INCLUDE_PATH}
|
||||||
NO_DEFAULT_PATH
|
NO_DEFAULT_PATH
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (CURSES_NEED_WIDE)
|
||||||
|
find_path(CURSES_INCLUDE_PATH
|
||||||
|
NAMES ncursesw/ncurses.h ncursesw/curses.h
|
||||||
|
HINTS "${_cursesParentDir}/include"
|
||||||
|
)
|
||||||
|
else()
|
||||||
find_path(CURSES_INCLUDE_PATH
|
find_path(CURSES_INCLUDE_PATH
|
||||||
NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h
|
NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h
|
||||||
HINTS "${_cursesParentDir}/include"
|
HINTS "${_cursesParentDir}/include"
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Previous versions of FindCurses provided these values.
|
# Previous versions of FindCurses provided these values.
|
||||||
if(NOT DEFINED CURSES_LIBRARY)
|
if(NOT DEFINED CURSES_LIBRARY)
|
||||||
@@ -123,10 +157,14 @@ else()
|
|||||||
get_filename_component(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH)
|
get_filename_component(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH)
|
||||||
get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
|
get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
|
||||||
|
|
||||||
|
#We can't find anything with CURSES_NEED_WIDE because we know
|
||||||
|
#only about ncursesw unicode curses version
|
||||||
|
if(NOT CURSES_NEED_WIDE)
|
||||||
find_path(CURSES_INCLUDE_PATH
|
find_path(CURSES_INCLUDE_PATH
|
||||||
NAMES curses.h
|
NAMES curses.h
|
||||||
HINTS "${_cursesParentDir}/include"
|
HINTS "${_cursesParentDir}/include"
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Previous versions of FindCurses provided these values.
|
# Previous versions of FindCurses provided these values.
|
||||||
if(NOT DEFINED CURSES_CURSES_H_PATH)
|
if(NOT DEFINED CURSES_CURSES_H_PATH)
|
||||||
@@ -139,32 +177,45 @@ endif()
|
|||||||
|
|
||||||
# Report whether each possible header name exists in the include directory.
|
# Report whether each possible header name exists in the include directory.
|
||||||
if(NOT DEFINED CURSES_HAVE_NCURSES_NCURSES_H)
|
if(NOT DEFINED CURSES_HAVE_NCURSES_NCURSES_H)
|
||||||
if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses/ncurses.h")
|
if(CURSES_NEED_WIDE)
|
||||||
|
if(EXISTS "${CURSES_INCLUDE_PATH}/ncursesw/ncurses.h")
|
||||||
|
set(CURSES_HAVE_NCURSES_NCURSES_H "${CURSES_INCLUDE_PATH}/ncursesw/ncurses.h")
|
||||||
|
endif()
|
||||||
|
elseif(EXISTS "${CURSES_INCLUDE_PATH}/ncurses/ncurses.h")
|
||||||
set(CURSES_HAVE_NCURSES_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses/ncurses.h")
|
set(CURSES_HAVE_NCURSES_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses/ncurses.h")
|
||||||
else()
|
endif()
|
||||||
|
if(NOT DEFINED CURSES_HAVE_NCURSES_NCURSES_H)
|
||||||
set(CURSES_HAVE_NCURSES_NCURSES_H "CURSES_HAVE_NCURSES_NCURSES_H-NOTFOUND")
|
set(CURSES_HAVE_NCURSES_NCURSES_H "CURSES_HAVE_NCURSES_NCURSES_H-NOTFOUND")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(NOT DEFINED CURSES_HAVE_NCURSES_CURSES_H)
|
if(NOT DEFINED CURSES_HAVE_NCURSES_CURSES_H)
|
||||||
if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses/curses.h")
|
if(CURSES_NEED_WIDE)
|
||||||
|
if(EXISTS "${CURSES_INCLUDE_PATH}/ncursesw/curses.h")
|
||||||
|
set(CURSES_HAVE_NCURSES_CURSES_H "${CURSES_INCLUDE_PATH}/ncursesw/curses.h")
|
||||||
|
endif()
|
||||||
|
elseif(EXISTS "${CURSES_INCLUDE_PATH}/ncurses/curses.h")
|
||||||
set(CURSES_HAVE_NCURSES_CURSES_H "${CURSES_INCLUDE_PATH}/ncurses/curses.h")
|
set(CURSES_HAVE_NCURSES_CURSES_H "${CURSES_INCLUDE_PATH}/ncurses/curses.h")
|
||||||
else()
|
endif()
|
||||||
|
if(NOT DEFINED CURSES_HAVE_NCURSES_CURSES_H)
|
||||||
set(CURSES_HAVE_NCURSES_CURSES_H "CURSES_HAVE_NCURSES_CURSES_H-NOTFOUND")
|
set(CURSES_HAVE_NCURSES_CURSES_H "CURSES_HAVE_NCURSES_CURSES_H-NOTFOUND")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(NOT DEFINED CURSES_HAVE_NCURSES_H)
|
if(NOT CURSES_NEED_WIDE)
|
||||||
|
#ncursesw can't be found for this paths
|
||||||
|
if(NOT DEFINED CURSES_HAVE_NCURSES_H)
|
||||||
if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses.h")
|
if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses.h")
|
||||||
set(CURSES_HAVE_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses.h")
|
set(CURSES_HAVE_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses.h")
|
||||||
else()
|
else()
|
||||||
set(CURSES_HAVE_NCURSES_H "CURSES_HAVE_NCURSES_H-NOTFOUND")
|
set(CURSES_HAVE_NCURSES_H "CURSES_HAVE_NCURSES_H-NOTFOUND")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(NOT DEFINED CURSES_HAVE_CURSES_H)
|
if(NOT DEFINED CURSES_HAVE_CURSES_H)
|
||||||
if(EXISTS "${CURSES_INCLUDE_PATH}/curses.h")
|
if(EXISTS "${CURSES_INCLUDE_PATH}/curses.h")
|
||||||
set(CURSES_HAVE_CURSES_H "${CURSES_INCLUDE_PATH}/curses.h")
|
set(CURSES_HAVE_CURSES_H "${CURSES_INCLUDE_PATH}/curses.h")
|
||||||
else()
|
else()
|
||||||
set(CURSES_HAVE_CURSES_H "CURSES_HAVE_CURSES_H-NOTFOUND")
|
set(CURSES_HAVE_CURSES_H "CURSES_HAVE_CURSES_H-NOTFOUND")
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_library(CURSES_FORM_LIBRARY form HINTS "${_cursesLibDir}")
|
find_library(CURSES_FORM_LIBRARY form HINTS "${_cursesLibDir}")
|
||||||
|
Reference in New Issue
Block a user