File: FindPCRE2.cmake

package info (click to toggle)
gmt 5.4.5%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 149,844 kB
  • sloc: ansic: 202,639; sh: 7,742; xml: 149; makefile: 73; fortran: 49; lisp: 41; csh: 5
file content (122 lines) | stat: -rw-r--r-- 3,408 bytes parent folder | download
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#
# $Id$
#
# Locate pcre2
#
# This module accepts the following environment variables:
#
#    PCRE2_DIR or PCRE2_ROOT - Specify the location of PCRE2
#
# This module defines the following CMake variables:
#
#    PCRE2_FOUND - True if libpcre2 is found
#    PCRE2_LIBRARY - A variable pointing to the PCRE2 library
#    PCRE2_INCLUDE_DIR - Where to find the headers

#=============================================================================
# Inspired by FindGDAL
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See COPYING-CMAKE-SCRIPTS for more information.
#=============================================================================

# This makes the presumption that you are include pcre2.h like
#
#include "pcre2.h"

if (DEFINED PCRE2_ROOT AND NOT PCRE2_ROOT)
	set (PCRE2_LIBRARY "" CACHE INTERNAL "")
	set (PCRE2_INCLUDE_DIR "" CACHE INTERNAL "")
	return ()
endif (DEFINED PCRE2_ROOT AND NOT PCRE2_ROOT)

if (UNIX AND NOT PCRE2_FOUND)
	# Use pcre2-config to obtain the library location and name, something like
	# -L/sw/lib -lpcre2-8)
	find_program (PCRE2_CONFIG pcre2-config
		HINTS
		${PCRE2_DIR}
		${PCRE2_ROOT}
		$ENV{PCRE2_DIR}
		$ENV{PCRE2_ROOT}
		PATH_SUFFIXES bin
		PATHS
		/sw # Fink
		/opt/local # DarwinPorts
		/opt/csw # Blastwave
		/opt
		/usr/local
	)

	if (PCRE2_CONFIG)
		execute_process (COMMAND ${PCRE2_CONFIG} --cflags
			ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
			OUTPUT_VARIABLE PCRE2_CONFIG_CFLAGS)
		if (PCRE2_CONFIG_CFLAGS)
			string (REGEX MATCHALL "-I[^ ]+" _pcre2_dashI ${PCRE2_CONFIG_CFLAGS})
			string (REGEX REPLACE "-I" "" _pcre2_includepath "${_pcre2_dashI}")
			string (REGEX REPLACE "-I[^ ]+" "" _pcre2_cflags_other ${PCRE2_CONFIG_CFLAGS})
		endif (PCRE2_CONFIG_CFLAGS)
		execute_process (COMMAND ${PCRE2_CONFIG} --libs8
			ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
			OUTPUT_VARIABLE PCRE2_CONFIG_LIBS)
		if (PCRE2_CONFIG_LIBS)
			string (REGEX MATCHALL "-l[^ ]+" _pcre2_dashl ${PCRE2_CONFIG_LIBS})
			string (REGEX REPLACE "-l" "" _pcre2_lib "${_pcre2_dashl}")
			string (REGEX MATCHALL "-L[^ ]+" _pcre2_dashL ${PCRE2_CONFIG_LIBS})
			string (REGEX REPLACE "-L" "" _pcre2_libpath "${_pcre2_dashL}")
		endif (PCRE2_CONFIG_LIBS)
	endif (PCRE2_CONFIG)
endif (UNIX AND NOT PCRE2_FOUND)

find_path (PCRE2_INCLUDE_DIR pcre2.h
	HINTS
	${_pcre2_includepath}
	${PCRE2_DIR}
	${PCRE2_ROOT}
	$ENV{PCRE2_DIR}
	$ENV{PCRE2_ROOT}
	PATH_SUFFIXES
	include/pcre2
	include/PCRE2
	include
	PATHS
	~/Library/Frameworks/pcre2.framework/Headers
	/Library/Frameworks/pcre2.framework/Headers
	/sw # Fink
	/opt/local # DarwinPorts
	/opt/csw # Blastwave
	/opt
	/usr/local
)

find_library (PCRE2_LIBRARY
	NAMES ${_pcre2_lib} pcre2-8 PCRE2
	HINTS
	${PCRE2_DIR}
	${PCRE2_ROOT}
	$ENV{PCRE2_DIR}
	$ENV{PCRE2_ROOT}
	${_pcre2_libpath}
	PATH_SUFFIXES lib
	PATHS
	~/Library/Frameworks/pcre2.framework
	/Library/Frameworks/pcre2.framework
	/sw
	/opt/local
	/opt/csw
	/opt
	/usr/local
)

include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (PCRE2 DEFAULT_MSG PCRE2_LIBRARY PCRE2_INCLUDE_DIR)

set (PCRE2_LIBRARIES ${PCRE2_LIBRARY})
set (PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR})

# vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2