-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
256 lines (213 loc) · 7.73 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
cmake_minimum_required(VERSION 3.10)
if (${CMAKE_VERSION} VERSION_GREATER "3.14")
cmake_policy(SET CMP0087 NEW)
endif ()
set(CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}" ${CMAKE_MODULE_PATH})
include(FeatureSummary)
include(FetchContent)
# Setup paths
SET(RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/")
SET(LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/")
SET(ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/")
SET(EXECUTABLE_OUTPUT_PATH ${RUNTIME_OUTPUT_DIRECTORY})
SET(LIBRARY_OUTPUT_PATH ${RUNTIME_OUTPUT_DIRECTORY})
# Fix executable paths for windows
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${RUNTIME_OUTPUT_DIRECTORY})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${RUNTIME_OUTPUT_DIRECTORY})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${RUNTIME_OUTPUT_DIRECTORY})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${RUNTIME_OUTPUT_DIRECTORY})
project(Diesel VERSION "2.0.0")
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_SOURCE_DIR}/ui")
# set(CMAKE_UNITY_BUILD ON)
FetchContent_Declare(
tabler_icons
URL https://github.com/tabler/tabler-icons/releases/download/v3.12.0/tabler-icons-3.12.0.zip
URL_HASH MD5=adf7f0af5e74fa8116c3f37f78ed205b
DOWNLOAD_EXTRACT_TIMESTAMP ON
)
FetchContent_MakeAvailable(tabler_icons)
include(cmake/resources.cmake)
find_package(Qt6 COMPONENTS Core Gui WebEngineCore WebEngineWidgets Core5Compat REQUIRED)
find_package(Qt6Keychain REQUIRED)
set(FORMS
ui/MainWindow.ui
ui/CommitDialog.ui
ui/FileActionDialog.ui
ui/SettingsDialog.ui
ui/FslSettingsDialog.ui
ui/CloneDialog.ui
ui/BrowserWidget.ui
ui/RevisionDialog.ui
ui/RemoteDialog.ui
ui/AboutDialog.ui)
set(SOURCES
src/main.cpp
src/MainWindow.cpp
src/CommitDialog.cpp
src/FileActionDialog.cpp
src/SettingsDialog.cpp
src/FslSettingsDialog.cpp
src/CloneDialog.cpp
src/RevisionDialog.cpp
src/Utils.cpp
src/FileTableView.cpp
src/LoggedProcess.cpp
src/BrowserWidget.cpp
src/CustomWebView.cpp
src/Fossil.cpp
src/Workspace.cpp
src/SearchBox.cpp
src/AppSettings.cpp
src/RemoteDialog.cpp
src/AboutDialog.cpp)
set(HEADERS
src/MainWindow.h
src/CommitDialog.h
src/FileActionDialog.h
src/SettingsDialog.h
src/FslSettingsDialog.h
src/CloneDialog.h
src/RevisionDialog.h
src/Utils.h
src/FileTableView.h
src/LoggedProcess.h
src/BrowserWidget.h
src/CustomWebView.h
src/Fossil.h
src/Workspace.h
src/SearchBox.h
src/AppSettings.h
src/RemoteDialog.h
src/AboutDialog.h
src/WorkspaceCommon.h)
set(RESOURCES
rsrc/resources.qrc
rsrc/resources_autogenerated.qrc
)
set(TRANSLATIONS
intl/en_US.ts
intl/el_GR.ts
intl/de_DE.ts
intl/es_ES.ts
intl/fr_FR.ts
intl/ru_RU.ts
intl/pt_PT.ts
intl/it_IT.ts
intl/nl_NL.ts
intl/ko_KR.ts)
find_package(Qt6LinguistTools)
if (Qt6LinguistTools_FOUND)
set_source_files_properties(${TRANSLATIONS} PROPERTIES OUTPUT_LOCATION "intl")
Qt6_create_translation(QM_MESSAGES ${CMAKE_SOURCE_DIR}/ui ${CMAKE_SOURCE_DIR}/src ${TRANSLATIONS})
Qt6_add_translation(QM_FILES ${TRANSLATIONS})
add_custom_target(messages DEPENDS ${QM_MESSAGES})
add_custom_target(translations DEPENDS ${QM_FILES} messages)
file(COPY rsrc/languages.qrc DESTINATION ${CMAKE_BINARY_DIR}/intl)
list(APPEND RESOURCES "${CMAKE_BINARY_DIR}/intl/languages.qrc")
else ()
message(WARNING "Qt6LinguistTools not found")
endif ()
if (WIN32)
# clang-cl doesn't support resource files
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
list(APPEND SOURCES "${CMAKE_SOURCE_DIR}/rsrc/diesel.rc")
endif ()
elseif (APPLE)
list(APPEND SOURCES "${CMAKE_SOURCE_DIR}/rsrc/icons/diesel.icns")
endif ()
add_executable(
${PROJECT_NAME}
${FORMS}
${HEADERS}
${SOURCES}
${QM_FILES}
${RESOURCES}
)
target_include_directories(
${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/ui/
${CMAKE_SOURCE_DIR}/src/
)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets Qt6::WebEngineCore Qt6::WebEngineWidgets Qt6::Core5Compat)
if (TARGET Qt6Keychain::Qt6Keychain)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6Keychain::Qt6Keychain)
else ()
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6keychain)
endif ()
target_compile_definitions(${PROJECT_NAME} PRIVATE DIESEL_VERSION="${PROJECT_VERSION}")
if (0)
add_dependencies(${PROJECT_NAME} translations)
endif ()
# ------------------------------------------------------------------------------------------------#
# Cpack
# ------------------------------------------------------------------------------------------------#
include(GNUInstallDirs)
include(FetchContent)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VENDOR "${PROJECT_NAME}")
set(CPACK_PACKAGE_DESCRIPTION "A GUI front-end for the Fossil SCM")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A GUI front-end for the Fossil SCM")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/rsrc/license.rtf")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_EXECUTABLES "${PROJECT_NAME}" "${PROJECT_NAME}")
set(CPACK_GENERATOR ZIP)
if (WIN32)
set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE TRUE)
get_target_property(Qt6_Core_Location Qt6::Core LOCATION)
get_filename_component(QT_BIN_DIR ${Qt6_Core_Location} DIRECTORY)
# Fix for windeployqt not being able to find Qt6keychain
if (EXISTS ${RUNTIME_OUTPUT_DIRECTORY}/Qt6keychain.dll AND NOT EXISTS ${QT_BIN_DIR}/Qt6keychain.dll)
message("Copying ${RUNTIME_OUTPUT_DIRECTORY}/Qt6keychain.dll to ${QT_BIN_DIR}")
file(COPY ${RUNTIME_OUTPUT_DIRECTORY}/Qt6keychain.dll DESTINATION ${QT_BIN_DIR})
endif ()
add_custom_target(
windeployqt
COMMAND ${QT_BIN_DIR}/windeployqt.exe $<TARGET_FILE:${PROJECT_NAME}> --release --no-compiler-runtime --no-opengl-sw
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
install(
TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION .
)
install(CODE "execute_process(COMMAND ${QT_BIN_DIR}/windeployqt.exe $<TARGET_FILE:${PROJECT_NAME}> --release --no-opengl-sw --dir \${CMAKE_INSTALL_PREFIX})")
FetchContent_Declare(
fossil
URL https://fossil-scm.org/home/uv/fossil-w64-2.23.zip
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
URL_MD5 043e72168635ca2a967e7c0b7967d521
)
FetchContent_MakeAvailable(fossil)
install(
PROGRAMS ${fossil_SOURCE_DIR}/fossil.exe
DESTINATION .
COMPONENT Fossil
EXCLUDE_FROM_ALL
)
# For Windows Desktop shortcuts
set(CPACK_CREATE_DESKTOP_LINKS "${PROJECT_NAME}" "${PROJECT_NAME}")
set(CPACK_INNOSETUP_ALLOW_CUSTOM_DIRECTORY ON)
set(CPACK_INNOSETUP_USE_MODERN_WIZARD ON)
set(CPACK_INNOSETUP_ICON_FILE "${CMAKE_SOURCE_DIR}/rsrc/icons/diesel.ico")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}")
set(CPACK_GENERATOR ${CPACK_GENERATOR} INNOSETUP)
endif ()
if (UNIX)
install(
TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(
FILES ${CMAKE_SOURCE_DIR}/rsrc/diesel.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications/
)
install(
FILES ${CMAKE_SOURCE_DIR}/rsrc/icons/diesel.png
DESTINATION ${CMAKE_INSTALL_DATADIR}/pixmaps/
)
endif ()
include(CPack)
feature_summary(WHAT ALL)