KDE/kdelibs/kdecore

Dario Freddi drf at kde.org
Tue Feb 16 15:43:51 CET 2010


SVN commit 1091017 by dafre:

CCMAIL: kde-buildsystem at kde.org

Make KAuth's fake plugins static to avoid assertion and consequent crashes if an installation/build problem was found.
Also, set the plugin directories with _set_fancy() to follow CMAKE_INSTALL_PREFIX



 M  +11 -5     CMakeLists.txt  
 M  +1 -0      auth/BackendsConfig.h.cmake  
 M  +23 -2     auth/BackendsManager.cpp  
 M  +51 -31    auth/ConfigureChecks.cmake  
 M  +0 -6      auth/backends/fake/FakeBackend.cpp  
 A             auth/backends/fakehelper (directory)  
 A             auth/backends/fakehelper/FakeHelperProxy.cpp   [License: LGPL (v2.1+)]
 A             auth/backends/fakehelper/FakeHelperProxy.h   [License: LGPL (v2.1+)]


--- trunk/KDE/kdelibs/kdecore/CMakeLists.txt #1091016:1091017
@@ -186,6 +186,8 @@
    auth/BackendsManager.cpp
    auth/HelperProxy.cpp
    auth/kauthhelpersupport.cpp
+   auth/backends/fake/FakeBackend.cpp
+   auth/backends/fakehelper/FakeHelperProxy.cpp
    services/kfoldermimetype.cpp
    services/kmimetypefactory.cpp
    services/kmimemagicrule.cpp
@@ -331,14 +333,18 @@
 
 # KAuth policy generator executable
 
-# KAUTH_POLICY_GEN_SRCS has been generated from auth/ConfigureChecks.cmake
-kde4_add_executable(kauth-policy-gen NOGUI ${KAUTH_POLICY_GEN_SRCS})
+# Compile only if fake backend has not been selected
 
-# KAUTH_POLICY_GEN_LIBRARIES has been generated from auth/ConfigureChecks.cmake
-target_link_libraries( kauth-policy-gen ${KAUTH_POLICY_GEN_LIBRARIES} )
+if (NOT KDE4_AUTH_BACKEND_NAME STREQUAL "FAKE")
+    # KAUTH_POLICY_GEN_SRCS has been generated from auth/ConfigureChecks.cmake
+    kde4_add_executable(kauth-policy-gen NOGUI ${KAUTH_POLICY_GEN_SRCS})
 
-install( TARGETS kauth-policy-gen EXPORT kdelibsToolsTargets DESTINATION ${LIBEXEC_INSTALL_DIR})
+    # KAUTH_POLICY_GEN_LIBRARIES has been generated from auth/ConfigureChecks.cmake
+    target_link_libraries( kauth-policy-gen ${KAUTH_POLICY_GEN_LIBRARIES} )
 
+    install( TARGETS kauth-policy-gen EXPORT kdelibsToolsTargets DESTINATION ${LIBEXEC_INSTALL_DIR})
+endif (NOT KDE4_AUTH_BACKEND_NAME STREQUAL "FAKE")
+
 ########### next target ###############
 
 # KAuth backend plugin
--- trunk/KDE/kdelibs/kdecore/auth/BackendsConfig.h.cmake #1091016:1091017
@@ -3,6 +3,7 @@
 #cmakedefine KAUTH_COMPILING_POLKITQT1_BACKEND 1
 #cmakedefine KAUTH_COMPILING_FAKE_BACKEND 1
 #cmakedefine KAUTH_COMPILING_DBUS_HELPER_BACKEND 1
+#cmakedefine KAUTH_COMPILING_FAKE_HELPER_BACKEND 1
 #define KAUTH_BACKEND_PLUGIN_DIR "${KAUTH_BACKEND_PLUGIN_DIR}"
 #define KAUTH_HELPER_PLUGIN_DIR "${KAUTH_HELPER_PLUGIN_DIR}"
 #define KAUTH_OTHER_PLUGIN_DIR "${KAUTH_OTHER_PLUGIN_DIR}"
--- trunk/KDE/kdelibs/kdecore/auth/BackendsManager.cpp #1091016:1091017
@@ -21,8 +21,13 @@
 
 #include "BackendsConfig.h"
 
