-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
CMakeLists.txt
261 lines (213 loc) · 7.45 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
256
257
258
259
260
261
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)
# WINDOWS PDB FILE
if (WIN32)
if (MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
endif ()
endif ()
# Find Qt
if (NOT QT_VERSION_MAJOR)
set(QT_VERSION_MAJOR 5)
endif ()
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network Svg LinguistTools)
if (NKR_CROSS)
set_property(TARGET Qt5::moc PROPERTY IMPORTED_LOCATION /usr/bin/moc)
set_property(TARGET Qt5::uic PROPERTY IMPORTED_LOCATION /usr/bin/uic)
set_property(TARGET Qt5::rcc PROPERTY IMPORTED_LOCATION /usr/bin/rcc)
set_property(TARGET Qt5::lrelease PROPERTY IMPORTED_LOCATION /usr/bin/lrelease)
set_property(TARGET Qt5::lupdate PROPERTY IMPORTED_LOCATION /usr/bin/lupdate)
endif ()
# Windows
include("cmake/fuck_windows/fuck.cmake")
# default prefix path
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/libs/deps/built)
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_NO_EXTERNAL)
add_compile_definitions(NKR_NO_EXTERNAL)
else ()
if (NKR_NO_GRPC)
add_compile_definitions(NKR_NO_GRPC)
else ()
# My proto
include("cmake/myproto.cmake")
list(APPEND NKR_EXTERNAL_TARGETS myproto)
endif ()
# yaml-cpp (static)
find_package(yaml-cpp CONFIG REQUIRED) # only Release is built
list(APPEND NKR_EXTERNAL_TARGETS yaml-cpp)
# zxing-cpp
find_package(ZXing CONFIG REQUIRED)
list(APPEND NKR_EXTERNAL_TARGETS ZXing::ZXing)
# QHotkey (static submodule)
set(QHOTKEY_INSTALL OFF)
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(3rdparty/QHotkey)
list(APPEND NKR_EXTERNAL_TARGETS qhotkey)
endif ()
# debug print
if (DBG_CMAKE)
print_all_variables()
print_target_properties(myproto)
print_target_properties(yaml-cpp)
print_target_properties(ZXing::ZXing)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CMAKE_COMMAND} -E time")
endif ()
# Sources
set(PROJECT_SOURCES
${PLATFORM_FUCKING_SOURCES}
main/main.cpp
main/NekoRay.cpp
main/NekoRay_Utils.cpp
3rdparty/qrcodegen.cpp
3rdparty/QtExtKeySequenceEdit.cpp
qv2ray/v2/ui/LogHighlighter.cpp
qv2ray/v2/ui/QvAutoCompleteTextEdit.cpp
qv2ray/v2/utils/HTTPRequestHelper.cpp
qv2ray/v2/components/proxy/QvProxyConfigurator.cpp
qv2ray/v2/ui/widgets/common/QJsonModel.cpp
qv2ray/v2/ui/widgets/editors/w_JsonEditor.cpp
qv2ray/v2/ui/widgets/editors/w_JsonEditor.hpp
qv2ray/v2/ui/widgets/editors/w_JsonEditor.ui
qv2ray/v3/components/GeositeReader/GeositeReader.cpp
qv2ray/v3/components/GeositeReader/picoproto.cpp
rpc/gRPC.cpp
db/Database.cpp
db/TrafficLooper.cpp
db/ProfileFilter.cpp
fmt/AbstractBean.cpp
fmt/Bean2CoreObj_ray.cpp
fmt/Bean2CoreObj_box.cpp
fmt/Bean2External.cpp
fmt/Bean2Link.cpp
fmt/InsecureHint.cpp
fmt/Link2Bean.cpp
db/ConfigBuilder.cpp
fmt/ChainBean.hpp # translate
sub/GroupUpdater.cpp
sys/ExternalProcess.cpp
sys/AutoRun.cpp
ui/ThemeManager.cpp
ui/TrayIcon.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/gen_hysteria.h
ui/edit/gen_hysteria.cpp
ui/edit/gen_hysteria.ui
ui/edit/edit_naive.h
ui/edit/edit_naive.cpp
ui/edit/edit_naive.ui
ui/edit/edit_custom.h
ui/edit/edit_custom.cpp
ui/edit/edit_custom.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
res/neko.qrc
res/theme/feiyangqingyun/qss.qrc
${QV2RAY_RC}
)
# Translations
set(TS_FILES
translations/zh_CN.ts
)
qt_create_translation(QM_FILES ${PROJECT_SOURCES} ${TS_FILES} OPTIONS -locations none)
configure_file(translations/translations.qrc ${CMAKE_BINARY_DIR} COPYONLY)
set(PROJECT_SOURCES ${PROJECT_SOURCES} ${TS_FILES} ${QM_FILES} ${CMAKE_BINARY_DIR}/translations.qrc)
# Qt exe
if (${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(nekoray
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET nekoray APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else ()
if (ANDROID)
add_library(nekoray SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else ()
add_executable(nekoray
${PROJECT_SOURCES}
)
endif ()
endif ()
# Target
set_property(TARGET nekoray PROPERTY AUTOUIC ON)
set_property(TARGET nekoray PROPERTY AUTOMOC ON)
set_property(TARGET nekoray PROPERTY AUTORCC ON)
# Target Link
target_link_libraries(nekoray PRIVATE
Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Svg
Threads::Threads
${NKR_EXTERNAL_TARGETS}
${PLATFORM_FUCKING_LIBRARIES}
)
set_target_properties(nekoray PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
if (QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(nekoray)
endif ()