diff options
Diffstat (limited to '3rdparty/pcre')
-rw-r--r-- | 3rdparty/pcre/CMakeLists.txt | 66 | ||||
-rw-r--r-- | 3rdparty/pcre/FindPCRE.cmake | 35 |
2 files changed, 101 insertions, 0 deletions
diff --git a/3rdparty/pcre/CMakeLists.txt b/3rdparty/pcre/CMakeLists.txt new file mode 100644 index 000000000..70448d40e --- /dev/null +++ b/3rdparty/pcre/CMakeLists.txt @@ -0,0 +1,66 @@ + +# +# local copy +# +if( WIN32 ) +message( STATUS "Detecting local PCRE" ) +find_path( PCRE_LOCAL_INCLUDE_DIRS "pcre.h" + PATHS "${CMAKE_CURRENT_SOURCE_DIR}/include" + NO_DEFAULT_PATH ) +find_library( PCRE_LOCAL_LIBRARIES + NAMES pcre + PATHS "${CMAKE_CURRENT_SOURCE_DIR}/lib" + NO_DEFAULT_PATH ) +mark_as_advanced( PCRE_LOCAL_LIBRARIES ) +mark_as_advanced( PCRE_LOCAL_INCLUDE_DIRS ) + +if( PCRE_LOCAL_LIBRARIES AND PCRE_LOCAL_INCLUDE_DIRS ) + file( STRINGS "${PCRE_LOCAL_INCLUDE_DIRS}/pcre.h" PCRE_H REGEX "^#define[ \t]+PCRE_M[A-Z]+[ \t]+[0-9]+.*$" ) + string( REGEX REPLACE "^.*PCRE_MAJOR[ \t]+([0-9]+).*$" "\\1" PCRE_MAJOR "${PCRE_H}" ) + string( REGEX REPLACE "^.*PCRE_MINOR[ \t]+([0-9]+).*$" "\\1" PCRE_MINOR "${PCRE_H}" ) + message( STATUS "Found PCRE: ${PCRE_LOCAL_LIBRARIES} (found version ${PCRE_MAJOR}.${PCRE_MINOR})" ) + set( HAVE_LOCAL_PCRE ON + CACHE BOOL "pcre is available as a local copy" ) + mark_as_advanced( HAVE_LOCAL_PCRE ) +else() + foreach( _VAR PCRE_LOCAL_LIBRARIES PCRE_LOCAL_INCLUDE_DIRS ) + if( NOT "${_VAR}" ) + set( MISSING_VARS ${MISSING_VARS} ${_VAR} ) + endif() + endforeach() + message( STATUS "Could NOT find PCRE (missing: ${MISSING_VARS})" ) + unset( HAVE_LOCAL_PCRE CACHE ) +endif() +message( STATUS "Detecting local PCRE - done" ) +endif( WIN32 ) + + +# +# system +# +message( STATUS "Detecting system PCRE" ) +set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) +unset( PCRE_LIBRARIES CACHE ) +unset( PCRE_INCLUDE_DIRS CACHE ) +find_package( PCRE ) +set( PCRE_SYSTEM_LIBRARIES ${PCRE_LIBRARIES} + CACHE PATH "system pcre libraries" ) +set( PCRE_SYSTEM_INCLUDE_DIRS ${PCRE_INCLUDE_DIRS} + CACHE PATH "system pcre include directories" ) +mark_as_advanced( PCRE_SYSTEM_LIBRARIES ) +mark_as_advanced( PCRE_SYSTEM_INCLUDE_DIRS ) + +if( PCRE_SYSTEM_LIBRARIES AND PCRE_SYSTEM_INCLUDE_DIRS ) + set( HAVE_SYSTEM_PCRE ON + CACHE BOOL "pcre is available on the system" ) + mark_as_advanced( HAVE_SYSTEM_PCRE ) +else() + unset( HAVE_SYSTEM_PCRE CACHE ) +endif() +message( STATUS "Detecting system PCRE - done" ) + + +# +# configure +# +CONFIGURE_WITH_LOCAL_OR_SYSTEM( PCRE ) diff --git a/3rdparty/pcre/FindPCRE.cmake b/3rdparty/pcre/FindPCRE.cmake new file mode 100644 index 000000000..cb4d9177b --- /dev/null +++ b/3rdparty/pcre/FindPCRE.cmake @@ -0,0 +1,35 @@ +# - Find pcre +# Find the native PCRE includes and library +# +# PCRE_INCLUDE_DIRS - where to find pcre.h +# PCRE_LIBRARIES - List of libraries when using pcre. +# PCRE_FOUND - True if pcre found. + + +find_path( PCRE_INCLUDE_DIR pcre.h ) + +set( PCRE_NAMES pcre ) +find_library( PCRE_LIBRARY NAMES ${PCRE_NAMES} ) +mark_as_advanced( PCRE_LIBRARY PCRE_INCLUDE_DIR ) + +if( PCRE_INCLUDE_DIR AND EXISTS "${PCRE_INCLUDE_DIR}/pcre.h" ) + file( STRINGS "${PCRE_INCLUDE_DIR}/pcre.h" PCRE_H REGEX "^#define[ \t]+PCRE_M[A-Z]+[ \t]+[0-9]+.*$" ) + string( REGEX REPLACE "^.*PCRE_MAJOR[ \t]+([0-9]+).*$" "\\1" PCRE_MAJOR "${PCRE_H}" ) + string( REGEX REPLACE "^.*PCRE_MINOR[ \t]+([0-9]+).*$" "\\1" PCRE_MINOR "${PCRE_H}" ) + + set( PCRE_VERSION_STRING "${PCRE_MAJOR}.${PCRE_MINOR}" ) + set( PCRE_VERSION_MAJOR "${PCRE_MAJOR}" ) + set( PCRE_VERSION_MINOR "${PCRE_MINOR}" ) +endif() + +# handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if +# all listed variables are TRUE +include( FindPackageHandleStandardArgs ) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( PCRE + REQUIRED_VARS PCRE_LIBRARY PCRE_INCLUDE_DIR + VERSION_VAR PCRE_VERSION_STRING ) + +if( PCRE_FOUND ) + set( PCRE_LIBRARIES ${PCRE_LIBRARY} ) + set( PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR} ) +endif() |