!61 panel中的CMakeLists文件优化

Merge pull request !61 from 卜萧庆/cmakereview
This commit is contained in:
卜萧庆 2023-04-15 06:14:58 +00:00 committed by Gitee
commit a4e6611bc7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 26 additions and 84 deletions

View File

@ -1,11 +1,9 @@
set(PROJECT ukui-panel)
project(ukui-panel LANGUAGES CXX)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
add_subdirectory(common)
#add_subdirectory(xdg)
#add_subdirectory(common_fun)
set(PRIV_HEADERS
panelpluginsmodel.h
@ -24,12 +22,10 @@ set(PUB_HEADERS
pluginsettings.h
iukuipanelplugin.h
iukuipanel.h
common/ukuisettings.h
common/ukuiplugininfo.h
common/ukuitranslator.h
common/common.h
common/ukuigridlayout.h
common/ukuiglobals.h
common_fun/listengsettings.h
@ -49,11 +45,9 @@ set(SOURCES
plugin.cpp
pluginsettings.cpp
contextmenu.cpp
common/ukuiplugininfo.cpp
common/ukuisettings.cpp
common/ukuitranslator.cpp
common/ukuigridlayout.cpp
common_fun/listengsettings.cpp
common_fun/ukuipanel_infomation.cpp
@ -62,12 +56,17 @@ set(SOURCES
customstyle.cpp
)
file(GLOB CONFIG_FILES resources/*.conf resources/*.qss)
############################################
set(PLUGIN_DESKTOPS_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/ukui/${PROJECT_NAME}")
set(QTX_LIBRARIES Qt5::Widgets Qt5::Xml Qt5::DBus)
set(UKUI_PANEL_MAN ../man/ukui-panel.1)
set(DESKTOP_FILE resources/ukui-panel.desktop)
set(IMAGE_DIR ./img/)
set(GSETTINGS_FILE resources/org.ukui.panel.settings.gschema.xml)
set(PANEL_GLOBAL_CONFIG_FILES resources/panel-commission.sh resources/panel-commission.ini
resources/ukui-panel-reset.sh resources/ukui-panel-config.sh)
file(GLOB UKUI_PANEL_CONFIG_FILES resources/*.conf)
add_definitions(-DCOMPILE_UKUI_PANEL)
set(PLUGIN_DESKTOPS_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/ukui/${PROJECT}")
add_definitions(-DPLUGIN_DESKTOPS_DIR=\"${PLUGIN_DESKTOPS_DIR}\")
if (WITH_SCREENSAVER_FALLBACK)
@ -75,38 +74,18 @@ if (WITH_SCREENSAVER_FALLBACK)
add_definitions(-DWITH_SCREENSAVER_FALLBACK "-DUKUI_LOCK_DESKTOP=\"${CMAKE_INSTALL_FULL_DATAROOTDIR}/applications/ukui-lockscreen.desktop\"")
endif ()
project(${PROJECT})
set(QTX_LIBRARIES Qt5::Widgets Qt5::Xml Qt5::DBus)
#Translations
#ukui_translate_ts(QM_FILES SOURCES
# UPDATE_TRANSLATIONS
# ${UPDATE_TRANSLATIONS}
# SOURCES
# ${PUB_HEADERS}
# ${PRIV_HEADERS}
# ${SOURCES}
# ${UI}
# INSTALL_DIR
# "${UKUI_TRANSLATIONS_DIR}/${PROJECT_NAME}"
#)
ukui_app_translation_loader(SOURCES ${PROJECT_NAME})
set_property(SOURCE ${DBUS_INTERFACE_SRCS} ${DBUS_ADAPTOR_SRCS} PROPERTY SKIP_AUTOGEN ON)
list(APPEND SOURCES "${DBUS_INTERFACE_SRCS}" "${DBUS_ADAPTOR_SRCS}")
add_executable(${PROJECT}
add_executable(${PROJECT_NAME}
${PUB_HEADERS}
${PRIV_HEADERS}
${QM_FILES}
${SOURCES}
${UI}
)
find_package(PkgConfig)
pkg_check_modules(GLIB2 REQUIRED glib-2.0)
pkg_check_modules(GIO2 REQUIRED gio-2.0)
@ -121,7 +100,7 @@ find_package(KF5Screen)
pkg_check_modules(KYSDKWAYLANDHELPER_PKG kysdk-waylandhelper)
#ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
target_link_libraries(${PROJECT}
target_link_libraries(${PROJECT_NAME}
${LIBRARIES}
${QTX_LIBRARIES}
KF5::WindowSystem
@ -134,70 +113,33 @@ target_link_libraries(${PROJECT}
KF5::Screen
)
target_include_directories(${PROJECT} PRIVATE ${KYSDKWAYLANDHELPER_PKG_INCLUDE_DIRS})
target_link_directories(${PROJECT} PRIVATE ${KYSDKWAYLANDHELPER_PKG_LIBRARY_DIRS} KF5::WindowSystem)
target_link_libraries(${PROJECT} ${KYSDKWAYLANDHELPER_PKG_LIBRARIES})
target_include_directories(${PROJECT_NAME} PRIVATE ${KYSDKWAYLANDHELPER_PKG_INCLUDE_DIRS})
target_link_directories(${PROJECT_NAME} PRIVATE ${KYSDKWAYLANDHELPER_PKG_LIBRARY_DIRS} KF5::WindowSystem)
target_link_libraries(${PROJECT_NAME} ${KYSDKWAYLANDHELPER_PKG_LIBRARIES})
target_compile_definitions(${PROJECT}
target_compile_definitions(${PROJECT_NAME}
PRIVATE
"UKUI_RELATIVE_SHARE_DIR=\"${UKUI_RELATIVE_SHARE_DIR}\""
#"UKUI_SHARE_DIR=\"${UKUI_SHARE_DIR}\""
"UKUI_RELATIVE_SHARE_TRANSLATIONS_DIR=\"${UKUI_RELATIVE_TRANSLATIONS_DIR}\""
"UKUI_SHARE_TRANSLATIONS_DIR=\"${UKUI_TRANSLATIONS_DIR}\""
"UKUI_GRAPHICS_DIR=\"${UKUI_GRAPHICS_DIR}\""
#"UKUI_ETC_XDG_DIR=\"${UKUI_ETC_XDG_DIR}\""
"UKUI_DATA_DIR=\"${UKUI_DATA_DIR}\""
"UKUI_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\""
#"UKUI_VERSION=\"${UKUI_VERSION}\""
#"COMPILE_LIBUKUI"
#"QT_USE_QSTRINGBUILDER"
#"QT_NO_CAST_FROM_ASCII"
#"QT_NO_CAST_TO_ASCII"
#"QT_NO_URL_CAST_FROM_STRING"
#"QT_NO_CAST_FROM_BYTEARRAY"
#"$<$<CONFIG:Release>:QT_NO_DEBUG_OUTPUT>"
#"$<$<CONFIG:Release>:QT_NO_WARNING_OUTPUT>"
)
install(TARGETS ${PROJECT} RUNTIME DESTINATION bin)
install(FILES ${CONFIG_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/ukui)
#ukui-panel
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
#DESKTOP FILE
install(FILES ${DESKTOP_FILE} DESTINATION "/etc/xdg/autostart/" COMPONENT Runtime)
install(FILES ${UKUI_PANEL_CONFIG_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/ukui)
install(FILES ${PUB_HEADERS} DESTINATION include/ukui)
install(FILES
../man/ukui-panel.1
DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
COMPONENT Runtime
)
install(FILES
resources/ukui-panel.desktop
DESTINATION "/etc/xdg/autostart/"
COMPONENT Runtime
)
install(DIRECTORY
./img/
DESTINATION "${PACKAGE_DATA_DIR}/panel/img"
)
install(FILES
resources/ukui-panel_zh_CN.qm resources/ukui-panel_zh_CN.ts resources/ukui-panel_tr.ts
DESTINATION "${PACKAGE_DATA_DIR}/panel/resources"
COMPONENT Runtime
)
install(FILES
resources/org.ukui.panel.settings.gschema.xml
DESTINATION "/usr/share/glib-2.0/schemas"
COMPONENT Runtime
)
install(FILES
resources/panel-commission.sh resources/panel-commission.ini resources/ukui-panel-reset.sh resources/ukui-panel-config.sh
DESTINATION "/usr/share/ukui/ukui-panel"
COMPONENT Runtime
install(FILES ${UKUI_PANEL_MAN} DESTINATION "${CMAKE_INSTALL_MANDIR}/man1" COMPONENT Runtime)
install(FILES ${GSETTINGS_FILE} DESTINATION "/usr/share/glib-2.0/schemas" COMPONENT Runtime)
install(FILES ${PANEL_GLOBAL_CONFIG_FILES} DESTINATION "/usr/share/ukui/ukui-panel" COMPONENT Runtime
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ GROUP_WRITE WORLD_READ WORLD_WRITE WORLD_EXECUTE
GROUP_EXECUTE GROUP_READ
)
install(DIRECTORY ${IMAGE_DIR} DESTINATION "${PACKAGE_DATA_DIR}/panel/img")
set(PLUGIN panel)
include(../cmake/UkuiPluginTranslationTs.cmake)