1####### checks for kdecore/kauth ############### 2 3set(KAUTH_BACKEND_NAME "" CACHE STRING "Specifies the KAuth backend to build. Current available options are 4 PolkitQt5-1, Fake, OSX. Not setting this variable will build the most 5 appropriate backend for your system") 6 7# Case-insensitive 8string(TOUPPER "${KAUTH_BACKEND_NAME}" KAUTH_BACKEND_NAME) 9 10set(KAUTH_BACKEND ${KAUTH_BACKEND_NAME}) 11 12## Check if the user did not specify a backend to be built. If that is the case, 13## we check what is the best backend to build on this system. 14if(NOT KAUTH_BACKEND) 15 # Look for the most appropriate backend 16 message(STATUS "No backend for KAuth was explicitly specified: probing system to find the best one available") 17 if(APPLE) 18 set(KAUTH_BACKEND "OSX") 19 elseif(UNIX) 20 find_package(PolkitQt5-1 0.99.0) 21 22 if(PolkitQt5-1_FOUND) 23 set(KAUTH_BACKEND "POLKITQT5-1") 24 25 set_package_properties(PolkitQt5-1 PROPERTIES 26 URL "http://techbase.kde.org/Polkit-Qt-1" 27 DESCRIPTION "PolicyKit API for Qt" 28 TYPE RECOMMENDED 29 PURPOSE "Support for executing privileged actions in a controlled way (KAuth)" 30 ) 31 else() 32 set(KAUTH_BACKEND "FAKE") 33 endif() 34 else() 35 set(KAUTH_BACKEND "FAKE") 36 endif() 37 38elseif(KAUTH_BACKEND AND NOT KAUTH_BUILD_CODEGENERATOR_ONLY) 39 # Check if the specified backend is valid. If it is not, we fall back to the FAKE one 40 if(NOT KAUTH_BACKEND STREQUAL "OSX" AND NOT KAUTH_BACKEND STREQUAL "POLKITQT" AND NOT KAUTH_BACKEND STREQUAL "POLKITQT5-1" AND NOT KAUTH_BACKEND STREQUAL "FAKE") 41 message("WARNING: The KAuth Backend ${KAUTH_BACKEND} you specified does not exist. Falling back to Fake backend") 42 set(KAUTH_BACKEND "FAKE") 43 endif() 44 45 # Check requirements for each backend. If not, fall back to the fake one 46 if(KAUTH_BACKEND STREQUAL "OSX" AND NOT APPLE) 47 message("WARNING: You chose the OSX KAuth backend but your system does not support it. Falling back to Fake backend") 48 set(KAUTH_BACKEND "FAKE") 49 endif() 50 if(KAUTH_BACKEND STREQUAL "POLKITQT") 51 find_package(PolkitQt) 52 53 set_package_properties(PolkitQt PROPERTIES 54 URL "http://api.kde.org/polkit-qt" 55 DESCRIPTION "PolicyKit API for Qt" 56 TYPE RECOMMENDED 57 PURPOSE "Support for executing privileged actions in a controlled way (KAuth). Either this or PolkitQt5-1 is required to make KAuth work, and hence enable certain workspace functionalities" 58 ) 59 if(NOT POLKITQT_FOUND) 60 message("WARNING: You chose the PolkitQt KAuth backend but you don't have PolkitQt installed. 61 Falling back to Fake backend") 62 set(KAUTH_BACKEND "FAKE") 63 endif() 64 endif() 65 if(KAUTH_BACKEND STREQUAL "POLKITQT5-1") 66 find_package(PolkitQt5-1 0.99.0) 67 set_package_properties(PolkitQt5-1 PROPERTIES 68 URL "http://techbase.kde.org/Polkit-Qt-1" 69 DESCRIPTION "PolicyKit API for Qt" 70 TYPE RECOMMENDED 71 PURPOSE "Support for executing privileged actions in a controlled way (KAuth). Either this or PolkitQt is required to make KAuth work, and hence enable certain workspace functionalities" 72 ) 73 if(NOT PolkitQt5-1_FOUND) 74 message("WARNING: You chose the PolkitQt5-1 KAuth backend but you don't have PolkitQt5-1 installed. 75 Falling back to Fake backend") 76 set(KAUTH_BACKEND "FAKE") 77 endif() 78 endif() 79endif() 80 81set(KAUTH_BACKEND_NAME ${KAUTH_BACKEND} CACHE STRING "Specifies the KAuth backend to build. Current available options are 82 PolkitQt, PolkitQt5-1, Fake, OSX. Not setting this variable will build the most 83 appropriate backend for your system" FORCE) 84 85# Add the correct libraries depending on the backend, and eventually set the policy files install location 86if(KAUTH_BACKEND_NAME STREQUAL "OSX") 87 find_library(CORE_FOUNDATION_LIBRARY CoreFoundation) 88 find_library(SECURITY_LIBRARY Security) 89 90 message(STATUS "Building OSX KAuth backend") 91 92 set(KAUTH_BACKEND_SRCS 93 backends/mac/AuthServicesBackend.cpp 94 ) 95 96 set(KAUTH_BACKEND_LIBS ${SECURITY_LIBRARY} Qt5::Core) 97elseif(KAUTH_BACKEND_NAME STREQUAL "POLKITQT5-1") 98 message(STATUS "Building PolkitQt5-1 KAuth backend") 99 100 include_directories(SYSTEM ${POLKITQT-1_INCLUDE_DIR}) 101 102 set(KAUTH_BACKEND_SRCS 103 backends/polkit-1/Polkit1Backend.cpp 104 ) 105 106 set(KAUTH_BACKEND_LIBS ${POLKITQT-1_CORE_LIBRARY} Qt5::DBus Qt5::Widgets) 107 108 # POLKITQT-1_POLICY_FILES_INSTALL_DIR has an absolute pathname, fix that. 109 if(PolkitQt5-1_FOUND) 110 string(REPLACE ${POLKITQT-1_INSTALL_DIR} 111 ${CMAKE_INSTALL_PREFIX} _KAUTH_POLICY_FILES_INSTALL_DIR 112 ${POLKITQT-1_POLICY_FILES_INSTALL_DIR}) 113 endif() 114 115 set(KAUTH_POLICY_FILES_INSTALL_DIR ${_KAUTH_POLICY_FILES_INSTALL_DIR} CACHE STRING 116 "Where policy files generated by KAuth will be installed" FORCE) 117elseif(KAUTH_BACKEND_NAME STREQUAL "FAKE") 118 set(KAUTH_COMPILING_FAKE_BACKEND TRUE) 119 120 message(STATUS "Building Fake KAuth backend") 121 message("WARNING: No valid KAuth backends will be built. The library will not work properly unless compiled with 122 a working backend") 123endif() 124 125# KAuth policy generator executable source probing 126set(KAUTH_POLICY_GEN_SRCS 127 policy-gen/policy-gen.cpp) 128set(KAUTH_POLICY_GEN_LIBRARIES) 129 130if(KAUTH_BACKEND_NAME STREQUAL "OSX") 131 set(KAUTH_POLICY_GEN_SRCS ${KAUTH_POLICY_GEN_SRCS} 132 backends/mac/kauth-policy-gen-mac.cpp) 133 set(KAUTH_POLICY_GEN_LIBRARIES ${KAUTH_POLICY_GEN_LIBRARIES} ${CORE_FOUNDATION_LIBRARY} ${SECURITY_LIBRARY} Qt5::Core) 134elseif(KAUTH_BACKEND_NAME STREQUAL "POLKITQT5-1") 135 set(KAUTH_POLICY_GEN_SRCS ${KAUTH_POLICY_GEN_SRCS} 136 backends/polkit-1/kauth-policy-gen-polkit1.cpp) 137 set(KAUTH_POLICY_GEN_LIBRARIES ${KAUTH_POLICY_GEN_LIBRARIES} 138 Qt5::Core) 139endif() 140 141######################## 142# Helper backend probing 143 144set(KAUTH_HELPER_BACKEND_NAME "" CACHE STRING "Specifies the KAuth helper backend to build. Current available options are 145 DBus, Fake. Not setting this variable will build the most appropriate backend for your system") 146 147set(KAUTH_HELPER_BACKEND ${KAUTH_HELPER_BACKEND_NAME}) 148 149if(NOT KAUTH_HELPER_BACKEND) 150 # No checks needed, just set the dbus backend 151 set(KAUTH_HELPER_BACKEND "DBus") 152 string(TOUPPER ${KAUTH_HELPER_BACKEND} KAUTH_HELPER_BACKEND_UPPER) 153 set(KAUTH_HELPER_BACKEND ${KAUTH_HELPER_BACKEND_UPPER}) 154else() 155 # No checks needed here either 156 string(TOUPPER ${KAUTH_HELPER_BACKEND} KAUTH_HELPER_BACKEND_UPPER) 157 set(KAUTH_HELPER_BACKEND ${KAUTH_HELPER_BACKEND_UPPER}) 158endif() 159 160set(KAUTH_HELPER_BACKEND_NAME ${KAUTH_HELPER_BACKEND} CACHE STRING "Specifies the KAuth helper backend to build. Current 161 available options are DBus, Fake. Not setting this variable will 162 build the most appropriate backend for your system" FORCE) 163 164# Add the correct libraries/files depending on the backend 165if(KAUTH_HELPER_BACKEND_NAME STREQUAL "DBUS") 166 qt5_add_dbus_adaptor(kauth_dbus_adaptor_SRCS 167 backends/dbus/org.kde.kf5auth.xml 168 backends/dbus/DBusHelperProxy.h 169 KAuth::DBusHelperProxy) 170 171 set(KAUTH_HELPER_BACKEND_SRCS 172 backends/dbus/DBusHelperProxy.cpp 173 ${kauth_dbus_adaptor_SRCS} 174 ) 175 176 set(KAUTH_HELPER_BACKEND_LIBS Qt5::DBus KF5::Auth) 177 178 # Install some files as well 179 install(FILES backends/dbus/org.kde.kf5auth.conf 180 DESTINATION ${KDE_INSTALL_DBUSDIR}/system.d) 181 182 install(FILES backends/dbus/dbus_policy.stub 183 backends/dbus/dbus_service.stub 184 DESTINATION ${KF5_DATA_INSTALL_DIR}/kauth COMPONENT Devel) 185elseif(KAUTH_HELPER_BACKEND_NAME STREQUAL "FAKE") 186 message("WARNING: No valid KAuth helper backends will be built. The library will not work properly unless compiled with 187 a working backend") 188endif() 189 190 191# Set directories for plugins 192if(NOT WIN32) 193 194 # ### 195 # WARNING Copied from KDE4Internal. Decide whether this should be fixed in 196 # CMake or in ECM: 197 # ### 198 199 # This macro implements some very special logic how to deal with the cache. 200 # By default the various install locations inherit their value from their "parent" variable 201 # so if you set CMAKE_INSTALL_PREFIX, then EXEC_INSTALL_PREFIX, PLUGIN_INSTALL_DIR will 202 # calculate their value by appending subdirs to CMAKE_INSTALL_PREFIX . 203 # This would work completely without using the cache. 204 # But if somebody wants e.g. a different EXEC_INSTALL_PREFIX this value has to go into 205 # the cache, otherwise it will be forgotten on the next cmake run. 206 # Once a variable is in the cache, it doesn't depend on its "parent" variables 207 # anymore and you can only change it by editing it directly. 208 # this macro helps in this regard, because as long as you don't set one of the 209 # variables explicitly to some location, it will always calculate its value from its 210 # parents. So modifying CMAKE_INSTALL_PREFIX later on will have the desired effect. 211 # But once you decide to set e.g. EXEC_INSTALL_PREFIX to some special location 212 # this will go into the cache and it will no longer depend on CMAKE_INSTALL_PREFIX. 213 # 214 # additionally if installing to the same location as kdelibs, the other install 215 # directories are reused from the installed kdelibs 216 macro(_SET_FANCY _var _value _comment) 217 set(predefinedvalue "${_value}") 218 if(NOT DEFINED ${_var}) 219 set(${_var} ${predefinedvalue}) 220 else() 221 set(${_var} "${${_var}}" CACHE PATH "${_comment}") 222 endif() 223 endmacro() 224 225 _set_fancy(KAUTH_HELPER_PLUGIN_DIR "kauth/helper" "Where KAuth's helper plugin will be installed") 226 _set_fancy(KAUTH_BACKEND_PLUGIN_DIR "kauth/backend" "Where KAuth's backend plugin will be installed") 227 #set(KAUTH_OTHER_PLUGIN_DIR "${QT_PLUGINS_DIR}/kauth/plugins") 228else() 229 set(KAUTH_HELPER_PLUGIN_DIR "kauth/helper") 230 set(KAUTH_BACKEND_PLUGIN_DIR "kauth/backend") 231endif() 232 233## End 234