mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-01 01:07:33 +00:00
Rewrite the PhoneNumber find module to be component-based
Summary: This allows us to only search for the parts we actually need, which is useful as this libraries turns out to be rather complicated to cross- compile. Reviewers: bshah, svuorela Reviewed By: bshah, svuorela Differential Revision: https://phabricator.kde.org/D16476
This commit is contained in:
parent
cd90f4a786
commit
306512efe9
2 changed files with 47 additions and 44 deletions
|
|
@ -3,25 +3,27 @@
|
||||||
# ---------------
|
# ---------------
|
||||||
#
|
#
|
||||||
# This module finds if PhoneNumber is installed.
|
# This module finds if PhoneNumber is installed.
|
||||||
# If found, this will define the following variables:
|
#
|
||||||
|
# This is a component-based find module, which makes use of the COMPONENTS and
|
||||||
|
# OPTIONAL_COMPONENTS arguments to find_module. The following components are
|
||||||
|
# available:
|
||||||
|
#
|
||||||
|
# PhoneNumber
|
||||||
|
# GeoCoding
|
||||||
|
#
|
||||||
|
# If no components are specified, this module will act as though all components
|
||||||
|
# were passed to OPTIONAL_COMPONENTS.
|
||||||
|
#
|
||||||
|
# This module will define the following variables, independently of the
|
||||||
|
# components searched for or found:
|
||||||
#
|
#
|
||||||
# ``PhoneNumber_FOUND``
|
# ``PhoneNumber_FOUND``
|
||||||
# Set to TRUE if PhoneNumber was found.
|
# True if (the requestion version of) PhoneNumber is available
|
||||||
# ``PhoneNumber_LIBRARIES``
|
|
||||||
# Path to PhoneNumber libraries.
|
|
||||||
# ``PhoneNumber_INCLUDE_DIR``
|
|
||||||
# Path to the PhoneNumber include directory.
|
|
||||||
# ``PhoneNumberGeoCoding_LIBRARIES``
|
|
||||||
# Path to PhoneNumber GeoCodeing libraries.
|
|
||||||
#
|
|
||||||
# If ``PhoneNumber_FOUND`` is TRUE the following imported targets
|
|
||||||
# will be defined:
|
|
||||||
#
|
|
||||||
# ``PhoneNumber::PhoneNumber``
|
|
||||||
# The PhoneNumber library
|
|
||||||
# ``PhoneNumber::GeoCoding``
|
|
||||||
# The PhoneNumber geo coding library
|
|
||||||
#
|
#
|
||||||
|
# For each searched-for components, ``PhoneNumber_<component>_FOUND`` will be set to
|
||||||
|
# TRUE if the corresponding library was found, and FALSE otherwise. If
|
||||||
|
# ``PhoneNumber_<component>_FOUND`` is TRUE, the imported target ``PhoneNumber::<component>``
|
||||||
|
# will be defined.
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
# Copyright (c) 2017 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
|
# Copyright (c) 2017 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
|
||||||
|
|
@ -51,37 +53,38 @@
|
||||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(ECMFindModuleHelpersStub)
|
||||||
|
|
||||||
find_library(PhoneNumber_LIBRARIES
|
ecm_find_package_version_check(PhoneNumber)
|
||||||
NAMES phonenumber
|
|
||||||
PATH_SUFFIXES lib
|
|
||||||
HINTS ENV PHONENUMBERDIR)
|
|
||||||
|
|
||||||
find_path(PhoneNumber_INCLUDE_DIR
|
set(PhoneNumber_known_components
|
||||||
NAMES phonenumbers/phonenumberutil.h
|
PhoneNumber
|
||||||
HINTS ENV PHONENUMBERDIR)
|
GeoCoding
|
||||||
|
)
|
||||||
|
set(PhoneNumber_default_components ${PhoneNumber_known_components})
|
||||||
|
|
||||||
find_library(PhoneNumberGeoCoding_LIBRARIES
|
set(PhoneNumber_PhoneNumber_lib phonenumber)
|
||||||
NAMES geocoding
|
set(PhoneNumber_PhoneNumber_header phonenumbers/phonenumberutil.h)
|
||||||
PATH_SUFFIXES lib
|
set(PhoneNumber_GeoCoding_lib geocoding)
|
||||||
HINTS ENV PHONENUMBERDIR)
|
set(PhoneNumber_GeoCoding_header phonenumbers/geocoding/phonenumber_offline_geocoder.h)
|
||||||
|
|
||||||
mark_as_advanced(PhoneNumber_LIBRARIES PhoneNumber_INCLUDE_DIR)
|
ecm_find_package_parse_components(PhoneNumber
|
||||||
mark_as_advanced(PhoneNumberGeoCoding_LIBRARIES)
|
RESULT_VAR PhoneNumber_components
|
||||||
|
KNOWN_COMPONENTS ${PhoneNumber_known_components}
|
||||||
find_package_handle_standard_args(PhoneNumber DEFAULT_MSG PhoneNumber_LIBRARIES PhoneNumber_INCLUDE_DIR PhoneNumberGeoCoding_LIBRARIES)
|
DEFAULT_COMPONENTS ${PhoneNumber_default_components}
|
||||||
|
)
|
||||||
if(PhoneNumber_FOUND AND NOT TARGET PhoneNumber::PhoneNumber)
|
ecm_find_package_handle_library_components(PhoneNumber
|
||||||
add_library(PhoneNumber::PhoneNumber UNKNOWN IMPORTED)
|
COMPONENTS ${PhoneNumber_components}
|
||||||
set_target_properties(PhoneNumber::PhoneNumber PROPERTIES
|
)
|
||||||
IMPORTED_LOCATION "${PhoneNumber_LIBRARIES}"
|
find_package_handle_standard_args(PhoneNumber
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${PhoneNumber_INCLUDE_DIR}")
|
FOUND_VAR
|
||||||
add_library(PhoneNumber::GeoCoding UNKNOWN IMPORTED)
|
PhoneNumber_FOUND
|
||||||
set_target_properties(PhoneNumber::GeoCoding PROPERTIES
|
REQUIRED_VARS
|
||||||
IMPORTED_LOCATION "${PhoneNumberGeoCoding_LIBRARIES}"
|
PhoneNumber_LIBRARIES
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${PhoneNumber_INCLUDE_DIR}")
|
VERSION_VAR
|
||||||
endif()
|
PhoneNumber_VERSION
|
||||||
|
HANDLE_COMPONENTS
|
||||||
|
)
|
||||||
|
|
||||||
include(FeatureSummary)
|
include(FeatureSummary)
|
||||||
set_package_properties(PhoneNumber PROPERTIES
|
set_package_properties(PhoneNumber PROPERTIES
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ add_executable(plasmaphonedialer ${plasmaphonedialer_SRCS})
|
||||||
target_compile_definitions(plasmaphonedialer PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}")
|
target_compile_definitions(plasmaphonedialer PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}")
|
||||||
|
|
||||||
#find_package(ActiveApp REQUIRED)
|
#find_package(ActiveApp REQUIRED)
|
||||||
find_package(PhoneNumber REQUIRED)
|
find_package(PhoneNumber COMPONENTS PhoneNumber REQUIRED)
|
||||||
|
|
||||||
target_link_libraries(plasmaphonedialer
|
target_link_libraries(plasmaphonedialer
|
||||||
PhoneNumber::PhoneNumber
|
PhoneNumber::PhoneNumber
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue