FindPEGTL.cmake
Go to the documentation of this file.
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 
17 # Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
18 # Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
19 # Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
20 # Redistribution and use is allowed according to the terms of the 2-clause BSD license.
21 
22 find_path(PEGTL_INCLUDE_DIR
23  NAMES pegtl/version.hpp
24  PATH_SUFFIXES tao
25  DOC "Path to PEGTL headers")
26 mark_as_advanced(PEGTL_INCLUDE_DIR)
27 
28 if (PEGTL_INCLUDE_DIR)
29  file(STRINGS "${PEGTL_INCLUDE_DIR}/pegtl/version.hpp" _pegtl_version_header
30  REGEX "TAO_PEGTL_VERSION")
31  string(REGEX MATCH "define[ \t]+TAO_PEGTL_VERSION[ \t]+\"([0-9.]+)\"" _pegtl_version_match "${_pegtl_version_header}")
32  set(PEGTL_VERSION "${CMAKE_MATCH_1}")
33  unset(_pegtl_version_header)
34  unset(_pegtl_version_match)
35 endif ()
36 
37 include(FindPackageHandleStandardArgs)
38 find_package_handle_standard_args(PEGTL
39  REQUIRED_VARS PEGTL_INCLUDE_DIR
40  VERSION_VAR PEGTL_VERSION)
41 
42 if (PEGTL_FOUND)
43  set(PEGTL_INCLUDE_DIRS "${PEGTL_INCLUDE_DIR}")
44  if (NOT TARGET PEGTL::PEGTL)
45  add_library(PEGTL::PEGTL INTERFACE IMPORTED)
46  set_target_properties(PEGTL::PEGTL PROPERTIES
47  INTERFACE_INCLUDE_DIRECTORIES "${PEGTL_INCLUDE_DIR}")
48  endif ()
49 endif ()
version
string