File: FindPolkitQt.cmake

package info (click to toggle)
kauth 5.78.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,024 kB
  • sloc: cpp: 2,967; python: 24; xml: 22; sh: 14; makefile: 7
file content (92 lines) | stat: -rw-r--r-- 3,689 bytes parent folder | download
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# - Try to find Polkit-qt
# Once done this will define
#
#  POLKITQT_FOUND - system has Polkit-qt
#  POLKITQT_INCLUDE_DIR - the Polkit-qt include directory
#  POLKITQT_LIBRARIES - Link these to use all Polkit-qt libs
#  POLKITQT_CORE_LIBRARY - Link this to use the polkit-qt-core library only
#  POLKITQT_GUI_LIBRARY - Link this to use GUI elements in polkit-qt (polkit-qt-gui)
#  POLKITQT_DEFINITIONS - Compiler switches required for using Polkit-qt
#  POLKITQT_POLICY_FILES_INSTALL_DIR - The directory where policy files should be installed to.
#
# The minimum required version of PolkitQt can be specified using the
# standard syntax, e.g. find_package(PolkitQt 1.0)
# For compatibility, this can also be done by setting the POLKITQT_MIN_VERSION variable.

# SPDX-FileCopyrightText: 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
# SPDX-FileCopyrightText: 2009 Dario Freddi <drf@kde.org>
# SPDX-FileCopyrightText: 2009 Michal Malek <michalm@jabster.pl>
# SPDX-FileCopyrightText: 2009 Alexander Neundorf <neundorf@kde.org>
# SPDX-License-Identifier: BSD-3-Clause

# Support POLKITQT_MIN_VERSION for compatibility:
if(NOT PolkitQt_FIND_VERSION)
  set(PolkitQt_FIND_VERSION "${POLKITQT_MIN_VERSION}")
endif()

# the minimum version of PolkitQt we require
if(NOT PolkitQt_FIND_VERSION)
  set(PolkitQt_FIND_VERSION "0.9.3")
endif()

if(NOT WIN32)
   # use pkg-config to get the directories and then use these values
   # in the FIND_PATH() and FIND_LIBRARY() calls
   find_package(PkgConfig)
   pkg_check_modules(PC_POLKITQT QUIET polkit-qt)
   set(POLKITQT_DEFINITIONS ${PC_POLKITQT_CFLAGS_OTHER})
endif()

find_path(POLKITQT_INCLUDE_DIR
     NAMES polkit-qt/auth.h
     PATH_SUFFIXES PolicyKit
)

find_file(POLKITQT_VERSION_FILE
     polkit-qt/polkitqtversion.h
     HINTS ${POLKITQT_INCLUDE_DIR}
)

if(POLKITQT_VERSION_FILE  AND NOT  POLKITQT_VERSION)
  file(READ ${POLKITQT_VERSION_FILE} POLKITQT_VERSION_CONTENT)
  string(REGEX MATCH "POLKITQT_VERSION_STRING \".*\"\n" POLKITQT_VERSION_MATCH "${POLKITQT_VERSION_CONTENT}")

  if(POLKITQT_VERSION_MATCH)
    string(REGEX REPLACE "POLKITQT_VERSION_STRING \"(.*)\"\n" "\\1" _POLKITQT_VERSION ${POLKITQT_VERSION_MATCH})
  endif()
  set(POLKITQT_VERSION "${_POLKITQT_VERSION}" CACHE STRING "Version number of PolkitQt" FORCE)
endif()

find_library(POLKITQT_CORE_LIBRARY
    NAMES polkit-qt-core
    HINTS ${PC_POLKITQT_LIBDIR}
)
find_library(POLKITQT_GUI_LIBRARY
    NAMES polkit-qt-gui
    HINTS ${PC_POLKITQT_LIBDIR}
)

set(POLKITQT_LIBRARIES ${POLKITQT_GUI_LIBRARY} ${POLKITQT_CORE_LIBRARY})

include(FindPackageHandleStandardArgs)
# Use the extended (new) syntax for FPHSA():
find_package_handle_standard_args(PolkitQt  REQUIRED_VARS POLKITQT_GUI_LIBRARY POLKITQT_CORE_LIBRARY POLKITQT_INCLUDE_DIR
                                            VERSION_VAR  POLKITQT_VERSION)

mark_as_advanced(POLKITQT_INCLUDE_DIR
                 POLKITQT_CORE_LIBRARY
                 POLKITQT_GUI_LIBRARY
                 POLKITQT_VERSION_FILE
                )

set(POLKITQT_POLICY_FILES_INSTALL_DIR share/PolicyKit/policy/)

if(POLKITQT_FOUND)
    get_filename_component(_POLKITQT_INSTALL_PREFIX "${POLKITQT_CORE_LIBRARY}"  PATH)
    get_filename_component(_POLKITQT_INSTALL_PREFIX "${_POLKITQT_INSTALL_PREFIX}"  PATH)
    if(NOT _POLKITQT_INSTALL_PREFIX STREQUAL CMAKE_INSTALL_PREFIX)
        message("WARNING: Installation prefix does not match PolicyKit install prefixes. You probably will need to move files installed "
                "in ${CMAKE_INSTALL_PREFIX}/${POLKITQT_POLICY_FILES_INSTALL_DIR} and by dbus_add_activation_system_service to the ${_POLKITQT_INSTALL_PREFIX}/${POLKITQT_POLICY_FILES_INSTALL_DIR} prefix")
    endif()
endif()