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
|
#
#
# Locate pcre
#
# This module accepts the following environment variables:
#
# PCRE_DIR or PCRE_ROOT - Specify the location of PCRE
#
# This module defines the following CMake variables:
#
# PCRE_FOUND - True if libpcre is found
# PCRE_LIBRARY - A variable pointing to the PCRE library
# PCRE_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 pcre.h like
#
#include "pcre.h"
if (DEFINED PCRE_ROOT AND NOT PCRE_ROOT)
set (PCRE_LIBRARY "" CACHE INTERNAL "")
set (PCRE_INCLUDE_DIR "" CACHE INTERNAL "")
return ()
endif (DEFINED PCRE_ROOT AND NOT PCRE_ROOT)
if (UNIX AND NOT PCRE_FOUND)
# Use pcre-config to obtain the library version (this should hopefully
# allow us to -lpcre1.x.y where x.y are correct version)
# For some reason, libpcre development packages do not contain
# libpcre.so...
find_program (PCRE_CONFIG pcre-config
HINTS
${PCRE_DIR}
${PCRE_ROOT}
$ENV{PCRE_DIR}
$ENV{PCRE_ROOT}
PATH_SUFFIXES bin
PATHS
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
/usr/local
)
if (PCRE_CONFIG)
execute_process (COMMAND ${PCRE_CONFIG} --cflags
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE PCRE_CONFIG_CFLAGS)
if (PCRE_CONFIG_CFLAGS)
string (REGEX MATCHALL "-I[^ ]+" _pcre_dashI ${PCRE_CONFIG_CFLAGS})
string (REGEX REPLACE "-I" "" _pcre_includepath "${_pcre_dashI}")
string (REGEX REPLACE "-I[^ ]+" "" _pcre_cflags_other ${PCRE_CONFIG_CFLAGS})
endif (PCRE_CONFIG_CFLAGS)
execute_process (COMMAND ${PCRE_CONFIG} --libs
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE PCRE_CONFIG_LIBS)
if (PCRE_CONFIG_LIBS)
string (REGEX MATCHALL "-l[^ ]+" _pcre_dashl ${PCRE_CONFIG_LIBS})
string (REGEX REPLACE "-l" "" _pcre_lib "${_pcre_dashl}")
string (REGEX MATCHALL "-L[^ ]+" _pcre_dashL ${PCRE_CONFIG_LIBS})
string (REGEX REPLACE "-L" "" _pcre_libpath "${_pcre_dashL}")
endif (PCRE_CONFIG_LIBS)
endif (PCRE_CONFIG)
endif (UNIX AND NOT PCRE_FOUND)
find_path (PCRE_INCLUDE_DIR pcre.h
HINTS
${_pcre_includepath}
${PCRE_DIR}
${PCRE_ROOT}
$ENV{PCRE_DIR}
$ENV{PCRE_ROOT}
PATH_SUFFIXES
include/pcre
include/PCRE
include
PATHS
~/Library/Frameworks/pcre.framework/Headers
/Library/Frameworks/pcre.framework/Headers
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
/usr/local
)
find_library (PCRE_LIBRARY
NAMES ${_pcre_lib} pcre pcre.0 PCRE
HINTS
${PCRE_DIR}
${PCRE_ROOT}
$ENV{PCRE_DIR}
$ENV{PCRE_ROOT}
${_pcre_libpath}
PATH_SUFFIXES lib
PATHS
~/Library/Frameworks/pcre.framework
/Library/Frameworks/pcre.framework
/sw
/opt/local
/opt/csw
/opt
/usr/local
)
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR)
set (PCRE_LIBRARIES ${PCRE_LIBRARY})
set (PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
|