+// Include fake backends
+#include "backends/fake/FakeBackend.h"
+#include "backends/fakehelper/FakeHelperProxy.h"
+
 #include <QPluginLoader>
 #include <QDir>
+#include <kdebug.h>
 
 namespace KAuth
 {
@@ -91,8 +96,24 @@
         }
     }
 
-    Q_ASSERT_X(auth, __FUNCTION__, "No AuthBackend found.");
-    Q_ASSERT_X(helper, __FUNCTION__, "No HelperBackend found.");
+    if (!auth) {
+        // Load the fake auth backend then
+        auth = new FakeBackend;
+#ifndef KAUTH_COMPILING_FAKE_BACKEND
+        // Spit a fat warning
+        kWarning() << "WARNING: KAuth was compiled with a working backend, but was unable to load it! Check your installation!";
+#endif
+    }
+
+    if (!helper) {
+        // Load the fake helper backend then
+        helper = new FakeHelperProxy;
+#ifndef KAUTH_COMPILING_FAKE_BACKEND
+        // Spit a fat warning
+        kWarning() << "WARNING: KAuth was compiled with a working helper backend, but was unable to load it! "
+                      "Check your installation!";
+#endif
+    }
 }
 
 AuthBackend *BackendsManager::authBackend()
--- trunk/KDE/kdelibs/kdecore/auth/ConfigureChecks.cmake #1091016:1091017
@@ -136,14 +136,8 @@
     set (KAUTH_COMPILING_FAKE_BACKEND TRUE)
 
     message(STATUS "Building Fake KAuth backend")
