From 8547dc427bd0d09faef7b26078adf39c2fe74e01 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 19 Aug 2014 18:54:46 +0200 Subject: [PATCH 6/6] Properly export cmake targets --- CMakeLists.txt | 7 +++++++ src/CMakeLists.txt | 20 +++++++++++--------- src/modules/packagekit-qt-config.cmake.in | 7 +++---- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa8978a..5df701d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ set (LOCALE_DIR "${DATADIR}/locale") set (VERSION "${QPACKAGEKIT_VERSION}") set (BUILDDIR "${CMAKE_BINARY_DIR}") set (LOCALSTATEDIR "/var") +set (CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${LIBNAME}/") add_definitions("-DLOCALSTATEDIR=\"${LOCALSTATEDIR}\"") add_definitions("-std=gnu++11") @@ -75,3 +76,9 @@ endif (DISABLE_MAINTAINER_CFLAGS) add_definitions(${MAINTAINER_CFLAGS}) add_subdirectory(src) + +install(EXPORT PackageKitQtTargets + DESTINATION "${CMAKECONFIG_INSTALL_DIR}" + FILE PackageKitQtTargets.cmake + NAMESPACE PK:: + COMPONENT Devel) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8ef7906..d1176ec 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,13 +55,14 @@ set(packagekitqt_SRC details.cpp ) -find_file(PK_INTERFACE_XML org.freedesktop.PackageKit.xml - PATHS ${CMAKE_INSTALL_PREFIX}/share/dbus-1/interfaces/ +find_path(PK_INTERFACES_DIR org.freedesktop.PackageKit.xml + HINTS ${CMAKE_INSTALL_PREFIX} /usr + PATH_SUFFIXES share/dbus-1/interfaces/ ) -find_file(PK_TRANSACTION_INTERFACE_XML org.freedesktop.PackageKit.Transaction.xml - PATHS ${CMAKE_INSTALL_PREFIX}/share/dbus-1/interfaces/ -) -if (PK_INTERFACE_XML STREQUAL "PK_INTERFACE_XML-NOTFOUND" OR PK_TRANSACTION_INTERFACE_XML STREQUAL "PK_TRANSACTION_INTERFACE_XML-NOTFOUND") +set(PK_INTERFACE_XML "${PK_INTERFACES_DIR}/org.freedesktop.PackageKit.xml") +set(PK_TRANSACTION_INTERFACE_XML "${PK_INTERFACES_DIR}/org.freedesktop.PackageKit.Transaction.xml") + +if (NOT PK_INTERFACE_XML OR NOT PK_TRANSACTION_INTERFACE_XML) message (FATAL_ERROR "Unable to find PackageKit DBus specifications! Please install PackageKit to continue!") endif () @@ -87,7 +88,8 @@ set_target_properties(${LIBNAME} PROPERTIES VERSION ${QPACKAGEKIT_VERSION} SOVER if (Qt5_FOUND) add_dependencies(${LIBNAME} mocs) target_link_libraries(${LIBNAME} - ${Qt5DBus_LIBRARIES} ${Qt5Sql_LIBRARIES} + LINK_PUBLIC Qt5::DBus + LINK_PRIVATE Qt5::Sql ) elseif (Qt4_FOUND) target_link_libraries(${LIBNAME} @@ -99,8 +101,8 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${LIBNAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${LIBNAME}.pc @ONLY ) - -install(TARGETS ${LIBNAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +target_include_directories(${LIBNAME} INTERFACE "$") +install(TARGETS ${LIBNAME} EXPORT PackageKitQtTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LIBNAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig ) diff --git a/src/modules/packagekit-qt-config.cmake.in b/src/modules/packagekit-qt-config.cmake.in index f9f4436..a91b095 100644 --- a/src/modules/packagekit-qt-config.cmake.in +++ b/src/modules/packagekit-qt-config.cmake.in @@ -1,11 +1,10 @@ # - Config information for PackageKit-Qt@QT_VERSION@ # This file defines: # -# PackageKitQt@QT_VERSION@_INCLUDE_DIR - the PackageKitQt@QT_VERSION@ include directory # PackageKitQt@QT_VERSION@_LIBRARIES - Link these to use PackageKitQt@QT_VERSION@ SET(prefix "@CMAKE_INSTALL_PREFIX@") SET(exec_prefix "@CMAKE_INSTALL_PREFIX@") -SET(PackageKitQt@QT_VERSION@_LIBRARIES "@PKQT_INSTALL_LIBDIR@/lib@LIBNAME@.so" CACHE FILEPATH "Libraries for PackageKitQt@QT_VERSION@") -SET(PackageKitQt@QT_VERSION@_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include/PackageKit/@LIBNAME@" CACHE PATH "Include path for PackageKitQt@QT_VERSION@") -SET(PackageKitQt@QT_VERSION@_FOUND "TRUE") +SET(PackageKitQt@QT_VERSION@_LIBRARIES "PK::packagekitqt5") + +include("${CMAKE_CURRENT_LIST_DIR}/PackageKitQtTargets.cmake") -- 1.9.3