Legends-of-Azeroth-Pandaria-5.4.8
113 строк · 3.3 Кб
1# Copyright (C) 2011-2016 Project SkyFire <http://www.projectskyfire.org/
2# Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3#
4# This file is free software; as a special exception the author gives
5# unlimited permission to copy and/or distribute it, with or without
6# modifications, as long as this notice is preserved.
7#
8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
12# find Readline (terminal input library) includes and library
13#
14# READLINE_INCLUDE_DIR - where the directory containing the READLINE headers can be found
15# READLINE_LIBRARY - full path to the READLINE library
16# READLINE_FOUND - TRUE if READLINE was found
17
18#[=======================================================================[.rst:
19FindReadline
20-----------
21
22Find The GNU Readline Library.
23
24Imported Targets
25^^^^^^^^^^^^^^^^
26
27This module defines the following :prop_tgt:`IMPORTED` targets:
28
29``Readline::Readline``
30The Readline library, if found.
31
32Result Variables
33^^^^^^^^^^^^^^^^
34
35This module will set the following variables in your project:
36
37``READLINE_FOUND``
38System has The GNU Readline Library.
39``READLINE_INCLUDE_DIR``
40The Readline include directory.
41``READLINE_LIBRARY``
42The Readline library.
43
44Hints
45^^^^^
46
47Set ``READLINE_ROOT_DIR`` to the root directory of Readline installation.
48#]=======================================================================]
49
50set(_READLINE_ROOT_HINTS
51${READLINE_ROOT_DIR}
52ENV READLINE_ROOT_DIR
53)
54
55if(HOMEBREW_PREFIX)
56list(APPEND _READLINE_ROOT_HINTS "${HOMEBREW_PREFIX}/opt/readline")
57endif()
58
59find_path(READLINE_INCLUDE_DIR
60NAMES
61readline/readline.h
62HINTS
63${_READLINE_ROOT_HINTS}
64PATH_SUFFIXES
65include)
66
67find_library(READLINE_LIBRARY
68NAMES
69readline
70HINTS
71${_READLINE_ROOT_HINTS}
72PATH_SUFFIXES
73lib)
74
75if(READLINE_INCLUDE_DIR AND EXISTS "${READLINE_INCLUDE_DIR}/readline/readline.h")
76file(STRINGS "${READLINE_INCLUDE_DIR}/readline/readline.h" readline_major
77REGEX "^#[\t ]*define[\t ]+RL_VERSION_MAJOR[\t ]+([0-9])+.*")
78file(STRINGS "${READLINE_INCLUDE_DIR}/readline/readline.h" readline_minor
79REGEX "^#[\t ]*define[\t ]+RL_VERSION_MINOR[\t ]+([0-9])+.*")
80if (readline_major AND readline_minor)
81string(REGEX REPLACE "^.*RL_VERSION_MAJOR[\t ]+([0-9])+.*$"
82"\\1" readline_major "${readline_major}")
83string(REGEX REPLACE "^.*RL_VERSION_MINOR[\t ]+([0-9])+.*$"
84"\\1" readline_minor "${readline_minor}")
85set(READLINE_VERSION "${readline_major}.${readline_minor}")
86endif()
87endif()
88
89include(FindPackageHandleStandardArgs)
90find_package_handle_standard_args(Readline
91REQUIRED_VARS
92READLINE_LIBRARY
93READLINE_INCLUDE_DIR
94VERSION_VAR
95READLINE_VERSION
96)
97
98mark_as_advanced(READLINE_FOUND READLINE_LIBRARY READLINE_INCLUDE_DIR)
99
100if(READLINE_FOUND)
101message(STATUS "Found Readline library: ${READLINE_LIBRARY}")
102message(STATUS "Found Readline headers: ${READLINE_INCLUDE_DIR}")
103
104if (NOT TARGET Readline::Readline)
105add_library(Readline::Readline UNKNOWN IMPORTED)
106set_target_properties(Readline::Readline
107PROPERTIES
108IMPORTED_LOCATION
109"${READLINE_LIBRARY}"
110INTERFACE_INCLUDE_DIRECTORIES
111"${READLINE_INCLUDE_DIR}")
112endif()
113endif()
114