Path: redb/redb.SQLite/native/CMakeLists.txt Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb Page: https://redbase.app/src/dev-2026-12-06/redb/redb.SQLite/native/CMakeLists.txt ---- cmake_minimum_required(VERSION 3.16) project(redb_sqlite_ext C) # REDB SQLite Free loadable extension. # Hosts the server-side SQL functions (get_object_json, pvt_*, permissions, # soft-delete) inside the SQLite engine — the SQLite analog of PostgreSQL Free. # Works in ANY SQLite host (Microsoft.Data.Sqlite, Python sqlite3, sqlite3 CLI), # because the extension is loaded by the host process and resolves the sqlite3 # API symbols from it at load time — we do NOT link against libsqlite3. set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED ON) # ---------------------------------------------------------------------------- # SQLite amalgamation headers (sqlite3.h + sqlite3ext.h). # A loadable extension only needs the HEADERS to compile against the public # API + the SQLITE_EXTENSION_INIT machinery. We fetch a pinned amalgamation # zip at configure time so the repo stays clean (no vendored 13k-line header). # Override SQLITE_AMALGAMATION_URL to bump or to point at a local mirror. # ---------------------------------------------------------------------------- include(FetchContent) set(SQLITE_AMALGAMATION_URL "https://www.sqlite.org/2024/sqlite-amalgamation-3460100.zip" CACHE STRING "URL of the SQLite amalgamation zip (provides sqlite3.h + sqlite3ext.h)") FetchContent_Declare(sqlite_amalgamation URL "${SQLITE_AMALGAMATION_URL}" DOWNLOAD_EXTRACT_TIMESTAMP TRUE) FetchContent_MakeAvailable(sqlite_amalgamation) # ---------------------------------------------------------------------------- # The extension itself — built as a shared MODULE (dlopen/LoadLibrary target). # Output base name is "redbsqlite" on every platform (a specific name, not the # generic/dangerous "redb", which collides with the managed redb.* assemblies and # the host's redb.* prune globs): # Windows : redbsqlite.dll # Linux : redbsqlite.so (PREFIX "" → not libredbsqlite.so) # macOS : redbsqlite.dylib # The C init symbol stays sqlite3_redb_init (see src/redb_extension.c); because the # file base name no longer derives it, consumers load with an EXPLICIT entry point: # conn.LoadExtension(path, "sqlite3_redb_init") (SqliteDataSource.LoadNativeExtension) # ---------------------------------------------------------------------------- add_library(redb MODULE src/redb_extension.c src/redb_pvt.c src/redb_pvt_analytics.c ) target_include_directories(redb PRIVATE "${sqlite_amalgamation_SOURCE_DIR}") set_target_properties(redb PROPERTIES PREFIX "" OUTPUT_NAME "redbsqlite") if(APPLE) set_target_properties(redb PROPERTIES SUFFIX ".dylib") endif() # Warnings as a quality gate (extension code must be clean). if(MSVC) target_compile_options(redb PRIVATE /W3) else() target_compile_options(redb PRIVATE -Wall -Wextra) endif()