diff options
Diffstat (limited to 'modules/FindPolkitQt.cmake')
-rw-r--r-- | modules/FindPolkitQt.cmake | 100 |
1 files changed, 36 insertions, 64 deletions
diff --git a/modules/FindPolkitQt.cmake b/modules/FindPolkitQt.cmake index b445b2e8..500b69d3 100644 --- a/modules/FindPolkitQt.cmake +++ b/modules/FindPolkitQt.cmake @@ -4,98 +4,70 @@ # 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_CORE_LIBRARY - Link this to use the polkit-qt-core library only +# POLKITQT_GUI_LIBRARY - Link this to use GUI elements in polkit-qt (polkit-qt-gui) # POLKITQT_DEFINITIONS - Compiler switches required for using Polkit-qt -# Copyright (c) 2008, Adrien Bustany, <madcat@mymadcat.com> # Copyright (c) 2009, Daniel Nicoletti, <dantti85-pk@yahoo.com.br> # Copyright (c) 2009, Dario Freddi, <drf54321@gmail.com> # Copyright (c) 2009, Michal Malek, <michalm@jabster.pl> # -# Redistribution and use is allowed according to the terms of the GPLv2+ license. +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (POLKITQT_INCLUDE_DIR AND POLKITQT_LIB) set(POLKITQT_FIND_QUIETLY TRUE) endif (POLKITQT_INCLUDE_DIR AND POLKITQT_LIB) -include(FindPkgConfig) - if (NOT POLKITQT_MIN_VERSION) set(POLKITQT_MIN_VERSION "0.9.0") endif (NOT POLKITQT_MIN_VERSION) -pkg_search_module( POLKITQT polkit-qt ) - -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) - message(STATUS "Found Polkit-Qt release >= ${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) -else (POLKITQT_FOUND) - set(POLKITQT_FOUND FALSE) - message(STATUS "Cannot find Polkit-Qt library!") - return() -endif (POLKITQT_FOUND) - +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) -# find_path( POLKITQT_INCLUDE_DIR PolicyKit/policykit-qt/Polkit-qt ) find_path( POLKITQT_INCLUDE_DIR - NAMES PolicyKit/polkit-qt/ - HINTS ${POLKITQT_INCLUDEDIR} + NAMES polkit-qt/auth.h + PATH_SUFFIXES PolicyKit ) - find_library( POLKITQT_CORE_LIBRARY NAMES polkit-qt-core - HINTS ${POLKITQT_LIBDIR} + HINTS ${PC_POLKITQT_LIBDIR} ) find_library( POLKITQT_GUI_LIBRARY NAMES polkit-qt-gui - HINTS ${POLKITQT_LIBDIR} + HINTS ${PC_POLKITQT_LIBDIR} +) +find_library( POLKITQT_LIBRARIES + NAMES polkit-qt-gui polkit-qt-core + HINTS ${PC_POLKITQT_LIBDIR} ) -if (POLKITQT_INCLUDE_DIR AND POLKITQT_CORE_LIBRARY AND POLKITQT_GUI_LIBRARY) - set(POLKITQT_FOUND TRUE) -else (POLKITQT_INCLUDE_DIR AND POLKITQT_CORE_LIBRARY AND POLKITQT_GUI_LIBRARY) - set(POLKITQT_FOUND FALSE) -endif (POLKITQT_INCLUDE_DIR AND POLKITQT_CORE_LIBRARY AND POLKITQT_GUI_LIBRARY) - -set(POLKITQT_LIBRARIES ${POLKITQT_CORE_LIBRARY} ${POLKITQT_GUI_LIBRARY}) +include(FindPackageHandleStandardArgs) -set(POLKITQT_INCLUDE_DIR ${POLKITQT_INCLUDE_DIR}/PolicyKit/polkit-qt ${POLKITQT_INCLUDE_DIR}/PolicyKit/) +# handle the QUIETLY and REQUIRED arguments and set POLKITQT_FOUND to TRUE if +# all listed variables are TRUE +find_package_handle_standard_args(PolkitQt DEFAULT_MSG POLKITQT_LIBRARIES POLKITQT_INCLUDE_DIR) -#if (POLKITQT_PREFIX != ${CMAKE_INSTALL_PREFIX}) -#message("Warning: Move polkit files to /usr prefix") -#endif() -set(POLICY_FILES_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/PolicyKit/policy/) +mark_as_advanced(POLKITQT_INCLUDE_DIR POLKITQT_CORE_LIBRARY POLKITQT_GUI_LIBRARY POLKITQT_LIBRARIES) if (POLKITQT_FOUND) - if (NOT POLKITQT_FIND_QUIETLY) - message(STATUS "Found Polkit-Qt: ${POLKITQT_LIBRARIES}") - endif (NOT POLKITQT_FIND_QUIETLY) -else (POLKITQT_FOUND) - if (POLKITQT_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find Polkit-Qt") - endif (POLKITQT_FIND_REQUIRED) + if (PC_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 (PC_POLKITQT_VERSION VERSION_LESS POLKITQT_MIN_VERSION) + if ( NOT PC_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 ${PC_POLKITQT_PREFIX} prefix") + endif (NOT PC_POLKITQT_PREFIX STREQUAL CMAKE_INSTALL_PREFIX) + endif (PC_POLKITQT_VERSION VERSION_LESS POLKITQT_MIN_VERSION) endif (POLKITQT_FOUND) -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) +set(POLKITQT_POLICY_FILES_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/PolicyKit/policy/) |