1 find_path(READLINE_INCLUDE_DIR readline/readline.h)
2 find_library(READLINE_LIBRARY NAMES readline)
4 if (READLINE_INCLUDE_DIR AND READLINE_LIBRARY)
5 set (READLINE_FOUND TRUE)
8 if (READLINE_INCLUDE_DIR AND EXISTS "${READLINE_INCLUDE_DIR}/readline/readline.h")
9 file(STRINGS "${READLINE_INCLUDE_DIR}/readline/readline.h"
10 READLINE_MAJOR_VERSION
11 REGEX "^#define RL_VERSION_MAJOR.*$")
12 file(STRINGS "${READLINE_INCLUDE_DIR}/readline/readline.h"
13 READLINE_MINOR_VERSION
14 REGEX "^#define RL_VERSION_MINOR.*$")
16 string(REGEX REPLACE "^.*RL_VERSION_MAJOR.*([0-9]+).*$"
18 READLINE_MAJOR_VERSION
19 "${READLINE_MAJOR_VERSION}")
20 string(REGEX REPLACE "^.*RL_VERSION_MINOR.*([0-9]+).*$"
22 READLINE_MINOR_VERSION
23 "${READLINE_MINOR_VERSION}")
25 if(READLINE_MAJOR_VERSION)
26 set(READLINE_VERSION "${READLINE_MAJOR_VERSION}.${READLINE_MINOR_VERSION}")
28 set(READLINE_VERSION "(unknown)")
33 if (Readline_FIND_VERSION VERSION_GREATER READLINE_VERSION)
34 message(STATUS "Found version ${READLINE_VERSION} of GNU Readline at ${READLINE_LIBRARY}, but version ${Readline_FIND_VERSION} required")
37 if (NOT READLINE_FIND_QUIETLY)
38 message(STATUS "Found GNU Readline version ${READLINE_VERSION}: ${READLINE_LIBRARY}")
42 if (READLINE_FIND_REQUIRED)
43 message(FATAL_ERROR "Could not find GNU Readline")