[Pcre-svn] [939] code/trunk: CMake support for linking pcret…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [939] code/trunk: CMake support for linking pcretest with libedit.
Revision: 939
          http://vcs.pcre.org/viewvc?view=rev&revision=939
Author:   ph10
Date:     2012-02-26 17:21:43 +0000 (Sun, 26 Feb 2012)


Log Message:
-----------
CMake support for linking pcretest with libedit.

Modified Paths:
--------------
    code/trunk/CMakeLists.txt
    code/trunk/Makefile.am
    code/trunk/README
    code/trunk/config-cmake.h.in


Added Paths:
-----------
    code/trunk/cmake/FindEditline.cmake


Modified: code/trunk/CMakeLists.txt
===================================================================
--- code/trunk/CMakeLists.txt    2012-02-26 16:08:15 UTC (rev 938)
+++ code/trunk/CMakeLists.txt    2012-02-26 17:21:43 UTC (rev 939)
@@ -56,6 +56,7 @@
 # 2012-01-13 Stephen Kelly added out of source build support
 # 2012-01-17 PH applied Stephen Kelly's patch to parse the version data out
 #            of the configure.ac file
+# 2012-02-26 PH added support for libedit


PROJECT(PCRE C CXX)

@@ -69,6 +70,7 @@
FIND_PACKAGE( BZip2 )
FIND_PACKAGE( ZLIB )
FIND_PACKAGE( Readline )
+FIND_PACKAGE( Editline )

# Configuration checks

@@ -181,6 +183,14 @@
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
ENDIF(PCRE_SUPPORT_LIBZ)

+# editline lib
+IF(EDITLINE_FOUND)
+  OPTION (PCRE_SUPPORT_LIBEDIT  "Enable support for linking pcretest with libedit." OFF)
+ENDIF(EDITLINE_FOUND)
+IF(PCRE_SUPPORT_LIBEDIT)
+  INCLUDE_DIRECTORIES(${EDITLINE_INCLUDE_DIR})
+ENDIF(PCRE_SUPPORT_LIBEDIT)
+
 # readline lib
 IF(READLINE_FOUND)
   OPTION (PCRE_SUPPORT_LIBREADLINE  "Enable support for linking pcretest with libreadline." ON)
@@ -239,6 +249,10 @@
         SET(PCRE_BUILD_PCREGREP OFF)
 ENDIF(PCRE_BUILD_PCREGREP AND NOT PCRE_BUILD_PCRE8)


+IF(PCRE_SUPPORT_LIBREADLINE AND PCRE_SUPPORT_LIBEDIT)
+        MESSAGE(FATAL_ERROR "Only one of libreadline or libeditline can be specified")
+ENDIF(PCRE_SUPPORT_LIBREADLINE AND PCRE_SUPPORT_LIBEDIT)
+
 IF(PCRE_SUPPORT_BSR_ANYCRLF)
         SET(BSR_ANYCRLF 1)
 ENDIF(PCRE_SUPPORT_BSR_ANYCRLF)
@@ -271,6 +285,13 @@
         SET(PCRETEST_LIBS ${READLINE_LIBRARY} ${NCURSES_LIBRARY})
 ENDIF(PCRE_SUPPORT_LIBREADLINE)


+# libedit is a plug-compatible alternative to libreadline
+
+IF(PCRE_SUPPORT_LIBEDIT)
+        SET(SUPPORT_LIBEDIT 1)
+        SET(PCRETEST_LIBS ${EDITLINE_LIBRARY} ${NCURSES_LIBRARY})
+ENDIF(PCRE_SUPPORT_LIBEDIT)
+
 IF(PCRE_SUPPORT_LIBZ)
         SET(SUPPORT_LIBZ 1)
         SET(PCREGREP_LIBS ${PCREGREP_LIBS} ${ZLIB_LIBRARIES})
@@ -817,18 +838,24 @@
   IF(ZLIB_FOUND)
     MESSAGE(STATUS "  Link pcregrep with libz ......... : ${PCRE_SUPPORT_LIBZ}")
   ELSE(ZLIB_FOUND)
-    MESSAGE(STATUS "  Link pcregrep with libz ......... : None" )
+    MESSAGE(STATUS "  Link pcregrep with libz ......... : Library not found" )
   ENDIF(ZLIB_FOUND)
   IF(BZIP2_FOUND)
     MESSAGE(STATUS "  Link pcregrep with libbz2 ....... : ${PCRE_SUPPORT_LIBBZ2}")
   ELSE(BZIP2_FOUND)
-    MESSAGE(STATUS "  Link pcregrep with libbz2 ....... : None" )
+    MESSAGE(STATUS "  Link pcregrep with libbz2 ....... : Library not found" )
   ENDIF(BZIP2_FOUND)
