FindCurses¶
尋找 curses 或 ncurses 程式庫:
find_package(Curses [...])
Curses is a terminal control library for Unix-like systems, used to build text user interface (TUI) applications. Originally developed in 1978, it has since evolved into multiple implementations, most notably ncurses (new curses), BSD curses, and PDCurses (a public domain curses library for non-Unix platforms).
結果變數¶
該模組定義了以下變數:
Curses_FOUND在 3.3 版被加入.
Boolean indicating whether Curses was found.
CURSES_INCLUDE_DIRS在 3.1 版被加入.
The include directories needed to use Curses.
CURSES_LIBRARIESThe libraries needed to use Curses.
CURSES_CFLAGS在 3.16 版被加入.
Compiler flags which ought be given to C/C++ compilers when using Curses.
CURSES_HAVE_CURSES_HBoolean indicating whether
curses.his available.CURSES_HAVE_NCURSES_HBoolean indicating whether
ncurses.his available.CURSES_HAVE_NCURSES_NCURSES_HBoolean indicating whether
ncurses/ncurses.his available.CURSES_HAVE_NCURSES_CURSES_HBoolean indicating whether
ncurses/curses.his available.
提示¶
This module accepts the following variables:
CURSES_NEED_NCURSESSet this variable to
TRUEbefore callingfind_package(Curses)if the the ncurses implementation functionality is specifically required.CURSES_NEED_WIDE在 3.10 版被加入.
Set this variable to
TRUEbefore callingfind_package(Curses)if Unicode (wide character) support is required.
棄用的變數¶
The following variables are provided for backward compatibility:
CURSES_FOUND在 4.2 版之後被棄用: Use
Curses_FOUND, which has the same value.Boolean indicating whether Curses was found.
CURSES_INCLUDE_DIR在 3.1 版之後被棄用: 請改用
CURSES_INCLUDE_DIRS變數。Curses 引入目錄的路徑。
CURSES_LIBRARY在 2.4 版之後被棄用: 請改用
CURSES_LIBRARIES變數。Curses 程式庫的路徑。
範例¶
Finding Curses and creating an imported interface target for linking it to a project target:
find_package(Curses)
if(Curses_FOUND AND NOT TARGET Curses::Curses)
add_library(Curses::Curses INTERFACE IMPORTED)
set_target_properties(
Curses::Curses
PROPERTIES
INTERFACE_LINK_LIBRARIES "${CURSES_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${CURSES_INCLUDE_DIRS}"
)
endif()
add_executable(app app.c)
target_link_libraries(app PRIVATE Curses::Curses)
When ncurses is specifically required:
set(CURSES_NEED_NCURSES TRUE)
find_package(Curses)