From e0205f5358ee7df40c42ff13734cf82e647fc207 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Mon, 14 Aug 2023 06:47:34 +0200 Subject: [PATCH] initial cmake tweaks to allow system sqlite3 - on linux --- CMakeLists.txt | 7 +++++-- src/librssguard/CMakeLists.txt | 29 +++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e56fc68bc..1f7fb4b33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,8 @@ # # Variables: # BUILD_WITH_QT6 - Build either with Qt 6 or Qt 5. +# USE_SYSTEM_SQLITE - Use system-wide SQLite3 library and header file. Defaults to "OFF" in whic +# case bundled "sqlite3.h" and "sqlite3.c" are used. # NO_UPDATE_CHECK - Disable automatic checking for new application updates. # IS_FLATPAK_BUILD - Set to "ON" when building RSS Guard with Flatpak. # FORCE_BUNDLE_ICONS - Forcibly bundles icons into executables. @@ -34,7 +36,7 @@ # - supports Windows, Linux, *BSD, macOS, OS/2, Android, # - Qt 5.12.0 or newer is required, # - Qt 6.3.0 or newer is required, -# - cmake 3.9.0 or newer is required, +# - cmake 3.14.0 or newer is required, # - if you wish to make packages for Windows, then you must initialize all submodules # within repository before compilation, # - C++ 17 is required. @@ -54,7 +56,7 @@ # ################################################################# -cmake_minimum_required(VERSION 3.9.0) +cmake_minimum_required(VERSION 3.14.0) # Global variables describing the project. string(TIMESTAMP YEAR "%Y") @@ -108,6 +110,7 @@ endif() # Global compilation switches. option(BUILD_WITH_QT6 "Build application with Qt 6" OFF) +option(USE_SYSTEM_SQLITE "Use system-wide SQLite3 library." OFF) option(USE_WEBENGINE "Use QtWebEngine for embedded web browser" ON) option(UPDATE_TRANSLATIONS "Call lupdate to update translation files from source (Qt 6 only)" OFF) option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GCC/Clang only)" OFF) diff --git a/src/librssguard/CMakeLists.txt b/src/librssguard/CMakeLists.txt index e3981d0b8..dea810f1f 100644 --- a/src/librssguard/CMakeLists.txt +++ b/src/librssguard/CMakeLists.txt @@ -519,10 +519,20 @@ list(APPEND SOURCES ) # Add sqlite. -list(APPEND SOURCES - 3rd-party/sqlite/sqlite3.c - 3rd-party/sqlite/sqlite3.h -) +if(USE_SYSTEM_SQLITE) + find_package(SQLite3) +endif() + +if(SQLite3_FOUND) + # Include directory and library are linked to below. +else() + message(STATUS "Using bundled SQLite3.") + + list(APPEND SOURCES + 3rd-party/sqlite/sqlite3.c + 3rd-party/sqlite/sqlite3.h + ) +endif() # Add SimpleCrypt. list(APPEND SOURCES @@ -644,6 +654,17 @@ target_include_directories(rssguard ${CMAKE_CURRENT_SOURCE_DIR}/gui/richtexteditor ) +if(SQLite3_FOUND) + target_include_directories(rssguard AFTER + PRIVATE + ${SQLite3_INCLUDE_DIRS} + ) + + target_link_libraries(rssguard PRIVATE + ${SQLite3_LIBRARIES} + ) +endif() + # Qt. target_link_libraries(rssguard PUBLIC Qt${QT_VERSION_MAJOR}::Core