-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
122 lines (93 loc) · 3.66 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
cmake_minimum_required(VERSION 3.5)
# set(PROJECT_NAME lingmo-control-center)
set(PROJECT_NAME lingmo-settings)
project(${PROJECT_NAME})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "-fcoroutines ${CMAKE_CXX_FLAGS}")
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# set(QT Core Gui Widgets Network WebEngine Quick QuickControls2 X11Extras DBus Xml Concurrent LinguistTools)
set(QT Core Gui Widgets Network Quick QuickControls2 DBus Xml Concurrent LinguistTools)
find_package(Qt6 REQUIRED ${QT})
find_package(X11 REQUIRED)
find_package(Freetype REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(Libcrypt REQUIRED)
find_package(KF6NetworkManagerQt REQUIRED)
find_package(KF6ModemManagerQt REQUIRED)
find_package(KF6Config)
find_package(LingmoLogger REQUIRED)
pkg_search_module(FontConfig REQUIRED fontconfig IMPORTED_TARGET)
pkg_search_module(ICU REQUIRED icu-i18n)
include_directories(${ICU_INCLUDE_DIRS})
file(GLOB_RECURSE SRCS_R "include/*.h" "src/*.c" "src/*.cpp" "src/*.h")
foreach(filepath ${SRCS_R})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
list(APPEND SRCS ${filename})
endforeach()
set(RESOURCES
src/resources.qrc
)
qt6_add_dbus_adaptor(DBUS_SOURCES
src/com.lingmo.SettingsUI.xml
src/application.h Application)
set_source_files_properties(${DBUS_SOURCES} PROPERTIES SKIP_AUTOGEN ON)
# qt6_add_dbus_interface(DBUS_SOURCES src/datetime/org.freedesktop.timedate1.xml timedated_interface)
add_executable(${PROJECT_NAME} ${DBUS_SOURCES} ${SRCS} ${RESOURCES})
target_include_directories(${PROJECT_NAME} PUBLIC "include" "src")
target_link_libraries(${PROJECT_NAME}
Qt6::Core
Qt6::Widgets
Qt6::Quick
Qt6::QuickControls2
Qt6::DBus
Qt6::Xml
Qt6::GuiPrivate
Qt6::Concurrent
Qt6::Network
KF6::NetworkManagerQt
KF6::ModemManagerQt
KF6::ConfigCore
PkgConfig::FontConfig
${FREETYPE_LIBRARIES}
${ICU_LDFLAGS}
Libcrypt::Libcrypt
${X11_LIBRARIES}
X11::X11
X11::Xi
X11::Xcursor
LingmoLogger
)
file(GLOB TS_FILES translations/*.ts)
foreach(filepath ${TS_FILES})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
list(APPEND ts_files_replaced ${filename})
endforeach()
qt6_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${ts_files_replaced})
add_custom_target(translations ALL DEPENDS ${QM_FILES} SOURCES ${TS_FILES})
foreach(_ts_file ${TS_FILES})
execute_process(
COMMAND ${LUPDATE_EXECUTABLE} -recursive ${CMAKE_SOURCE_DIR} -ts ${_ts_file})
execute_process(COMMAND lrelease ${_ts_file})
endforeach()
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES
lingmo-settings.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications/
COMPONENT Runtime
)
install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/translations)
# 安装工具脚本
install(DIRECTORY "tools" DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
# dev files
file(GLOB EXPORT_HEADERS LIST_DIRECTORIES true "include/*")
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
install(DIRECTORY ${EXPORT_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR})
install(FILES "tools/auto-install-policy/org.lingmo.settings.update.lminstall.policy" DESTINATION "${CMAKE_INSTALL_DATADIR}/polkit-1/actions/")