Fix class loading issue for enum class
[hiphop-php.git] / CMake / FindPCRE.cmake
blobda7d6349831ee0a95911c17602a363619cae0e28
2 # $Id$
4 # - Find pcre
5 # Find the native PCRE includes and library
7 #  PCRE_INCLUDE_DIR  - where to find pcre.h, etc.
8 #  PCRE_LIBRARY      - Path to the pcre library.
9 #  PCRE_FOUND        - True if pcre found.
12 IF (PCRE_INCLUDE_DIR)
13   # Already in cache, be silent
14   SET(PCRE_FIND_QUIETLY TRUE)
15 ENDIF (PCRE_INCLUDE_DIR)
17 FIND_PATH(SYSTEM_PCRE_INCLUDE_DIR pcre.h)
19 SET(PCRE_NAMES pcre)
20 FIND_LIBRARY(SYSTEM_PCRE_LIBRARY NAMES ${PCRE_NAMES} )
22 # handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if
23 # all listed variables are TRUE
24 INCLUDE(FindPackageHandleStandardArgs)
25 FIND_PACKAGE_HANDLE_STANDARD_ARGS(
26   PCRE DEFAULT_MSG SYSTEM_PCRE_LIBRARY SYSTEM_PCRE_INCLUDE_DIR
29 # Make sure it's got the jit enabled. If not, don't use it.
30 IF (PCRE_FOUND)
31   INCLUDE(CheckCSourceRuns)
32   SET(CMAKE_REQUIRED_LIBRARIES pcre)
33   CHECK_C_SOURCE_RUNS("#include <pcre.h>
34 int main() {
35   int has_jit = 0;
36   pcre_config(PCRE_CONFIG_JIT, &has_jit);
37   return has_jit ? 0 : 1;
39 " SYSTEM_PCRE_HAS_JIT)
40 ENDIF (PCRE_FOUND)
42 IF(NOT SYSTEM_PCRE_HAS_JIT)
43   MESSAGE(STATUS
44     "System PCRE does not have JIT enabled - will use hhvm-third-party/pcre")
45   UNSET(PCRE_INCLUDE_DIR CACHE)
46   UNSET(PCRE_LIBRARY CACHE)
48   # This is used to configure bundled pcre
49   SET(PCRE_SUPPORT_JIT ON CACHE BOOL "")
50   SET(PCRE_SUPPORT_UTF ON CACHE BOOL "")
51   SET(PCRE_SUPPORT_UNICODE_PROPERTIES ON CACHE BOOL "")
52 ELSE()
53   SET(PCRE_INCLUDE_DIR ${SYSTEM_PCRE_INCLUDE_DIR}
54     CACHE PATH "PCRE include directory")
55   SET(PCRE_LIBRARY ${SYSTEM_PCRE_LIBRARY} CACHE FILEPATH "PCRE library")
56 ENDIF()
58 MARK_AS_ADVANCED( PCRE_LIBRARY PCRE_INCLUDE_DIR )