summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorAlexandr (Sagrer) Gridnev <sagrer@yandex.ru>2017-08-21 21:07:02 +0300
committerBrad King <brad.king@kitware.com>2017-08-22 10:42:20 -0400
commit4b02afc0caf46244f12f87f363ace6c1ab47fae5 (patch)
tree2d6cd9f97275043d2ba040ff08a777c0cc7ef226 /Modules
parent10edb0c7d52b1252517990c2e8b898a804f440d3 (diff)
downloadcmake-4b02afc0caf46244f12f87f363ace6c1ab47fae5.tar.gz
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
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindCurses.cmake111
1 files changed, 81 insertions, 30 deletions
diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake
index 8d58d03ff7..4f59d2c1e8 100644
--- a/Modules/FindCurses.cmake
+++ b/Modules/FindCurses.cmake
@@ -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)
+ 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()
+
+ 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
- PATHS ${CURSES_NCURSES_INCLUDE_PATH}
- NO_DEFAULT_PATH
+ HINTS "${_cursesParentDir}/include"
)
- endif()
-
- 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()