CMakeLists.txt 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. cmake_minimum_required(VERSION 3.15)
  2. project(sqlitebrowser
  3. VERSION 3.12.99
  4. DESCRIPTION "GUI editor for SQLite databases"
  5. )
  6. # Fix behavior of CMAKE_CXX_STANDARD when targeting macOS.
  7. if(POLICY CMP0025)
  8. # https://cmake.org/cmake/help/latest/policy/CMP0025.html
  9. cmake_policy(SET CMP0025 NEW)
  10. endif()
  11. # Fix warning of AUTOMOC behavior
  12. if(POLICY CMP0071)
  13. # https://cmake.org/cmake/help/latest/policy/CMP0071.html
  14. cmake_policy(SET CMP0071 NEW)
  15. endif()
  16. # Fix warning of Cached Variables
  17. if(POLICY CMP0102)
  18. # https://cmake.org/cmake/help/latest/policy/CMP0102.html
  19. cmake_policy(SET CMP0102 NEW)
  20. endif()
  21. include(GNUInstallDirs)
  22. OPTION(BUILD_STABLE_VERSION "Don't build the stable version by default" OFF) # Choose between building a stable version or nightly (the default), depending on whether '-DBUILD_STABLE_VERSION=1' is passed on the command line or not.
  23. OPTION(ENABLE_TESTING "Enable the unit tests" OFF)
  24. OPTION(FORCE_INTERNAL_QSCINTILLA "Don't use the distribution's QScintilla library even if there is one" OFF)
  25. OPTION(FORCE_INTERNAL_QCUSTOMPLOT "Don't use distribution's QCustomPlot even if available" ON)
  26. OPTION(FORCE_INTERNAL_QHEXEDIT "Don't use distribution's QHexEdit even if available" ON)
  27. OPTION(ALL_WARNINGS "Enable some useful warning flags" OFF)
  28. OPTION(sqlcipher "Build with SQLCipher library" OFF)
  29. OPTION(customTap "Using SQLCipher, SQLite and Qt installed through our custom Homebrew tap" OFF)
  30. set(CMAKE_CXX_STANDARD 14)
  31. set(CMAKE_CXX_STANDARD_REQUIRED True)
  32. set(CMAKE_AUTOMOC ON)
  33. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  34. if(APPLE)
  35. add_executable(${PROJECT_NAME} MACOSX_BUNDLE)
  36. elseif(WIN32)
  37. add_executable(${PROJECT_NAME} WIN32)
  38. else()
  39. add_executable(${PROJECT_NAME})
  40. endif()
  41. # Determine the git commit hash
  42. execute_process(
  43. COMMAND git rev-parse --short --verify HEAD
  44. OUTPUT_VARIABLE GIT_COMMIT_HASH
  45. OUTPUT_STRIP_TRAILING_WHITESPACE
  46. ERROR_QUIET
  47. )
  48. if (GIT_COMMIT_HASH STREQUAL "")
  49. MESSAGE(WARNING "Could not determine git commit hash")
  50. set(GIT_COMMIT_HASH "Unknown")
  51. endif()
  52. add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}")
  53. if(NOT BUILD_STABLE_VERSION)
  54. # BUILD_VERSION is the current date in YYYYMMDD format. It is only
  55. # used by the nightly version to add the date of the build.
  56. # Default defined in Version.h.in
  57. string(TIMESTAMP BUILD_VERSION "%Y%m%d")
  58. target_compile_definitions(${PROJECT_NAME} PRIVATE BUILD_VERSION=${BUILD_VERSION})
  59. endif()
  60. set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")
  61. if(NOT CMAKE_BUILD_TYPE)
  62. set(CMAKE_BUILD_TYPE "Release")
  63. endif()
  64. if(MSVC)
  65. if(CMAKE_CL_64)
  66. # Paths for 64-bit windows builds
  67. set(OPENSSL_PATH "C:/dev/OpenSSL-Win64" CACHE PATH "OpenSSL Path")
  68. set(QT5_PATH "C:/dev/Qt/5.12.12/msvc2017_64" CACHE PATH "Qt5 Path")
  69. # Choose between SQLCipher or SQLite, depending whether
  70. # -Dsqlcipher=on is passed on the command line
  71. if(sqlcipher)
  72. set(SQLITE3_PATH "C:/git_repos/SQLCipher-Win64" CACHE PATH "SQLCipher Path")
  73. else()
  74. set(SQLITE3_PATH "C:/dev/SQLite-Win64" CACHE PATH "SQLite Path")
  75. endif()
  76. else()
  77. # Paths for 32-bit windows builds
  78. set(OPENSSL_PATH "C:/dev/OpenSSL-Win32" CACHE PATH "OpenSSL Path")
  79. set(QT5_PATH "C:/dev/Qt/5.12.12/msvc2017" CACHE PATH "Qt5 Path")
  80. # Choose between SQLCipher or SQLite, depending whether
  81. # -Dsqlcipher=on is passed on the command line
  82. if(sqlcipher)
  83. set(SQLITE3_PATH "C:/git_repos/SQLCipher-Win32" CACHE PATH "SQLCipher Path")
  84. else()
  85. set(SQLITE3_PATH "C:/dev/SQLite-Win32" CACHE PATH "SQLite Path")
  86. endif()
  87. endif()
  88. list(PREPEND CMAKE_PREFIX_PATH ${QT5_PATH} ${SQLITE3_PATH})
  89. endif()
  90. if(APPLE)
  91. # For Intel Mac's
  92. if(EXISTS /usr/local/opt/qt5)
  93. list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/qt5")
  94. endif()
  95. # For Apple Silicon Mac's
  96. if(EXISTS /opt/homebrew/opt/qt5)
  97. list(APPEND CMAKE_PREFIX_PATH "/opt/homebrew/opt/qt5")
  98. endif()
  99. if(EXISTS /opt/homebrew/opt/sqlitefts5)
  100. list(PREPEND CMAKE_PREFIX_PATH "/opt/homebrew/opt/sqlitefts5")
  101. endif()
  102. # For Apple Silicon Mac's and install dependencies via our Homebrew tap(sqlitebrowser/homebrew-tap)
  103. if(customTap AND EXISTS /opt/homebrew/opt/)
  104. list(PREPEND CMAKE_PREFIX_PATH "/opt/homebrew/opt/db4subqt@5")
  105. list(PREPEND CMAKE_PREFIX_PATH "/opt/homebrew/opt/db4subsqlitefts@5")
  106. if(sqlcipher)
  107. list(APPEND SQLCIPHER_INCLUDE_DIR "/opt/homebrew/include")
  108. list(APPEND SQLCIPHER_LIBRARY "/opt/homebrew/opt/db4subsqlcipher/lib/libsqlcipher.0.dylib")
  109. endif()
  110. endif()
  111. endif()
  112. find_package(Qt5 REQUIRED COMPONENTS Concurrent Gui LinguistTools Network PrintSupport Test Widgets Xml)
  113. if(NOT FORCE_INTERNAL_QSCINTILLA)
  114. find_package(QScintilla 2.8.10)
  115. endif()
  116. if(NOT FORCE_INTERNAL_QCUSTOMPLOT)
  117. find_package(QCustomPlot)
  118. endif()
  119. if(NOT FORCE_INTERNAL_QHEXEDIT)
  120. find_package(QHexEdit)
  121. endif()
  122. target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/libs/json)
  123. if(NOT QSCINTILLA_FOUND)
  124. add_subdirectory(libs/qscintilla/Qt4Qt5)
  125. endif()
  126. if(NOT QHexEdit_FOUND)
  127. add_subdirectory(libs/qhexedit)
  128. endif()
  129. if(NOT QCustomPlot_FOUND)
  130. add_subdirectory(libs/qcustomplot-source)
  131. endif()
  132. if(ENABLE_TESTING)
  133. enable_testing()
  134. endif()
  135. # generate file with version information
  136. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in
  137. ${CMAKE_CURRENT_BINARY_DIR}/version.h
  138. )
  139. target_sources(${PROJECT_NAME}
  140. PRIVATE
  141. src/sql/sqlitetypes.h
  142. src/sql/Query.h
  143. src/sql/ObjectIdentifier.h
  144. src/csvparser.h
  145. src/sqlite.h
  146. src/Data.h
  147. src/IconCache.h
  148. src/sql/parser/ParserDriver.h
  149. src/sql/parser/sqlite3_lexer.h
  150. src/sql/parser/sqlite3_location.h
  151. src/sql/parser/sqlite3_parser.hpp
  152. )
  153. target_sources(${PROJECT_NAME}
  154. PRIVATE
  155. src/sqlitedb.h
  156. src/AboutDialog.h
  157. src/EditIndexDialog.h
  158. src/EditDialog.h
  159. src/EditTableDialog.h
  160. src/AddRecordDialog.h
  161. src/ExportDataDialog.h
  162. src/ExtendedTableWidget.h
  163. src/FilterTableHeader.h
  164. src/ImportCsvDialog.h
  165. src/MainWindow.h
  166. src/Settings.h
  167. src/PreferencesDialog.h
  168. src/SqlExecutionArea.h
  169. src/VacuumDialog.h
  170. src/sqlitetablemodel.h
  171. src/RowLoader.h
  172. src/RowCache.h
  173. src/sqltextedit.h
  174. src/docktextedit.h
  175. src/DbStructureModel.h
  176. src/dbstructureqitemviewfacade.h
  177. src/Application.h
  178. src/CipherDialog.h
  179. src/ExportSqlDialog.h
  180. src/SqlUiLexer.h
  181. src/FileDialog.h
  182. src/ColumnDisplayFormatDialog.h
  183. src/FilterLineEdit.h
  184. src/RemoteDatabase.h
  185. src/ForeignKeyEditorDelegate.h
  186. src/PlotDock.h
  187. src/RemoteDock.h
  188. src/RemoteModel.h
  189. src/RemotePushDialog.h
  190. src/FindReplaceDialog.h
  191. src/ExtendedScintilla.h
  192. src/FileExtensionManager.h
  193. src/CondFormatManager.h
  194. src/CipherSettings.h
  195. src/DotenvFormat.h
  196. src/Palette.h
  197. src/CondFormat.h
  198. src/RunSql.h
  199. src/ProxyDialog.h
  200. src/SelectItemsPopup.h
  201. src/TableBrowser.h
  202. src/ImageViewer.h
  203. src/RemoteLocalFilesModel.h
  204. src/RemoteCommitsModel.h
  205. src/RemoteNetwork.h
  206. src/TableBrowserDock.h
  207. )
  208. target_sources(${PROJECT_NAME}
  209. PRIVATE
  210. src/AboutDialog.cpp
  211. src/EditIndexDialog.cpp
  212. src/EditDialog.cpp
  213. src/EditTableDialog.cpp
  214. src/AddRecordDialog.cpp
  215. src/ExportDataDialog.cpp
  216. src/ExtendedTableWidget.cpp
  217. src/FilterTableHeader.cpp
  218. src/ImportCsvDialog.cpp
  219. src/MainWindow.cpp
  220. src/Settings.cpp
  221. src/PreferencesDialog.cpp
  222. src/SqlExecutionArea.cpp
  223. src/VacuumDialog.cpp
  224. src/sqlitedb.cpp
  225. src/sqlitetablemodel.cpp
  226. src/RowLoader.cpp
  227. src/sql/sqlitetypes.cpp
  228. src/sql/Query.cpp
  229. src/sql/ObjectIdentifier.cpp
  230. src/sqltextedit.cpp
  231. src/docktextedit.cpp
  232. src/csvparser.cpp
  233. src/DbStructureModel.cpp
  234. src/dbstructureqitemviewfacade.cpp
  235. src/main.cpp
  236. src/Application.cpp
  237. src/CipherDialog.cpp
  238. src/ExportSqlDialog.cpp
  239. src/SqlUiLexer.cpp
  240. src/FileDialog.cpp
  241. src/ColumnDisplayFormatDialog.cpp
  242. src/FilterLineEdit.cpp
  243. src/RemoteDatabase.cpp
  244. src/ForeignKeyEditorDelegate.cpp
  245. src/PlotDock.cpp
  246. src/RemoteDock.cpp
  247. src/RemoteModel.cpp
  248. src/RemotePushDialog.cpp
  249. src/FindReplaceDialog.cpp
  250. src/ExtendedScintilla.cpp
  251. src/FileExtensionManager.cpp
  252. src/CondFormatManager.cpp
  253. src/Data.cpp
  254. src/CipherSettings.cpp
  255. src/DotenvFormat.cpp
  256. src/Palette.cpp
  257. src/CondFormat.cpp
  258. src/RunSql.cpp
  259. src/ProxyDialog.cpp
  260. src/IconCache.cpp
  261. src/SelectItemsPopup.cpp
  262. src/TableBrowser.cpp
  263. src/sql/parser/ParserDriver.cpp
  264. src/sql/parser/sqlite3_lexer.cpp
  265. src/sql/parser/sqlite3_parser.cpp
  266. src/ImageViewer.cpp
  267. src/RemoteLocalFilesModel.cpp
  268. src/RemoteCommitsModel.cpp
  269. src/RemoteNetwork.cpp
  270. src/TableBrowserDock.cpp
  271. )
  272. set(SQLB_FORMS
  273. src/AboutDialog.ui
  274. src/EditIndexDialog.ui
  275. src/EditDialog.ui
  276. src/EditTableDialog.ui
  277. src/AddRecordDialog.ui
  278. src/ExportDataDialog.ui
  279. src/ImportCsvDialog.ui
  280. src/MainWindow.ui
  281. src/PreferencesDialog.ui
  282. src/SqlExecutionArea.ui
  283. src/VacuumDialog.ui
  284. src/CipherDialog.ui
  285. src/ExportSqlDialog.ui
  286. src/ColumnDisplayFormatDialog.ui
  287. src/PlotDock.ui
  288. src/RemoteDock.ui
  289. src/RemotePushDialog.ui
  290. src/FindReplaceDialog.ui
  291. src/FileExtensionManager.ui
  292. src/CondFormatManager.ui
  293. src/ProxyDialog.ui
  294. src/SelectItemsPopup.ui
  295. src/TableBrowser.ui
  296. src/ImageViewer.ui
  297. )
  298. set(SQLB_RESOURCES
  299. src/icons/icons.qrc
  300. src/translations/flags/flags.qrc
  301. src/translations/translations.qrc
  302. src/certs/CaCerts.qrc
  303. src/qdarkstyle/dark/darkstyle.qrc
  304. src/qdarkstyle/light/lightstyle.qrc
  305. )
  306. set(SQLB_MISC
  307. src/sql/parser/sqlite3_parser.yy
  308. src/sql/parser/sqlite3_lexer.ll
  309. )
  310. # Translation files
  311. set(SQLB_TSS
  312. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_ar_SA.ts"
  313. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_cs.ts"
  314. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_zh.ts"
  315. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_zh_TW.ts"
  316. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_de.ts"
  317. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_es_ES.ts"
  318. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_fr.ts"
  319. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_ru.ts"
  320. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_pl.ts"
  321. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_pt_BR.ts"
  322. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_en_GB.ts"
  323. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_ko_KR.ts"
  324. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_tr.ts"
  325. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_uk_UA.ts"
  326. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_it.ts"
  327. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_ja.ts"
  328. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_nl.ts"
  329. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_sv.ts"
  330. "${CMAKE_SOURCE_DIR}/src/translations/sqlb_id.ts"
  331. )
  332. # Windows image format plugin files
  333. set(WIN_IMG_PLUGINS
  334. "${QT5_PATH}/plugins/imageformats/qgif.dll"
  335. "${QT5_PATH}/plugins/imageformats/qicns.dll"
  336. "${QT5_PATH}/plugins/imageformats/qico.dll"
  337. "${QT5_PATH}/plugins/imageformats/qjpeg.dll"
  338. "${QT5_PATH}/plugins/imageformats/qsvg.dll"
  339. "${QT5_PATH}/plugins/imageformats/qtga.dll"
  340. "${QT5_PATH}/plugins/imageformats/qtiff.dll"
  341. "${QT5_PATH}/plugins/imageformats/qwbmp.dll"
  342. "${QT5_PATH}/plugins/imageformats/qwebp.dll"
  343. )
  344. set(WIN_IMG_PLUGINS_DEBUG
  345. "${QT5_PATH}/plugins/imageformats/qgifd.dll"
  346. "${QT5_PATH}/plugins/imageformats/qicnsd.dll"
  347. "${QT5_PATH}/plugins/imageformats/qicod.dll"
  348. "${QT5_PATH}/plugins/imageformats/qjpegd.dll"
  349. "${QT5_PATH}/plugins/imageformats/qsvgd.dll"
  350. "${QT5_PATH}/plugins/imageformats/qtgad.dll"
  351. "${QT5_PATH}/plugins/imageformats/qtiffd.dll"
  352. "${QT5_PATH}/plugins/imageformats/qwbmpd.dll"
  353. "${QT5_PATH}/plugins/imageformats/qwebpd.dll"
  354. )
  355. # License files
  356. set(LICENSE_FILES
  357. LICENSE
  358. LICENSE-PLUGINS
  359. )
  360. qt5_wrap_ui(SQLB_FORM_HDR ${SQLB_FORMS})
  361. if(SQLB_TSS)
  362. # add translations
  363. foreach(SQLB_TS ${SQLB_TSS})
  364. set_source_files_properties("${SQLB_TS}" PROPERTIES OUTPUT_LOCATION "${CMAKE_SOURCE_DIR}/src/translations")
  365. endforeach()
  366. qt5_add_translation(SQLB_QMS ${SQLB_TSS})
  367. endif()
  368. qt5_add_resources(SQLB_RESOURCES_RCC ${SQLB_RESOURCES})
  369. #icon and correct libs/subsystem for windows
  370. if(WIN32)
  371. #enable version check for windows
  372. add_definitions(-DCHECKNEWVERSION)
  373. if(MINGW)
  374. # resource compilation for MinGW
  375. add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/sqlbicon.o"
  376. COMMAND windres "-I${CMAKE_CURRENT_BINARY_DIR}" "-i${CMAKE_CURRENT_SOURCE_DIR}/src/winapp.rc" -o "${CMAKE_CURRENT_BINARY_DIR}/sqlbicon.o" VERBATIM
  377. )
  378. target_sources(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/sqlbicon.o")
  379. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-subsystem,windows")
  380. set(WIN32_STATIC_LINK -Wl,-Bstatic -lssl -lcrypto -lws2_32)
  381. set(ADDITIONAL_LIBS lzma)
  382. else()
  383. target_sources(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/winapp.rc")
  384. endif()
  385. else()
  386. set(LPTHREAD pthread)
  387. endif()
  388. #enable version check for macOS
  389. if(APPLE)
  390. add_definitions(-DCHECKNEWVERSION)
  391. endif()
  392. # SQLCipher option
  393. if(sqlcipher)
  394. add_definitions(-DENABLE_SQLCIPHER)
  395. set(LIBSQLITE_NAME SQLCipher)
  396. else()
  397. set(LIBSQLITE_NAME SQLite3)
  398. endif()
  399. # add extra library path for MacOS and FreeBSD
  400. set(EXTRAPATH APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
  401. if(EXTRAPATH)
  402. list(PREPEND CMAKE_PREFIX_PATH /usr/local/opt/sqlite/lib)
  403. list(PREPEND CMAKE_PREFIX_PATH /usr/local/opt/sqlitefts5/lib)
  404. endif()
  405. find_package(${LIBSQLITE_NAME})
  406. if (sqlcipher)
  407. target_link_libraries(${PROJECT_NAME} SQLCipher::SQLCipher)
  408. else()
  409. target_link_libraries(${PROJECT_NAME} SQLite::SQLite3)
  410. endif()
  411. if(MSVC)
  412. if(sqlcipher)
  413. find_file(SQLITE3_DLL sqlcipher.dll)
  414. else()
  415. find_file(SQLITE3_DLL sqlite3.dll)
  416. endif()
  417. endif()
  418. target_include_directories(${PROJECT_NAME} PRIVATE src)
  419. target_sources(${PROJECT_NAME}
  420. PRIVATE
  421. ${SQLB_FORM_HDR}
  422. ${SQLB_MOC}
  423. ${SQLB_RESOURCES_RCC}
  424. ${SQLB_MISC}
  425. )
  426. # Warnings
  427. if(ALL_WARNINGS AND CMAKE_COMPILER_IS_GNUCC)
  428. target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion)
  429. target_compile_options(${PROJECT_NAME} PRIVATE -Wdouble-promotion -Wformat=2 -Wlogical-op -Wuseless-cast)
  430. if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7.0)
  431. target_compile_options(${PROJECT_NAME} PRIVATE -Wnull-dereference -Wduplicated-cond -Wduplicated-branches)
  432. endif()
  433. endif()
  434. set(QT_LIBS Qt5::Gui Qt5::Test Qt5::PrintSupport Qt5::Widgets Qt5::Network Qt5::Concurrent Qt5::Xml)
  435. target_link_libraries(${PROJECT_NAME}
  436. ${LPTHREAD}
  437. ${QT_LIBS}
  438. ${WIN32_STATIC_LINK}
  439. ${ADDITIONAL_LIBS}
  440. )
  441. target_link_libraries(${PROJECT_NAME}
  442. QHexEdit::QHexEdit
  443. QCustomPlot::QCustomPlot
  444. QScintilla::QScintilla
  445. )
  446. if(MSVC)
  447. set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "DB Browser for SQLite")
  448. set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
  449. set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE")
  450. set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
  451. set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS_RELWITHDEBINFO "_CONSOLE")
  452. if(CMAKE_CL_64)
  453. set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS,5.02 /ENTRY:mainCRTStartup")
  454. set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS,5.02")
  455. else()
  456. set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS,5.01 /ENTRY:mainCRTStartup")
  457. set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS,5.01")
  458. endif()
  459. endif()
  460. if((NOT WIN32 AND NOT APPLE) OR MINGW)
  461. install(TARGETS ${PROJECT_NAME}
  462. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  463. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  464. )
  465. endif()
  466. if(UNIX)
  467. target_link_libraries(${PROJECT_NAME} dl)
  468. endif()
  469. if(ENABLE_TESTING)
  470. add_subdirectory(src/tests)
  471. endif()
  472. if(UNIX)
  473. install(FILES src/icons/${PROJECT_NAME}.png
  474. DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/256x256/apps/
  475. )
  476. install(FILES images/logo.svg
  477. DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps/
  478. RENAME ${PROJECT_NAME}.svg
  479. )
  480. install(FILES distri/${PROJECT_NAME}.desktop
  481. DESTINATION ${CMAKE_INSTALL_DATADIR}/applications/
  482. )
  483. install(FILES distri/${PROJECT_NAME}.desktop.appdata.xml
  484. DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo/
  485. )
  486. endif()
  487. if(WIN32 AND MSVC)
  488. install(TARGETS ${PROJECT_NAME}
  489. RUNTIME DESTINATION "/"
  490. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  491. )
  492. set(QT5_BIN_PATH ${QT5_PATH}/bin)
  493. # The Qt5 Debug configuration library files have a 'd' postfix
  494. install(FILES
  495. ${QT5_BIN_PATH}/Qt5Cored.dll
  496. ${QT5_BIN_PATH}/Qt5Guid.dll
  497. ${QT5_BIN_PATH}/Qt5Networkd.dll
  498. ${QT5_BIN_PATH}/Qt5PrintSupportd.dll
  499. ${QT5_BIN_PATH}/Qt5Widgetsd.dll
  500. ${QT5_BIN_PATH}/Qt5Concurrentd.dll
  501. ${QT5_BIN_PATH}/Qt5Svgd.dll
  502. DESTINATION "/"
  503. CONFIGURATIONS Debug
  504. )
  505. # The Qt5 Release configuration files don't have a postfix
  506. install(FILES
  507. ${QT5_BIN_PATH}/Qt5Core.dll
  508. ${QT5_BIN_PATH}/Qt5Gui.dll
  509. ${QT5_BIN_PATH}/Qt5Network.dll
  510. ${QT5_BIN_PATH}/Qt5PrintSupport.dll
  511. ${QT5_BIN_PATH}/Qt5Widgets.dll
  512. ${QT5_BIN_PATH}/Qt5Concurrent.dll
  513. ${QT5_BIN_PATH}/Qt5Svg.dll
  514. DESTINATION "/"
  515. CONFIGURATIONS Release
  516. )
  517. # The files below are common to all configurations
  518. install(FILES
  519. ${SQLITE3_DLL}
  520. ${OPENSSL_PATH}/libeay32.dll
  521. ${OPENSSL_PATH}/ssleay32.dll
  522. DESTINATION "/"
  523. )
  524. install(FILES
  525. ${QT5_PATH}/plugins/platforms/qwindows.dll
  526. DESTINATION platforms
  527. )
  528. # The XML dll
  529. install(FILES
  530. "${QT5_PATH}/bin/Qt5Xmld.dll"
  531. DESTINATION "/"
  532. CONFIGURATIONS Debug
  533. )
  534. install(FILES
  535. "${QT5_PATH}/bin/Qt5Xml.dll"
  536. DESTINATION "/"
  537. CONFIGURATIONS Release
  538. )
  539. # The image format plugins
  540. install(FILES
  541. ${WIN_IMG_PLUGINS_DEBUG}
  542. DESTINATION imageformats
  543. CONFIGURATIONS Debug
  544. )
  545. install(FILES
  546. ${WIN_IMG_PLUGINS}
  547. DESTINATION imageformats
  548. CONFIGURATIONS Release
  549. )
  550. # The license files
  551. install(FILES
  552. ${LICENSE_FILES}
  553. DESTINATION licenses
  554. )
  555. # The batch file launcher
  556. install(FILES
  557. distri/winlaunch.bat
  558. DESTINATION "/"
  559. )
  560. endif()
  561. if(APPLE)
  562. set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15)
  563. set(ENV{MACOSX_DEPLOYMENT_TARGET} 10.15)
  564. set_target_properties(${PROJECT_NAME} PROPERTIES
  565. BUNDLE True
  566. OUTPUT_NAME "DB Browser for SQLite"
  567. MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/src/app.plist
  568. )
  569. endif()
  570. # CPack configuration
  571. set(CPACK_STRIP_FILES ON)
  572. set(CPACK_DEBIAN_PACKAGE_PRIORITY optional)
  573. set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
  574. set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON)
  575. set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Tristan Stenner <dbbrowser@nicht.dienstli.ch>")
  576. set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
  577. if(APPLE)
  578. set(CPACK_DEFAULT_GEN TBZ2)
  579. elseif(WIN32)
  580. set(CPACK_DEFAULT_GEN ZIP)
  581. set(CPACK_NSIS_MODIFY_PATH ON)
  582. set(CPACK_WIX_CMAKE_PACKAGE_REGISTRY ON)
  583. set(CPACK_WIX_UPGRADE_GUID "78c885a7-e9c8-4ded-9b62-9abe47466950")
  584. elseif(UNIX)
  585. set(CPACK_DEFAULT_GEN DEB)
  586. set(CPACK_SET_DESTDIR 1)
  587. set(CPACK_INSTALL_PREFIX "/usr")
  588. endif()
  589. set(CPACK_GENERATOR ${CPACK_DEFAULT_GEN} CACHE STRING "CPack pkg type(s) to generate")
  590. include(CPack)