ukui-menu/CMakeLists.txt

173 lines
6.8 KiB
CMake
Raw Normal View History

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组件
find_package(Qt5 COMPONENTS
Core Gui Quick Widgets LinguistTools DBus X11Extras
2022-12-02 15:58:09 +08:00
REQUIRED)
# 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)
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
set(UKUI_MENU_PC_PKGS glib-2.0 gsettings-qt x11 kysdk-waylandhelper ukui-search)
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}")
# include single-application
add_subdirectory(3rd-parties/SingleApplication)
# static lib of single-application.
set(SingleApplication "SingleApplication")
2022-12-02 15:58:09 +08:00
# include文件夹
include_directories(src)
2023-03-16 14:30:46 +08:00
include_directories(src/menu)
2022-12-02 15:58:09 +08:00
include_directories(src/model)
include_directories(src/appdata)
include_directories(src/settings)
include_directories(src/uiconfig)
include_directories(src/windows)
include_directories(src/utils)
2022-12-02 15:58:09 +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)
#message(STATUS "QML_IMPORT_PATH: ${QML_IMPORT_PATH}")
2022-12-02 15:58:09 +08:00
# 基础设置
set(UKUI_MENU_DATA_DIR "/usr/share/ukui-menu")
set(UKUI_MENU_TRANSLATION_DIR "${UKUI_MENU_DATA_DIR}/translations")
set(UKUI_MENU_EXTENSION_DIR "${UKUI_MENU_DATA_DIR}/extensions")
set(UKUI_MENU_GLOBAL_CONFIG_FILE "${UKUI_MENU_DATA_DIR}/ukui-menu-global-config.conf")
set(UKUI_MENU_LIBRARY_NAME "ukui-menu-extension")
# 子项目
add_subdirectory(extension/recent-file)
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}"
UKUI_MENU_EXTENSION_DIR="${UKUI_MENU_EXTENSION_DIR}"
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
src/commons.h src/commons.cpp
2022-12-12 10:02:44 +08:00
src/menu-dbus-service.cpp src/menu-dbus-service.h
src/ukui-menu-application.cpp src/ukui-menu-application.h
src/model/app-model.cpp src/model/app-model.h
src/model/label-model.cpp src/model/label-model.h
src/model/app-group-model.cpp src/model/app-group-model.h
src/model/model-manager.cpp src/model/model-manager.h
2023-03-28 17:25:12 +08:00
src/model/folder-model.cpp src/model/folder-model.h
src/settings/settings.cpp src/settings/settings.h
src/uiconfig/color-helper.cpp src/uiconfig/color-helper.h
2022-12-12 17:00:30 +08:00
src/uiconfig/theme-palette.cpp src/uiconfig/theme-palette.h
src/windows/menu-main-window.cpp src/windows/menu-main-window.h
2022-12-28 15:38:44 +08:00
src/appdata/data-provider-plugin-iface.h
src/appdata/app-data-manager.cpp src/appdata/app-data-manager.h
src/appdata/app-folder-helper.cpp src/appdata/app-folder-helper.h
src/appdata/app-icon-provider.cpp src/appdata/app-icon-provider.h
src/appdata/data-provider-manager.cpp src/appdata/data-provider-manager.h
2023-01-16 15:17:54 +08:00
src/appdata/plugin/all-app-data-provider.cpp src/appdata/plugin/all-app-data-provider.h
src/appdata/plugin/app-search-plugin.cpp src/appdata/plugin/app-search-plugin.h
2023-03-01 18:03:50 +08:00
src/appdata/plugin/app-category-plugin.cpp src/appdata/plugin/app-category-plugin.h
2023-03-03 11:20:02 +08:00
src/appdata/plugin/app-letter-sort-plugin.cpp src/appdata/plugin/app-letter-sort-plugin.h
src/extension/menu-extension.cpp src/extension/menu-extension.h
src/extension/extensions/favorite-extension.cpp src/extension/extensions/favorite-extension.h
src/utils/app-page-header-utils.cpp src/utils/app-page-header-utils.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-03-16 14:30:46 +08:00
src/menu/menu-manager.cpp src/menu/menu-manager.h
2023-03-17 16:37:09 +08:00
src/items/theme-icon.h src/items/theme-icon.cpp
2022-12-02 15:58:09 +08:00
)
# library sources
set(LIBRARY_SOURCES src/extension/menu-extension-iface.h)
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)
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})
add_library(${UKUI_MENU_LIBRARY_NAME} SHARED ${LIBRARY_SOURCES})
SET_TARGET_PROPERTIES(${UKUI_MENU_LIBRARY_NAME} PROPERTIES VERSION 1.0.0 SOVERSION 0)
target_link_libraries(${UKUI_MENU_LIBRARY_NAME} PRIVATE Qt5::Core)
2022-12-02 15:58:09 +08:00
add_executable(
${PROJECT_NAME}
${QRC_FILES}
${QM_FILES}
${SOURCE_FILES}
)
target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_link_libraries(${PROJECT_NAME}
PRIVATE
Qt5::Core
Qt5::Gui
2022-12-02 15:58:09 +08:00
Qt5::Quick
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
${SingleApplication}
2022-12-02 15:58:09 +08:00
${UKUI_MENU_EXTERNAL_LIBS}
${UKUI_MENU_LIBRARY_NAME}
2022-12-02 15:58:09 +08:00
)
# 安装ukui-menu
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "/usr/bin")
install(TARGETS ${UKUI_MENU_LIBRARY_NAME} 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")
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/")
install(DIRECTORY "qml/org" DESTINATION "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/qt5/qml")