blob: 19af7b772fd8f28ce9cabc73de3ecffb1d6ed272 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# - Find pcre
# Find the native PCRE2 headers and libraries.
#
# PCRE2_INCLUDE_DIRS - where to find pcre.h, etc.
# PCRE2_LIBRARIES - List of libraries when using pcre.
# PCRE2_FOUND - True if pcre found.
include(FindPackageHandleStandardArgs)
if(PCRE2_LIBRARIES AND PCRE2_INCLUDE_DIRS)
# in cache already
set(PCRE2_FOUND TRUE)
else()
find_path(PCRE2_INCLUDE_DIR
NAMES
pcre2.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
${CMAKE_INCLUDE_PATH}
${CMAKE_INSTALL_PREFIX}/include)
# Look for the library.
find_library(PCRE2_LIBRARY
NAMES
libpcre2.a
pcre2-8
PATHS
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/opt/local/lib
/sw/lib
${CMAKE_LIBRARY_PATH}
${CMAKE_INSTALL_PREFIX}/lib)
if(PCRE2_INCLUDE_DIR AND PCRE2_LIBRARY)
# learn pcre2 version
file(STRINGS ${PCRE2_INCLUDE_DIR}/pcre2.h PCRE2_VERSION_MAJOR
REGEX "#define[ ]+PCRE2_MAJOR[ ]+[0-9]+")
string(REGEX MATCH " [0-9]+" PCRE2_VERSION_MAJOR ${PCRE2_VERSION_MAJOR})
string(STRIP "${PCRE2_VERSION_MAJOR}" PCRE2_VERSION_MAJOR)
file(STRINGS ${PCRE2_INCLUDE_DIR}/pcre2.h PCRE2_VERSION_MINOR
REGEX "#define[ ]+PCRE2_MINOR[ ]+[0-9]+")
string(REGEX MATCH " [0-9]+" PCRE2_VERSION_MINOR ${PCRE2_VERSION_MINOR})
string(STRIP "${PCRE2_VERSION_MINOR}" PCRE2_VERSION_MINOR)
set(PCRE2_VERSION ${PCRE2_VERSION_MAJOR}.${PCRE2_VERSION_MINOR})
endif()
set(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR})
set(PCRE2_LIBRARIES ${PCRE2_LIBRARY})
mark_as_advanced(PCRE2_INCLUDE_DIRS PCRE2_LIBRARIES)
# Handle the QUIETLY and REQUIRED arguments and set PCRE2_FOUND to TRUE if all listed variables are TRUE.
find_package_handle_standard_args(PCRE2 FOUND_VAR PCRE2_FOUND
REQUIRED_VARS PCRE2_LIBRARY PCRE2_INCLUDE_DIR
VERSION_VAR PCRE2_VERSION)
endif()
|