forked from ragnar-lodbrok/meow-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
executable file
·500 lines (425 loc) · 15.4 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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
# see http://doc.qt.io/qt-5/cmake-manual.html
# https://github.com/rhtyd/cmakeqt/blob/master/CMakeLists.txt
# https://github.com/district10/cmake-templates
cmake_minimum_required(VERSION 3.1)
#set(QT_MINIMUM_VERSION 5.0.0) # TODO
project(meowsql)
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 4)
set(PROJECT_VERSION_PATCH 16)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
#set(CMAKE_AUTORCC ON) # TODO
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11) # TODO 14 for Qt >= 5.5
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
find_package(Qt5Widgets CONFIG REQUIRED)
find_package(Qt5Sql REQUIRED)
add_definitions(-DYY_NO_UNISTD_H) # fix flex compilation on win
option(WITH_MYSQL "MySQL support" ON)
option(WITH_POSTGRESQL "PostgreSQL support" ON)
option(WITH_SQLITE "SQLite support" ON)
option(WITH_QTSQL "Qt SQL Module" ON)
option(WITH_LIBSSH "Use libssh" OFF) # not finished
option(USE_CONAN_IO "Use conan.io package manager" OFF)
if(WIN32)
set(USE_CONAN_IO ON)
endif()
if(WITH_POSTGRESQL)
add_definitions(-DWITH_POSTGRESQL)
endif()
if(WITH_SQLITE)
add_definitions(-DWITH_SQLITE)
endif()
if(WITH_MYSQL)
add_definitions(-DWITH_MYSQL)
endif()
if(WITH_QTSQL)
add_definitions(-DWITH_QTSQL)
endif()
if(WITH_LIBSSH)
add_definitions(-DWITH_LIBSSH)
endif()
set(HEADER_FILES
db/data_type/connection_data_types.h
db/data_type/data_type_category.h
db/db_thread_initializer.h
db/collation_fetcher.h
db/common.h
db/query_column.h
db/query_results.h
db/user_manager.h
db/user_editor_interface.h
ssh/ssh_tunnel_interface.h
threads/helpers.h
threads/mutex.h
ui/common/mysql_syntax.h
ui/main_window/central_right/global_data_filter_interface.h
ui/main_window/central_right/base_root_tab.h
)
if(WITH_MYSQL)
list(APPEND HEADER_FILES
db/data_type/mysql_data_type.h
)
endif()
if(WITH_POSTGRESQL)
list(APPEND HEADER_FILES
db/data_type/pg_data_type.h
)
endif()
set(SOURCE_FILES
main.cpp
app/actions.cpp
app/app.cpp
app/log.cpp
db/connection.cpp
db/connection_features.cpp
db/connection_parameters.cpp
db/connection_params_manager.cpp
db/connection_query_killer.cpp
db/connections_manager.cpp
db/database_editor.cpp
db/db_thread_initializer.cpp
db/data_type/data_type.cpp
db/editable_grid_data.cpp
db/entity/database_entity.cpp
db/entity/entities_fetcher.cpp
db/entity/entity.cpp
db/entity/entity_factory.cpp
db/entity/entity_filter.cpp
db/entity/entity_holder.cpp
db/entity/routine_entity.cpp
db/entity/session_entity.cpp
db/entity/table_entity_comparator.cpp
db/entity/table_entity.cpp
db/entity/trigger_entity.cpp
db/entity/view_entity.cpp
db/exception.cpp
db/foreign_key.cpp
db/native_query_result.cpp
db/query.cpp
db/query_criteria.cpp
db/query_data.cpp
db/query_data_editor.cpp
db/query_data_fetcher.cpp
db/routine_editor.cpp
db/routine_structure_parser.cpp
db/routine_structure.cpp
db/session_variables.cpp
db/table_column.cpp
db/table_editor.cpp
db/table_index.cpp
db/table_structure.cpp
db/table_structure_parser.cpp
db/trigger_editor.cpp
db/trigger_structure_parser.cpp
db/trigger_structure.cpp
db/view_editor.cpp
db/view_structure.cpp
db/view_structure_parser.cpp
db/user_queries_manager.cpp
db/user_query/batch_executor.cpp
db/user_query/sentences_parser.cpp
db/user_query/user_query.cpp
helpers/formatting.cpp
helpers/logger.cpp
helpers/parsing.cpp
helpers/random_password_generator.cpp
helpers/text.cpp
settings/settings_core.cpp
settings/settings_geometry.cpp
settings/settings_icons.cpp
settings/settings_text.cpp
settings/data_editors.cpp
settings/queries_storage.cpp
settings/table_filters_storage.cpp
ssh/openssh_tunnel.cpp
ssh/ssh_tunnel_factory.cpp
ssh/ssh_tunnel_parameters.cpp
threads/db_thread.cpp
threads/queries_task.cpp
threads/thread_task.cpp
threads/thread_init_task.cpp
ui/common/checkbox_list_popup.cpp
ui/common/data_type_combo_box.cpp
ui/common/geometry_helpers.cpp
ui/common/editable_data_table_view.cpp
ui/common/sql_editor.cpp
ui/common/sql_log_editor.cpp
ui/common/sql_syntax_highlighter.cpp
ui/common/table_cell_line_edit.cpp
ui/common/table_column_default_editor.cpp
ui/common/table_view.cpp
ui/common/text_editor_popup.cpp
ui/delegates/checkbox_delegate.cpp
ui/delegates/checkbox_list_item_editor_wrapper.cpp
ui/delegates/combobox_delegate.cpp
ui/delegates/combobox_item_editor_wrapper.cpp
ui/delegates/edit_query_data_delegate.cpp
ui/delegates/line_edit_item_editor_wrapper.cpp
ui/delegates/date_time_item_editor_wrapper.cpp
ui/delegates/foreign_key_columns_delegate.cpp
ui/delegates/foreign_key_foreign_columns_delegate.cpp
ui/delegates/foreign_key_reference_option_delegate.cpp
ui/delegates/foreign_key_reference_table_delegate.cpp
ui/delegates/table_column_collation_delegate.cpp
ui/delegates/table_column_default_delegate.cpp
ui/delegates/table_column_type_delegate.cpp
ui/delegates/table_index_delegate.cpp
ui/edit_database/dialog.cpp
ui/export_database/bottom_widget.cpp
ui/export_database/export_dialog.cpp
ui/export_database/top_widget.cpp
ui/main_window/central_bottom_widget.cpp
ui/main_window/central_left_db_tree.cpp
ui/main_window/central_left_widget.cpp
ui/main_window/central_log_widget.cpp
ui/main_window/central_right/database/central_right_database_tab.cpp
ui/main_window/central_right/data/central_right_data_tab.cpp
ui/main_window/central_right/data/cr_data_filter_widget.cpp
ui/main_window/central_right/host/central_right_host_tab.cpp
ui/main_window/central_right/host/cr_host_databases_tab.cpp
ui/main_window/central_right/host/cr_host_variables_tab.cpp
ui/main_window/central_right/routine/central_right_routine_tab.cpp
ui/main_window/central_right/routine/cr_routine_body.cpp
ui/main_window/central_right/routine/cr_routine_info.cpp
ui/main_window/central_right/routine/cr_routine_info_options_tab.cpp
ui/main_window/central_right/routine/cr_routine_info_parameters_tab.cpp
ui/main_window/central_right/routine/cr_routine_parameters_tools.cpp
ui/main_window/central_right/query/central_right_query_tab.cpp
ui/main_window/central_right/query/cr_query_data_tab.cpp
ui/main_window/central_right/query/cr_query_panel.cpp
ui/main_window/central_right/query/cr_query_result.cpp
ui/main_window/central_right/table/central_right_table_tab.cpp
ui/main_window/central_right/table/cr_table_columns.cpp
ui/main_window/central_right/table/cr_table_columns_tools.cpp
ui/main_window/central_right/table/cr_table_foreign_keys_tools.cpp
ui/main_window/central_right/table/cr_table_indexes_tools.cpp
ui/main_window/central_right/table/cr_table_info_basic_tab.cpp
ui/main_window/central_right/table/cr_table_info.cpp
ui/main_window/central_right/table/cr_table_info_foreign_keys_tab.cpp
ui/main_window/central_right/table/cr_table_info_indexes_tab.cpp
ui/main_window/central_right/table/cr_table_info_options_tab.cpp
ui/main_window/central_right/trigger/central_right_trigger_tab.cpp
ui/main_window/central_right/trigger/cr_trigger_body.cpp
ui/main_window/central_right/trigger/cr_trigger_options.cpp
ui/main_window/central_right/view/central_right_view_tab.cpp
ui/main_window/central_right/global_filter_widget.cpp
ui/main_window/central_right_widget.cpp
ui/main_window/central_widget.cpp
ui/main_window/main_window.cpp
ui/main_window/main_window_status_bar.cpp
ui/models/base_data_table_model.cpp
ui/models/connection_params_model.cpp
ui/models/database_entities_table_model.cpp
ui/models/databases_table_model.cpp
ui/models/data_table_model.cpp
ui/models/entities_tree_model.cpp
ui/models/entities_tree_sort_filter_proxy_model.cpp
ui/models/query_data_sort_filter_proxy_model.cpp
ui/models/table_columns_model.cpp
ui/models/table_foreign_keys_model.cpp
ui/models/table_indexes_model.cpp
ui/models/table_indexes_model_item.cpp
ui/models/routine_parameters_model.cpp
ui/models/users_table_model.cpp
ui/models/user_privileges_model.cpp
ui/models/variables_table_model.cpp
ui/models/session_objects_tree_model.cpp
ui/presenters/central_right_host_widget_model.cpp
ui/presenters/central_right_widget_model.cpp
ui/presenters/central_right_data_filter_form.cpp
ui/presenters/table_info_widget_model.cpp
ui/presenters/routine_info_widget_model.cpp
ui/presenters/central_right_query_presenter.cpp
ui/presenters/connection_parameters_form.cpp
ui/presenters/edit_database_form.cpp
ui/presenters/editable_data_context_menu_presenter.cpp
ui/presenters/export_database_form.cpp
ui/presenters/routine_form.cpp
ui/presenters/select_db_object_form.cpp
ui/presenters/table_info_form.cpp
ui/presenters/trigger_form.cpp
ui/presenters/text_editor_popup_form.cpp
ui/presenters/view_form.cpp
ui/presenters/user_management_form.cpp
ui/session_manager/session_form.cpp
ui/session_manager/settings_tab.cpp
ui/session_manager/ssh_tunnel_tab.cpp
ui/session_manager/start_tab.cpp
ui/session_manager/window.cpp
ui/user_manager/user_manager_window.cpp
ui/user_manager/left_widget.cpp
ui/user_manager/right_widget.cpp
ui/user_manager/options_widget.cpp
ui/user_manager/privileges_widget.cpp
ui/user_manager/credentials_tab.cpp
ui/user_manager/limitations_tab.cpp
ui/user_manager/select_db_object.cpp
utils/exporting/mysql_dump_console.cpp
)
if (WITH_MYSQL)
list(APPEND SOURCE_FILES
db/data_type/mysql_connection_data_types.cpp
db/entity/mysql_entity_filter.cpp
db/mysql/mysql_database_editor.cpp
db/mysql/mysql_entities_fetcher.cpp
db/mysql/mysql_library_initializer.cpp
db/mysql/mysql_query_result.cpp
db/mysql/mysql_query_data_editor.cpp
db/mysql/mysql_collation_fetcher.cpp
db/mysql/mysql_connection.cpp
db/mysql/mysql_connection_query_killer.cpp
db/mysql/mysql_query_data_fetcher.cpp
db/mysql/mysql_table_editor.cpp
db/mysql/mysql_table_engines_fetcher.cpp
db/mysql/mysql_user_manager.cpp
db/mysql/mysql_user_editor.cpp
db/mysql/mysql_thread_initializer.cpp
)
endif()
if (WITH_POSTGRESQL)
list(APPEND SOURCE_FILES
db/data_type/pg_connection_data_types.cpp
db/pg/pg_connection.cpp
db/pg/pg_connection_query_killer.cpp
db/pg/pg_entities_fetcher.cpp
db/pg/pg_entity_create_code_generator.cpp
db/pg/pg_query_data_editor.cpp
db/pg/pg_query_data_fetcher.cpp
db/pg/pg_query_result.cpp
)
endif()
if (WITH_SQLITE)
list(APPEND SOURCE_FILES
db/data_type/sqlite_connection_datatypes.cpp
db/sqlite/sqlite_connection.cpp
db/sqlite/sqlite_entities_fetcher.cpp
db/sqlite/sqlite_table_structure_parser.cpp
utils/sql_parser/sqlite/sqlite_parser.cpp
utils/sql_parser/sqlite/sqlite_bison_parser.cpp
utils/sql_parser/sqlite/sqlite_flex_lexer.cpp
utils/sql_parser/sqlite/sqlite_types.cpp
)
endif()
if(WITH_QTSQL)
list(APPEND SOURCE_FILES
db/qtsql/qtsql_query_result.cpp
)
endif()
if(WITH_LIBSSH)
list(APPEND SOURCE_FILES
ssh/libssh_tunnel.cpp
)
endif()
if(WIN32)
list(APPEND SOURCE_FILES
ssh/plink_ssh_tunnel.cpp
)
endif()
qt5_add_resources(RESOURCE_FILES icons.qrc)
if (WIN32)
list(APPEND RESOURCE_FILES meowsql.rc)
endif()
if (WIN32)
SET(EXE_TYPE WIN32)
endif()
if (APPLE)
SET(EXE_TYPE MACOSX_BUNDLE)
endif()
add_executable(meowsql
${EXE_TYPE}
${HEADER_FILES}
${SOURCE_FILES}
${RESOURCE_FILES})
target_link_libraries(meowsql Qt5::Widgets)
if(WITH_QTSQL)
target_link_libraries(meowsql Qt5::Sql)
endif()
if (WIN32)
target_link_libraries(meowsql
User32 #SetProcessDPIAware()
ws2_32 # WSAStartup() - sockets
)
endif()
if (USE_CONAN_IO)
# assume you run conan from ./conan folder
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/conan)
endif()
# MySQL ---------------------------------------------
if (WITH_MYSQL)
set(MEOW_MYSQL_CLIENT_LIB mysqlclient) #linux
if (WIN32)
if (USE_CONAN_IO)
find_package(mysql-connector-c REQUIRED)
include_directories(${mysql-connector-c_INCLUDE_DIR})
message("mysql-connector-c_INCLUDE_DIR = ${mysql-connector-c_INCLUDE_DIR}")
set(MEOW_MYSQL_CLIENT_LIB ${mysql-connector-c_LIBRARY_LIST})
target_link_directories(meowsql PUBLIC ${mysql-connector-c_LIB_DIRS})
message("mysql-connector-c_LIB_DIRS = ${mysql-connector-c_LIB_DIRS}")
else()
# find mysql manually
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package(MySQL REQUIRED)
include_directories(${MYSQL_INCLUDE_DIR})
set(MEOW_MYSQL_CLIENT_LIB ${MYSQL_LIBRARY})
endif()
endif()
endif() # if (WITH_MYSQL)
# PG --------------------------------------------------
# ubuntu: apt-get install libpq-dev postgresql-server-dev-all
# win: https://www.enterprisedb.com/downloads/postgres-postgresql-downloads (10.7 32bit)
# win2: conan install .. --settings arch=x86 --settings arch_build=x86 --settings build_type=Release --build=missing
if(WITH_POSTGRESQL)
if (WIN32)
if (${USE_CONAN_IO} EQUAL OFF)
# find postgres in third_party
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/third_party/libpq/windows/include/postgresql")
# PostgreSQL_INCLUDE_DIR - the path to where the PostgreSQL include files are.
set (PostgreSQL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/libpq/windows/include/postgresql")
# PostgreSQL_LIBRARY_DIR - The path to where the PostgreSQL library files are.
set (PostgreSQL_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/libpq/windows/lib")
endif()
endif()
find_package(PostgreSQL REQUIRED)
include_directories(meowsql ${PostgreSQL_INCLUDE_DIRS})
message ("PostgreSQL_VERSION_STRING = ${PostgreSQL_VERSION_STRING}")
message ("PostgreSQL_INCLUDE_DIRS = ${PostgreSQL_INCLUDE_DIRS}")
message ("PostgreSQL_LIBRARY_DIRS = ${PostgreSQL_LIBRARY_DIRS}")
message ("PostgreSQL_LIBRARIES = ${PostgreSQL_LIBRARIES}")
endif() # if(WITH_POSTGRESQL)
# PG end ----------------------------------------------
if(WITH_LIBSSH)
# https://www.libssh.org/2019/11/07/libssh-0-9-2/
find_package(libssh REQUIRED)
message ("LIBSSH_INCLUDE_DIR = ${LIBSSH_INCLUDE_DIR}")
message ("LIBSSH_LIBRARIES = ${LIBSSH_LIBRARIES}")
target_link_libraries(meowsql pthread ssh)
endif()
if(WITH_MYSQL)
target_link_libraries(meowsql
${MEOW_MYSQL_CLIENT_LIB}
)
endif()
if(WITH_POSTGRESQL)
target_link_libraries(meowsql
${PostgreSQL_LIBRARIES}
)
endif()
if(UNIX)
if(NOT DEFINED CMAKE_INSTALL_DATAROOTDIR)
set(CMAKE_INSTALL_DATAROOTDIR "share")
endif()
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib)
install(FILES meowsql.png
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/256x256/apps/")
install(FILES meowsql.svg
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps/"
RENAME ${PROJECT_NAME}.svg)
install(FILES meowsql.desktop
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications/")
endif(UNIX)