From 15f626b7b1d6e973442aa7a1b6d1ad23c15df46c Mon Sep 17 00:00:00 2001 From: iaom Date: Thu, 16 Feb 2023 09:28:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BA=93=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 1 + libukui-notification/CMakeLists.txt | 33 +++++++++++++++---- .../notification-client-private.h | 2 +- libukui-notification/notification-client.cpp | 2 +- libukui-notification/notification-client.h | 2 +- .../ukui-notification-config.cmake.in | 5 ++- 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03025d1..1e91ba0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) include(GNUInstallDirs) find_package(QT NAMES Qt6 Qt5 COMPONENTS Core LinguistTools DBus Network Gui REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core LinguistTools DBus Network Gui REQUIRED) +set(REQUIRED_QT_VERSION 5.12.8) add_subdirectory(notification-server) add_subdirectory(libukui-notification) diff --git a/libukui-notification/CMakeLists.txt b/libukui-notification/CMakeLists.txt index 8ac3282..59f1bc5 100644 --- a/libukui-notification/CMakeLists.txt +++ b/libukui-notification/CMakeLists.txt @@ -32,24 +32,43 @@ target_link_libraries(ukui-notification Qt${QT_VERSION_MAJOR}::Gui KF5::WindowSystem ) -target_compile_definitions(ukui-notification PRIVATE UKUINOTIFICATION_LIBRARY) + include(CMakePackageConfigHelpers) -set(CMAKECONFIG_INSTALL_DIR "/usr/include/ukui-notification") +set(CMAKECONFIG_INSTALL_DIR "/usr/share/cmake/ukui-notification") +set(HEADERS_INSTALL_DIR /usr/include/ukui-notification) +set(PC_INSTALL_DIR "/usr/lib/pkgconfig") + +target_include_directories(ukui-notification PUBLIC $) configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/ukui-notification-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/ukui-notification-config.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}) -set(PC_INSTALL_DIR "/usr/lib/pkgconfig") +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/ukui-notification-config-version.cmake + VERSION ${UKUI_NOTIFICATION_VERSION} + COMPATIBILITY SameMajorVersion +) + configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/ukui-notification.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/ukui-notification.pc" INSTALL_DESTINATION ${PC_INSTALL_DIR}) set_target_properties(ukui-notification PROPERTIES VERSION ${UKUI_NOTIFICATION_VERSION} - SOVERSION "1" + SOVERSION ${VERSION_MAJOR} OUTPUT_NAME ukui-notification ) -install(TARGETS ukui-notification DESTINATION /usr/lib) -install(FILES ${HEADERS} DESTINATION /usr/include/ukui-notification) +install(TARGETS ukui-notification + EXPORT ukui-notification + PUBLIC_HEADER DESTINATION ${HEADERS_INSTALL_DIR} + LIBRARY DESTINATION /usr/lib + ) +install(EXPORT ukui-notification + FILE ukui-notification-targets.cmake + DESTINATION ${CMAKECONFIG_INSTALL_DIR}) + +install(FILES ${HEADERS} DESTINATION ${HEADERS_INSTALL_DIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ukui-notification.pc DESTINATION ${PC_INSTALL_DIR}) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ukui-notification-config.cmake DESTINATION ${CMAKECONFIG_INSTALL_DIR}) \ No newline at end of file +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ukui-notification-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/ukui-notification-config-version.cmake + DESTINATION ${CMAKECONFIG_INSTALL_DIR}) \ No newline at end of file diff --git a/libukui-notification/notification-client-private.h b/libukui-notification/notification-client-private.h index 9037a82..4f71a80 100644 --- a/libukui-notification/notification-client-private.h +++ b/libukui-notification/notification-client-private.h @@ -13,7 +13,7 @@ class NotificationClientPrivate : public QObject { Q_OBJECT public: - explicit NotificationClientPrivate(NotificationClient *q, QObject *parent = nullptr); + explicit NotificationClientPrivate(NotificationClient *q); ~NotificationClientPrivate() override; bool init(); static QString clientServicePath(); diff --git a/libukui-notification/notification-client.cpp b/libukui-notification/notification-client.cpp index 9db8a6c..7a12157 100644 --- a/libukui-notification/notification-client.cpp +++ b/libukui-notification/notification-client.cpp @@ -9,7 +9,7 @@ using namespace UkuiNotification; -NotificationClientPrivate::NotificationClientPrivate(NotificationClient *q, QObject *parent) : QObject(parent), q(q) +NotificationClientPrivate::NotificationClientPrivate(NotificationClient *q) : QObject(q), q(q) { } diff --git a/libukui-notification/notification-client.h b/libukui-notification/notification-client.h index 1677d2c..59783d0 100644 --- a/libukui-notification/notification-client.h +++ b/libukui-notification/notification-client.h @@ -23,7 +23,7 @@ public: Undefined = 4, //Undefined/reserved reasons. }; Q_ENUM(CloseReason) - explicit NotificationClient(QObject *parent); + explicit NotificationClient(QObject *parent = nullptr); ~NotificationClient(); /** * 注册成为弹窗通知客户端 diff --git a/libukui-notification/ukui-notification-config.cmake.in b/libukui-notification/ukui-notification-config.cmake.in index 3f63f85..62b2ea1 100644 --- a/libukui-notification/ukui-notification-config.cmake.in +++ b/libukui-notification/ukui-notification-config.cmake.in @@ -1,10 +1,9 @@ @PACKAGE_INIT@ include(CMakeFindDependencyMacro) -find_dependency(Qt@QT_MAJOR_VERSION@Core "@REQUIRED_QT_VERSION@") - +find_dependency(Qt@QT_VERSION_MAJOR@Core "@REQUIRED_QT_VERSION@") if(TARGET Qt6::Core) find_dependency(Qt6Core5Compat @REQUIRED_QT_VERSION@) endif() -include("${CMAKE_CURRENT_LIST_DIR}/ukui-notificationTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/ukui-notification-targets.cmake") \ No newline at end of file