KDE/kdelibs

Dario Freddi drf at kde.org
Tue Oct 20 23:11:40 CEST 2009


SVN commit 1038230 by dafre:

CCMAIL: kde-buildsystem at kde.org

Vastly improve KAuth's backend detection, also letting packagers specify explicitely
the backend they want to build with the variable KAUTH_BACKEND.



 M  +0 -5      CMakeLists.txt  
 M  +31 -18    kdecore/CMakeLists.txt  
 M  +57 -8     kdecore/auth/ConfigureChecks.cmake  


--- trunk/KDE/kdelibs/CMakeLists.txt #1038229:1038230
@@ -86,11 +86,6 @@
 macro_optional_find_package(Libintl)
 macro_log_feature(LIBINTL_FOUND "Libintl" "Library for message translation" "http://www.gnu.org/software/gettext" FALSE "" "STRONGLY RECOMMENDED: Enables KDE to be available in many different languages.")
 
-if (UNIX AND NOT APPLE)
-macro_optional_find_package(PolkitQt)
-macro_log_feature(POLKITQT_FOUND "PolkitQt" "Qt Wrapper around Policykit" "http://api.kde.org/polkit-qt" FALSE "" "STRONGLY RECOMMENDED: Needed to make KAuth work, hence to enable some workspace functionalities")
-endif (UNIX AND NOT APPLE)
-
 macro_optional_find_package(OpenGL)
 macro_log_feature(OPENGL_FOUND "OpenGL" "API for developing portable, interactive 2D and 3D graphics applications" "http://mesa3d.sourceforge.net" FALSE "" "STRONGLY RECOMMENDED: The 3D hardware acceleration available through the OpenGL API is used in applications ranging from graphics and modellers to screensavers and video players.")
 
--- trunk/KDE/kdelibs/kdecore/CMakeLists.txt #1038229:1038230
@@ -64,9 +64,9 @@
 if (APPLE)
    set(kdecore_OPTIONAL_SRCS ${kdecore_OPTIONAL_SRCS}
       kernel/kkernel_mac.cpp
-      auth/backends/mac/AuthServicesBackend.cpp
    )
-   set(kdecore_OPTIONAL_LIBS ${kdecore_OPTIONAL_LIBS} ${CARBON_LIBRARY} ${SECURITY_LIBRARY})
+
+   set(kdecore_OPTIONAL_LIBS ${kdecore_OPTIONAL_LIBS} ${CARBON_LIBRARY})
 endif (APPLE)
 
 if (WIN32)
@@ -106,22 +106,35 @@
       util/kmacroexpander_unix.cpp
       fakes.c
    )
-
-   if (POLKITQT_FOUND)
-      set(kdecore_OPTIONAL_SRCS ${kdecore_OPTIONAL_SRCS}
-          auth/backends/policykit/PolicyKitBackend.cpp
-      )
-      set(kdecore_OPTIONAL_LIBS ${kdecore_OPTIONAL_LIBS} ${POLKITQT_CORE_LIBRARY})
-   else (POLKITQT_FOUND)
-     if (NOT APPLE)
-       set(kdecore_OPTIONAL_SRCS ${kdecore_OPTIONAL_SRCS}
-           auth/backends/fake/FakeBackend.cpp
-       )
-     endif (NOT APPLE)
-   endif (POLKITQT_FOUND)
 endif (UNIX)
 
+if (KAUTH_BACKEND STREQUAL "POLKITQT")
+    message(STATUS "Building PolkitQt KAuth backend")
 
