~neon/extra-cmake-modules/master

« back to all changes in this revision

Viewing changes to find-modules/FindPhoneNumber.cmake

  • Committer: Volker Krause
  • Date: 2018-12-04 16:47:13 UTC
  • Revision ID: git-v1:ebb05ecafb02294c2ed471638c35576d2852b456
Add find module for Google's libphonenumber

Summary:
This is currently in use by plasma-phone-components, but will also be
needed by KItinerary.

Reviewers: #build_system, #frameworks, cgiboudeaux

Reviewed By: cgiboudeaux

Subscribers: cgiboudeaux, kde-frameworks-devel, kde-buildsystem

Tags: #frameworks, #build_system

Differential Revision: https://phabricator.kde.org/D16954

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#.rst:
 
2
# FindPhoneNumber
 
3
# ---------------
 
4
#
 
5
# This module finds if PhoneNumber is installed.
 
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:
 
19
#
 
20
# ``PhoneNumber_FOUND``
 
21
#     True if (the requestion version of) PhoneNumber is available
 
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.
 
27
#
 
28
# Since 5.54.0.
 
29
 
 
30
#=============================================================================
 
31
# Copyright (c) 2017 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
 
32
# Copyright (c) 2018 Volker Krause <vkrause@kde.org>
 
33
#
 
34
# Redistribution and use in source and binary forms, with or without
 
35
# modification, are permitted provided that the following conditions
 
36
# are met:
 
37
#
 
38
# 1. Redistributions of source code must retain the copyright
 
39
#    notice, this list of conditions and the following disclaimer.
 
40
# 2. Redistributions in binary form must reproduce the copyright
 
41
#    notice, this list of conditions and the following disclaimer in the
 
42
#    documentation and/or other materials provided with the distribution.
 
43
# 3. The name of the author may not be used to endorse or promote products
 
44
#    derived from this software without specific prior written permission.
 
45
#
 
46
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 
47
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 
48
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 
49
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 
50
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 
51
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
52
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
53
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
54
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 
55
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
56
#=============================================================================
 
57
 
 
58
include(ECMFindModuleHelpersStub)
 
59
 
 
60
ecm_find_package_version_check(PhoneNumber)
 
61
 
 
62
set(PhoneNumber_known_components
 
63
    PhoneNumber
 
64
    GeoCoding
 
65
)
 
66
set(PhoneNumber_default_components ${PhoneNumber_known_components})
 
67
 
 
68
set(PhoneNumber_PhoneNumber_lib phonenumber)
 
69
set(PhoneNumber_PhoneNumber_header phonenumbers/phonenumberutil.h)
 
70
set(PhoneNumber_GeoCoding_lib geocoding)
 
71
set(PhoneNumber_GeoCoding_header phonenumbers/geocoding/phonenumber_offline_geocoder.h)
 
72
 
 
73
ecm_find_package_parse_components(PhoneNumber
 
74
    RESULT_VAR PhoneNumber_components
 
75
    KNOWN_COMPONENTS ${PhoneNumber_known_components}
 
76
    DEFAULT_COMPONENTS ${PhoneNumber_default_components}
 
77
)
 
78
ecm_find_package_handle_library_components(PhoneNumber
 
79
    COMPONENTS ${PhoneNumber_components}
 
80
)
 
81
find_package_handle_standard_args(PhoneNumber
 
82
    FOUND_VAR
 
83
        PhoneNumber_FOUND
 
84
    REQUIRED_VARS
 
85
        PhoneNumber_LIBRARIES
 
86
    VERSION_VAR
 
87
        PhoneNumber_VERSION
 
88
    HANDLE_COMPONENTS
 
89
)
 
90
set(PhoneNumber_VERSION 0) # there is no observable version number in the installed files
 
91
 
 
92
include(FeatureSummary)
 
93
set_package_properties(PhoneNumber PROPERTIES
 
94
  URL "https://github.com/googlei18n/libphonenumber"
 
95
  DESCRIPTION "Library for parsing, formatting, and validating international phone numbers")