FindPEGTL.cmake 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # - Try to find PEGTL lib
  2. #
  3. # This module supports requiring a minimum version, e.g. you can do
  4. # find_package(PEGTL 3.1.2)
  5. # to require version 3.1.2 or newer of PEGTL.
  6. #
  7. # Once done this will define
  8. #
  9. # PEGTL_FOUND - system has eigen lib with correct version
  10. # PEGTL_INCLUDE_DIRS - the eigen include directory
  11. # PEGTL_VERSION - eigen version
  12. #
  13. # And the following imported target:
  14. #
  15. # PEGTL::PEGTL
  16. # Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
  17. # Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
  18. # Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
  19. # Redistribution and use is allowed according to the terms of the 2-clause BSD license.
  20. find_path(PEGTL_INCLUDE_DIR
  21. NAMES pegtl/version.hpp
  22. PATH_SUFFIXES tao
  23. DOC "Path to PEGTL headers")
  24. mark_as_advanced(PEGTL_INCLUDE_DIR)
  25. if (PEGTL_INCLUDE_DIR)
  26. file(STRINGS "${PEGTL_INCLUDE_DIR}/pegtl/version.hpp" _pegtl_version_header
  27. REGEX "TAO_PEGTL_VERSION")
  28. string(REGEX MATCH "define[ \t]+TAO_PEGTL_VERSION[ \t]+\"([0-9.]+)\"" _pegtl_version_match "${_pegtl_version_header}")
  29. set(PEGTL_VERSION "${CMAKE_MATCH_1}")
  30. unset(_pegtl_version_header)
  31. unset(_pegtl_version_match)
  32. endif ()
  33. include(FindPackageHandleStandardArgs)
  34. find_package_handle_standard_args(PEGTL
  35. REQUIRED_VARS PEGTL_INCLUDE_DIR
  36. VERSION_VAR PEGTL_VERSION)
  37. if (PEGTL_FOUND)
  38. set(PEGTL_INCLUDE_DIRS "${PEGTL_INCLUDE_DIR}")
  39. if (NOT TARGET PEGTL::PEGTL)
  40. add_library(PEGTL::PEGTL INTERFACE IMPORTED)
  41. set_target_properties(PEGTL::PEGTL PROPERTIES
  42. INTERFACE_INCLUDE_DIRECTORIES "${PEGTL_INCLUDE_DIR}")
  43. endif ()
  44. endif ()