File tree Expand file tree Collapse file tree 3 files changed +54
-4
lines changed
Expand file tree Collapse file tree 3 files changed +54
-4
lines changed Original file line number Diff line number Diff line change 1+ # Copyright (C) 2007-2009 LuaDist.
2+ # Created by Peter Kapec <kapecp@gmail.com>
3+ # Redistribution and use of this file is allowed according to the terms of the MIT license.
4+ # For details see the COPYRIGHT file distributed with LuaDist.
5+ # Note:
6+ # Searching headers and libraries is very simple and is NOT as powerful as scripts
7+ # distributed with CMake, because LuaDist defines directories to search for.
8+ # Everyone is encouraged to contact the author with improvements. Maybe this file
9+ # becomes part of CMake distribution sometimes.
10+
11+ # - Find pcre
12+ # Find the native PCRE headers and libraries.
13+ #
14+ # PCRE_INCLUDE_DIRS - where to find pcre.h, etc.
15+ # PCRE_LIBRARIES - List of libraries when using pcre.
16+ # PCRE_FOUND - True if pcre found.
17+
18+ # Look for the header file.
19+ FIND_PATH (PCRE_INCLUDE_DIR NAMES pcreposix.h)
20+
21+ # Look for the library.
22+ FIND_LIBRARY (PCRE_LIBRARY NAMES pcre)
23+ FIND_LIBRARY (PCRE_POSIX_LIBRARY NAMES pcreposix)
24+
25+ # Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE.
26+ INCLUDE (FindPackageHandleStandardArgs)
27+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_POSIX_LIBRARY PCRE_INCLUDE_DIR)
28+
29+ # Copy the results to the output variables.
30+ IF (PCRE_FOUND)
31+ SET (PCRE_LIBRARIES ${PCRE_LIBRARY} ${PCRE_POSIX_LIBRARY} )
32+ SET (PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR} )
33+ ELSE (PCRE_FOUND)
34+ SET (PCRE_LIBRARIES)
35+ SET (PCRE_INCLUDE_DIRS)
36+ ENDIF (PCRE_FOUND)
37+
38+ MARK_AS_ADVANCED (PCRE_INCLUDE_DIRS PCRE_LIBRARIES)
Original file line number Diff line number Diff line change @@ -290,13 +290,14 @@ ELSE()
290290ENDIF ()
291291
292292# Specify regular expression implementation
293+ FIND_PACKAGE (PCRE)
294+
293295IF (REGEX STREQUAL "" )
294296 CHECK_SYMBOL_EXISTS(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
295- CHECK_SYMBOL_EXISTS(pcre_regcomp "pcreposix.h" HAVE_PCRE)
296297
297298 IF (HAVE_REGCOMP_L)
298299 SET (REGEX "regcomp_l" )
299- ELSEIF (HAVE_PCRE )
300+ ELSEIF (PCRE_FOUND )
300301 SET (REGEX "pcre" )
301302 ELSE ()
302303 SET (REGEX "builtin" )
@@ -309,6 +310,9 @@ IF(REGEX STREQUAL "regcomp_l")
309310ELSEIF (REGEX STREQUAL "pcre" )
310311 ADD_FEATURE_INFO(regex ON "using system PCRE" )
311312 SET (GIT_REGEX_PCRE 1)
313+
314+ LIST (APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE_INCLUDE_DIRS} )
315+ LIST (APPEND LIBGIT2_LIBS ${PCRE_LIBRARIES} )
312316ELSEIF (REGEX STREQUAL "regcomp" )
313317 ADD_FEATURE_INFO(regex ON "using system regcomp" )
314318 SET (GIT_REGEX_REGCOMP 1)
Original file line number Diff line number Diff line change 3030# define p_regexec pcre_regexec
3131# define p_regfree pcre_regfree
3232
33- /* Otherwise, use regcomp_l if available, or regcomp if not. */
33+ /*
34+ * Use the system-provided `regex` routines, whether that's via the
35+ * PCRE emulation layer, or libc, preferring `regcomp_l` it's available.
36+ */
37+
3438#else
3539
36- # include <regex.h>
40+ # ifdef GIT_REGEX_PCRE
41+ # include <pcreposix.h>
42+ # else
43+ # include <regex.h>
44+ # endif
3745
3846# define P_REG_EXTENDED REG_EXTENDED
3947# define P_REG_ICASE REG_ICASE
You can’t perform that action at this time.
0 commit comments