blob: 81743b2707362ad10a112fd3d80c150b881c8bea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#[=======================================================================[.rst:
FindReadline
-----------
Find The GNU Readline Library.
Imported Targets
^^^^^^^^^^^^^^^^
This module defines the following :prop_tgt:`IMPORTED` targets:
``Readline::Readline``
The Readline library, if found.
Result Variables
^^^^^^^^^^^^^^^^
This module will set the following variables in your project:
``READLINE_FOUND``
System has The GNU Readline Library.
``READLINE_INCLUDE_DIR``
The Readline include directory.
``READLINE_LIBRARY``
The Readline library.
Hints
^^^^^
Set ``READLINE_ROOT_DIR`` to the root directory of Readline installation.
#]=======================================================================]
set(_READLINE_ROOT_HINTS
${READLINE_ROOT_DIR}
ENV READLINE_ROOT_DIR
)
if(HOMEBREW_PREFIX)
list(APPEND _READLINE_ROOT_HINTS "${HOMEBREW_PREFIX}/opt/readline")
endif()
find_path(READLINE_INCLUDE_DIR
NAMES
readline/readline.h
HINTS
${_READLINE_ROOT_HINTS}
PATH_SUFFIXES
include)
find_library(READLINE_LIBRARY
NAMES
readline
HINTS
${_READLINE_ROOT_HINTS}
PATH_SUFFIXES
lib)
if(READLINE_INCLUDE_DIR AND EXISTS "${READLINE_INCLUDE_DIR}/readline/readline.h")
file(STRINGS "${READLINE_INCLUDE_DIR}/readline/readline.h" readline_major
REGEX "^#[\t ]*define[\t ]+RL_VERSION_MAJOR[\t ]+([0-9])+.*")
file(STRINGS "${READLINE_INCLUDE_DIR}/readline/readline.h" readline_minor
REGEX "^#[\t ]*define[\t ]+RL_VERSION_MINOR[\t ]+([0-9])+.*")
if (readline_major AND readline_minor)
string(REGEX REPLACE "^.*RL_VERSION_MAJOR[\t ]+([0-9])+.*$"
"\\1" readline_major "${readline_major}")
string(REGEX REPLACE "^.*RL_VERSION_MINOR[\t ]+([0-9])+.*$"
"\\1" readline_minor "${readline_minor}")
set(READLINE_VERSION "${readline_major}.${readline_minor}")
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Readline
REQUIRED_VARS
READLINE_LIBRARY
READLINE_INCLUDE_DIR
VERSION_VAR
READLINE_VERSION
)
mark_as_advanced(READLINE_FOUND READLINE_LIBRARY READLINE_INCLUDE_DIR)
if(READLINE_FOUND)
message(STATUS "Found Readline library: ${READLINE_LIBRARY}")
message(STATUS "Found Readline headers: ${READLINE_INCLUDE_DIR}")
if (NOT TARGET Readline::Readline)
add_library(Readline::Readline UNKNOWN IMPORTED)
set_target_properties(Readline::Readline
PROPERTIES
IMPORTED_LOCATION
"${READLINE_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES
"${READLINE_INCLUDE_DIR}")
endif()
endif()
|