2022-12-02 15:58:09 +08:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
|
|
|
|
|
|
|
project(ukui-menu LANGUAGES CXX)
|
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
|
|
|
|
# see https://cmake.org/cmake/help/v3.16/manual/cmake-qt.7.html
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
|
|
|
|
# 查找qt组件
|
2023-04-09 19:38:27 +08:00
|
|
|
find_package(QT NAMES Qt6 Qt5
|
|
|
|
COMPONENTS Core Gui Quick Widgets LinguistTools DBus X11Extras REQUIRED)
|
|
|
|
find_package(Qt${QT_VERSION_MAJOR}
|
|
|
|
COMPONENTS Core Gui Quick Widgets LinguistTools DBus X11Extras REQUIRED)
|
2022-12-02 15:58:09 +08:00
|
|
|
|
|
|
|
# find kde framework components
|
|
|
|
# see: https://api.kde.org/frameworks/index.html > KWindowSystem
|
|
|
|
find_package(KF5WindowSystem REQUIRED)
|
2023-02-22 10:54:44 +08:00
|
|
|
find_package(Qt5Xdg REQUIRED)
|
2024-03-07 20:29:07 +08:00
|
|
|
find_package(ukui-quick COMPONENTS platform REQUIRED)
|
2022-12-02 15:58:09 +08:00
|
|
|
|
|
|
|
# 查找其他组件
|
|
|
|
# see: https://cmake.org/cmake/help/v3.16/module/FindPkgConfig.html
|
|
|
|
# see: https://cmake.org/cmake/help/v3.16/command/list.html
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
|
|
|
|
set(UKUI_MENU_EXTERNAL_LIBS "")
|
|
|
|
# glib-2.0 gio-unix-2.0 gsettings-qt x11 kysdk-waylandhelper
|
2024-03-07 20:29:07 +08:00
|
|
|
set(UKUI_MENU_PC_PKGS gsettings-qt ukui-search kysdk-datacollect)
|
2022-12-23 11:08:16 +08:00
|
|
|
|
|
|
|
foreach(external_lib IN ITEMS ${UKUI_MENU_PC_PKGS})
|
|
|
|
pkg_check_modules(${external_lib} REQUIRED ${external_lib})
|
|
|
|
if(${${external_lib}_FOUND})
|
|
|
|
include_directories(${${external_lib}_INCLUDE_DIRS})
|
|
|
|
link_directories(${${external_lib}_LIBRARY_DIRS})
|
|
|
|
list(APPEND UKUI_MENU_EXTERNAL_LIBS ${${external_lib}_LIBRARIES})
|
2022-12-02 15:58:09 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
message(STATUS "External libraries found: ${UKUI_MENU_EXTERNAL_LIBS}")
|
|
|
|
|
2022-12-08 14:37:02 +08:00
|
|
|
# include single-application
|
2023-04-10 18:01:18 +08:00
|
|
|
add_subdirectory(3rd-parties/qtsingleapplication)
|
2022-12-08 14:37:02 +08:00
|
|
|
# static lib of single-application.
|
2023-04-10 18:01:18 +08:00
|
|
|
set(SingleApplication "qtsingleapplication")
|
2022-12-08 14:37:02 +08:00
|
|
|
|
2022-12-02 15:58:09 +08:00
|
|
|
# include文件夹
|
|
|
|
include_directories(src)
|
2024-01-15 07:16:59 +08:00
|
|
|
#include_directories(src/model)
|
2022-12-02 15:58:09 +08:00
|
|
|
include_directories(src/appdata)
|
2024-01-09 10:08:53 +08:00
|
|
|
include_directories(src/libappdata)
|
2022-12-02 15:58:09 +08:00
|
|
|
include_directories(src/settings)
|
|
|
|
include_directories(src/uiconfig)
|
2022-12-23 11:08:16 +08:00
|
|
|
include_directories(src/windows)
|
2023-12-11 10:43:25 +08:00
|
|
|
include_directories(src/extension)
|
2023-02-14 09:58:57 +08:00
|
|
|
include_directories(src/utils)
|
2023-04-10 18:01:18 +08:00
|
|
|
include_directories(3rd-parties/qtsingleapplication/src)
|
2022-12-02 15:58:09 +08:00
|
|
|
|
2022-12-13 16:33:14 +08:00
|
|
|
# 用于Qt Creator识别自定义qml模块的导入路径
|
|
|
|
list(APPEND QML_MODULE_DIRS "${PROJECT_SOURCE_DIR}/qml")
|
|
|
|
set(QML_IMPORT_PATH "${QML_MODULE_DIRS}" CACHE STRING "Qt Creator extra qml import paths." FORCE)
|
2023-04-09 11:22:39 +08:00
|
|
|
#message(STATUS "QML_IMPORT_PATH: ${QML_IMPORT_PATH}")
|
2022-12-13 16:33:14 +08:00
|
|
|
|
2022-12-02 15:58:09 +08:00
|
|
|
# 基础设置
|
|
|
|
set(UKUI_MENU_DATA_DIR "/usr/share/ukui-menu")
|
2023-04-09 19:38:27 +08:00
|
|
|
set(UKUI_MENU_SO_DIR "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/ukui-menu")
|
2022-12-02 15:58:09 +08:00
|
|
|
set(UKUI_MENU_TRANSLATION_DIR "${UKUI_MENU_DATA_DIR}/translations")
|
2023-03-17 12:35:34 +08:00
|
|
|
set(UKUI_MENU_GLOBAL_CONFIG_FILE "${UKUI_MENU_DATA_DIR}/ukui-menu-global-config.conf")
|
2023-04-09 19:38:27 +08:00
|
|
|
set(UKUI_MENU_EXTENSION_DIR "${UKUI_MENU_SO_DIR}/extensions")
|
|
|
|
set(UKUI_MENU_CONTEXT_MENU_DIR "${UKUI_MENU_SO_DIR}/context-menu")
|
|
|
|
|
|
|
|
|
|
|
|
set(UKUI_MENU_LIBRARY_VERSION 1.0.0)
|
|
|
|
set(UKUI_MENU_LIBRARY_API_VERSION 1)
|
|
|
|
#set(UKUI_MENU_LIBRARY_NAME "ukui-menu${UKUI_MENU_LIBRARY_API_VERSION}")
|
2023-12-11 10:43:25 +08:00
|
|
|
set(UKUI_MENU_LIBRARY_NAME "ukui-menu")
|
|
|
|
set(UKUI_MENU_LIBRARY_TARGET "libukui-menu")
|
2023-04-09 19:38:27 +08:00
|
|
|
set(PC_INSTALL_DIR "/usr/lib/pkgconfig")
|
|
|
|
set(CMAKE_CONFIG_INSTALL_DIR "/usr/share/cmake/${UKUI_MENU_LIBRARY_NAME}")
|
2023-04-09 11:22:39 +08:00
|
|
|
|
2022-12-02 15:58:09 +08:00
|
|
|
# 宏定义
|
|
|
|
add_compile_definitions(UKUI_MENU_TRANSLATION_DIR="${UKUI_MENU_TRANSLATION_DIR}"
|
|
|
|
UKUI_MENU_DATA_DIR="${UKUI_MENU_DATA_DIR}"
|
2023-04-09 19:38:27 +08:00
|
|
|
UKUI_MENU_CONTEXT_MENU_DIR="${UKUI_MENU_CONTEXT_MENU_DIR}"
|
2022-12-26 15:21:43 +08:00
|
|
|
UKUI_MENU_EXTENSION_DIR="${UKUI_MENU_EXTENSION_DIR}"
|
2023-03-17 12:35:34 +08:00
|
|
|
UKUI_MENU_GLOBAL_CONFIG_FILE="${UKUI_MENU_GLOBAL_CONFIG_FILE}"
|
2022-12-02 15:58:09 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# ukui-menu的源码
|
|
|
|
set(SOURCE_FILES
|
|
|
|
src/main.cpp
|
2022-12-13 15:00:05 +08:00
|
|
|
src/commons.h src/commons.cpp
|
2022-12-12 10:02:44 +08:00
|
|
|
src/menu-dbus-service.cpp src/menu-dbus-service.h
|
2023-02-03 16:03:35 +08:00
|
|
|
src/ukui-menu-application.cpp src/ukui-menu-application.h
|
2022-12-23 11:08:16 +08:00
|
|
|
src/windows/menu-main-window.cpp src/windows/menu-main-window.h
|
2024-01-18 03:24:01 +08:00
|
|
|
src/settings/settings.cpp src/settings/settings.h
|
|
|
|
src/settings/user-config.cpp src/settings/user-config.h
|
2023-02-13 09:31:11 +08:00
|
|
|
src/utils/power-button.cpp src/utils/power-button.h
|
2023-02-20 17:23:08 +08:00
|
|
|
src/utils/app-manager.cpp src/utils/app-manager.h
|
2023-11-07 16:35:46 +08:00
|
|
|
src/utils/event-track.cpp src/utils/event-track.h
|
2023-11-30 14:01:43 +08:00
|
|
|
src/utils/sidebar-button-utils.cpp src/utils/sidebar-button-utils.h
|
2023-12-11 10:43:25 +08:00
|
|
|
src/extension/menu-extension-plugin.cpp src/extension/menu-extension-plugin.h
|
|
|
|
src/extension/menu-extension-loader.cpp src/extension/menu-extension-loader.h
|
2023-12-11 10:38:02 +08:00
|
|
|
src/extension/widget-extension.cpp src/extension/widget-extension.h
|
|
|
|
src/extension/context-menu-extension.cpp src/extension/context-menu-extension.h
|
2023-12-11 10:43:25 +08:00
|
|
|
src/extension/context-menu-manager.cpp src/extension/context-menu-manager.h
|
2023-12-11 10:38:02 +08:00
|
|
|
src/extension/widget-extension-model.cpp src/extension/widget-extension-model.h
|
|
|
|
src/extension/widget-model.cpp src/extension/widget-model.h
|
2023-12-11 10:43:25 +08:00
|
|
|
src/extension/menu/app-menu-plugin.cpp src/extension/menu/app-menu-plugin.h
|
2024-01-24 11:31:57 +08:00
|
|
|
src/extension/favorite/folder-model.cpp src/extension/favorite/folder-model.h
|
|
|
|
src/extension/favorite/favorites-model.cpp src/extension/favorite/favorites-model.h
|
2023-12-11 10:32:52 +08:00
|
|
|
src/extension/favorite/favorite-widget.cpp src/extension/favorite/favorite-widget.h
|
2024-01-19 11:10:07 +08:00
|
|
|
src/extension/favorite/favorites-config.cpp src/extension/favorite/favorites-config.h
|
2024-01-24 11:31:57 +08:00
|
|
|
src/extension/favorite/app-favorite-model.cpp src/extension/favorite/app-favorite-model.h
|
|
|
|
src/extension/favorite/favorite-context-menu.cpp src/extension/favorite/favorite-context-menu.h
|
2024-01-19 11:10:07 +08:00
|
|
|
src/extension/favorite/favorite-folder-helper.cpp src/extension/favorite/favorite-folder-helper.h
|
2024-01-24 11:31:57 +08:00
|
|
|
src/extension/favorite/favorite-extension-plugin.cpp src/extension/favorite/favorite-extension-plugin.h
|
2023-12-12 10:12:16 +08:00
|
|
|
src/libappdata/basic-app-model.cpp src/libappdata/basic-app-model.h
|
|
|
|
src/libappdata/app-database-interface.cpp src/libappdata/app-database-interface.h
|
2024-01-09 10:08:53 +08:00
|
|
|
src/libappdata/app-category-model.cpp src/libappdata/app-category-model.h
|
|
|
|
src/libappdata/combined-list-model.cpp src/libappdata/combined-list-model.h
|
|
|
|
src/libappdata/recently-installed-model.cpp src/libappdata/recently-installed-model.h
|
|
|
|
src/libappdata/app-page-backend.cpp src/libappdata/app-page-backend.h
|
|
|
|
src/libappdata/app-list-model.cpp src/libappdata/app-list-model.h
|
|
|
|
src/libappdata/app-list-plugin.cpp src/libappdata/app-list-plugin.h
|
|
|
|
src/libappdata/app-search-plugin.cpp src/libappdata/app-search-plugin.h
|
|
|
|
src/libappdata/app-category-plugin.cpp src/libappdata/app-category-plugin.h
|
2024-01-15 07:16:59 +08:00
|
|
|
src/libappdata/app-group-model.cpp src/libappdata/app-group-model.h
|
2023-12-11 10:38:02 +08:00
|
|
|
)
|
2022-12-02 15:58:09 +08:00
|
|
|
|
2023-09-12 10:24:28 +08:00
|
|
|
|
|
|
|
if(COMMAND qt_add_dbus_adaptor)
|
|
|
|
qt_add_dbus_adaptor(SOURCE_FILES data/org.ukui.menu.xml menu-dbus-service.h UkuiMenu::MenuDbusService)
|
|
|
|
else()
|
|
|
|
qt5_add_dbus_adaptor(SOURCE_FILES data/org.ukui.menu.xml menu-dbus-service.h UkuiMenu::MenuDbusService)
|
|
|
|
endif()
|
|
|
|
|
2023-04-09 11:22:39 +08:00
|
|
|
# library sources
|
2023-04-09 19:38:27 +08:00
|
|
|
set(LIBRARY_SOURCES
|
|
|
|
src/data-entity.cpp
|
2023-12-11 10:43:25 +08:00
|
|
|
src/extension/menu-extension-plugin.cpp
|
|
|
|
src/extension/widget-extension.cpp
|
|
|
|
src/extension/context-menu-extension.cpp
|
|
|
|
)
|
2023-04-09 19:38:27 +08:00
|
|
|
|
|
|
|
set(LIBRARY_HEADERS_DIR "/usr/include/${UKUI_MENU_LIBRARY_NAME}")
|
|
|
|
set(LIBRARY_HEADERS
|
|
|
|
src/data-entity.h
|
2023-12-11 10:38:02 +08:00
|
|
|
src/extension/menu-extension-plugin.h
|
|
|
|
src/extension/widget-extension.h
|
|
|
|
src/extension/context-menu-extension.h
|
2023-04-09 19:38:27 +08:00
|
|
|
)
|
2023-04-09 11:22:39 +08:00
|
|
|
|
2022-12-02 15:58:09 +08:00
|
|
|
# qrc文件
|
|
|
|
set(QRC_FILES qml/qml.qrc res/res.qrc)
|
|
|
|
# desktop file
|
|
|
|
set(DESKTOP_FILE data/ukui-menu.desktop)
|
2022-12-09 15:01:14 +08:00
|
|
|
set(GSETTING_FILE data/org.ukui.menu.settings.gschema.xml)
|
2023-03-28 17:25:12 +08:00
|
|
|
set(GLOBAL_CONFIG_FILE data/ukui-menu-global-config.conf)
|
2023-03-31 09:48:11 +08:00
|
|
|
set(DBUS_SERVICE_FILE data/org.ukui.menu.service)
|
2022-12-02 15:58:09 +08:00
|
|
|
# data files
|
|
|
|
#set(DATA_FILES data/xxx)
|
|
|
|
|
|
|
|
# 翻译文件
|
|
|
|
file(GLOB TS_FILES "${PROJECT_SOURCE_DIR}/translations/*.ts")
|
|
|
|
# 更新翻译并创建.qm文件
|
|
|
|
qt5_create_translation(QM_FILES ${PROJECT_SOURCE_DIR} ${TS_FILES})
|
|
|
|
# see https://cmake.org/cmake/help/v3.16/command/add_custom_command.html
|
|
|
|
# add_custom_target(GEN_TS ALL DEPENDS ${TS_FILES})
|
|
|
|
# add_custom_target(generate_qm ALL DEPENDS ${QM_FILES})
|
|
|
|
|
2023-12-11 10:43:25 +08:00
|
|
|
add_library(${UKUI_MENU_LIBRARY_TARGET} SHARED ${LIBRARY_SOURCES})
|
|
|
|
set_target_properties(${UKUI_MENU_LIBRARY_TARGET} PROPERTIES
|
2023-04-09 19:38:27 +08:00
|
|
|
VERSION ${UKUI_MENU_LIBRARY_VERSION}
|
|
|
|
SOVERSION ${UKUI_MENU_LIBRARY_API_VERSION}
|
2023-12-11 10:43:25 +08:00
|
|
|
OUTPUT_NAME "ukui-menu"
|
2023-04-09 19:38:27 +08:00
|
|
|
)
|
2023-12-11 10:43:25 +08:00
|
|
|
target_link_libraries(${UKUI_MENU_LIBRARY_TARGET} PRIVATE Qt5::Core Qt5::Gui Qt5::Widgets)
|
2023-04-09 11:22:39 +08:00
|
|
|
|
2022-12-02 15:58:09 +08:00
|
|
|
add_executable(
|
|
|
|
${PROJECT_NAME}
|
|
|
|
${QRC_FILES}
|
|
|
|
${QM_FILES}
|
|
|
|
${SOURCE_FILES}
|
|
|
|
)
|
|
|
|
|
2023-05-31 14:55:13 +08:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<CONFIG:Debug>:UKUI_MENU_LOG_FILE_DISABLE>)
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<CONFIG:Debug>:QT_QML_DEBUG>)
|
2022-12-02 15:58:09 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME}
|
|
|
|
PRIVATE
|
|
|
|
Qt5::Core
|
2022-12-07 13:49:52 +08:00
|
|
|
Qt5::Gui
|
2022-12-02 15:58:09 +08:00
|
|
|
Qt5::Quick
|
2022-12-09 09:08:16 +08:00
|
|
|
Qt5::Widgets
|
2022-12-02 15:58:09 +08:00
|
|
|
Qt5::DBus
|
|
|
|
Qt5::X11Extras
|
|
|
|
KF5::WindowSystem
|
2023-02-22 10:54:44 +08:00
|
|
|
Qt5Xdg
|
2022-12-08 14:37:02 +08:00
|
|
|
${SingleApplication}
|
2022-12-02 15:58:09 +08:00
|
|
|
${UKUI_MENU_EXTERNAL_LIBS}
|
2023-12-11 10:43:25 +08:00
|
|
|
${UKUI_MENU_LIBRARY_TARGET}
|
2024-03-07 20:29:07 +08:00
|
|
|
ukui-quick::platform
|
2022-12-02 15:58:09 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# 安装ukui-menu
|
|
|
|
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "/usr/bin")
|
2023-12-11 10:43:25 +08:00
|
|
|
install(TARGETS ${UKUI_MENU_LIBRARY_TARGET}
|
2023-04-09 19:38:27 +08:00
|
|
|
EXPORT ${UKUI_MENU_LIBRARY_NAME}
|
|
|
|
PUBLIC_HEADER DESTINATION ${LIBRARY_HEADERS_DIR}
|
|
|
|
LIBRARY DESTINATION "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
|
|
|
)
|
2022-12-02 15:58:09 +08:00
|
|
|
# 安装翻译文件
|
|
|
|
install(FILES ${QM_FILES} DESTINATION "${UKUI_MENU_TRANSLATION_DIR}")
|
|
|
|
# 安装desktop文件
|
|
|
|
install(FILES ${DESKTOP_FILE} DESTINATION "/etc/xdg/autostart")
|
2022-12-09 15:01:14 +08:00
|
|
|
install(FILES ${GSETTING_FILE} DESTINATION "/usr/share/glib-2.0/schemas")
|
2023-03-28 17:25:12 +08:00
|
|
|
install(FILES ${GLOBAL_CONFIG_FILE} DESTINATION "${UKUI_MENU_DATA_DIR}")
|
2023-03-31 09:48:11 +08:00
|
|
|
install(FILES ${DBUS_SERVICE_FILE} DESTINATION "/usr/share/dbus-1/services/")
|
2023-04-09 19:38:27 +08:00
|
|
|
install(FILES ${LIBRARY_HEADERS} DESTINATION "${LIBRARY_HEADERS_DIR}")
|
2023-04-09 11:22:39 +08:00
|
|
|
install(DIRECTORY "qml/org" DESTINATION "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/qt5/qml")
|
2023-04-09 19:38:27 +08:00
|
|
|
|
|
|
|
## 生成开发配置文件
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
target_include_directories(${UKUI_MENU_LIBRARY_NAME} PUBLIC $<INSTALL_INTERFACE:${LIBRARY_HEADERS_DIR}>)
|
|
|
|
|
|
|
|
configure_package_config_file(
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/${UKUI_MENU_LIBRARY_NAME}-config.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${UKUI_MENU_LIBRARY_NAME}-config.cmake"
|
|
|
|
INSTALL_DESTINATION ${CMAKE_CONFIG_INSTALL_DIR}
|
|
|
|
)
|
|
|
|
|
|
|
|
write_basic_package_version_file(
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/cmake/${UKUI_MENU_LIBRARY_NAME}-config-version.cmake
|
|
|
|
VERSION ${UKUI_MENU_LIBRARY_VERSION}
|
|
|
|
COMPATIBILITY SameMajorVersion
|
|
|
|
)
|
|
|
|
|
|
|
|
configure_package_config_file(
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/${UKUI_MENU_LIBRARY_NAME}.pc.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${UKUI_MENU_LIBRARY_NAME}.pc"
|
|
|
|
INSTALL_DESTINATION ${PC_INSTALL_DIR}
|
|
|
|
)
|
|
|
|
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/${UKUI_MENU_LIBRARY_NAME}.pc DESTINATION ${PC_INSTALL_DIR})
|
|
|
|
|
|
|
|
install(EXPORT ${UKUI_MENU_LIBRARY_NAME}
|
|
|
|
FILE ${UKUI_MENU_LIBRARY_NAME}-targets.cmake
|
|
|
|
DESTINATION ${CMAKE_CONFIG_INSTALL_DIR})
|
|
|
|
|
|
|
|
install(FILES
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/cmake/${UKUI_MENU_LIBRARY_NAME}-config.cmake
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/cmake/${UKUI_MENU_LIBRARY_NAME}-config-version.cmake
|
|
|
|
DESTINATION ${CMAKE_CONFIG_INSTALL_DIR})
|