FindPCRE.cmake 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # - Find pcre
  2. # Find the native PCRE includes and library
  3. #
  4. # PCRE_INCLUDE_DIRS - where to find pcre.h
  5. # PCRE_LIBRARIES - List of libraries when using pcre.
  6. # PCRE_FOUND - True if pcre found.
  7. find_path( PCRE_INCLUDE_DIR pcre.h )
  8. set( PCRE_NAMES pcre )
  9. find_library( PCRE_LIBRARY NAMES ${PCRE_NAMES} )
  10. mark_as_advanced( PCRE_LIBRARY PCRE_INCLUDE_DIR )
  11. if( PCRE_INCLUDE_DIR AND EXISTS "${PCRE_INCLUDE_DIR}/pcre.h" )
  12. file( STRINGS "${PCRE_INCLUDE_DIR}/pcre.h" PCRE_H REGEX "^#define[ \t]+PCRE_M[A-Z]+[ \t]+[0-9]+.*$" )
  13. string( REGEX REPLACE "^.*PCRE_MAJOR[ \t]+([0-9]+).*$" "\\1" PCRE_MAJOR "${PCRE_H}" )
  14. string( REGEX REPLACE "^.*PCRE_MINOR[ \t]+([0-9]+).*$" "\\1" PCRE_MINOR "${PCRE_H}" )
  15. set( PCRE_VERSION_STRING "${PCRE_MAJOR}.${PCRE_MINOR}" )
  16. set( PCRE_VERSION_MAJOR "${PCRE_MAJOR}" )
  17. set( PCRE_VERSION_MINOR "${PCRE_MINOR}" )
  18. endif()
  19. # handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if
  20. # all listed variables are TRUE
  21. include( FindPackageHandleStandardArgs )
  22. FIND_PACKAGE_HANDLE_STANDARD_ARGS( PCRE
  23. REQUIRED_VARS PCRE_LIBRARY PCRE_INCLUDE_DIR
  24. VERSION_VAR PCRE_VERSION_STRING )
  25. if( PCRE_FOUND )
  26. set( PCRE_LIBRARIES ${PCRE_LIBRARY} )
  27. set( PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR} )
  28. endif()