forked from Qv2ray/Qv2ray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
223 lines (189 loc) · 7.31 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
cmake_minimum_required(VERSION 3.10.1)
file(STRINGS "${CMAKE_SOURCE_DIR}/makespec/VERSION" QCLASH_VERSION)
file(STRINGS "${CMAKE_SOURCE_DIR}/makespec/BUILDVERSION" QCLASH_BUILD_VERSION)
file(STRINGS "${CMAKE_SOURCE_DIR}/makespec/VERSIONSUFFIX" QCLASH_VERSION_SUFFIX)
set(QCLASH_VERSION_STRING "${QCLASH_VERSION}${QCLASH_VERSION_SUFFIX}")
project(Qclash)
set(VERSION_LIST ${QCLASH_VERSION})
string(REPLACE "." ";" VERSION_LIST ${VERSION_LIST})
separate_arguments(VERSION_LIST)
list(GET VERSION_LIST 0 CMAKE_PROJECT_VERSION_MAJOR)
list(GET VERSION_LIST 1 CMAKE_PROJECT_VERSION_MINOR)
list(GET VERSION_LIST 2 CPACK_PACKAGE_VERSION_PATCH)
add_definitions(-DQCLASH_VERSION_MAJOR=${CMAKE_PROJECT_VERSION_MAJOR})
add_definitions(-DQCLASH_VERSION_MINOR=${CMAKE_PROJECT_VERSION_MINOR})
add_definitions(-DQCLASH_VERSION_BUGFIX=${CPACK_PACKAGE_VERSION_PATCH})
add_definitions(-DQCLASH_VERSION_BUILD=${QCLASH_BUILD_VERSION})
add_definitions(-DQCLASH_VERSION_STRING="${QCLASH_VERSION_STRING}")
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(MSVC)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
if(WIN32)
include(cmake/versioninfo/generate_product_version.cmake)
generate_product_version(
QCLASH_RC
NAME "Qclash"
BUNDLE "clash Project Family"
ICON "${CMAKE_SOURCE_DIR}/assets/icons/qclash.ico"
VERSION_MAJOR ${CMAKE_PROJECT_VERSION_MAJOR}
VERSION_MINOR ${CMAKE_PROJECT_VERSION_MINOR}
VERSION_PATCH ${CPACK_PACKAGE_VERSION_PATCH}
VERSION_REVISION ${QCLASH_BUILD_VERSION}
COMPANY_NAME "Qclash"
COMPANY_COPYRIGHT "Qclash"
FILE_DESCRIPTION "Qclash Main Application"
)
add_definitions(-DUNICODE -D_UNICODE -DNOMINMAX)
set(GUI_TYPE WIN32)
add_compile_options("/utf-8")
add_compile_options("/std:c++17")
add_definitions(-D_WIN32_WINNT=0x600 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS)
set(QCLASH_PLATFORM_LIBS_PREFIX ${CMAKE_SOURCE_DIR}/libs/x64-windows/)
include(cmake/platforms/prefixes.cmake)
endif()
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.17.0")
cmake_policy(SET CMP0100 NEW)
endif()
option(QCLASH_AUTO_DEPLOY "Automatically run deploy command after build" ON)
set(QCLASH_DEFAULT_VASSETS_PATH "unset" CACHE STRING "Default assets path")
set(QCLASH_DEFAULT_VCORE_PATH "unset" CACHE STRING "Default core path")
option(QCLASH_DISABLE_AUTO_UPDATE "Disable Update Checker" OFF)
option(QCLASH_HAS_BUILTIN_PLUGINS "Build with builtin plugins" ON)
option(QCLASH_EMBED_TRANSLATIONS "Embed Translations" OFF)
option(QCLASH_HAS_SINGLEAPPLICATION "Build With SingleApplication" ON)
set(QCLASH_UI_TYPE "QWidget" CACHE STRING "GUI Component")
if(QCLASH_UI_TYPE STREQUAL "QWidget")
set(QCLASH_USE_QWIDGET ON)
endif()
if(QCLASH_HAS_SINGLEAPPLICATION)
set(QCLASH_SINGLEAPPLICATION_PROVIDER "module" CACHE STRING "SingleApplication Provider")
endif()
if(QCLASH_USE_QWIDGET)
option(QCLASH_HAS_BUILTIN_THEMES "Build with built-in themes" ON)
set(QVMESSOCKET_QNODEEDITOR_PROVIDER "module" CACHE STRING "QNodeEditor Provider")
endif()
cmake_policy(SET CMP0072 NEW)
set(QV_QT_MAJOR_VERSION 6)
set(QV_QT_MINOR_VERSION 0)
set(QV_QT_LIBNAME Qt6)
if(QCLASH_DISABLE_AUTO_UPDATE)
add_definitions(-DDISABLE_AUTO_UPDATE)
endif()
add_definitions(-D_QCLASH_BUILD_INFO_STR_="${_QCLASH_BUILD_INFO_STR_}")
add_definitions(-D_QCLASH_BUILD_EXTRA_INFO_STR_="${_QCLASH_BUILD_EXTRA_INFO_STR_}")
include(cmake/libuv.cmake)
include(cmake/libcurl.cmake)
include(cmake/libsemver.cmake)
include(cmake/protobuf.cmake)
include(cmake/backend.cmake)
include(3rdparty/QJsonStruct/QJsonStruct.cmake)
find_package(Threads REQUIRED)
find_package(${QV_QT_LIBNAME} ${QV_QT_MAJOR_VERSION}.${QV_QT_MINOR_VERSION} COMPONENTS Core Network REQUIRED)
list(APPEND QCLASH_QT_LIBS ${QV_QT_LIBNAME}::Core ${QV_QT_LIBNAME}::Network)
cmake_policy(SET CMP0071 NEW)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
if(QCLASH_USE_QWIDGET)
find_package(${QV_QT_LIBNAME} ${QV_QT_MAJOR_VERSION}.${QV_QT_MINOR_VERSION} COMPONENTS Widgets Svg Gui REQUIRED)
list(APPEND QCLASH_QT_LIBS
${QV_QT_LIBNAME}::Widgets
${QV_QT_LIBNAME}::Svg
${QV_QT_LIBNAME}::Gui)
set(_QCLASH_HAS_GUI_INTERNAL_ ON)
endif()
include(cmake/components/base.cmake)
include(src/plugin-interface/QvPluginInterface.cmake)
if(QCLASH_HAS_SINGLEAPPLICATION)
include(cmake/singleapplication.cmake)
else()
add_definitions(-DQCLASH_NO_SINGLEAPPLICATON)
endif()
add_library(Qclash_baselib STATIC
${QCLASH_BASE_SOURCES}
${SINGLEAPPLICATION_SOURCES}
${QVPLUGIN_INTERFACE_HEADERS}
${LIBSEMVER_SOURCES}
${PROTO_SRCS}
${PROTO_HDRS}
${API_GRPC_SRCS}
${API_PROTO_SRCS}
)
target_link_libraries(Qclash_baselib
${QCLASH_QT_LIBS}
${QCLASH_PROTOBUF_LIBRARY}
${QCLASH_BACKEND_LIBRARY}
${LibUV_LIBRARIES}
${CURL_LIBRARIES}
${SINGLEAPPLICATION_LIBRARY}
Threads::Threads
)
target_include_directories(Qclash_baselib PUBLIC
${CMAKE_BINARY_DIR}
${LibUV_INCLUDE_DIR}
${SINGLEAPPLICATION_DIR}
${CURL_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
${Protobuf_INCLUDE_DIRS}
)
if(QCLASH_HAS_BUILTIN_PLUGINS)
include(src/plugins/protocols/QvPlugin-BuiltinProtocolSupport.cmake)
include(src/plugins/subscription-adapters/QvPlugin-BuiltinSubscriptionAdapters.cmake)
#include(src/plugins/utils/QvPlugin-BuiltinUtils.cmake)
endif()
if(_QCLASH_HAS_GUI_INTERNAL_)
add_definitions(-DQCLASH_GUI)
include(cmake/qrencode.cmake)
include(cmake/components/ui.cmake)
list(APPEND QCLASH_UI_SOURCES ${QCLASH_UI_COMMON_SOURCES})
include(src/plugin-interface/QvGUIPluginInterface.cmake)
list(APPEND QCLASH_UI_SOURCES ${QVGUIPLUGIN_INTERFACE_HEADERS})
if(QCLASH_USE_QWIDGET)
add_definitions(-DQCLASH_GUI_QWIDGETS)
include(cmake/components/ui-widget.cmake)
list(APPEND QCLASH_UI_SOURCES ${QCLASH_UI_WIDGET_SOURCES})
if (QCLASH_HAS_BUILTIN_THEMES)
include(3rdparty/uistyles/uistyles.cmake)
list(APPEND QCLASH_QRC_RESOURCES ${UISTYLE_QRCS})
endif()
include(cmake/qnodeeditor.cmake)
list(APPEND QCLASH_QRC_RESOURCES ${QNODEEDITOR_QRC_RESOURCES})
endif()
endif()
list(APPEND QCLASH_QRC_RESOURCES
${CMAKE_SOURCE_DIR}/resources.qrc
${CMAKE_SOURCE_DIR}/resources.new.qrc
)
set(QCLASH_FULL_SOURCES
${QCLASH_RC}
${CMAKE_CURRENT_LIST_DIR}/src/main.cpp
${QCLASH_UI_SOURCES}
${QCLASH_EMBED_TRANSLATION_QRC}
${QCLASH_QRC_RESOURCES}
${QVMESSOCKET_QM_FILES}
)
qt6_add_executable(Qvmessocket ${GUI_TYPE} ${QCLASH_FULL_SOURCES})
target_include_directories(Qvmessocket PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}
${QNODEEDITOR_INCLUDE_PATH}
${Protobuf_INCLUDE_DIRS}
)
target_link_libraries(Qvmessocket PUBLIC
Qclash_baselib
${QNODEEDITOR_LIBRARY}
${QCLASH_QRENCODE_LIBRARY}
)
if(UNIX)
include(cmake/platforms/linux.cmake)
elseif(WIN32)
include(cmake/platforms/windows.cmake)
endif()
get_target_property(QVMESSOCKET_BASE_LINK_LIBS Qclash_baselib LINK_LIBRARIES)
get_target_property(QVMESSOCKET_EXEC_LINK_LIBS Qvmessocket LINK_LIBRARIES)