Find readline.h in both editline/ and edit/readline/

This commit is contained in:
Sunrim KIM (keen) 2014-08-11 21:39:04 +09:00
parent df471bd5a2
commit 9b390a58d3
3 changed files with 30 additions and 2 deletions

View File

@ -5,6 +5,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/contrib/10.rea
find_package(Libedit)
if (Libedit_FOUND)
add_definitions(${Libedit_DEFINITIONS} -DPIC_READLINE_FOUND=1)
add_definitions(${Libedit_DEFINITIONS} -DPIC_READLINE_INCLUDE_DIR_SUFFIX=${Libedit_INCLUDE_DIR_SUFFIX})
include_directories(${Libedit_INCLUDE_DIR})
file(GLOB PICRIN_READLINE_SOURCES ${PROJECT_SOURCE_DIR}/contrib/10.readline/src/*.c)

View File

@ -30,7 +30,7 @@ else (Libedit_LIBRARIES AND Libedit_INCLUDE_DIRS)
pkg_check_modules(_LIBEDIT libedit)
endif (PKG_CONFIG_FOUND)
endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
find_path(Libedit_INCLUDE_DIR
find_path(Libedit_EDITLINE_INCLUDE_DIR
NAMES
readline.h
history.h
@ -43,7 +43,29 @@ else (Libedit_LIBRARIES AND Libedit_INCLUDE_DIRS)
PATH_SUFFIXES
editline
)
if (Libedit_EDITLINE_INCLUDE_DIR)
set(Libedit_INCLUDE_DIR_SUFFIX editline)
set(Libedit_INCLUDE_DIR Libedit_EDITLINE_INCLUDE_DIR)
else (Libedit_EDITLINE_INCLUDE_DIR)
find_path(Libedit_READLINE_INCLUDE_DIR
NAMES
readline.h
history.h
PATHS
${_Libedit_INCLUDEDIR}/edit
/usr/include/edit
/usr/local/include/edit
/opt/local/include/edit
/sw/include/edit
PATH_SUFFIXES
readline
)
if (Libedit_READLINE_INCLUDE_DIR)
set(Libedit_INCLUDE_DIR_SUFFIX readline)
set(Libedit_INCLUDE_DIR Libedit_READLINE_INCLUDE_DIR)
endif (Libedit_READLINE_INCLUDE_DIR)
endif (Libedit_EDITLINE_INCLUDE_DIR)
find_library(Libedit_LIBRARY
NAMES
edit

View File

@ -5,8 +5,13 @@
/* This will include all our libedit functions. If you use C++ don't
forget to use the C++ extern "C" to get it to compile.
*/
#if PIC_READLINE_INCLUDE_DIR_SUFFIX == readline
#include <readline/readline.h>
#include <readline/history.h>
#else
#include <editline/readline.h>
#include <editline/history.h>
#endif
#include "picrin.h"
#include "picrin/pair.h"
#include "picrin/string.h"