forked from sqlitebrowser/sqlitebrowser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
322 lines (289 loc) · 8.08 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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
cmake_minimum_required(VERSION 3.16)
project(sqlitebrowser
VERSION 3.13.99
DESCRIPTION "GUI editor for SQLite databases"
LANGUAGES CXX
)
include(GNUInstallDirs)
include(config/options.cmake)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
add_executable(${PROJECT_NAME})
if(QT_MAJOR STREQUAL "Qt5")
set(CMAKE_CXX_STANDARD 14)
elseif(QT_MAJOR STREQUAL "Qt6")
set(CMAKE_CXX_STANDARD 17)
else()
message(FATAL_ERROR "Uknown Qt Version: ${QT_MAJOR}")
endif()
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES
WIN32_EXECUTABLE ON
MACOSX_BUNDLE ON
)
execute_process(
COMMAND git -C ${CMAKE_CURRENT_SOURCE_DIR} rev-parse --short --verify HEAD
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if (GIT_COMMIT_HASH STREQUAL "")
MESSAGE(WARNING "Could not determine git commit hash")
set(GIT_COMMIT_HASH "Unknown")
endif()
add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}")
if(NOT BUILD_STABLE_VERSION)
# BUILD_VERSION is the current date in YYYYMMDD format. It is only
# used by the nightly version to add the date of the build.
# Default defined in Version.h.in
string(TIMESTAMP BUILD_VERSION "%Y%m%d")
target_compile_definitions(${PROJECT_NAME} PRIVATE BUILD_VERSION=${BUILD_VERSION})
endif()
include(config/platform.cmake)
find_package(${QT_MAJOR} REQUIRED COMPONENTS Concurrent Gui LinguistTools Network PrintSupport Test Widgets Xml)
set(QT_LIBS
${QT_MAJOR}::Gui
${QT_MAJOR}::Test
${QT_MAJOR}::PrintSupport
${QT_MAJOR}::Widgets
${QT_MAJOR}::Network
${QT_MAJOR}::Concurrent
${QT_MAJOR}::Xml
)
if(QT_MAJOR STREQUAL "Qt6")
find_package(Qt6 REQUIRED COMPONENTS Core5Compat)
list(APPEND QT_LIBS Qt6::Core5Compat)
set_target_properties(${PROJECT_NAME} PROPERTIES
AUTOUIC_OPTIONS "--connections=string"
)
endif()
target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE ${CMAKE_CURRENT_LIST_DIR}/libs/json)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR} src)
include(config/3dparty.cmake)
# SQLCipher option
if(sqlcipher)
add_definitions(-DENABLE_SQLCIPHER)
find_package(SQLCipher REQUIRED)
include_directories(SYSTEM "${SQLCIPHER_INCLUDE_DIR}/sqlcipher")
set(LIBSQLITE_NAME SQLCipher::SQLCipher)
else()
find_package(SQLite3 REQUIRED)
set(LIBSQLITE_NAME SQLite::SQLite3)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in
${CMAKE_CURRENT_BINARY_DIR}/version.h
)
target_sources(${PROJECT_NAME}
PRIVATE
src/sql/sqlitetypes.h
src/sql/Query.h
src/sql/ObjectIdentifier.h
src/csvparser.h
src/sqlite.h
src/Data.h
src/IconCache.h
src/sql/parser/ParserDriver.h
src/sql/parser/sqlite3_lexer.h
src/sql/parser/sqlite3_location.h
src/sql/parser/sqlite3_parser.hpp
)
target_sources(${PROJECT_NAME}
PRIVATE
src/sqlitedb.h
src/AboutDialog.h
src/EditIndexDialog.h
src/EditDialog.h
src/EditTableDialog.h
src/AddRecordDialog.h
src/ExportDataDialog.h
src/ExtendedTableWidget.h
src/FilterTableHeader.h
src/ImportCsvDialog.h
src/MainWindow.h
src/Settings.h
src/PreferencesDialog.h
src/SqlExecutionArea.h
src/VacuumDialog.h
src/sqlitetablemodel.h
src/RowLoader.h
src/RowCache.h
src/sqltextedit.h
src/docktextedit.h
src/DbStructureModel.h
src/dbstructureqitemviewfacade.h
src/Application.h
src/CipherDialog.h
src/ExportSqlDialog.h
src/SqlUiLexer.h
src/FileDialog.h
src/ColumnDisplayFormatDialog.h
src/FilterLineEdit.h
src/RemoteDatabase.h
src/ForeignKeyEditorDelegate.h
src/PlotDock.h
src/RemoteDock.h
src/RemoteModel.h
src/RemotePushDialog.h
src/FindReplaceDialog.h
src/ExtendedScintilla.h
src/FileExtensionManager.h
src/CondFormatManager.h
src/CipherSettings.h
src/Palette.h
src/CondFormat.h
src/RunSql.h
src/ProxyDialog.h
src/SelectItemsPopup.h
src/TableBrowser.h
src/ImageViewer.h
src/RemoteLocalFilesModel.h
src/RemoteCommitsModel.h
src/RemoteNetwork.h
src/TableBrowserDock.h
)
target_sources(${PROJECT_NAME}
PRIVATE
src/AboutDialog.cpp
src/EditIndexDialog.cpp
src/EditDialog.cpp
src/EditTableDialog.cpp
src/AddRecordDialog.cpp
src/ExportDataDialog.cpp
src/ExtendedTableWidget.cpp
src/FilterTableHeader.cpp
src/ImportCsvDialog.cpp
src/MainWindow.cpp
src/Settings.cpp
src/PreferencesDialog.cpp
src/SqlExecutionArea.cpp
src/VacuumDialog.cpp
src/sqlitedb.cpp
src/sqlitetablemodel.cpp
src/RowLoader.cpp
src/sql/sqlitetypes.cpp
src/sql/Query.cpp
src/sql/ObjectIdentifier.cpp
src/sqltextedit.cpp
src/docktextedit.cpp
src/csvparser.cpp
src/DbStructureModel.cpp
src/dbstructureqitemviewfacade.cpp
src/main.cpp
src/Application.cpp
src/CipherDialog.cpp
src/ExportSqlDialog.cpp
src/SqlUiLexer.cpp
src/FileDialog.cpp
src/ColumnDisplayFormatDialog.cpp
src/FilterLineEdit.cpp
src/RemoteDatabase.cpp
src/ForeignKeyEditorDelegate.cpp
src/PlotDock.cpp
src/RemoteDock.cpp
src/RemoteModel.cpp
src/RemotePushDialog.cpp
src/FindReplaceDialog.cpp
src/ExtendedScintilla.cpp
src/FileExtensionManager.cpp
src/CondFormatManager.cpp
src/Data.cpp
src/CipherSettings.cpp
src/Palette.cpp
src/CondFormat.cpp
src/RunSql.cpp
src/ProxyDialog.cpp
src/IconCache.cpp
src/SelectItemsPopup.cpp
src/TableBrowser.cpp
src/sql/parser/ParserDriver.cpp
src/sql/parser/sqlite3_lexer.cpp
src/sql/parser/sqlite3_parser.cpp
src/ImageViewer.cpp
src/RemoteLocalFilesModel.cpp
src/RemoteCommitsModel.cpp
src/RemoteNetwork.cpp
src/TableBrowserDock.cpp
)
source_group("Qt UI" "src/.*\.ui$")
target_sources(${PROJECT_NAME}
PRIVATE
src/AboutDialog.ui
src/EditIndexDialog.ui
src/EditDialog.ui
src/EditTableDialog.ui
src/AddRecordDialog.ui
src/ExportDataDialog.ui
src/ImportCsvDialog.ui
src/MainWindow.ui
src/PreferencesDialog.ui
src/SqlExecutionArea.ui
src/VacuumDialog.ui
src/CipherDialog.ui
src/ExportSqlDialog.ui
src/ColumnDisplayFormatDialog.ui
src/PlotDock.ui
src/RemoteDock.ui
src/RemotePushDialog.ui
src/FindReplaceDialog.ui
src/FileExtensionManager.ui
src/CondFormatManager.ui
src/ProxyDialog.ui
src/SelectItemsPopup.ui
src/TableBrowser.ui
src/ImageViewer.ui
)
include(config/translations.cmake)
source_group("Qt Resources" "src/.*\.qrc$")
target_sources(${PROJECT_NAME}
PRIVATE
# General
src/certs/CaCerts.qrc
src/sql/parser/sqlite3_parser.yy
src/sql/parser/sqlite3_lexer.ll
# Graphics
src/icons/icons.qrc
# Translations
src/translations/flags/flags.qrc
src/translations/translations.qrc
# Styles
src/qdarkstyle/dark/darkstyle.qrc
src/qdarkstyle/light/lightstyle.qrc
)
target_link_libraries(${PROJECT_NAME}
PRIVATE
${QT_LIBS}
QHexEdit::QHexEdit QCustomPlot::QCustomPlot QScintilla::QScintilla
${LIBSQLITE_NAME}
${PLATFORM_LIBS}
)
include(config/install.cmake)
if(ENABLE_TESTING)
enable_testing()
add_subdirectory(src/tests)
endif()
# CPack configuration
set(CPACK_STRIP_FILES ON)
set(CPACK_DEBIAN_PACKAGE_PRIORITY optional)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Tristan Stenner <dbbrowser@nicht.dienstli.ch>")
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
if(APPLE)
set(CPACK_DEFAULT_GEN TBZ2)
elseif(WIN32)
set(CPACK_DEFAULT_GEN ZIP)
set(CPACK_NSIS_MODIFY_PATH ON)
set(CPACK_WIX_CMAKE_PACKAGE_REGISTRY ON)
set(CPACK_WIX_UPGRADE_GUID "78c885a7-e9c8-4ded-9b62-9abe47466950")
elseif(UNIX)
set(CPACK_DEFAULT_GEN DEB)
set(CPACK_SET_DESTDIR 1)
set(CPACK_INSTALL_PREFIX "/usr")
endif()
set(CPACK_GENERATOR ${CPACK_DEFAULT_GEN} CACHE STRING "CPack pkg type(s) to generate")
include(CPack)