5 # Find the ncursesw (wide ncurses) include file and library.
7 # Based on FindCurses.cmake which comes with CMake.
9 # Checks for ncursesw first. If not found, it then executes the
10 # regular old FindCurses.cmake to look for for ncurses (or curses).
16 # This module defines the following variables:
19 # True if curses is found.
21 # True if ncursesw is found.
22 # ``CURSES_INCLUDE_DIRS``
23 # The include directories needed to use Curses.
24 # ``CURSES_LIBRARIES``
25 # The libraries needed to use Curses.
26 # ``CURSES_HAVE_CURSES_H``
27 # True if curses.h is available.
28 # ``CURSES_HAVE_NCURSES_H``
29 # True if ncurses.h is available.
30 # ``CURSES_HAVE_NCURSES_NCURSES_H``
31 # True if ``ncurses/ncurses.h`` is available.
32 # ``CURSES_HAVE_NCURSES_CURSES_H``
33 # True if ``ncurses/curses.h`` is available.
34 # ``CURSES_HAVE_NCURSESW_NCURSES_H``
35 # True if ``ncursesw/ncurses.h`` is available.
36 # ``CURSES_HAVE_NCURSESW_CURSES_H``
37 # True if ``ncursesw/curses.h`` is available.
39 # Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the
40 # ``find_package(Ncursesw)`` call if NCurses functionality is required.
42 #=============================================================================
43 # Copyright 2001-2014 Kitware, Inc.
44 # modifications: Copyright 2015 kahrl <kahrl@gmx.net>
46 # Redistribution and use in source and binary forms, with or without
47 # modification, are permitted provided that the following conditions
50 # * Redistributions of source code must retain the above copyright
51 # notice, this list of conditions and the following disclaimer.
53 # * Redistributions in binary form must reproduce the above copyright
54 # notice, this list of conditions and the following disclaimer in the
55 # documentation and/or other materials provided with the distribution.
57 # * Neither the names of Kitware, Inc., the Insight Software Consortium,
58 # nor the names of their contributors may be used to endorse or promote
59 # products derived from this software without specific prior written
62 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
63 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
64 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
65 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
66 # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
67 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
68 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
69 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
70 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
71 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
72 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74 # ------------------------------------------------------------------------------
76 # The above copyright and license notice applies to distributions of
77 # CMake in source and binary form. Some source files contain additional
78 # notices of original copyright by their contributors; see each source
79 # for details. Third-party software packages supplied with CMake under
80 # compatible licenses provide their own copyright notices documented in
81 # corresponding subdirectories.
83 # ------------------------------------------------------------------------------
85 # CMake was initially developed by Kitware with the following sponsorship:
87 # * National Library of Medicine at the National Institutes of Health
88 # as part of the Insight Segmentation and Registration Toolkit (ITK).
90 # * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
91 # Visualization Initiative.
93 # * National Alliance for Medical Image Computing (NAMIC) is funded by the
94 # National Institutes of Health through the NIH Roadmap for Medical Research,
98 #=============================================================================
100 include(CheckLibraryExists)
102 find_library(CURSES_NCURSESW_LIBRARY NAMES ncursesw
103 DOC "Path to libncursesw.so or .lib or .a")
105 set(CURSES_USE_NCURSES FALSE)
106 set(CURSES_USE_NCURSESW FALSE)
108 if(CURSES_NCURSESW_LIBRARY)
109 set(CURSES_USE_NCURSES TRUE)
110 set(CURSES_USE_NCURSESW TRUE)
113 if(CURSES_USE_NCURSESW)
114 get_filename_component(_cursesLibDir "${CURSES_NCURSESW_LIBRARY}" PATH)
115 get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
117 find_path(CURSES_INCLUDE_PATH
118 NAMES ncursesw/ncurses.h ncursesw/curses.h ncurses.h curses.h
119 HINTS "${_cursesParentDir}/include"
122 # Previous versions of FindCurses provided these values.
123 if(NOT DEFINED CURSES_LIBRARY)
124 set(CURSES_LIBRARY "${CURSES_NCURSESW_LIBRARY}")
127 CHECK_LIBRARY_EXISTS("${CURSES_NCURSESW_LIBRARY}"
128 cbreak "" CURSES_NCURSESW_HAS_CBREAK)
129 if(NOT CURSES_NCURSESW_HAS_CBREAK)
130 find_library(CURSES_EXTRA_LIBRARY tinfo HINTS "${_cursesLibDir}"
131 DOC "Path to libtinfo.so or .lib or .a")
132 find_library(CURSES_EXTRA_LIBRARY tinfo )
135 # Report whether each possible header name exists in the include directory.
136 if(NOT DEFINED CURSES_HAVE_NCURSESW_NCURSES_H)
137 if(EXISTS "${CURSES_INCLUDE_PATH}/ncursesw/ncurses.h")
138 set(CURSES_HAVE_NCURSESW_NCURSES_H "${CURSES_INCLUDE_PATH}/ncursesw/ncurses.h")
140 set(CURSES_HAVE_NCURSESW_NCURSES_H "CURSES_HAVE_NCURSESW_NCURSES_H-NOTFOUND")
143 if(NOT DEFINED CURSES_HAVE_NCURSESW_CURSES_H)
144 if(EXISTS "${CURSES_INCLUDE_PATH}/ncursesw/curses.h")
145 set(CURSES_HAVE_NCURSESW_CURSES_H "${CURSES_INCLUDE_PATH}/ncursesw/curses.h")
147 set(CURSES_HAVE_NCURSESW_CURSES_H "CURSES_HAVE_NCURSESW_CURSES_H-NOTFOUND")
150 if(NOT DEFINED CURSES_HAVE_NCURSES_H)
151 if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses.h")
152 set(CURSES_HAVE_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses.h")
154 set(CURSES_HAVE_NCURSES_H "CURSES_HAVE_NCURSES_H-NOTFOUND")
157 if(NOT DEFINED CURSES_HAVE_CURSES_H)
158 if(EXISTS "${CURSES_INCLUDE_PATH}/curses.h")
159 set(CURSES_HAVE_CURSES_H "${CURSES_INCLUDE_PATH}/curses.h")
161 set(CURSES_HAVE_CURSES_H "CURSES_HAVE_CURSES_H-NOTFOUND")
166 find_library(CURSES_FORM_LIBRARY form HINTS "${_cursesLibDir}"
167 DOC "Path to libform.so or .lib or .a")
168 find_library(CURSES_FORM_LIBRARY form )
170 # Need to provide the *_LIBRARIES
171 set(CURSES_LIBRARIES ${CURSES_LIBRARY})
173 if(CURSES_EXTRA_LIBRARY)
174 set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_EXTRA_LIBRARY})
177 if(CURSES_FORM_LIBRARY)
178 set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_FORM_LIBRARY})
181 # Provide the *_INCLUDE_DIRS result.
182 set(CURSES_INCLUDE_DIRS ${CURSES_INCLUDE_PATH})
183 set(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH}) # compatibility
185 # handle the QUIETLY and REQUIRED arguments and set CURSES_FOUND to TRUE if
186 # all listed variables are TRUE
187 include(FindPackageHandleStandardArgs)
188 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ncursesw DEFAULT_MSG
189 CURSES_LIBRARY CURSES_INCLUDE_PATH)
190 set(CURSES_FOUND ${NCURSESW_FOUND})
194 set(NCURSESW_FOUND FALSE)
199 CURSES_CURSES_LIBRARY
200 CURSES_NCURSES_LIBRARY
201 CURSES_NCURSESW_LIBRARY