File: FindIMobileDevice.cmake

package info (click to toggle)
solid 5.78.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 5,100 kB
  • sloc: cpp: 21,549; xml: 464; lex: 111; yacc: 83; sh: 14; makefile: 5
file content (72 lines) | stat: -rw-r--r-- 2,569 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#.rst:
# FindIMobileDevice
# --------
#
# Try to find the imobiledevice library, once done this will define:
#
#  ``IMobileDevice_FOUND``
#      System has libimobiledevice.
#
#  ``IMobileDevice_INCLUDE_DIRS``
#      The libimobiledevice include directory.
#
# ``IMobileDevice_LIBRARIES``
#     The libimobiledevice libraries.
#
# ``IMobileDevice_VERSION``
#     The libimobiledevice version.
#
# If ``IMobileDevice_FOUND`` is TRUE, the following imported target
# will be available:
#
# ``IMobileDevice::IMobileDevice``
#     The libimobiledevice library

#=============================================================================
# SPDX-FileCopyrightText: 2020 MBition GmbH
# SPDX-FileContributor: Kai Uwe Broulik <kai_uwe.broulik@mbition.io>
#
# SPDX-License-Identifier: BSD-3-Clause
#=============================================================================

find_package(PkgConfig QUIET)
pkg_check_modules(PC_libimobiledevice QUIET libimobiledevice-1.0)

find_path(IMobileDevice_INCLUDE_DIRS NAMES libimobiledevice/libimobiledevice.h HINTS ${PC_libimobiledevice_INCLUDE_DIRS})
find_library(IMobileDevice_LIBRARIES NAMES imobiledevice-1.0 imobiledevice HINTS ${PC_libimobiledevice_LIBRARY_DIRS})

set(IMobileDevice_VERSION ${PC_libimobiledevice_VERSION})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(IMobileDevice
    FOUND_VAR IMobileDevice_FOUND
    REQUIRED_VARS IMobileDevice_INCLUDE_DIRS IMobileDevice_LIBRARIES
    VERSION_VAR IMobileDevice_VERSION
)

mark_as_advanced(IMobileDevice_INCLUDE_DIRS IMobileDevice_LIBRARIES)

if(IMobileDevice_FOUND AND NOT TARGET IMobileDevice::IMobileDevice)
    # Handle API variations, follow QT_VERSION_CHECK conventions
    set(_imobile_version "0x00000")
    if (IMobileDevice_VERSION VERSION_GREATER_EQUAL 1.3.0)
        set(_imobile_version "0x10300")
    elseif(IMobileDevice_VERSION VERSION_GREATER_EQUAL 1.2.0)
        set(_imobile_version "0x10200")
    endif()

    # Imported target
    add_library(IMobileDevice::IMobileDevice UNKNOWN IMPORTED)
    set_target_properties(IMobileDevice::IMobileDevice PROPERTIES
        IMPORTED_LOCATION "${IMobileDevice_LIBRARIES}"
        INTERFACE_INCLUDE_DIRECTORIES "${IMobileDevice_INCLUDE_DIRS}"
        INTERFACE_COMPILE_OPTIONS "${PC_libimobiledevice_CFLAGS_OTHER}"
        INTERFACE_COMPILE_DEFINITIONS "IMOBILEDEVICE_API=${_imobile_version}"
    )
endif()

include(FeatureSummary)
set_package_properties(IMobileDevice PROPERTIES
    DESCRIPTION "library to communicate with iOS devices"
    URL "https://www.libimobiledevice.org/"
)