forked from cpeditor/cpeditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
310 lines (261 loc) · 10.1 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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
cmake_minimum_required(VERSION 3.5)
if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version")
endif()
project(cpeditor LANGUAGES CXX VERSION 6.12.0)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(WIN32)
set(GUI_TYPE WIN32)
endif()
find_package(Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt5 COMPONENTS Network REQUIRED)
find_package(Qt5 COMPONENTS LinguistTools REQUIRED)
find_package(Python3 COMPONENTS Interpreter REQUIRED)
find_package(KF5SyntaxHighlighting REQUIRED)
set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication")
add_subdirectory(third_party/singleapplication)
add_subdirectory(third_party/QtFindReplaceDialog/dialogs)
add_subdirectory(third_party/lsp-cpp)
add_subdirectory(third_party/qhttp)
add_subdirectory(third_party/diff_match_patch)
option(PORTABLE_VERSION "Build the portable version" Off)
option(USE_CLANG_TIDY "Use clang-tidy to lint the files" Off)
string(TIMESTAMP BUILD_DATE "%Y-%m-%d")
message(STATUS "Makefile generated on ${BUILD_DATE}")
if(${PORTABLE_VERSION})
message(STATUS "Will build the portable version")
else()
message(STATUS "Will build the setup version")
endif()
# https://medium.com/@alasher/colored-c-compiler-output-with-ninja-clang-gcc-10bfe7f2b949
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." On)
if(${FORCE_COLORED_OUTPUT})
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-fcolor-diagnostics)
endif()
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
find_package(Git)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE "GIT_COMMIT_HASH"
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Git commit hash: ${GIT_COMMIT_HASH}")
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --long --tags --abbrev=8
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE "GIT_DESCRIBE"
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT "${GIT_DESCRIBE}" EQUAL "")
string(REGEX REPLACE "(.+)-(.+)-(.+)" "\\2" "COMMITS_SINCE_LAST_RELEASE" "${GIT_DESCRIBE}")
if(NOT "${COMMITS_SINCE_LAST_RELEASE}" EQUAL "0")
string(REGEX REPLACE "(.+)-(.+)-(.+)" "\\1.r\\2.\\3" "DISPLAY_VERSION" "${GIT_DESCRIBE}")
string(REGEX REPLACE "(.+)-(.+)-.+" "\\1.\\2" "FOUR_PART_VERSION" "${GIT_DESCRIBE}")
else()
string(REGEX REPLACE "([0-9]+\\.[0-9]+)\\..+" "v\\1" "MINOR_VERSION" "${GIT_DESCRIBE}")
endif()
endif()
endif()
endif()
if(NOT DEFINED "DISPLAY_VERSION")
set("DISPLAY_VERSION" "${PROJECT_VERSION}")
set("FOUR_PART_VERSION" "${PROJECT_VERSION}.0")
endif()
message(STATUS "Display version: ${DISPLAY_VERSION}")
message(STATUS "Four part version: ${FOUR_PART_VERSION}")
message(STATUS "Minor version: ${MINOR_VERSION}")
if (WIN32)
string(REGEX REPLACE "\\." "," "COMMA_VERSION" "${FOUR_PART_VERSION}")
configure_file(cmake/version.rc.in ${CMAKE_BINARY_DIR}/generated/version.rc)
endif()
configure_file(cmake/version.hpp.in ${CMAKE_BINARY_DIR}/generated/version.hpp)
configure_file(cmake/portable.hpp.in ${CMAKE_BINARY_DIR}/generated/portable.hpp)
configure_file(cmake/cpeditor.appdata.xml.in ${PROJECT_SOURCE_DIR}/dist/linux/cpeditor.appdata.xml)
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/generated/SettingsHelper.hpp ${CMAKE_BINARY_DIR}/generated/SettingsInfo.cpp
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/Settings/genSettings.py ${PROJECT_SOURCE_DIR}/src/Settings/settings.json
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS ${PROJECT_SOURCE_DIR}/src/Settings/settings.json ${PROJECT_SOURCE_DIR}/src/Settings/genSettings.py)
set(TSS
${CMAKE_SOURCE_DIR}/translations/el_GR.ts
${CMAKE_SOURCE_DIR}/translations/es_MX.ts
${CMAKE_SOURCE_DIR}/translations/pt_BR.ts
${CMAKE_SOURCE_DIR}/translations/ru_RU.ts
${CMAKE_SOURCE_DIR}/translations/zh_CN.ts
${CMAKE_SOURCE_DIR}/translations/zh_TW.ts
)
set_source_files_properties(${TSS} PROPERTIES OUTPUT_LOCATION ${CMAKE_BINARY_DIR}/translations)
qt5_add_translation(QMFILES ${TSS})
file(COPY ${CMAKE_SOURCE_DIR}/translations/translations.qrc DESTINATION ${CMAKE_BINARY_DIR}/translations)
set_property(SOURCE ${CMAKE_BINARY_DIR}/generated/SettingsHelper.hpp ${CMAKE_BINARY_DIR}/generated/SettingsInfo.cpp PROPERTY SKIP_AUTOGEN ON)
if(USE_CLANG_TIDY)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy")
message(STATUS "clang-tidy checks will be performed")
endif()
set(RESOURCES resources/resources.qrc)
if(APPLE)
list(APPEND RESOURCES resources/macos-resources.qrc)
endif()
if(WIN32)
list(APPEND RESOURCES ${CMAKE_BINARY_DIR}/generated/version.rc)
endif()
add_executable(cpeditor
${GUI_TYPE}
src/Core/Checker.cpp
src/Core/Checker.hpp
src/Core/Compiler.cpp
src/Core/Compiler.hpp
src/Core/EventLogger.cpp
src/Core/EventLogger.hpp
src/Core/MessageLogger.cpp
src/Core/MessageLogger.hpp
src/Core/Runner.cpp
src/Core/Runner.hpp
src/Core/SessionManager.cpp
src/Core/SessionManager.hpp
src/Core/StyleManager.cpp
src/Core/StyleManager.hpp
src/Core/TestCasesCopyPaster.cpp
src/Core/TestCasesCopyPaster.hpp
src/Core/Translator.cpp
src/Core/Translator.hpp
src/Editor/CodeEditor.cpp
src/Editor/CodeEditor.hpp
src/Editor/CodeEditorSideBar.cpp
src/Editor/CodeEditorSideBar.hpp
src/Editor/HighLighter.cpp
src/Editor/HighLighter.hpp
src/Editor/KSHRepository.cpp
src/Editor/KSHRepository.hpp
src/Editor/LanguageRepository.cpp
src/Editor/LanguageRepository.hpp
src/Extensions/CFTool.cpp
src/Extensions/CFTool.hpp
src/Extensions/ClangFormatter.cpp
src/Extensions/ClangFormatter.hpp
src/Extensions/CodeFormatter.cpp
src/Extensions/CodeFormatter.hpp
src/Extensions/CompanionServer.cpp
src/Extensions/CompanionServer.hpp
src/Extensions/LanguageServer.cpp
src/Extensions/LanguageServer.hpp
src/Extensions/WakaTime.cpp
src/Extensions/WakaTime.hpp
src/Extensions/YAPFormatter.cpp
src/Extensions/YAPFormatter.hpp
src/Settings/CodeSnippetsPage.cpp
src/Settings/CodeSnippetsPage.hpp
src/Settings/DefaultPathManager.cpp
src/Settings/DefaultPathManager.hpp
src/Settings/FileProblemBinder.cpp
src/Settings/FileProblemBinder.hpp
src/Settings/FontItem.cpp
src/Settings/FontItem.hpp
src/Settings/ParenthesesPage.cpp
src/Settings/ParenthesesPage.hpp
src/Settings/PathItem.cpp
src/Settings/PathItem.hpp
src/Settings/PreferencesGridPage.cpp
src/Settings/PreferencesGridPage.hpp
src/Settings/PreferencesHomePage.cpp
src/Settings/PreferencesHomePage.hpp
src/Settings/PreferencesPage.cpp
src/Settings/PreferencesPage.hpp
src/Settings/PreferencesPageTemplate.cpp
src/Settings/PreferencesPageTemplate.hpp
src/Settings/PreferencesWindow.cpp
src/Settings/PreferencesWindow.hpp
src/Settings/SettingsManager.cpp
src/Settings/SettingsManager.hpp
src/Settings/SettingsUpdater.cpp
src/Settings/SettingsUpdater.hpp
src/Settings/ShortcutItem.cpp
src/Settings/ShortcutItem.hpp
src/Settings/StringListsItem.cpp
src/Settings/StringListsItem.hpp
src/Settings/ValueWrapper.cpp
src/Settings/ValueWrapper.hpp
src/Telemetry/UpdateChecker.cpp
src/Telemetry/UpdateChecker.hpp
src/Util/FileUtil.cpp
src/Util/FileUtil.hpp
src/Util/Singleton.hpp
src/Util/Util.cpp
src/Util/Util.hpp
src/Widgets/ContestDialog.cpp
src/Widgets/ContestDialog.hpp
src/Widgets/DiffViewer.cpp
src/Widgets/DiffViewer.hpp
src/Widgets/RichTextCheckBox.cpp
src/Widgets/RichTextCheckBox.hpp
src/Widgets/Stopwatch.cpp
src/Widgets/Stopwatch.hpp
src/Widgets/SupportUsDialog.cpp
src/Widgets/SupportUsDialog.hpp
src/Widgets/TestCase.cpp
src/Widgets/TestCase.hpp
src/Widgets/TestCaseEdit.cpp
src/Widgets/TestCaseEdit.hpp
src/Widgets/TestCases.cpp
src/Widgets/TestCases.hpp
src/Widgets/UpdatePresenter.cpp
src/Widgets/UpdatePresenter.hpp
src/Widgets/UpdateProgressDialog.cpp
src/Widgets/UpdateProgressDialog.hpp
src/application.cpp
src/application.hpp
src/appwindow.cpp
src/appwindow.hpp
src/mainwindow.cpp
src/mainwindow.hpp
src/SignalHandler.cpp
src/SignalHandler.hpp
src/main.cpp
ui/appwindow.ui
ui/mainwindow.ui
${CMAKE_BINARY_DIR}/generated/version.hpp
${CMAKE_BINARY_DIR}/generated/SettingsHelper.hpp
src/Settings/SettingsInfo.hpp
${CMAKE_BINARY_DIR}/generated/SettingsInfo.cpp
${CMAKE_BINARY_DIR}/translations/translations.qrc
${RESOURCES}
assets/appicon.rc)
include_directories("generated/")
include_directories("src/")
target_link_libraries(cpeditor PRIVATE LSPClient)
target_link_libraries(cpeditor PRIVATE Qt5::Network)
target_link_libraries(cpeditor PRIVATE Qt5::Widgets)
target_link_libraries(cpeditor PRIVATE QtFindReplaceDialog)
target_link_libraries(cpeditor PRIVATE SingleApplication)
target_link_libraries(cpeditor PRIVATE QHttp)
target_link_libraries(cpeditor PRIVATE diff_match_patch)
target_link_libraries(cpeditor PRIVATE KF5::SyntaxHighlighting)
if(MSVC)
target_compile_options(cpeditor PUBLIC "/utf-8")
endif(MSVC)
if(APPLE)
set_target_properties(cpeditor
PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/Info.plist.in
RESOURCE "dist/mac/cpeditor.icns"
)
endif()
if(UNIX AND NOT APPLE)
include(GNUInstallDirs)
install(TARGETS cpeditor
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES dist/linux/cpeditor.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
install(FILES resources/cpicon.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/512x512/apps RENAME cpeditor.png)
install(FILES dist/linux/cpeditor.appdata.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo)
install(FILES ${QMFILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/cpeditor/translations)
endif()