mirror of
https://github.com/reactos/CMake.git
synced 2025-01-21 02:45:05 +00: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:
parent
10edb0c7d5
commit
4b02afc0ca
@ -29,6 +29,8 @@
|
||||
#
|
||||
# Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the
|
||||
# ``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
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -42,9 +44,20 @@
|
||||
|
||||
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_NCURSES_LIBRARY NAMES ncurses )
|
||||
find_library(CURSES_NCURSES_LIBRARY NAMES "${NCURSES_LIBRARY_NAME}" )
|
||||
set(CURSES_USE_NCURSES FALSE)
|
||||
|
||||
if(CURSES_NCURSES_LIBRARY AND ((NOT CURSES_CURSES_LIBRARY) OR CURSES_NEED_NCURSES))
|
||||
@ -55,8 +68,14 @@ endif()
|
||||
# message. Cygwin is an ncurses package, so force ncurses on
|
||||
# cygwin if the curses.h is missing
|
||||
if(CYGWIN)
|
||||
if(NOT EXISTS /usr/include/curses.h)
|
||||
set(CURSES_USE_NCURSES TRUE)
|
||||
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)
|
||||
set(CURSES_USE_NCURSES TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -96,17 +115,32 @@ if(CURSES_USE_NCURSES)
|
||||
|
||||
# Use CURSES_NCURSES_INCLUDE_PATH if set, for compatibility.
|
||||
if(CURSES_NCURSES_INCLUDE_PATH)
|
||||
find_path(CURSES_INCLUDE_PATH
|
||||
NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h
|
||||
PATHS ${CURSES_NCURSES_INCLUDE_PATH}
|
||||
NO_DEFAULT_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
|
||||
NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h
|
||||
PATHS ${CURSES_NCURSES_INCLUDE_PATH}
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_path(CURSES_INCLUDE_PATH
|
||||
NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h
|
||||
HINTS "${_cursesParentDir}/include"
|
||||
)
|
||||
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
|
||||
NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h
|
||||
HINTS "${_cursesParentDir}/include"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Previous versions of FindCurses provided these values.
|
||||
if(NOT DEFINED CURSES_LIBRARY)
|
||||
@ -123,10 +157,14 @@ else()
|
||||
get_filename_component(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH)
|
||||
get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
|
||||
|
||||
find_path(CURSES_INCLUDE_PATH
|
||||
NAMES curses.h
|
||||
HINTS "${_cursesParentDir}/include"
|
||||
)
|
||||
#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
|
||||
NAMES curses.h
|
||||
HINTS "${_cursesParentDir}/include"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Previous versions of FindCurses provided these values.
|
||||
if(NOT DEFINED CURSES_CURSES_H_PATH)
|
||||
@ -139,31 +177,44 @@ endif()
|
||||
|
||||
# Report whether each possible header name exists in the include directory.
|
||||
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")
|
||||
else()
|
||||
endif()
|
||||
if(NOT DEFINED CURSES_HAVE_NCURSES_NCURSES_H)
|
||||
set(CURSES_HAVE_NCURSES_NCURSES_H "CURSES_HAVE_NCURSES_NCURSES_H-NOTFOUND")
|
||||
endif()
|
||||
endif()
|
||||
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")
|
||||
else()
|
||||
endif()
|
||||
if(NOT DEFINED CURSES_HAVE_NCURSES_CURSES_H)
|
||||
set(CURSES_HAVE_NCURSES_CURSES_H "CURSES_HAVE_NCURSES_CURSES_H-NOTFOUND")
|
||||
endif()
|
||||
endif()
|
||||
if(NOT DEFINED CURSES_HAVE_NCURSES_H)
|
||||
if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses.h")
|
||||
set(CURSES_HAVE_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses.h")
|
||||
else()
|
||||
set(CURSES_HAVE_NCURSES_H "CURSES_HAVE_NCURSES_H-NOTFOUND")
|
||||
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")
|
||||
set(CURSES_HAVE_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses.h")
|
||||
else()
|
||||
set(CURSES_HAVE_NCURSES_H "CURSES_HAVE_NCURSES_H-NOTFOUND")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if(NOT DEFINED CURSES_HAVE_CURSES_H)
|
||||
if(EXISTS "${CURSES_INCLUDE_PATH}/curses.h")
|
||||
set(CURSES_HAVE_CURSES_H "${CURSES_INCLUDE_PATH}/curses.h")
|
||||
else()
|
||||
set(CURSES_HAVE_CURSES_H "CURSES_HAVE_CURSES_H-NOTFOUND")
|
||||
if(NOT DEFINED CURSES_HAVE_CURSES_H)
|
||||
if(EXISTS "${CURSES_INCLUDE_PATH}/curses.h")
|
||||
set(CURSES_HAVE_CURSES_H "${CURSES_INCLUDE_PATH}/curses.h")
|
||||
else()
|
||||
set(CURSES_HAVE_CURSES_H "CURSES_HAVE_CURSES_H-NOTFOUND")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user