Warning, /frameworks/kauth/cmake/KF6AuthMacros.cmake is written in an unsupported language. File is not indexed.
0001 # SPDX-FileCopyrightText: 2006-2009 Alexander Neundorf <neundorf@kde.org> 0002 # SPDX-FileCopyrightText: 2006, 2007 Laurent Montel <montel@kde.org> 0003 # SPDX-FileCopyrightText: 2007 Matthias Kretz <kretz@kde.org> 0004 # SPDX-License-Identifier: BSD-3-Clause 0005 0006 # This macro adds the needed files for an helper executable meant to be used by applications using KAuth. 0007 # It accepts the helper target, the helper ID (the DBUS name) and the user under which the helper will run on. 0008 # This macro takes care of generate the needed files, and install them in the right location. This boils down 0009 # to a DBus policy to let the helper register on the system bus, and a service file for letting the helper 0010 # being automatically activated by the system bus. 0011 # *WARNING* You have to install the helper in ${KAUTH_HELPER_INSTALL_DIR} to make sure everything will work. 0012 function(KAUTH_INSTALL_HELPER_FILES HELPER_TARGET HELPER_ID HELPER_USER) 0013 if(KAUTH_HELPER_BACKEND_NAME STREQUAL "DBUS") 0014 configure_file(${KAUTH_STUB_FILES_DIR}/dbus_policy.stub 0015 ${CMAKE_CURRENT_BINARY_DIR}/${HELPER_ID}.conf) 0016 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${HELPER_ID}.conf 0017 DESTINATION ${KDE_INSTALL_DBUSDIR}/system.d/) 0018 0019 configure_file(${KAUTH_STUB_FILES_DIR}/dbus_service.stub 0020 ${CMAKE_CURRENT_BINARY_DIR}/${HELPER_ID}.service) 0021 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${HELPER_ID}.service 0022 DESTINATION ${KDE_INSTALL_DBUSSYSTEMSERVICEDIR}) 0023 endif() 0024 endfunction() 0025 0026 # This macro generates an action file, depending on the backend used, for applications using KAuth. 0027 # It accepts the helper id (the DBUS name) and a file containing the actions (check kdelibs/kdecore/auth/example 0028 # for file format). The macro will take care of generating the file according to the backend specified, 0029 # and to install it in the right location. This (at the moment) means that on Linux (PolicyKit) a .policy 0030 # file will be generated and installed into the policykit action directory (usually /usr/share/PolicyKit/policy/), 0031 # and on Mac (Authorization Services) will be added to the system action registry using the native MacOS API during 0032 # the install phase 0033 function(KAUTH_INSTALL_ACTIONS HELPER_ID ACTIONS_FILE) 0034 0035 if(KAUTH_BACKEND_NAME STREQUAL "APPLE" OR KAUTH_BACKEND_NAME STREQUAL "OSX") 0036 get_target_property(kauth_policy_gen KF6::kauth-policy-gen LOCATION) 0037 install(CODE "execute_process(COMMAND ${kauth_policy_gen} ${ACTIONS_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})") 0038 message(STATUS "installation will execute ${kauth_policy_gen} ${ACTIONS_FILE} in ${CMAKE_CURRENT_SOURCE_DIR}") 0039 elseif(KAUTH_BACKEND_NAME STREQUAL "POLKITQT6-1") 0040 set(_output ${CMAKE_CURRENT_BINARY_DIR}/${HELPER_ID}.policy) 0041 get_filename_component(_input ${ACTIONS_FILE} ABSOLUTE) 0042 0043 add_custom_command(OUTPUT ${_output} 0044 COMMAND KF6::kauth-policy-gen ${_input} ${_output} 0045 MAIN_DEPENDENCY ${_input} 0046 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 0047 COMMENT "Generating ${HELPER_ID}.policy" 0048 DEPENDS KF6::kauth-policy-gen) 0049 add_custom_target(${HELPER_ID}.policy-customtarget ALL COMMENT "actions for ${HELPER_ID}" DEPENDS ${_output}) 0050 0051 if(INSTALL_BROKEN_KAUTH_POLICY_FILES) 0052 set(OVERRIDEN_KAUTH_POLICY_FILES_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/polkit-1/actions/) 0053 if(NOT OVERRIDEN_KAUTH_POLICY_FILES_INSTALL_DIR STREQUAL KAUTH_POLICY_FILES_INSTALL_DIR) 0054 MESSAGE(WARNING "INSTALL_BROKEN_KAUTH_POLICY_FILES is enabled. The following files will be installed to ${OVERRIDEN_KAUTH_POLICY_FILES_INSTALL_DIR} instead of ${KAUTH_POLICY_FILES_INSTALL_DIR}.\n${_output}") 0055 endif() 0056 install(FILES ${_output} DESTINATION ${OVERRIDEN_KAUTH_POLICY_FILES_INSTALL_DIR}) 0057 else() 0058 install(FILES ${_output} DESTINATION ${KAUTH_POLICY_FILES_INSTALL_DIR}) 0059 endif() 0060 endif() 0061 0062 endfunction()