1 if(NOT READLINE_INCLUDE_DIR OR NOT READLINE_LIBRARY)
2 find_path(READLINE_INCLUDE_DIR readline/readline.h)
3 find_library(READLINE_LIBRARY NAMES readline)
6 if (READLINE_INCLUDE_DIR AND READLINE_LIBRARY)
7 set(READLINE_FOUND TRUE)
10 if (READLINE_INCLUDE_DIR AND EXISTS "${READLINE_INCLUDE_DIR}/readline/readline.h")
11 file(STRINGS "${READLINE_INCLUDE_DIR}/readline/readline.h"
12 READLINE_MAJOR_VERSION
13 REGEX "^#define RL_VERSION_MAJOR.*$")
14 file(STRINGS "${READLINE_INCLUDE_DIR}/readline/readline.h"
15 READLINE_MINOR_VERSION
16 REGEX "^#define RL_VERSION_MINOR.*$")
18 string(REGEX REPLACE "^.*RL_VERSION_MAJOR.*([0-9]+).*$"
20 READLINE_MAJOR_VERSION
21 "${READLINE_MAJOR_VERSION}")
22 string(REGEX REPLACE "^.*RL_VERSION_MINOR.*([0-9]+).*$"
24 READLINE_MINOR_VERSION
25 "${READLINE_MINOR_VERSION}")
27 if(READLINE_MAJOR_VERSION)
28 set(READLINE_VERSION "${READLINE_MAJOR_VERSION}.${READLINE_MINOR_VERSION}")
30 set(READLINE_VERSION "(unknown)")
35 if (Readline_FIND_VERSION VERSION_GREATER READLINE_VERSION)
36 message(STATUS "Found version ${READLINE_VERSION} of GNU Readline at ${READLINE_LIBRARY}, but version ${Readline_FIND_VERSION} required")
39 if (NOT READLINE_FIND_QUIETLY)
40 message(STATUS "Found GNU Readline version ${READLINE_VERSION}: ${READLINE_LIBRARY}")
44 if (READLINE_FIND_REQUIRED)
45 message(FATAL_ERROR "Could not find GNU Readline")