Warning, /frameworks/kauth/src/ConfigureChecks.cmake is written in an unsupported language. File is not indexed.

0001 ####### checks for kdecore/kauth ###############
0002 
0003 set(KAUTH_BACKEND_NAME "" CACHE STRING "Specifies the KAuth backend to build. Current available options are
0004                                    PolkitQt6-1, Fake, OSX. Not setting this variable will build the most
0005                                    appropriate backend for your system")
0006 
0007 # Case-insensitive
0008 string(TOUPPER "${KAUTH_BACKEND_NAME}" KAUTH_BACKEND_NAME)
0009 
0010 set(KAUTH_BACKEND ${KAUTH_BACKEND_NAME})
0011 
0012 set(POLKITQT_MIN_VERSION 0.112.0 PARENT_SCOPE)
0013 
0014 ## Check if the user did not specify a backend to be built. If that is the case,
0015 ## we check what is the best backend to build on this system.
0016 if(NOT KAUTH_BACKEND)
0017     # Look for the most appropriate backend
0018     message(STATUS "No backend for KAuth was explicitly specified: probing system to find the best one available")
0019     if(APPLE)
0020         set(KAUTH_BACKEND "OSX")
0021     elseif(UNIX)
0022         find_package(PolkitQt6-1 ${POLKITQT_MIN_VERSION})
0023 
0024         if(PolkitQt6-1_FOUND)
0025             set(KAUTH_BACKEND "POLKITQT6-1")
0026 
0027             set_package_properties(PolkitQt6-1 PROPERTIES
0028               URL "http://techbase.kde.org/Polkit-Qt-1"
0029               DESCRIPTION "PolicyKit API for Qt"
0030               TYPE RECOMMENDED
0031               PURPOSE "Support for executing privileged actions in a controlled way (KAuth)"
0032             )
0033 
0034             find_package(KF6WindowSystem ${KF_DEP_VERSION} REQUIRED)
0035         else()
0036             set(KAUTH_BACKEND "FAKE")
0037         endif()
0038     else()
0039         set(KAUTH_BACKEND "FAKE")
0040     endif()
0041 
0042 elseif(KAUTH_BACKEND AND NOT KAUTH_BUILD_CODEGENERATOR_ONLY)
0043     # Check if the specified backend is valid. If it is not, we fall back to the FAKE one
0044     if(NOT KAUTH_BACKEND STREQUAL "OSX"
0045         AND NOT KAUTH_BACKEND STREQUAL "POLKITQT6-1"
0046         AND NOT KAUTH_BACKEND STREQUAL "FAKE")
0047         message("WARNING: The KAuth Backend ${KAUTH_BACKEND} you specified does not exist. Falling back to Fake backend")
0048         set(KAUTH_BACKEND "FAKE")
0049     endif()
0050 
0051     # Check requirements for each backend. If not, fall back to the fake one
0052     if(KAUTH_BACKEND STREQUAL "OSX" AND NOT APPLE)
0053         message("WARNING: You chose the OSX KAuth backend but your system does not support it. Falling back to Fake backend")
0054         set(KAUTH_BACKEND "FAKE")
0055     endif()
0056 
0057     if(KAUTH_BACKEND STREQUAL "POLKITQT6-1")
0058         find_package(PolkitQt6-1 ${POLKITQT_MIN_VERSION})
0059         set_package_properties(PolkitQt6-1 PROPERTIES
0060           URL "http://techbase.kde.org/Polkit-Qt-1"
0061           DESCRIPTION "PolicyKit API for Qt"
0062           TYPE RECOMMENDED
0063           PURPOSE "Support for executing privileged actions in a controlled way (KAuth). This is required to make KAuth work, and hence enable certain workspace functionalities"
0064         )
0065 
0066         if(NOT PolkitQt6-1_FOUND)
0067             message("WARNING: You chose the PolkitQt6-1 KAuth backend but you don't have PolkitQt6-1 installed.
0068                       Falling back to Fake backend")
0069             set(KAUTH_BACKEND "FAKE")
0070         else()
0071             find_package(KF6WindowSystem ${KF_DEP_VERSION} REQUIRED)
0072         endif()
0073     endif()
0074 endif()
0075 
0076 set(KAUTH_BACKEND_NAME ${KAUTH_BACKEND} CACHE STRING "Specifies the KAuth backend to build. Current available options are
0077                                    PolkitQt6-1, Fake, OSX. Not setting this variable will build the most
0078                                    appropriate backend for your system" FORCE)
0079 
0080 # Add the correct libraries depending on the backend, and eventually set the policy files install location
0081 if(KAUTH_BACKEND_NAME STREQUAL "OSX")
0082     find_library(CORE_FOUNDATION_LIBRARY CoreFoundation)
0083     find_library(SECURITY_LIBRARY Security)
0084 
0085     message(STATUS "Building OSX KAuth backend")
0086 
0087     set(KAUTH_BACKEND_SRCS
0088         backends/mac/AuthServicesBackend.cpp
0089     )
0090 
0091     set(KAUTH_BACKEND_LIBS ${SECURITY_LIBRARY} Qt6::Core KF6::AuthCore)
0092 elseif(KAUTH_BACKEND_NAME STREQUAL "POLKITQT6-1")
0093     message(STATUS "Building PolkitQt6-1 KAuth backend")
0094 
0095     include_directories(SYSTEM ${POLKITQT-1_INCLUDE_DIR})
0096 
0097     set(KAUTH_BACKEND_SRCS
0098         backends/polkit-1/Polkit1Backend.cpp
0099     )
0100 
0101     set(KAUTH_BACKEND_LIBS ${POLKITQT-1_CORE_LIBRARY} Qt6::DBus Qt6::Gui KF6::AuthCore KF6::WindowSystem)
0102 
0103     # POLKITQT-1_POLICY_FILES_INSTALL_DIR has an absolute pathname, fix that.
0104     if(PolkitQt6-1_FOUND)
0105         string(REPLACE ${POLKITQT-1_INSTALL_DIR}
0106             ${CMAKE_INSTALL_PREFIX} _KAUTH_POLICY_FILES_INSTALL_DIR
0107             ${POLKITQT-1_POLICY_FILES_INSTALL_DIR})
0108     endif()
0109 
0110     set(KAUTH_POLICY_FILES_INSTALL_DIR ${_KAUTH_POLICY_FILES_INSTALL_DIR} CACHE STRING
0111         "Where policy files generated by KAuth will be installed" FORCE)
0112 elseif(KAUTH_BACKEND_NAME STREQUAL "FAKE")
0113     set(KAUTH_COMPILING_FAKE_BACKEND TRUE)
0114 
0115     message(STATUS "Building Fake KAuth backend")
0116     message("WARNING: No valid KAuth backends will be built. The library will not work properly unless compiled with
0117              a working backend")
0118 endif()
0119 
0120 # KAuth policy generator executable source probing
0121 set(KAUTH_POLICY_GEN_SRCS
0122     policy-gen/policy-gen.cpp)
0123 set(KAUTH_POLICY_GEN_LIBRARIES)
0124 
0125 if(KAUTH_BACKEND_NAME STREQUAL "OSX")
0126    set(KAUTH_POLICY_GEN_SRCS ${KAUTH_POLICY_GEN_SRCS}
0127        backends/mac/kauth-policy-gen-mac.cpp)
0128    set(KAUTH_POLICY_GEN_LIBRARIES ${KAUTH_POLICY_GEN_LIBRARIES} ${CORE_FOUNDATION_LIBRARY} ${SECURITY_LIBRARY} Qt6::Core)
0129 elseif(KAUTH_BACKEND_NAME STREQUAL "POLKITQT6-1")
0130   set(KAUTH_POLICY_GEN_SRCS ${KAUTH_POLICY_GEN_SRCS}
0131       backends/polkit-1/kauth-policy-gen-polkit1.cpp)
0132   set(KAUTH_POLICY_GEN_LIBRARIES ${KAUTH_POLICY_GEN_LIBRARIES}
0133       Qt6::Core)
0134 endif()
0135 
0136 ########################
0137 # Helper backend probing
0138 
0139 set(KAUTH_HELPER_BACKEND_NAME "" CACHE STRING "Specifies the KAuth helper backend to build. Current available options are
0140                                    DBus, Fake. Not setting this variable will build the most appropriate backend for your system")
0141 
0142 set(KAUTH_HELPER_BACKEND ${KAUTH_HELPER_BACKEND_NAME})
0143 
0144 if(NOT KAUTH_HELPER_BACKEND)
0145     # No checks needed, just set the dbus backend
0146     set(KAUTH_HELPER_BACKEND "DBus")
0147     string(TOUPPER ${KAUTH_HELPER_BACKEND} KAUTH_HELPER_BACKEND_UPPER)
0148     set(KAUTH_HELPER_BACKEND ${KAUTH_HELPER_BACKEND_UPPER})
0149 else()
0150     # No checks needed here either
0151     string(TOUPPER ${KAUTH_HELPER_BACKEND} KAUTH_HELPER_BACKEND_UPPER)
0152     set(KAUTH_HELPER_BACKEND ${KAUTH_HELPER_BACKEND_UPPER})
0153 endif()
0154 
0155 set(KAUTH_HELPER_BACKEND_NAME ${KAUTH_HELPER_BACKEND} CACHE STRING "Specifies the KAuth helper backend to build. Current
0156                                                             available options are DBus, Fake. Not setting this variable will
0157                                                             build the most appropriate backend for your system" FORCE)
0158 
0159 # Add the correct libraries/files depending on the backend
0160 if(KAUTH_HELPER_BACKEND_NAME STREQUAL "DBUS")
0161     qt_add_dbus_adaptor(kauth_dbus_adaptor_SRCS
0162                         backends/dbus/org.kde.kf6auth.xml
0163                         backends/dbus/DBusHelperProxy.h
0164                         KAuth::DBusHelperProxy)
0165 
0166     set(KAUTH_HELPER_BACKEND_SRCS
0167         backends/dbus/DBusHelperProxy.cpp
0168         ${kauth_dbus_adaptor_SRCS}
0169     )
0170 
0171     set(KAUTH_HELPER_BACKEND_LIBS Qt6::DBus KF6::AuthCore)
0172 
0173     # Install some files as well
0174     install(FILES backends/dbus/org.kde.kf6auth.conf
0175              DESTINATION ${KDE_INSTALL_DBUSDIR}/system.d)
0176 
0177     install(FILES backends/dbus/dbus_policy.stub
0178                    backends/dbus/dbus_service.stub
0179              DESTINATION ${KDE_INSTALL_DATADIR_KF}/kauth COMPONENT Devel)
0180 elseif(KAUTH_HELPER_BACKEND_NAME STREQUAL "FAKE")
0181     message("WARNING: No valid KAuth helper backends will be built. The library will not work properly unless compiled with
0182              a working backend")
0183 endif()
0184 
0185 # Set directories for plugins
0186 if(NOT WIN32)
0187 
0188   # ###
0189   # WARNING Copied from KDE4Internal. Decide whether this should be fixed in
0190   # CMake or in ECM:
0191   # ###
0192 
0193   # This macro implements some very special logic how to deal with the cache.
0194   # By default the various install locations inherit their value from their "parent" variable
0195   # so if you set CMAKE_INSTALL_PREFIX, then EXEC_INSTALL_PREFIX, PLUGIN_INSTALL_DIR will
0196   # calculate their value by appending subdirs to CMAKE_INSTALL_PREFIX .
0197   # This would work completely without using the cache.
0198   # But if somebody wants e.g. a different EXEC_INSTALL_PREFIX this value has to go into
0199   # the cache, otherwise it will be forgotten on the next cmake run.
0200   # Once a variable is in the cache, it doesn't depend on its "parent" variables
0201   # anymore and you can only change it by editing it directly.
0202   # this macro helps in this regard, because as long as you don't set one of the
0203   # variables explicitly to some location, it will always calculate its value from its
0204   # parents. So modifying CMAKE_INSTALL_PREFIX later on will have the desired effect.
0205   # But once you decide to set e.g. EXEC_INSTALL_PREFIX to some special location
0206   # this will go into the cache and it will no longer depend on CMAKE_INSTALL_PREFIX.
0207   #
0208   # additionally if installing to the same location as kdelibs, the other install
0209   # directories are reused from the installed kdelibs
0210   macro(_SET_FANCY _var _value _comment)
0211     set(predefinedvalue "${_value}")
0212     if(NOT DEFINED ${_var})
0213         set(${_var} ${predefinedvalue})
0214     else()
0215         set(${_var} "${${_var}}" CACHE PATH "${_comment}")
0216     endif()
0217   endmacro()
0218   _set_fancy(KAUTH_HELPER_PLUGIN_DIR "kf6/kauth/helper" "Where KAuth's helper plugin will be installed")
0219   _set_fancy(KAUTH_BACKEND_PLUGIN_DIR "kf6/kauth/backend" "Where KAuth's backend plugin will be installed")
0220   #set(KAUTH_OTHER_PLUGIN_DIR "${QT_PLUGINS_DIR}/kauth/plugins")
0221 else()
0222     set(KAUTH_HELPER_PLUGIN_DIR "kf6/kauth/helper")
0223     set(KAUTH_BACKEND_PLUGIN_DIR "kf6/kauth/backend")
0224 endif()
0225 
0226 ## End