From a2fbe3aa43f55981b951b373e2fd10dfde3b5258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Thu, 24 Jan 2019 17:28:39 +0100 Subject: [PATCH] Add tde_setup_polkit macro. This resolves issue #21. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- modules/TDEMacros.cmake | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake index 1b21c23..338625d 100644 --- a/modules/TDEMacros.cmake +++ b/modules/TDEMacros.cmake @@ -2091,6 +2091,51 @@ macro( tde_setup_dbus ) endmacro( ) +################################################# +##### +##### tde_setup_polkit + +macro( tde_setup_polkit ) + if( NOT POLKIT_GOBJECT_FOUND ) + pkg_search_module( POLKIT_GOBJECT polkit-gobject-1 ) + if( NOT POLKIT_GOBJECT_FOUND ) + tde_message_fatal( "polkit-gobject-1 is required, but not found on your system" ) + endif( ) + endif( ) + + foreach( _arg ${ARGV} ) + if( NOT "${_arg}" MATCHES "^polkit-" ) + set( _arg "polkit-${_arg}" ) + endif( ) + string( TOUPPER "${_arg}" _polkit_module ) + if( "${_polkit_module}" MATCHES "-[0-9]+$" ) + string( REGEX REPLACE "-[0-9]+$" "" _polkit_module "${_polkit_module}" ) + endif( ) + string( REPLACE "-" "_" _polkit_module "${_polkit_module}" ) + if( NOT "${_arg}" MATCHES "-[0-9]+$" ) + set( _arg "${_arg}-1" ) + endif( ) + if( NOT ${_polkit_module}_FOUND ) + pkg_search_module( ${_polkit_module} ${_arg} ) + if( NOT ${_polkit_module}_FOUND ) + tde_message_fatal( "${_arg} is required, but not found on your system" ) + endif( ) + endif( ) + endforeach( ) + + if( NOT DEFINED POLKIT_ACTIONS_DIRECTORY ) + execute_process( + COMMAND ${PKG_CONFIG_EXECUTABLE} + polkit-gobject-1 --variable=actiondir + OUTPUT_VARIABLE POLKIT_ACTIONS_DIRECTORY + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + message( STATUS "Using " ${POLKIT_ACTIONS_DIRECTORY} " for PolicyKit action files" ) + endif( ) + +endmacro( ) + + ################################################ ##### ##### Restore CMP0026 policy