+    set(kdecore_OPTIONAL_SRCS ${kdecore_OPTIONAL_SRCS}
+       auth/backends/policykit/PolicyKitBackend.cpp
+    )
+
+    set(kdecore_OPTIONAL_LIBS ${kdecore_OPTIONAL_LIBS} ${POLKITQT_CORE_LIBRARY})
+elseif (KAUTH_BACKEND STREQUAL "APPLE")
+    message(STATUS "Building Apple KAuth backend")
+
+    set(kdecore_OPTIONAL_SRCS ${kdecore_OPTIONAL_SRCS}
+       auth/backends/mac/AuthServicesBackend.cpp
+    )
+
+    set(kdecore_OPTIONAL_LIBS ${kdecore_OPTIONAL_LIBS} ${SECURITY_LIBRARY})
+elseif (KAUTH_BACKEND STREQUAL "FAKE")
+    message(STATUS "Building Fake KAuth backend")
+    message("WARNING: KAuth will be built with Fake backend. The library will not work properly unless compiled with
+             a working backend")
+
+    set(kdecore_OPTIONAL_SRCS ${kdecore_OPTIONAL_SRCS}
+       auth/backends/fake/FakeBackend.cpp
+    )
+endif ()
+
+
 add_subdirectory( kconfig_compiler )
 add_subdirectory( tests )
 add_subdirectory( sonnet/tests )
@@ -354,13 +367,13 @@
 set(kauth_policy_gen_SRCS
     auth/policy-gen/policy-gen.cpp )
 
-if(APPLE)
+if(KAUTH_BACKEND STREQUAL "APPLE")
    set(kauth_policy_gen_SRCS ${kauth_policy_gen_SRCS}
        auth/backends/mac/kauth-policy-gen-mac.cpp )
-elseif(UNIX)
+elseif(KAUTH_BACKEND STREQUAL "POLKITQT")
    set(kauth_policy_gen_SRCS ${kauth_policy_gen_SRCS}
        auth/backends/policykit/kauth-policy-gen-polkit.cpp )
-elseif(WIN32)
+else()
     set(kauth_policy_gen_SRCS ${kauth_policy_gen_SRCS}
        auth/backends/fake/kauth-policy-gen-polkit.cpp )
 endif()
--- trunk/KDE/kdelibs/kdecore/auth/ConfigureChecks.cmake #1038229:1038230
@@ -1,13 +1,62 @@
 ####### checks for kdecore/kauth ###############
 
-if(APPLE)
+set(KAUTH_BACKEND "" CACHE STRING "Specifies the KAuth backend to build. Current available options are 
+                                   PolkitQt, Fake, Apple. Not setting this variable will build the most 
+                                   appropriate backend for your system")
+## Check if the user did not specify a backend to be built. If that is the case,
+## we check what is the best backend to build on this system.
+## 4.4: We leave polkit-0.9 having more priority over polkit-1. This will change from 4.5 on
+if(NOT KAUTH_BACKEND)
+    if (APPLE)
+        set (KAUTH_BACKEND "Apple")
+    elseif (UNIX)
+        macro_optional_find_package(PolkitQt)
+        macro_log_feature(POLKITQT_FOUND "PolkitQt" "Qt Wrapper around Policykit" "http://api.kde.org/polkit-qt"
+                          FALSE "" "STRONGLY RECOMMENDED: Needed to make KAuth work, hence to enable some workspace functionalities")
+
+        if (POLKITQT_FOUND)
+            set (KAUTH_BACKEND "PolkitQt")
+        else (POLKITQT_FOUND)
+            set (KAUTH_BACKEND "Fake")
+        endif (POLKITQT_FOUND)
+    else(UNIX)
+        set (KAUTH_BACKEND "Fake")
+    endif(APPLE)
+
+    # Case-insensitive
+    string(TOUPPER ${KAUTH_BACKEND} KAUTH_BACKEND)
+else(NOT KAUTH_BACKEND)
+    # Case-insensitive
+    string(TOUPPER ${KAUTH_BACKEND} KAUTH_BACKEND)
+    
+    # Check if the specified backend is valid. If it is not, we fall back to the Fake one
+    if (NOT KAUTH_BACKEND STREQUAL "APPLE" AND NOT KAUTH_BACKEND STREQUAL "POLKITQT" AND NOT KAUTH_BACKEND STREQUAL "FAKE")
+        message ("WARNING: The KAuth Backend ${KAUTH_BACKEND} you specified does not exist. Falling back to Fake backend")
+        set (KAUTH_BACKEND "Fake")
+    endif (NOT KAUTH_BACKEND STREQUAL "APPLE" AND NOT KAUTH_BACKEND STREQUAL "POLKITQT" AND NOT KAUTH_BACKEND STREQUAL "FAKE")
+
+    # Check requirements for each backend. If not, fall back to the fake one
+    if (KAUTH_BACKEND STREQUAL "APPLE" AND NOT APPLE)
+        message ("WARNING: You chose the Apple KAuth backend but your system does not support it. Falling back to Fake backend")
+        set (KAUTH_BACKEND "FAKE")
+    endif (KAUTH_BACKEND STREQUAL "APPLE" AND NOT APPLE)
+    if (KAUTH_BACKEND STREQUAL "POLKITQT")
+        macro_optional_find_package(PolkitQt)
+        macro_log_feature(POLKITQT_FOUND "PolkitQt" "Qt Wrapper around Policykit" "http://api.kde.org/polkit-qt"
+                          FALSE "" "STRONGLY RECOMMENDED: Needed to make KAuth work, hence to enable some workspace functionalities")
+
+        if (NOT POLKITQT_FOUND)
+            message ("WARNING: You chose the PolkitQt KAuth backend but you don't have PolkitQt installed.
+                      Falling back to Fake backend")
+            set (KAUTH_BACKEND "FAKE")
+        endif (NOT POLKITQT_FOUND)
+    endif (KAUTH_BACKEND STREQUAL "POLKITQT")
+endif(NOT KAUTH_BACKEND)
+
+# Add the correct libraries depending on the backend
+if(KAUTH_BACKEND STREQUAL "APPLE")
     find_library(CORE_FOUNDATION_LIBRARY CoreFoundation)
     find_library(SECURITY_LIBRARY Security)
-elseif(UNIX)
-    if(NOT POLKITQT_FOUND)
-        message("WARNING: PolkitQt library not found. KAuth will be built with a fake backend")
-    endif(NOT POLKITQT_FOUND)
-    if (POLKITQT_INCLUDE_DIR)
-      include_directories(${POLKITQT_INCLUDE_DIR})
-    endif()
+elseif(KAUTH_BACKEND STREQUAL "POLKITQT")
+    include_directories(${POLKITQT_INCLUDE_DIR})
 endif()


More information about the Kde-buildsystem mailing list