118 lines
3.6 KiB
CMake
118 lines
3.6 KiB
CMake
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
|
|
REQUIRED)
|
|
|
|
# find kde framework components
|
|
# see: https://api.kde.org/frameworks/index.html > KWindowSystem
|
|
find_package(KF5WindowSystem REQUIRED)
|
|
|
|
# 查找其他组件
|
|
# 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 gio-unix-2.0 gsettings-qt x11)
|
|
|
|
foreach(external_libs IN ITEMS ${UKUI_MENU_PC_PKGS})
|
|
pkg_check_modules(${external_libs} REQUIRED ${external_libs})
|
|
if(${${external_libs}_FOUND})
|
|
include_directories(${${external_libs}_INCLUDE_DIRS})
|
|
list(APPEND UKUI_MENU_EXTERNAL_LIBS ${${external_libs}_LIBRARIES})
|
|
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")
|
|
|
|
# include文件夹
|
|
include_directories(src)
|
|
include_directories(src/model)
|
|
include_directories(src/appdata)
|
|
include_directories(src/settings)
|
|
include_directories(src/uiconfig)
|
|
|
|
# 基础设置
|
|
set(UKUI_MENU_DATA_DIR "/usr/share/ukui-menu")
|
|
set(UKUI_MENU_TRANSLATION_DIR "${UKUI_MENU_DATA_DIR}/translations")
|
|
|
|
# 宏定义
|
|
add_compile_definitions(UKUI_MENU_TRANSLATION_DIR="${UKUI_MENU_TRANSLATION_DIR}"
|
|
UKUI_MENU_DATA_DIR="${UKUI_MENU_DATA_DIR}"
|
|
)
|
|
|
|
# ukui-menu的源码
|
|
set(SOURCE_FILES
|
|
src/main.cpp
|
|
src/commons.h
|
|
src/menu-dbus-service.cpp src/menu-dbus-service.h
|
|
src/model/model.cpp src/model/model.h
|
|
src/settings/settings.cpp src/settings/settings.h
|
|
src/uiconfig/color-helper.cpp src/uiconfig/color-helper.h
|
|
src/ukui-menu-application.cpp src/ukui-menu-application.h
|
|
)
|
|
|
|
# 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)
|
|
# 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_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
|
|
Qt5::Quick
|
|
Qt5::Widgets
|
|
Qt5::DBus
|
|
Qt5::X11Extras
|
|
KF5::WindowSystem
|
|
${SingleApplication}
|
|
${UKUI_MENU_EXTERNAL_LIBS}
|
|
)
|
|
|
|
# 安装ukui-menu
|
|
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "/usr/bin")
|
|
# 安装翻译文件
|
|
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")
|