Changeset View
Changeset View
Standalone View
Standalone View
cmake/FindPhoneNumber.cmake
1 | #.rst: | 1 | #.rst: | ||
---|---|---|---|---|---|
2 | # FindPhoneNumber | 2 | # FindPhoneNumber | ||
3 | # --------------- | 3 | # --------------- | ||
4 | # | 4 | # | ||
5 | # This module finds if PhoneNumber is installed. | 5 | # This module finds if PhoneNumber is installed. | ||
6 | # If found, this will define the following variables: | 6 | # | ||
7 | # This is a component-based find module, which makes use of the COMPONENTS and | ||||
8 | # OPTIONAL_COMPONENTS arguments to find_module. The following components are | ||||
9 | # available: | ||||
10 | # | ||||
11 | # PhoneNumber | ||||
12 | # GeoCoding | ||||
13 | # | ||||
14 | # If no components are specified, this module will act as though all components | ||||
15 | # were passed to OPTIONAL_COMPONENTS. | ||||
16 | # | ||||
17 | # This module will define the following variables, independently of the | ||||
18 | # components searched for or found: | ||||
7 | # | 19 | # | ||
8 | # ``PhoneNumber_FOUND`` | 20 | # ``PhoneNumber_FOUND`` | ||
9 | # Set to TRUE if PhoneNumber was found. | 21 | # True if (the requestion version of) PhoneNumber is available | ||
10 | # ``PhoneNumber_LIBRARIES`` | | |||
11 | # Path to PhoneNumber libraries. | | |||
12 | # ``PhoneNumber_INCLUDE_DIR`` | | |||
13 | # Path to the PhoneNumber include directory. | | |||
14 | # ``PhoneNumberGeoCoding_LIBRARIES`` | | |||
15 | # Path to PhoneNumber GeoCodeing libraries. | | |||
16 | # | | |||
17 | # If ``PhoneNumber_FOUND`` is TRUE the following imported targets | | |||
18 | # will be defined: | | |||
19 | # | | |||
20 | # ``PhoneNumber::PhoneNumber`` | | |||
21 | # The PhoneNumber library | | |||
22 | # ``PhoneNumber::GeoCoding`` | | |||
23 | # The PhoneNumber geo coding library | | |||
24 | # | 22 | # | ||
23 | # For each searched-for components, ``PhoneNumber_<component>_FOUND`` will be set to | ||||
24 | # TRUE if the corresponding library was found, and FALSE otherwise. If | ||||
25 | # ``PhoneNumber_<component>_FOUND`` is TRUE, the imported target ``PhoneNumber::<component>`` | ||||
26 | # will be defined. | ||||
25 | 27 | | |||
26 | #============================================================================= | 28 | #============================================================================= | ||
27 | # Copyright (c) 2017 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | 29 | # Copyright (c) 2017 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | ||
28 | # Copyright (c) 2018 Volker Krause <vkrause@kde.org> | 30 | # Copyright (c) 2018 Volker Krause <vkrause@kde.org> | ||
29 | # | 31 | # | ||
30 | # Redistribution and use in source and binary forms, with or without | 32 | # Redistribution and use in source and binary forms, with or without | ||
31 | # modification, are permitted provided that the following conditions | 33 | # modification, are permitted provided that the following conditions | ||
32 | # are met: | 34 | # are met: | ||
Show All 13 Lines | |||||
46 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 48 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
47 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 49 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
48 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 50 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
49 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 51 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
50 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 52 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
51 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 53 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
52 | #============================================================================= | 54 | #============================================================================= | ||
53 | 55 | | |||
54 | include(FindPackageHandleStandardArgs) | 56 | include(ECMFindModuleHelpersStub) | ||
57 | | ||||
58 | ecm_find_package_version_check(PhoneNumber) | ||||
55 | 59 | | |||
56 | find_library(PhoneNumber_LIBRARIES | 60 | set(PhoneNumber_known_components | ||
57 | NAMES phonenumber | 61 | PhoneNumber | ||
58 | PATH_SUFFIXES lib | 62 | GeoCoding | ||
59 | HINTS ENV PHONENUMBERDIR) | 63 | ) | ||
60 | 64 | set(PhoneNumber_default_components ${PhoneNumber_known_components}) | |||
61 | find_path(PhoneNumber_INCLUDE_DIR | 65 | | ||
62 | NAMES phonenumbers/phonenumberutil.h | 66 | set(PhoneNumber_PhoneNumber_lib phonenumber) | ||
63 | HINTS ENV PHONENUMBERDIR) | 67 | set(PhoneNumber_PhoneNumber_header phonenumbers/phonenumberutil.h) | ||
64 | 68 | set(PhoneNumber_GeoCoding_lib geocoding) | |||
65 | find_library(PhoneNumberGeoCoding_LIBRARIES | 69 | set(PhoneNumber_GeoCoding_header phonenumbers/geocoding/phonenumber_offline_geocoder.h) | ||
66 | NAMES geocoding | 70 | | ||
67 | PATH_SUFFIXES lib | 71 | ecm_find_package_parse_components(PhoneNumber | ||
68 | HINTS ENV PHONENUMBERDIR) | 72 | RESULT_VAR PhoneNumber_components | ||
69 | 73 | KNOWN_COMPONENTS ${PhoneNumber_known_components} | |||
70 | mark_as_advanced(PhoneNumber_LIBRARIES PhoneNumber_INCLUDE_DIR) | 74 | DEFAULT_COMPONENTS ${PhoneNumber_default_components} | ||
71 | mark_as_advanced(PhoneNumberGeoCoding_LIBRARIES) | 75 | ) | ||
72 | 76 | ecm_find_package_handle_library_components(PhoneNumber | |||
73 | find_package_handle_standard_args(PhoneNumber DEFAULT_MSG PhoneNumber_LIBRARIES PhoneNumber_INCLUDE_DIR PhoneNumberGeoCoding_LIBRARIES) | 77 | COMPONENTS ${PhoneNumber_components} | ||
74 | 78 | ) | |||
75 | if(PhoneNumber_FOUND AND NOT TARGET PhoneNumber::PhoneNumber) | 79 | find_package_handle_standard_args(PhoneNumber | ||
76 | add_library(PhoneNumber::PhoneNumber UNKNOWN IMPORTED) | 80 | FOUND_VAR | ||
77 | set_target_properties(PhoneNumber::PhoneNumber PROPERTIES | 81 | PhoneNumber_FOUND | ||
78 | IMPORTED_LOCATION "${PhoneNumber_LIBRARIES}" | 82 | REQUIRED_VARS | ||
79 | INTERFACE_INCLUDE_DIRECTORIES "${PhoneNumber_INCLUDE_DIR}") | 83 | PhoneNumber_LIBRARIES | ||
80 | add_library(PhoneNumber::GeoCoding UNKNOWN IMPORTED) | 84 | VERSION_VAR | ||
81 | set_target_properties(PhoneNumber::GeoCoding PROPERTIES | 85 | PhoneNumber_VERSION | ||
82 | IMPORTED_LOCATION "${PhoneNumberGeoCoding_LIBRARIES}" | 86 | HANDLE_COMPONENTS | ||
83 | INTERFACE_INCLUDE_DIRECTORIES "${PhoneNumber_INCLUDE_DIR}") | 87 | ) | ||
84 | endif() | | |||
85 | 88 | | |||
86 | include(FeatureSummary) | 89 | include(FeatureSummary) | ||
87 | set_package_properties(PhoneNumber PROPERTIES | 90 | set_package_properties(PhoneNumber PROPERTIES | ||
88 | URL "https://github.com/googlei18n/libphonenumber" | 91 | URL "https://github.com/googlei18n/libphonenumber" | ||
89 | DESCRIPTION "Library for parsing, formatting, and validating international phone numbers") | 92 | DESCRIPTION "Library for parsing, formatting, and validating international phone numbers") |