]> git.lizzy.rs Git - dragonfireclient.git/blob - cmake/Modules/FindNcursesw.cmake
Merge pull request #59 from PrairieAstronomer/readme_irrlicht_change
[dragonfireclient.git] / cmake / Modules / FindNcursesw.cmake
1 #.rst:
2 # FindNcursesw
3 # ------------
4 #
5 # Find the ncursesw (wide ncurses) include file and library.
6 #
7 # Based on FindCurses.cmake which comes with CMake.
8 #
9 # Checks for ncursesw first. If not found, it then executes the
10 # regular old FindCurses.cmake to look for for ncurses (or curses).
11 #
12 #
13 # Result Variables
14 # ^^^^^^^^^^^^^^^^
15 #
16 # This module defines the following variables:
17 #
18 # ``CURSES_FOUND``
19 #   True if curses is found.
20 # ``NCURSESW_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.
38 #
39 # Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the
40 # ``find_package(Ncursesw)`` call if NCurses functionality is required.
41 #
42 #=============================================================================
43 # Copyright 2001-2014 Kitware, Inc.
44 # modifications: Copyright 2015 kahrl <kahrl@gmx.net>
45 #
46 # Redistribution and use in source and binary forms, with or without
47 # modification, are permitted provided that the following conditions
48 # are met:
49 #
50 # * Redistributions of source code must retain the above copyright
51 #   notice, this list of conditions and the following disclaimer.
52 #
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.
56 #
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
60 #   permission.
61 #
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.
73 #
74 # ------------------------------------------------------------------------------
75 #
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.
82 #
83 # ------------------------------------------------------------------------------
84 #
85 # CMake was initially developed by Kitware with the following sponsorship:
86 #
87 #  * National Library of Medicine at the National Institutes of Health
88 #    as part of the Insight Segmentation and Registration Toolkit (ITK).
89 #
90 #  * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
91 #    Visualization Initiative.
92 #
93 #  * National Alliance for Medical Image Computing (NAMIC) is funded by the
94 #    National Institutes of Health through the NIH Roadmap for Medical Research,
95 #    Grant U54 EB005149.
96 #
97 #  * Kitware, Inc.
98 #=============================================================================
99
100 include(CheckLibraryExists)
101
102 find_library(CURSES_NCURSESW_LIBRARY NAMES ncursesw
103   DOC "Path to libncursesw.so or .lib or .a")
104
105 set(CURSES_USE_NCURSES FALSE)
106 set(CURSES_USE_NCURSESW FALSE)
107
108 if(CURSES_NCURSESW_LIBRARY)
109   set(CURSES_USE_NCURSES TRUE)
110   set(CURSES_USE_NCURSESW TRUE)
111 endif()
112
113 if(CURSES_USE_NCURSESW)
114   get_filename_component(_cursesLibDir "${CURSES_NCURSESW_LIBRARY}" PATH)
115   get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
116
117   find_path(CURSES_INCLUDE_PATH
118     NAMES ncursesw/ncurses.h ncursesw/curses.h ncurses.h curses.h
119     HINTS "${_cursesParentDir}/include"
120     )
121
122   # Previous versions of FindCurses provided these values.
123   if(NOT DEFINED CURSES_LIBRARY)
124     set(CURSES_LIBRARY "${CURSES_NCURSESW_LIBRARY}")
125   endif()
126
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 )
133   endif()
134
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")
139     else()
140       set(CURSES_HAVE_NCURSESW_NCURSES_H "CURSES_HAVE_NCURSESW_NCURSES_H-NOTFOUND")
141     endif()
142   endif()
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")
146     else()
147       set(CURSES_HAVE_NCURSESW_CURSES_H "CURSES_HAVE_NCURSESW_CURSES_H-NOTFOUND")
148     endif()
149   endif()
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")
153     else()
154       set(CURSES_HAVE_NCURSES_H "CURSES_HAVE_NCURSES_H-NOTFOUND")
155     endif()
156   endif()
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")
160     else()
161       set(CURSES_HAVE_CURSES_H "CURSES_HAVE_CURSES_H-NOTFOUND")
162     endif()
163   endif()
164
165
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 )
169
170   # Need to provide the *_LIBRARIES
171   set(CURSES_LIBRARIES ${CURSES_LIBRARY})
172
173   if(CURSES_EXTRA_LIBRARY)
174     set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_EXTRA_LIBRARY})
175   endif()
176
177   if(CURSES_FORM_LIBRARY)
178     set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_FORM_LIBRARY})
179   endif()
180
181   # Provide the *_INCLUDE_DIRS result.
182   set(CURSES_INCLUDE_DIRS ${CURSES_INCLUDE_PATH})
183   set(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH}) # compatibility
184
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})
191
192 else()
193   find_package(Curses)
194   set(NCURSESW_FOUND FALSE)
195 endif()
196
197 mark_as_advanced(
198   CURSES_INCLUDE_PATH
199   CURSES_CURSES_LIBRARY
200   CURSES_NCURSES_LIBRARY
201   CURSES_NCURSESW_LIBRARY
202   CURSES_EXTRA_LIBRARY
203   CURSES_FORM_LIBRARY
204   )