forked from MatsuriDayo/nekoray
-
Notifications
You must be signed in to change notification settings - Fork 31
/
CMakeLists.txt
255 lines (198 loc) · 6.64 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
cmake_minimum_required(VERSION 3.5)
project(nekoray VERSION 0.1 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 REQUIRED COMPONENTS Widgets Network Svg LinguistTools QuickControls2)
if (NKR_CROSS)
set_property(TARGET Qt6::moc PROPERTY IMPORTED_LOCATION /usr/bin/moc)
set_property(TARGET Qt6::uic PROPERTY IMPORTED_LOCATION /usr/bin/uic)
set_property(TARGET Qt6::rcc PROPERTY IMPORTED_LOCATION /usr/bin/rcc)
set_property(TARGET Qt6::lrelease PROPERTY IMPORTED_LOCATION /usr/bin/lrelease)
set_property(TARGET Qt6::lupdate PROPERTY IMPORTED_LOCATION /usr/bin/lupdate)
endif ()
#### Platform Variables ####
if (APPLE)
include("cmake/macos/macos.cmake")
elseif (WIN32)
include("cmake/windows/windows.cmake")
else ()
include("cmake/linux/linux.cmake")
endif ()
#### default prefix path ####
list(APPEND NKR_LIBS ${CMAKE_SOURCE_DIR}/libs/deps/built)
list(APPEND CMAKE_PREFIX_PATH ${NKR_LIBS})
if(WIN32)
list(APPEND CMAKE_PREFIX_PATH "libs/deps/built/x64-windows-static")
endif ()
add_definitions(-DCURL_STATICLIB)
message("[CMAKE_PREFIX_PATH] ${CMAKE_PREFIX_PATH}")
# for some cross toolchain
list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH})
message("[CMAKE_FIND_ROOT_PATH] ${CMAKE_FIND_ROOT_PATH}")
#### NKR ####
include("cmake/print.cmake")
include("cmake/nkr.cmake")
find_package(Threads)
if (NKR_PACKAGE OR NKR_PACKAGE_MACOS)
nkr_add_compile_definitions(NKR_CPP_USE_APPDATA)
endif ()
include("cmake/myproto.cmake")
list(APPEND NKR_EXTERNAL_TARGETS myproto)
find_package(yaml-cpp CONFIG REQUIRED) # only Release is built
list(APPEND NKR_EXTERNAL_TARGETS yaml-cpp)
find_package(ZXing CONFIG REQUIRED)
list(APPEND NKR_EXTERNAL_TARGETS ZXing::ZXing)
find_package(cpr REQUIRED)
list(APPEND NKR_EXTERNAL_TARGETS cpr::cpr)
set(QHOTKEY_INSTALL OFF)
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(3rdparty/QHotkey)
list(APPEND NKR_EXTERNAL_TARGETS qhotkey)
# Sources
set(PROJECT_SOURCES
${PLATFORM_SOURCES}
main/main.cpp
main/NekoGui.cpp
main/NekoGui_Utils.cpp
main/HTTPRequestHelper.cpp
3rdparty/base64.cpp
3rdparty/qrcodegen.cpp
3rdparty/QtExtKeySequenceEdit.cpp
3rdparty/qv2ray/v2/ui/LogHighlighter.cpp
3rdparty/qv2ray/v2/ui/QvAutoCompleteTextEdit.cpp
3rdparty/qv2ray/v2/ui/widgets/common/QJsonModel.cpp
3rdparty/qv2ray/v2/ui/widgets/editors/w_JsonEditor.cpp
3rdparty/qv2ray/v2/ui/widgets/editors/w_JsonEditor.hpp
3rdparty/qv2ray/v2/ui/widgets/editors/w_JsonEditor.ui
3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.cpp
rpc/gRPC.cpp
db/Database.cpp
db/traffic/TrafficLooper.cpp
db/ProfileFilter.cpp
db/ConfigBuilder.cpp
fmt/AbstractBean.cpp
fmt/Bean2CoreObj_box.cpp
fmt/Bean2External.cpp
fmt/Bean2Link.cpp
fmt/Link2Bean.cpp
fmt/ChainBean.hpp # translate
sub/GroupUpdater.cpp
sys/ExternalProcess.cpp
sys/AutoRun.cpp
ui/ThemeManager.cpp
ui/Icon.cpp
ui/mainwindow_grpc.cpp
ui/mainwindow.cpp
ui/mainwindow.h
ui/mainwindow.ui
ui/edit/dialog_edit_profile.h
ui/edit/dialog_edit_profile.cpp
ui/edit/dialog_edit_profile.ui
ui/edit/dialog_edit_group.h
ui/edit/dialog_edit_group.cpp
ui/edit/dialog_edit_group.ui
ui/edit/edit_chain.h
ui/edit/edit_chain.cpp
ui/edit/edit_chain.ui
ui/edit/edit_socks_http.h
ui/edit/edit_socks_http.cpp
ui/edit/edit_socks_http.ui
ui/edit/edit_shadowsocks.h
ui/edit/edit_shadowsocks.cpp
ui/edit/edit_shadowsocks.ui
ui/edit/edit_vmess.h
ui/edit/edit_vmess.cpp
ui/edit/edit_vmess.ui
ui/edit/edit_trojan_vless.h
ui/edit/edit_trojan_vless.cpp
ui/edit/edit_trojan_vless.ui
ui/edit/edit_naive.h
ui/edit/edit_naive.cpp
ui/edit/edit_naive.ui
ui/edit/edit_quic.h
ui/edit/edit_quic.cpp
ui/edit/edit_quic.ui
ui/edit/edit_custom.h
ui/edit/edit_custom.cpp
ui/edit/edit_custom.ui
ui/edit/edit_wireguard.h
ui/edit/edit_wireguard.cpp
ui/edit/edit_wireguard.ui
ui/dialog_basic_settings.cpp
ui/dialog_basic_settings.h
ui/dialog_basic_settings.ui
ui/dialog_manage_groups.cpp
ui/dialog_manage_groups.h
ui/dialog_manage_groups.ui
ui/dialog_manage_routes.cpp
ui/dialog_manage_routes.h
ui/dialog_manage_routes.ui
ui/dialog_vpn_settings.cpp
ui/dialog_vpn_settings.h
ui/dialog_vpn_settings.ui
ui/dialog_hotkey.cpp
ui/dialog_hotkey.h
ui/dialog_hotkey.ui
ui/widget/ProxyItem.cpp
ui/widget/ProxyItem.h
ui/widget/ProxyItem.ui
ui/widget/GroupItem.cpp
ui/widget/GroupItem.h
ui/widget/GroupItem.ui
ui/widget/RouteItem.cpp
ui/widget/RouteItem.h
ui/widget/RouteItem.ui
res/neko.qrc
${QV2RAY_RC}
db/RouteEntity.h
db/RouteEntity.cpp
res/darkstyle.qrc
ui/edit/edit_ssh.cpp
ui/edit/edit_ssh.h
ui/edit/edit_ssh.ui
fmt/SSHBean.h
)
# Qt exe
qt_add_executable(nekoray
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Target
set_property(TARGET nekoray PROPERTY AUTOUIC ON)
set_property(TARGET nekoray PROPERTY AUTOMOC ON)
set_property(TARGET nekoray PROPERTY AUTORCC ON)
# Target Source macOS
set(MACOSX_ICON ${CMAKE_SOURCE_DIR}/res/nekoray.icns)
if (APPLE)
target_sources(nekoray PRIVATE ${MACOSX_ICON})
endif ()
set_target_properties(nekoray PROPERTIES
MACOSX_BUNDLE_ICON_FILE "nekoray.icns"
RESOURCE ${MACOSX_ICON}
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/MacOSXBundleInfo.plist
MACOSX_BUNDLE_GUI_IDENTIFIER moe.nekoray.macosx
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
# Target Source Translations
set(TS_FILES
translations/zh_CN.ts
translations/fa_IR.ts
translations/ru_RU.ts
)
set(LUPDATE_OPTIONS
-locations none -no-obsolete
)
qt_add_lupdate(nekoray TS_FILES ${TS_FILES} OPTIONS ${LUPDATE_OPTIONS})
qt_add_lrelease(nekoray TS_FILES ${TS_FILES} QM_FILES_OUTPUT_VARIABLE QM_FILES)
configure_file(translations/translations.qrc ${CMAKE_BINARY_DIR} COPYONLY)
target_sources(nekoray PRIVATE ${CMAKE_BINARY_DIR}/translations.qrc)
# Target Link
target_link_libraries(nekoray PRIVATE
Qt6::Widgets Qt6::Network Qt6::Svg
Threads::Threads
${NKR_EXTERNAL_TARGETS}
${PLATFORM_LIBRARIES}
)
qt_finalize_executable(nekoray)