2016-09-27 22:01:08 +03:00
|
|
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
|
|
|
2013-10-15 19:17:36 +04:00
|
|
|
#.rst:
|
|
|
|
# FindCurses
|
|
|
|
# ----------
|
|
|
|
#
|
2014-07-14 19:20:51 +04:00
|
|
|
# Find the curses or ncurses include file and library.
|
2013-10-15 19:17:36 +04:00
|
|
|
#
|
2014-07-14 19:20:51 +04:00
|
|
|
# Result Variables
|
|
|
|
# ^^^^^^^^^^^^^^^^
|
2013-10-15 19:17:36 +04:00
|
|
|
#
|
2014-07-14 19:20:51 +04:00
|
|
|
# This module defines the following variables:
|
2013-10-15 19:17:36 +04:00
|
|
|
#
|
2014-07-14 19:20:51 +04:00
|
|
|
# ``CURSES_FOUND``
|
|
|
|
# True if Curses is found.
|
|
|
|
# ``CURSES_INCLUDE_DIRS``
|
|
|
|
# The include directories needed to use Curses.
|
|
|
|
# ``CURSES_LIBRARIES``
|
|
|
|
# The libraries needed to use Curses.
|
|
|
|
# ``CURSES_HAVE_CURSES_H``
|
|
|
|
# True if curses.h is available.
|
|
|
|
# ``CURSES_HAVE_NCURSES_H``
|
|
|
|
# True if ncurses.h is available.
|
|
|
|
# ``CURSES_HAVE_NCURSES_NCURSES_H``
|
|
|
|
# True if ``ncurses/ncurses.h`` is available.
|
|
|
|
# ``CURSES_HAVE_NCURSES_CURSES_H``
|
|
|
|
# True if ``ncurses/curses.h`` is available.
|
2013-10-15 19:17:36 +04:00
|
|
|
#
|
2014-07-14 19:20:51 +04:00
|
|
|
# Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the
|
|
|
|
# ``find_package(Curses)`` call if NCurses functionality is required.
|
2013-10-15 19:17:36 +04:00
|
|
|
#
|
2014-07-14 19:20:51 +04:00
|
|
|
# Backward Compatibility
|
|
|
|
# ^^^^^^^^^^^^^^^^^^^^^^
|
2013-10-15 19:17:36 +04:00
|
|
|
#
|
2014-07-14 19:20:51 +04:00
|
|
|
# The following variable are provided for backward compatibility:
|
2013-10-15 19:17:36 +04:00
|
|
|
#
|
2014-07-14 19:20:51 +04:00
|
|
|
# ``CURSES_INCLUDE_DIR``
|
|
|
|
# Path to Curses include. Use ``CURSES_INCLUDE_DIRS`` instead.
|
|
|
|
# ``CURSES_LIBRARY``
|
|
|
|
# Path to Curses library. Use ``CURSES_LIBRARIES`` instead.
|
2007-08-15 17:43:01 +04:00
|
|
|
|
2014-10-28 15:52:18 +03:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
find_library(CURSES_CURSES_LIBRARY NAMES curses )
|
2007-08-15 17:43:01 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
find_library(CURSES_NCURSES_LIBRARY NAMES ncurses )
|
|
|
|
set(CURSES_USE_NCURSES FALSE)
|
2007-08-15 17:43:01 +04:00
|
|
|
|
2014-01-17 15:34:58 +04:00
|
|
|
if(CURSES_NCURSES_LIBRARY AND ((NOT CURSES_CURSES_LIBRARY) OR CURSES_NEED_NCURSES))
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CURSES_USE_NCURSES TRUE)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2010-05-04 19:54:55 +04:00
|
|
|
# http://cygwin.com/ml/cygwin-announce/2010-01/msg00002.html
|
|
|
|
# cygwin ncurses stopped providing curses.h symlinks see above
|
|
|
|
# message. Cygwin is an ncurses package, so force ncurses on
|
|
|
|
# cygwin if the curses.h is missing
|
2012-08-13 21:47:32 +04:00
|
|
|
if(CYGWIN)
|
|
|
|
if(NOT EXISTS /usr/include/curses.h)
|
|
|
|
set(CURSES_USE_NCURSES TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
2007-08-15 17:43:01 +04:00
|
|
|
|
|
|
|
|
|
|
|
# Not sure the logic is correct here.
|
|
|
|
# If NCurses is required, use the function wsyncup() to check if the library
|
|
|
|
# has NCurses functionality (at least this is where it breaks on NetBSD).
|
|
|
|
# If wsyncup is in curses, use this one.
|
|
|
|
# If not, try to find ncurses and check if this has the symbol.
|
|
|
|
# Once the ncurses library is found, search the ncurses.h header first, but
|
|
|
|
# some web pages also say that even with ncurses there is not always a ncurses.h:
|
|
|
|
# http://osdir.com/ml/gnome.apps.mc.devel/2002-06/msg00029.html
|
|
|
|
# So at first try ncurses.h, if not found, try to find curses.h under the same
|
2012-08-13 21:42:58 +04:00
|
|
|
# prefix as the library was found, if still not found, try curses.h with the
|
2007-08-15 17:43:01 +04:00
|
|
|
# default search paths.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES)
|
2014-03-30 06:22:54 +04:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
|
|
|
|
cmake_push_check_state()
|
|
|
|
set(CMAKE_REQUIRED_QUIET ${Curses_FIND_QUIETLY})
|
2012-08-13 21:42:58 +04:00
|
|
|
CHECK_LIBRARY_EXISTS("${CURSES_CURSES_LIBRARY}"
|
2008-09-18 23:23:00 +04:00
|
|
|
wsyncup "" CURSES_CURSES_HAS_WSYNCUP)
|
2007-08-15 17:43:01 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_HAS_WSYNCUP)
|
2012-08-13 21:42:58 +04:00
|
|
|
CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}"
|
2008-09-18 23:23:00 +04:00
|
|
|
wsyncup "" CURSES_NCURSES_HAS_WSYNCUP)
|
2012-08-13 21:47:32 +04:00
|
|
|
if( CURSES_NCURSES_HAS_WSYNCUP)
|
|
|
|
set(CURSES_USE_NCURSES TRUE)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
2014-03-30 06:22:54 +04:00
|
|
|
cmake_pop_check_state()
|
2007-08-15 17:43:01 +04:00
|
|
|
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-08-15 17:43:01 +04:00
|
|
|
|
2014-07-14 19:20:51 +04:00
|
|
|
if(CURSES_USE_NCURSES)
|
2012-08-13 21:47:32 +04:00
|
|
|
get_filename_component(_cursesLibDir "${CURSES_NCURSES_LIBRARY}" PATH)
|
|
|
|
get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
|
2007-08-27 17:01:14 +04:00
|
|
|
|
2014-07-14 19:20:51 +04:00
|
|
|
# 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
|
|
|
|
)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2014-07-14 19:20:51 +04:00
|
|
|
|
|
|
|
find_path(CURSES_INCLUDE_PATH
|
|
|
|
NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h
|
|
|
|
HINTS "${_cursesParentDir}/include"
|
|
|
|
)
|
|
|
|
|
|
|
|
# Previous versions of FindCurses provided these values.
|
|
|
|
if(NOT DEFINED CURSES_LIBRARY)
|
|
|
|
set(CURSES_LIBRARY "${CURSES_NCURSES_LIBRARY}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-09-18 23:23:00 +04:00
|
|
|
|
2014-01-17 15:34:58 +04:00
|
|
|
CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}"
|
|
|
|
cbreak "" CURSES_NCURSES_HAS_CBREAK)
|
|
|
|
if(NOT CURSES_NCURSES_HAS_CBREAK)
|
|
|
|
find_library(CURSES_EXTRA_LIBRARY tinfo HINTS "${_cursesLibDir}")
|
|
|
|
find_library(CURSES_EXTRA_LIBRARY tinfo )
|
|
|
|
endif()
|
2014-07-14 19:20:51 +04:00
|
|
|
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"
|
|
|
|
)
|
|
|
|
|
|
|
|
# Previous versions of FindCurses provided these values.
|
|
|
|
if(NOT DEFINED CURSES_CURSES_H_PATH)
|
|
|
|
set(CURSES_CURSES_H_PATH "${CURSES_INCLUDE_PATH}")
|
|
|
|
endif()
|
|
|
|
if(NOT DEFINED CURSES_LIBRARY)
|
|
|
|
set(CURSES_LIBRARY "${CURSES_CURSES_LIBRARY}")
|
|
|
|
endif()
|
|
|
|
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")
|
|
|
|
set(CURSES_HAVE_NCURSES_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses/ncurses.h")
|
|
|
|
else()
|
|
|
|
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")
|
|
|
|
set(CURSES_HAVE_NCURSES_CURSES_H "${CURSES_INCLUDE_PATH}/ncurses/curses.h")
|
|
|
|
else()
|
|
|
|
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")
|
|
|
|
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")
|
|
|
|
endif()
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-07-19 17:00:51 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
find_library(CURSES_FORM_LIBRARY form HINTS "${_cursesLibDir}")
|
|
|
|
find_library(CURSES_FORM_LIBRARY form )
|
2001-11-05 21:24:44 +03:00
|
|
|
|
2014-07-14 19:20:51 +04:00
|
|
|
# Previous versions of FindCurses provided these values.
|
|
|
|
if(NOT DEFINED FORM_LIBRARY)
|
|
|
|
set(FORM_LIBRARY "${CURSES_FORM_LIBRARY}")
|
|
|
|
endif()
|
2008-05-11 03:07:47 +04:00
|
|
|
|
2005-09-08 19:38:55 +04:00
|
|
|
# Need to provide the *_LIBRARIES
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CURSES_LIBRARIES ${CURSES_LIBRARY})
|
2005-09-08 19:38:55 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(CURSES_EXTRA_LIBRARY)
|
|
|
|
set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_EXTRA_LIBRARY})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2005-09-08 19:38:55 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(CURSES_FORM_LIBRARY)
|
|
|
|
set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_FORM_LIBRARY})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2005-09-08 19:38:55 +04:00
|
|
|
|
2014-07-14 19:20:51 +04:00
|
|
|
# Provide the *_INCLUDE_DIRS result.
|
|
|
|
set(CURSES_INCLUDE_DIRS ${CURSES_INCLUDE_PATH})
|
|
|
|
set(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH}) # compatibility
|
2005-09-08 19:38:55 +04:00
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
# handle the QUIETLY and REQUIRED arguments and set CURSES_FOUND to TRUE if
|
2007-07-19 17:00:51 +04:00
|
|
|
# all listed variables are TRUE
|
2012-08-13 21:47:32 +04:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
2008-09-18 23:23:00 +04:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Curses DEFAULT_MSG
|
|
|
|
CURSES_LIBRARY CURSES_INCLUDE_PATH)
|
2007-07-19 17:00:51 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
mark_as_advanced(
|
2005-09-08 19:38:55 +04:00
|
|
|
CURSES_INCLUDE_PATH
|
2008-05-11 03:07:47 +04:00
|
|
|
CURSES_CURSES_LIBRARY
|
2007-08-15 17:43:01 +04:00
|
|
|
CURSES_NCURSES_LIBRARY
|
2005-09-08 19:38:55 +04:00
|
|
|
CURSES_EXTRA_LIBRARY
|
|
|
|
)
|