From cbb129cba4aa367757fb0e0962ef6287b2ddd8c5 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 9 Feb 2016 11:26:16 +0000 Subject: [PATCH] Add pcre2 detection --- CMakeLists.txt | 45 ++++++++++++++++++++++++++++++++++----------- config.h.in | 1 + 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24f380560..ae950659d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,7 @@ OPTION(ENABLE_SNOWBALL "Enable snowball stemmer [default: ON]" OPTION(ENABLE_CLANG_PLUGIN "Enable clang static analysing plugin [default: OFF]" OFF) OPTION(ENABLE_HYPERSCAN "Enable hyperscan for fast regexp processing [default: OFF]" OFF) OPTION(ENABLE_FANN "Enable fann for neural network plugin [default: OFF]" OFF) +OPTION(ENABLE_PCRE2 "Enable pcre2 instead of pcre [default: OFF]" OFF) INCLUDE(FindArch.cmake) TARGET_ARCHITECTURE(ARCH) @@ -66,6 +67,12 @@ ELSE() MESSAGE(STATUS "Hyperscan support is possible only for x86_64 architecture") SET(ENABLE_HYPERSCAN "OFF") ENDIF() + +IF(ENABLE_PCRE2 MATCHES "ON") + SET(WITH_PCRE2 1) + # For utf8 API + LIST(APPEND CMAKE_REQUIRED_DEFINITIONS "-DPCRE2_CODE_UNIT_WIDTH=8") +ENDIF() # Build optimized code for following CPU (default i386) #SET(CPU_TUNE "i686") @@ -623,8 +630,14 @@ ENDIF(ENABLE_LUAJIT MATCHES "ON") ProcessPackage(GLIB2 LIBRARY glib-2.0 INCLUDE glib.h INCLUDE_SUFFIXES include/glib ROOT ${GLIB_ROOT_DIR} MODULES glib-2.0>=2.28) -ProcessPackage(PCRE LIBRARY pcre INCLUDE pcre.h INCLUDE_SUFFIXES include/pcre - ROOT ${PCRE_ROOT_DIR} MODULES pcre libpcre pcre3 libpcre3) + +IF(ENABLE_PCRE2 MATCHES "ON") + ProcessPackage(PCRE LIBRARY pcre2 INCLUDE pcre2.h INCLUDE_SUFFIXES include/pcre2 + ROOT ${PCRE_ROOT_DIR} MODULES pcre2 libpcre2 libpcre2-8) +ELSE() + ProcessPackage(PCRE LIBRARY pcre INCLUDE pcre.h INCLUDE_SUFFIXES include/pcre + ROOT ${PCRE_ROOT_DIR} MODULES pcre libpcre pcre3 libpcre3) +ENDIF() ProcessPackage(GMIME LIBRARY gmime-2.6 gmime-2.4 gmime-2.2 gmime-2 INCLUDE gmime.h INCLUDE_SUFFIXES include/gmime ROOT ${GMIME_ROOT_DIR} MODULES gmime-2.6 gmime-2.4 gmime-2.0) ProcessPackage(LIBEVENT LIBRARY event INCLUDE event.h INCLUDE_SUFFIXES include/event @@ -660,13 +673,6 @@ IF(GMIME2_VERSION VERSION_GREATER "2.4.0" OR NOT GMIME2_VERSION) SET(GMIME24 1) ENDIF() -LIST(APPEND CMAKE_REQUIRED_INCLUDES "${PCRE_INCLUDE}") -IF(PCRE_LIBRARY_PATH) - SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};-L${PCRE_LIBRARY_PATH};-lpcre") -ELSE(PCRE_LIBRARY_PATH) - SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};-lpcre") -ENDIF(PCRE_LIBRARY_PATH) - IF(ENABLE_HIREDIS MATCHES "ON") ADD_SUBDIRECTORY(contrib/hiredis) SET(WITH_HIREDIS 1) @@ -872,12 +878,29 @@ CHECK_SYMBOL_EXISTS(getaddrinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRI CHECK_SYMBOL_EXISTS(sched_yield "sched.h" HAVE_SCHED_YIELD) CHECK_SYMBOL_EXISTS(__get_cpuid "cpuid.h" HAVE_GET_CPUID) CHECK_SYMBOL_EXISTS(nftw "sys/types.h;ftw.h" HAVE_NFTW) -CHECK_SYMBOL_EXISTS(PCRE_CONFIG_JIT "pcre.h" HAVE_PCRE_JIT) +IF(ENABLE_PCRE2 MATCHES "ON") + LIST(APPEND CMAKE_REQUIRED_INCLUDES "${PCRE_INCLUDE}") + CHECK_SYMBOL_EXISTS(PCRE2_CONFIG_JIT "pcre2.h" HAVE_PCRE_JIT) +ELSE() + LIST(APPEND CMAKE_REQUIRED_INCLUDES "${PCRE_INCLUDE}") + CHECK_SYMBOL_EXISTS(PCRE_CONFIG_JIT "pcre.h" HAVE_PCRE_JIT) +ENDIF() CHECK_SYMBOL_EXISTS(SOCK_SEQPACKET "sys/types.h;sys/socket.h" HAVE_SOCK_SEQPACKET) CHECK_SYMBOL_EXISTS(I_SETSIG "sys/types.h;sys/ioctl.h" HAVE_SETSIG) CHECK_SYMBOL_EXISTS(O_ASYNC "sys/types.h;sys/fcntl.h" HAVE_OASYNC) CHECK_SYMBOL_EXISTS(O_NOFOLLOW "sys/types.h;sys/fcntl.h" HAVE_ONOFOLLOW) +IF(ENABLE_PCRE2 MATCHES "ON") + IF(HAVE_PCRE_JIT) + SET(HAVE_PCRE_JIT_FAST 1) + ENDIF() +ELSE() + LIST(APPEND CMAKE_REQUIRED_INCLUDES "${PCRE_INCLUDE}") + IF(PCRE_LIBRARY_PATH) + SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};-L${PCRE_LIBRARY_PATH};${PCRE_LIBRARY}") + ELSE(PCRE_LIBRARY_PATH) + SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};-lpcre") + ENDIF(PCRE_LIBRARY_PATH) # Some PCRE implementations are lacking of pcre_jit_exec fast path SET(_PCRE_FAST_TEST " #include \"pcre.h\" @@ -898,13 +921,13 @@ int main (void) return rc; } ") - CHECK_C_SOURCE_COMPILES("${_PCRE_FAST_TEST}" HAVE_PCRE_JIT_FAST) IF(HAVE_PCRE_JIT_FAST) MESSAGE(STATUS "pcre_jit_exec is supported") ELSE(HAVE_PCRE_JIT_FAST) MESSAGE(STATUS "pcre_jit_exec is -NOT- supported") ENDIF(HAVE_PCRE_JIT_FAST) +ENDIF() FILE(WRITE ${CMAKE_BINARY_DIR}/pthread_setpshared.c " #include diff --git a/config.h.in b/config.h.in index fbe3bb37b..bae4efdb9 100644 --- a/config.h.in +++ b/config.h.in @@ -124,6 +124,7 @@ #cmakedefine WITH_HYPERSCAN 1 #cmakedefine WITH_JUDY 1 #cmakedefine WITH_LUA 1 +#cmakedefine WITH_PCRE2 1 #cmakedefine WITH_PROFILER 1 #cmakedefine WITH_SNOWBALL 1 #cmakedefine WITH_SQLITE 1 -- 2.39.5