blob: 65d6dc6f5f56d655dd18aa05d2f037024f466293 [file] [log] [blame]
Radek Krejci54579462019-04-30 12:47:06 +02001# - Find pcre
2# Find the native PCRE2 headers and libraries.
3#
4# PCRE2_INCLUDE_DIRS - where to find pcre.h, etc.
5# PCRE2_LIBRARIES - List of libraries when using pcre.
6# PCRE2_FOUND - True if pcre found.
Michal Vasko57f8de62021-06-09 11:43:12 +02007include(FindPackageHandleStandardArgs)
Radek Krejci54579462019-04-30 12:47:06 +02008
Michal Vasko57f8de62021-06-09 11:43:12 +02009if(PCRE2_LIBRARIES AND PCRE2_INCLUDE_DIRS)
10 # in cache already
11 set(PCRE2_FOUND TRUE)
12else()
13 find_path(PCRE2_INCLUDE_DIR
14 NAMES
15 pcre2.h
16 PATHS
17 /usr/include
18 /usr/local/include
19 /opt/local/include
20 /sw/include
21 ${CMAKE_INCLUDE_PATH}
22 ${CMAKE_INSTALL_PREFIX}/include)
Radek Krejci54579462019-04-30 12:47:06 +020023
Michal Vasko57f8de62021-06-09 11:43:12 +020024 # Look for the library.
25 find_library(PCRE2_LIBRARY
26 NAMES
27 libpcre2.a
28 pcre2-8
29 PATHS
30 /usr/lib
31 /usr/lib64
32 /usr/local/lib
33 /usr/local/lib64
34 /opt/local/lib
35 /sw/lib
36 ${CMAKE_LIBRARY_PATH}
37 ${CMAKE_INSTALL_PREFIX}/lib)
Radek Krejci54579462019-04-30 12:47:06 +020038
Michal Vasko57f8de62021-06-09 11:43:12 +020039 if(PCRE2_LIBRARY)
40 # Check required version
41 execute_process(COMMAND pcre2-config --version OUTPUT_VARIABLE PCRE2_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
42 endif()
Radek Krejcid9e68c42019-05-31 16:26:26 +020043
Michal Vasko57f8de62021-06-09 11:43:12 +020044 set(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR})
45 set(PCRE2_LIBRARIES ${PCRE2_LIBRARY})
46 mark_as_advanced(PCRE2_INCLUDE_DIRS PCRE2_LIBRARIES)
Radek Krejci54579462019-04-30 12:47:06 +020047
Michal Vasko57f8de62021-06-09 11:43:12 +020048 # Handle the QUIETLY and REQUIRED arguments and set PCRE2_FOUND to TRUE if all listed variables are TRUE.
49 find_package_handle_standard_args(PCRE2 FOUND_VAR PCRE2_FOUND
50 REQUIRED_VARS PCRE2_LIBRARY PCRE2_INCLUDE_DIR
51 VERSION_VAR PCRE2_VERSION)
52endif()