-  IF(NOT PCRE_SUPPORT_LIBREADLINE)
-    MESSAGE(STATUS "  Link pcretest with libreadline .. : None" )
-  ELSE(NOT PCRE_SUPPORT_LIBREADLINE)
+  IF(EDITLINE_FOUND)
+    MESSAGE(STATUS "  Link pcretest with libeditline .. : ${PCRE_SUPPORT_LIBEDIT}")
+  ELSE(EDITLINE_FOUND)
+    MESSAGE(STATUS "  Link pcretest with libeditline .. : Library not found" )
+  ENDIF(EDITLINE_FOUND)
+  IF(READLINE_FOUND)
     MESSAGE(STATUS "  Link pcretest with libreadline .. : ${PCRE_SUPPORT_LIBREADLINE}")
-  ENDIF(NOT PCRE_SUPPORT_LIBREADLINE)
+  ELSE(READLINE_FOUND)
+    MESSAGE(STATUS "  Link pcretest with libreadline .. : Library not found" )
+  ENDIF(READLINE_FOUND)
+
   IF(MINGW AND NOT PCRE_STATIC)
     MESSAGE(STATUS "  Non-standard dll names (prefix) . : ${NON_STANDARD_LIB_PREFIX}")
     MESSAGE(STATUS "  Non-standard dll names (suffix) . : ${NON_STANDARD_LIB_SUFFIX}")


Modified: code/trunk/Makefile.am
===================================================================
--- code/trunk/Makefile.am    2012-02-26 16:08:15 UTC (rev 938)
+++ code/trunk/Makefile.am    2012-02-26 17:21:43 UTC (rev 939)
@@ -560,6 +560,7 @@
   cmake/COPYING-CMAKE-SCRIPTS \
   cmake/FindPackageHandleStandardArgs.cmake \
   cmake/FindReadline.cmake \
+  cmake/FindEditline.cmake \
   CMakeLists.txt \
   config-cmake.h.in



Modified: code/trunk/README
===================================================================
--- code/trunk/README    2012-02-26 16:08:15 UTC (rev 938)
+++ code/trunk/README    2012-02-26 17:21:43 UTC (rev 939)
@@ -334,7 +334,7 @@
   the readline() function. This provides line-editing and history facilities.
   Note that libreadline is GPL-licenced, so if you distribute a binary of
   pcretest linked in this way, there may be licensing issues. These can be
-  avoided by linking with libedit instead. 
+  avoided by linking with libedit (which has a BSD licence) instead. 


Enabling libreadline causes the -lreadline option to be added to the pcretest
build. In many operating environments with a sytem-installed readline
@@ -856,6 +856,7 @@

cmake/COPYING-CMAKE-SCRIPTS
cmake/FindPackageHandleStandardArgs.cmake
+ cmake/FindEditline.cmake
cmake/FindReadline.cmake
CMakeLists.txt
config-cmake.h.in
@@ -881,4 +882,4 @@
Philip Hazel
Email local part: ph10
Email domain: cam.ac.uk
-Last updated: 25 February 2012
+Last updated: 26 February 2012

Added: code/trunk/cmake/FindEditline.cmake
===================================================================
--- code/trunk/cmake/FindEditline.cmake                            (rev 0)
+++ code/trunk/cmake/FindEditline.cmake    2012-02-26 17:21:43 UTC (rev 939)
@@ -0,0 +1,17 @@
+# Modified from FindReadline.cmake (PH Feb 2012)
+
+if(EDITLINE_INCLUDE_DIR AND EDITLINE_LIBRARY AND NCURSES_LIBRARY)
+  set(EDITLINE_FOUND TRUE)
+else(EDITLINE_INCLUDE_DIR AND EDITLINE_LIBRARY AND NCURSES_LIBRARY)
+  FIND_PATH(EDITLINE_INCLUDE_DIR readline.h
+    /usr/include/editline
+    /usr/include/edit/readline  
+    /usr/include/readline
+  )
+  
+  FIND_LIBRARY(EDITLINE_LIBRARY NAMES edit)
+  include(FindPackageHandleStandardArgs)
+  FIND_PACKAGE_HANDLE_STANDARD_ARGS(Editline DEFAULT_MSG EDITLINE_INCLUDE_DIR EDITLINE_LIBRARY )
+
+  MARK_AS_ADVANCED(EDITLINE_INCLUDE_DIR EDITLINE_LIBRARY)
+endif(EDITLINE_INCLUDE_DIR AND EDITLINE_LIBRARY AND NCURSES_LIBRARY)


Modified: code/trunk/config-cmake.h.in
===================================================================
--- code/trunk/config-cmake.h.in    2012-02-26 16:08:15 UTC (rev 938)
+++ code/trunk/config-cmake.h.in    2012-02-26 17:21:43 UTC (rev 939)
@@ -33,6 +33,7 @@


#cmakedefine SUPPORT_LIBBZ2 1
#cmakedefine SUPPORT_LIBZ 1
+#cmakedefine SUPPORT_LIBEDIT 1
#cmakedefine SUPPORT_LIBREADLINE 1

 #define NEWLINE            @NEWLINE@