Skip to content

Commit

Permalink
Use bundled SQLite if not installed in system
Browse files Browse the repository at this point in the history
  • Loading branch information
kraxarn committed Jul 16, 2022
1 parent 2025d83 commit b49303c
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions lib/thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ project(spotify-qt-lib-third-party)
add_library(${PROJECT_NAME} STATIC)

# SQLite cache support
if (NOT DEFINED USE_DB_CACHE)
set(USE_DB_CACHE ON)
endif ()
option(USE_DB_CACHE "Use SQLite based cache" ON)
option(USE_BUNDLED_SQLITE "Force use bundled SQLite" OFF)

# TODO: On error, use bundled SQLite instead
if (USE_DB_CACHE)
if (USE_DB_CACHE AND NOT USE_BUNDLED_SQLITE)
find_package(PkgConfig QUIET)
if (PkgConfig_FOUND)
pkg_check_modules(SQLITE sqlite3 QUIET)
Expand All @@ -18,10 +16,17 @@ if (USE_DB_CACHE)
target_include_directories(${PROJECT_NAME} PRIVATE "${SQLITE_INCLUDE_DIRS}")
target_link_libraries(${PROJECT_NAME} PRIVATE "${SQLITE_LIBRARIES}")
message(STATUS "Using SQLite ${SQLITE_VERSION} (system)")
else ()
message(WARNING "SQLite error: sqlite3 not found")
endif ()
else ()
message(WARNING "SQLite error: pkg-config not found")
endif ()
endif ()

if (NOT SQLITE_VERSION)
# sqlite3.h is expected in the root
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include/thirdparty)

target_sources(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/sqlite3.c)

message(STATUS "Using SQLite (bundled)")
endif ()

0 comments on commit b49303c

Please sign in to comment.