FindPCRE.cmake 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  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. PATHS
  9. "/usr/include/pcre" )
  10. set( PCRE_NAMES pcre )
  11. find_library( PCRE_LIBRARY NAMES ${PCRE_NAMES} )
  12. mark_as_advanced( PCRE_LIBRARY PCRE_INCLUDE_DIR )
  13. if( PCRE_INCLUDE_DIR AND EXISTS "${PCRE_INCLUDE_DIR}/pcre.h" )
  14. file( STRINGS "${PCRE_INCLUDE_DIR}/pcre.h" PCRE_H REGEX "^#define[ \t]+PCRE_M[A-Z]+[ \t]+[0-9]+.*$" )
  15. string( REGEX REPLACE "^.*PCRE_MAJOR[ \t]+([0-9]+).*$" "\\1" PCRE_MAJOR "${PCRE_H}" )
  16. string( REGEX REPLACE "^.*PCRE_MINOR[ \t]+([0-9]+).*$" "\\1" PCRE_MINOR "${PCRE_H}" )
  17. set( PCRE_VERSION_STRING "${PCRE_MAJOR}.${PCRE_MINOR}" )
  18. set( PCRE_VERSION_MAJOR "${PCRE_MAJOR}" )
  19. set( PCRE_VERSION_MINOR "${PCRE_MINOR}" )
  20. endif()
  21. # handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if
  22. # all listed variables are TRUE
  23. include( FindPackageHandleStandardArgs )
  24. FIND_PACKAGE_HANDLE_STANDARD_ARGS( PCRE
  25. REQUIRED_VARS PCRE_LIBRARY PCRE_INCLUDE_DIR
  26. VERSION_VAR PCRE_VERSION_STRING )
  27. if( PCRE_FOUND )
  28. set( PCRE_LIBRARIES ${PCRE_LIBRARY} )
  29. set( PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR} )
  30. endif()