New SHARED module (separate from Data so Json/Csv/Ini consumers don't link SQLite). Generic, Result-based: - Database — open (file or :memory:), exec, prepare, begin, last_insert_rowid, changes; enables WAL + busy timeout + foreign_keys for writable modes. - Statement — move-only prepared statement; 1-based typed bind (int/double/ text/null/optional), step(), reset, 0-based column accessors. - Transaction — RAII; rolls back on scope exit unless commit() is called. - Migration + Database::migrate() — forward, in-order, idempotent schema upgrades tracked via PRAGMA user_version. Dependencies.cmake resolves SQLite::SQLite3 via find_package. Tests exercise CRUD, null handling, commit/rollback, migrations and errors on :memory:. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
77 lines
2.8 KiB
CMake
77 lines
2.8 KiB
CMake
include(FetchContent)
|
|
|
|
function(void_fetch_dependency DEP_NAME)
|
|
if(DEP_NAME STREQUAL "Boost")
|
|
# Components Void uses across modules: stacktrace_backtrace (Stacktrace),
|
|
# url + system (Net; beast/asio are header-only and come via Boost::headers).
|
|
if(TARGET Boost::stacktrace_backtrace AND TARGET Boost::url)
|
|
return()
|
|
endif()
|
|
|
|
# On modern Boost (1.85+) system/asio/beast are header-only and folded
|
|
# into Boost::headers; only stacktrace_backtrace and url are components.
|
|
find_package(Boost QUIET COMPONENTS stacktrace_backtrace url)
|
|
if(TARGET Boost::stacktrace_backtrace AND TARGET Boost::url)
|
|
return()
|
|
endif()
|
|
|
|
message(STATUS "[Void] Boost (stacktrace/url) not found — falling back to FetchContent")
|
|
set(BOOST_INCLUDE_LIBRARIES "stacktrace;url;system;beast;asio" CACHE STRING "" FORCE)
|
|
set(BOOST_ENABLE_CMAKE ON CACHE BOOL "" FORCE)
|
|
FetchContent_Declare(Boost
|
|
URL https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.xz
|
|
URL_HASH SHA256=2e64e5d79a738d0fa6fb546c6e5c2bd28f88d268a2a080546f74e5ff98f29d0e
|
|
EXCLUDE_FROM_ALL
|
|
)
|
|
FetchContent_MakeAvailable(Boost)
|
|
|
|
if(NOT TARGET Boost::stacktrace_backtrace AND TARGET boost_stacktrace_backtrace)
|
|
add_library(Boost::stacktrace_backtrace ALIAS boost_stacktrace_backtrace)
|
|
endif()
|
|
return()
|
|
endif()
|
|
|
|
if(DEP_NAME STREQUAL "OpenSSL")
|
|
if(NOT TARGET OpenSSL::SSL)
|
|
find_package(OpenSSL REQUIRED)
|
|
endif()
|
|
return()
|
|
endif()
|
|
|
|
if(DEP_NAME STREQUAL "Threads")
|
|
if(NOT TARGET Threads::Threads)
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
find_package(Threads REQUIRED)
|
|
endif()
|
|
return()
|
|
endif()
|
|
|
|
if(DEP_NAME STREQUAL "SQLite")
|
|
if(NOT TARGET SQLite::SQLite3)
|
|
find_package(SQLite3 REQUIRED)
|
|
endif()
|
|
return()
|
|
endif()
|
|
# FIXME: Add if needed external
|
|
# if(DEP_NAME STREQUAL "glaze")
|
|
# if(NOT glaze_POPULATED)
|
|
# message(STATUS "[MyLib] Fetching Glaze on-demand...")
|
|
# FetchContent_Declare(glaze
|
|
# GIT_REPOSITORY https://github.com/stephenberry/glaze.git
|
|
# GIT_TAG v2.8.5
|
|
# )
|
|
# FetchContent_MakeAvailable(glaze)
|
|
# endif()
|
|
#
|
|
# elseif(DEP_NAME STREQUAL "fmt")
|
|
# if(NOT fmt_POPULATED)
|
|
# message(STATUS "[MyLib] Fetching fmt on-demand...")
|
|
# FetchContent_Declare(fmt
|
|
# GIT_REPOSITORY https://github.com/fmtlib/fmt.git
|
|
# GIT_TAG 10.2.1
|
|
# )
|
|
# FetchContent_MakeAvailable(fmt)
|
|
# endif()
|
|
# endif()
|
|
endfunction()
|