-    message("WARNING: KAuth will be built with Fake backend. The library will not work properly unless compiled with
+    message("WARNING: No valid KAuth backends will be built. The library will not work properly unless compiled with
              a working backend")
-
-    set(KAUTH_BACKEND_SRCS ${KAUTH_BACKEND_SRCS}
-       auth/backends/fake/FakeBackend.cpp
-    )
-
-    set(KAUTH_BACKEND_LIBS ${QT_QTCORE_LIBRARY})
 endif()
 
 # KAuth policy generator executable source probing
@@ -161,39 +155,65 @@
 elseif(KDE4_AUTH_BACKEND_NAME STREQUAL "POLKITQT-1")
   set(KAUTH_POLICY_GEN_SRCS ${KAUTH_POLICY_GEN_SRCS}
       auth/backends/polkit-1/kauth-policy-gen-polkit1.cpp )
-else()
-  set(KAUTH_POLICY_GEN_SRCS ${KAUTH_POLICY_GEN_SRCS}
-      auth/backends/fake/kauth-policy-gen-polkit.cpp )
 endif()
 
-# Helper backend
-# No selection, we have D-Bus only
+########################
+# Helper backend probing
 
-set (KAUTH_COMPILING_DBUS_HELPER_BACKEND TRUE)
+set(KDE4_AUTH_HELPER_BACKEND_NAME "" CACHE STRING "Specifies the KAuth helper backend to build. Current available options are
+                                   DBus, Fake. Not setting this variable will build the most appropriate backend for your system")
 
-qt4_add_dbus_adaptor(kauth_dbus_adaptor_SRCS
-                     auth/backends/dbus/org.kde.auth.xml
-                     auth/backends/dbus/DBusHelperProxy.h
-                     KAuth::DBusHelperProxy)
+set(KAUTH_HELPER_BACKEND ${KDE4_AUTH_HELPER_BACKEND_NAME})
 
-set(KAUTH_HELPER_BACKEND_SRCS
-   auth/backends/dbus/DBusHelperProxy.cpp
-   ${kauth_dbus_adaptor_SRCS}
-)
+if(NOT KAUTH_HELPER_BACKEND)
+    # No checks needed, just set the dbus backend
+    set(KAUTH_HELPER_BACKEND "DBus")
+    string(TOUPPER ${KAUTH_HELPER_BACKEND} KAUTH_HELPER_BACKEND_UPPER)
+    set (KAUTH_HELPER_BACKEND ${KAUTH_HELPER_BACKEND_UPPER})
+else(NOT KAUTH_HELPER_BACKEND)
+    # No checks needed here either
+    string(TOUPPER ${KAUTH_HELPER_BACKEND} KAUTH_HELPER_BACKEND_UPPER)
+    set (KAUTH_HELPER_BACKEND ${KAUTH_HELPER_BACKEND_UPPER})
+endif(NOT KAUTH_HELPER_BACKEND)
 
-set(KAUTH_HELPER_BACKEND_LIBS kdecore)
+set(KDE4_AUTH_HELPER_BACKEND_NAME ${KAUTH_HELPER_BACKEND} CACHE STRING "Specifies the KAuth helper backend to build. Current
+                                                            available options are DBus, Fake. Not setting this variable will
+                                                            build the most appropriate backend for your system" FORCE)
 
-# Install some files as well
-install( FILES auth/backends/dbus/org.kde.auth.conf
-         DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d )
+# Add the correct libraries/files depending on the backend
+if(KDE4_AUTH_HELPER_BACKEND_NAME STREQUAL "DBUS")
+    set (KAUTH_COMPILING_DBUS_HELPER_BACKEND TRUE)
 
-install( FILES auth/backends/dbus/dbus_policy.stub
-               auth/backends/dbus/dbus_service.stub
-         DESTINATION ${DATA_INSTALL_DIR}/kauth COMPONENT Devel)
+    qt4_add_dbus_adaptor(kauth_dbus_adaptor_SRCS
+                        auth/backends/dbus/org.kde.auth.xml
+                        auth/backends/dbus/DBusHelperProxy.h
+                        KAuth::DBusHelperProxy)
 
-# Set the various directories
-set(KAUTH_HELPER_PLUGIN_DIR "${PLUGIN_INSTALL_DIR}/plugins/kauth/helper" CACHE STRING "Where KAuth's helper plugin will be installed")
-set(KAUTH_BACKEND_PLUGIN_DIR "${PLUGIN_INSTALL_DIR}/plugins/kauth/backend" CACHE STRING "Where KAuth's backend plugin will be installed")
+    set(KAUTH_HELPER_BACKEND_SRCS
+        auth/backends/dbus/DBusHelperProxy.cpp
+        ${kauth_dbus_adaptor_SRCS}
+    )
+
+    set(KAUTH_HELPER_BACKEND_LIBS kdecore)
+
+    # Install some files as well
+    install( FILES auth/backends/dbus/org.kde.auth.conf
+             DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d )
+
+    install( FILES auth/backends/dbus/dbus_policy.stub
+                   auth/backends/dbus/dbus_service.stub
+             DESTINATION ${DATA_INSTALL_DIR}/kauth COMPONENT Devel)
+elseif(KDE4_AUTH_HELPER_BACKEND_NAME STREQUAL "FAKE")
+    set (KAUTH_COMPILING_FAKE_HELPER_BACKEND TRUE)
+
+    message("WARNING: No valid KAuth helper backends will be built. The library will not work properly unless compiled with
+             a working backend")
+endif()
+
+
+# Set directories for plugins
+_set_fancy(KAUTH_HELPER_PLUGIN_DIR "${PLUGIN_INSTALL_DIR}/plugins/kauth/helper" "Where KAuth's helper plugin will be installed")
+_set_fancy(KAUTH_BACKEND_PLUGIN_DIR "${PLUGIN_INSTALL_DIR}/plugins/kauth/backend" "Where KAuth's backend plugin will be installed")
 #set(KAUTH_OTHER_PLUGIN_DIR "${QT_PLUGINS_DIR}/kauth/plugins")
 
 ## End
--- trunk/KDE/kdelibs/kdecore/auth/backends/fake/FakeBackend.cpp #1091016:1091017
@@ -19,10 +19,6 @@
 
 #include "FakeBackend.h"
 
-#include <QtCore/qplugin.h>
-
-#include <syslog.h>
-
 namespace KAuth
 {
 
@@ -61,5 +57,3 @@
 }
 
 } // namespace Auth
-
-Q_EXPORT_PLUGIN2(kauth_backend, KAuth::FakeBackend)


More information about the Kde-buildsystem mailing list