-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
210 lines (168 loc) · 5.82 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
cmake_minimum_required(VERSION 3.7)
project(deepin-clone CXX)
set(HONEST_NAME deepin-clone-honest)
set(APP_NAME deepin-clone)
set(PLUGIN_NAME dfm-plugin-dim-file)
set(CMAKE_CXX_STANDARD_REQUIRED 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(APP_SOURCE_DIR ${CMAKE_SOURCE_DIR}/app)
if (NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast")
# generate policy file translations
execute_process (
COMMAND deepin-policy-ts-convert policy2ts com.deepin.pkexec.deepin-clone.policy.tmp translations
WORKING_DIRECTORY ${APP_SOURCE_DIR}
)
# generate back to policy file
execute_process (
COMMAND deepin-policy-ts-convert ts2policy com.deepin.pkexec.deepin-clone.policy.tmp translations com.deepin.pkexec.deepin-clone.policy
RESULT_VARIABLE POLICY_FILE_GENERATED
WORKING_DIRECTORY ${APP_SOURCE_DIR}
)
# fallback
if (NOT ${POLICY_FILE_GENERATED} EQUAL 0)
execute_process(COMMAND cp com.deepin.pkexec.deepin-clone.policy.tmp com.deepin.pkexec.deepin-clone.policy WORKING_DIRECTORY ${APP_SOURCE_DIR})
endif ()
# generate qm
execute_process(COMMAND bash "translate_generation.sh"
WORKING_DIRECTORY ${APP_SOURCE_DIR})
execute_process(COMMAND bash "translate_ts2desktop.sh"
WORKING_DIRECTORY ${APP_SOURCE_DIR})
else ()
message("Building debug mode, translation files will not generated")
endif ()
# Install settings
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX /usr)
endif()
find_package(PkgConfig REQUIRED)
find_package(Qt5 COMPONENTS Core REQUIRED)
add_definitions(-DQT_MESSAGELOGCONTEXT)
add_definitions(-DHOST_ARCH_${CMAKE_SYSTEM_PROCESSOR})
add_definitions(-DHOST_ARCH="${CMAKE_SYSTEM_PROCESSOR}")
file(GLOB_RECURSE WIDGETS_SRCS
"app/src/widgets/*.h"
"app/src/widgets/*.cpp"
"app/src/widgets/qss.qrc"
"app/sources.qrc"
)
file(GLOB_RECURSE FIXBOOT_SRCS
"app/src/fixboot/*.h"
"app/src/fixboot/*.cpp"
"app/src/fixboot/*.qrc"
)
file(GLOB_RECURSE CORELIB_SRCS
"app/src/corelib/*.h"
"app/src/corelib/*.cpp"
)
file(GLOB_RECURSE DFM_PLUGIN_SRCS
"dfm_plugin/*.h"
"dfm_plugin/*.cpp"
)
set(APP_SRCS
app/src/main.cpp
app/src/dglobal.h
app/src/commandlineparser.cpp
app/src/commandlineparser.h
${FIXBOOT_SRCS}
${CORELIB_SRCS}
)
set(APP_INCLUDE
${Qt5Core_INCLUDE_DIRS}
)
set(APP_LIBRARY
${Qt5Core_LIBRARIES}
)
if(NOT DEFINED DISABLE_GUI OR NOT DEFINED DISABLE_DTK)
add_definitions(-DDEEPIN_CLONE_UID="DEEPIN_CLONE_UID"
-DDEEPIN_CLONE_OPEN_DIALOG="DEEPIN_CLONE_OPEN_DIALOG"
-DDEEPIN_CLONE_OPEN_URL="DEEPIN_CLONE_OPEN_URL"
-DDEEPIN_CLONE_PARENT_WINID="DEEPIN_CLONE_PARENT_WINID"
-DDEEPIN_CLONE_TITLE="DEEPIN_CLONE_TITLE"
-DDEEPIN_CLONE_FILE_NAME="DEEPIN_CLONE_FILE_NAME"
-DDEEPIN_CLONE_NAME_FILTER="DEEPIN_CLONE_NAME_FILTER"
-DDEEPIN_CLONE_GET_FILE="DEEPIN_CLONE_GET_FILE"
-DDEEPIN_CLONE_SHOW_FILE="DEEPIN_CLONE_SHOW_FILE")
add_definitions(-DENABLE_GUI)
find_package(Qt5 COMPONENTS Widgets REQUIRED)
find_package(DtkWidget REQUIRED)
#HONEST_NAME start
add_executable(${HONEST_NAME}
honest_child/main.cpp
)
target_include_directories(${HONEST_NAME} PUBLIC
${DtkWidget_INCLUDE_DIRS}
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
)
target_link_libraries(${HONEST_NAME} PRIVATE
${DtkWidget_LIBRARIES}
${Qt5Core_LIBRARIES}
${Qt5Widgets_LIBRARIES}
)
install(TARGETS ${HONEST_NAME} DESTINATION bin)
#HONEST_NAME end
#APP_NAME start
list(APPEND APP_SRCS
${WIDGETS_SRCS}
)
list(APPEND APP_INCLUDE
${DtkWidget_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${Qt5Gui_PRIVATE_INCLUDE_DIRS}
)
list(APPEND APP_LIBRARY
${DtkWidget_LIBRARIES}
${Qt5Widgets_LIBRARIES}
)
#APP_NAME end
else()
add_definitions(-DDISABLE_DTK)
add_definitions(-DDISABLE_GUI)
endif()
if(NOT DEFINED DISABLE_DFM_PLUGIN)
find_package(Qt5 COMPONENTS Widgets REQUIRED)
pkg_check_modules(DdeFileManagerInterface REQUIRED dde-file-manager)
add_library(${PLUGIN_NAME} SHARED ${DFM_PLUGIN_SRCS} ${CORELIB_SRCS})
target_include_directories(${PLUGIN_NAME} PUBLIC
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${Qt5Gui_PRIVATE_INCLUDE_DIRS}
${DdeFileManagerInterface_INCLUDE_DIRS}
)
target_link_libraries(${PLUGIN_NAME} PRIVATE
${Qt5Core_LIBRARIES}
${Qt5Widgets_LIBRARIES}
${DdeFileManagerInterface_LIBRARIES}
)
if(NOT DEFINED LIB_INSTALL_DIR)
set(LIB_INSTALL_DIR lib/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu)
endif()
if(NOT DEFINED DFM_PLUGIN_DIR)
set(DFM_PLUGIN_DIR ${LIB_INSTALL_DIR}/dde-file-manager/plugins/controllers)
endif()
install(TARGETS ${PLUGIN_NAME} DESTINATION ${DFM_PLUGIN_DIR})
endif()
add_executable(${APP_NAME}
${APP_SRCS}
)
target_include_directories(${APP_NAME} PUBLIC
${APP_INCLUDE}
)
target_link_libraries(${APP_NAME} PRIVATE
${APP_LIBRARY}
)
install(TARGETS ${APP_NAME} DESTINATION sbin)
#mimetype
install(FILES app/mimetype/deepin-clone.xml DESTINATION share/mime/packages)
install(FILES app/mimetype/application-x-deepinclone-dim.svg DESTINATION share/icons/hicolor/scalable/mimetypes)
#policy file
install(FILES app/com.deepin.pkexec.deepin-clone.policy DESTINATION share/polkit-1/actions)
#bin
install(FILES app/deepin-clone-ionice DESTINATION sbin)
install(FILES app/deepin-clone-pkexec DESTINATION bin)
#qm files
file(GLOB QM_FILES "app/translations/*.qm")
install(FILES ${QM_FILES} DESTINATION share/${APP_NAME}/translations)
install(FILES app/deepin-clone.desktop DESTINATION share/applications)