First attempt to refactor.

Problems: include paths seems not to work. It should include 
/usr/include/PolicyKit but somehow it does not work. Hints?

TODO: Move the macros
           Is there a way to check version better than what I'm doing?

-- 
-------------------

Dario Freddi
KDE Developer
GPG Key Signature: 511A9A3B
# - Try to find Polkit-qt
# Once done this will define
#
#  POLKITQT_FOUND - system has Polkit-qt
#  POLKITQT_INCLUDE_DIR - the Polkit-qt include directory
#  POLKITQT_LIBRARIES - Link these to use all Polkit-qt libs
#  POLKITQT_CORE_LIBRARY
#  POLKITQT_GUI_LIBRARY
#  POLKITQT_DEFINITIONS - Compiler switches required for using Polkit-qt

# Copyright (c) 2008, Adrien Bustany, <[email protected]>
# Copyright (c) 2009, Daniel Nicoletti, <[email protected]>
# Copyright (c) 2009, Dario Freddi, <[email protected]>
# Copyright (c) 2009, Michal Malek, <[email protected]>
#
# Redistribution and use is allowed according to the terms of the GPLv2+ license.

if (POLKITQT_INCLUDE_DIR AND POLKITQT_LIB)
    set(POLKITQT_FIND_QUIETLY TRUE)
endif (POLKITQT_INCLUDE_DIR AND POLKITQT_LIB)

if (NOT POLKITQT_MIN_VERSION)
  set(POLKITQT_MIN_VERSION "0.9.0")
endif (NOT POLKITQT_MIN_VERSION)

IF (NOT WIN32)
   # use pkg-config to get the directories and then use these values
   # in the FIND_PATH() and FIND_LIBRARY() calls
   find_package(PkgConfig)
   pkg_check_modules(PC_POLKITQT QUIET polkit-qt)
   set(POLKITQT_DEFINITIONS ${PC_POLKITQT_CFLAGS_OTHER})
endif (NOT WIN32)

message(${POLKITQT_INCLUDEDIR})

find_path( POLKITQT_INCLUDE_DIR
    NAMES PolicyKit
    HINTS ${POLKITQT_INCLUDEDIR}
)

find_library( POLKITQT_CORE_LIBRARY 
    NAMES polkit-qt-core 
    HINTS ${POLKITQT_LIBDIR}
)
find_library( POLKITQT_GUI_LIBRARY 
    NAMES polkit-qt-gui 
    HINTS ${POLKITQT_LIBDIR}
)
find_library( POLKITQT_GUI_LIBRARIES
    NAMES polkit-qt-gui polkit-qt-core 
    HINTS ${POLKITQT_LIBDIR}
)

include(FindPackageHandleStandardArgs)

# handle the QUIETLY and REQUIRED arguments and set POLKIQT_FOUND to TRUE if 
# all listed variables are TRUE
find_package_handle_standard_args(PolkitQt DEFAULT_MSG POLKITQT_LIBRARIES POLKITQT_INCLUDE_DIR)

mark_as_advanced(POLKITQT_INCLUDE_DIR POLKITQT_LIBRARIES)

if (POLKITQT_FOUND)
    if (POLKITQT_VERSION VERSION_LESS POLKITQT_MIN_VERSION)
        message(STATUS "Found Polkit-Qt release < ${POLKITQT_MIN_VERSION}")
        message(STATUS "You need Polkit-Qt version ${POLKITQT_MIN_VERSION} or newer to compile this component")
        set(POLKITQT_FOUND FALSE)
        return()
    else (POLKITQT_VERSION VERSION_LESS POLKITQT_MIN_VERSION)
        if ( NOT POLKITQT_PREFIX STREQUAL CMAKE_INSTALL_PREFIX )
            message("WARNING: Installation prefix does not match PolicyKit install prefixes. You probably will need to move files installed "
                    "in POLICY_FILES_INSTALL_DIR and by dbus_add_activation_system_service to the ${POLKITQT_PREFIX} prefix")
        endif (NOT POLKITQT_PREFIX STREQUAL CMAKE_INSTALL_PREFIX)
    endif (POLKITQT_VERSION VERSION_LESS POLKITQT_MIN_VERSION)
endif (POLKITQT_FOUND)

set(POLICY_FILES_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/PolicyKit/policy/)

mark_as_advanced(POLKITQT_INCLUDE_DIR POLKITQT_LIB)

macro(dbus_add_activation_system_service _sources)
    pkg_search_module( DBUS dbus-1 )
    foreach (_i ${_sources})
        get_filename_component(_service_file ${_i} ABSOLUTE)
        string(REGEX REPLACE "\\.service.*$" ".service" _output_file ${_i})
        set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_output_file})
        configure_file(${_service_file} ${_target})
        install(FILES ${_target} DESTINATION ${DBUS_PREFIX}/share/dbus-1/system-services )
    endforeach (_i ${ARGN})
endmacro(dbus_add_activation_system_service _sources)

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Kde-buildsystem mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-buildsystem

Reply via email to