summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2019-01-24 17:28:39 +0100
committerSlávek Banko <slavek.banko@axis.cz>2019-01-28 16:33:12 +0100
commita2fbe3aa43f55981b951b373e2fd10dfde3b5258 (patch)
treef80baecd26bdfd68cd9ec4f52c94763a5dae7070 /modules
parentac342e63c62b70f37027a3636fe0ed1a538c7ef5 (diff)
downloadtde-cmake-a2fbe3aa43f55981b951b373e2fd10dfde3b5258.tar.gz
tde-cmake-a2fbe3aa43f55981b951b373e2fd10dfde3b5258.zip
Add tde_setup_polkit macro.
This resolves issue #21. Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'modules')
-rw-r--r--modules/TDEMacros.cmake45
1 files changed, 45 insertions, 0 deletions
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