feat(system,config,sqlite): implement VL-001, VL-003, VL-010, VL-011
This commit is contained in:
1 parent
adfc8548dc
commit
b50131f52e
14 files changed
+2660
-139
No files matched your search
@@ -158,9 +158,89 @@ function(void_fetch_dependency DEP_NAME)
|
||||
endif()
|
||||
|
||||
if(DEP_NAME STREQUAL "SQLite3")
|
||||
if(NOT TARGET SQLite3::SQLite3 AND NOT TARGET SQLite::SQLite3)
|
||||
find_package(SQLite3 REQUIRED)
|
||||
if(TARGET SQLite3::SQLite3)
|
||||
return()
|
||||
endif()
|
||||
if(TARGET SQLite::SQLite3)
|
||||
add_library(SQLite3::SQLite3 ALIAS SQLite::SQLite3)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(_void_sqlite_dir "${VOID_SQLITE3_AMALGAMATION_DIR}")
|
||||
if(NOT _void_sqlite_dir)
|
||||
find_package(SQLite3 QUIET)
|
||||
if(TARGET SQLite3::SQLite3)
|
||||
return()
|
||||
endif()
|
||||
if(TARGET SQLite::SQLite3)
|
||||
add_library(SQLite3::SQLite3 ALIAS SQLite::SQLite3)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(VOID_FETCH_SQLITE3
|
||||
"Allow FetchContent SQLite3 amalgamation fallback when system SQLite3 is unavailable"
|
||||
ON)
|
||||
set(VOID_SQLITE3_AMALGAMATION_DIR "" CACHE PATH
|
||||
"Path containing pre-downloaded sqlite3.c and sqlite3.h amalgamation sources")
|
||||
set(VOID_SQLITE3_FETCH_URL
|
||||
"https://www.sqlite.org/2025/sqlite-amalgamation-3490100.zip"
|
||||
CACHE STRING "SQLite3 amalgamation archive URL for FetchContent fallback")
|
||||
set(VOID_SQLITE3_FETCH_HASH "" CACHE STRING
|
||||
"Optional SHA256 hash (SHA256=...) for VOID_SQLITE3_FETCH_URL")
|
||||
|
||||
if(NOT _void_sqlite_dir AND VOID_FETCH_SQLITE3 AND
|
||||
NOT CMAKE_DISABLE_FIND_PACKAGE_SQLite3)
|
||||
message(STATUS "[Void] System SQLite3 not found — falling back to SQLite3 amalgamation")
|
||||
if(VOID_SQLITE3_FETCH_HASH)
|
||||
FetchContent_Declare(SQLite3
|
||||
URL "${VOID_SQLITE3_FETCH_URL}"
|
||||
URL_HASH "${VOID_SQLITE3_FETCH_HASH}"
|
||||
SYSTEM
|
||||
)
|
||||
else()
|
||||
FetchContent_Declare(SQLite3
|
||||
URL "${VOID_SQLITE3_FETCH_URL}"
|
||||
SYSTEM
|
||||
)
|
||||
endif()
|
||||
FetchContent_MakeAvailable(SQLite3)
|
||||
if(EXISTS "${sqlite3_SOURCE_DIR}/sqlite3.c")
|
||||
set(_void_sqlite_dir "${sqlite3_SOURCE_DIR}")
|
||||
else()
|
||||
file(GLOB _found_sqlite_c LIST_DIRECTORIES FALSE
|
||||
"${sqlite3_SOURCE_DIR}/*/sqlite3.c")
|
||||
if(_found_sqlite_c)
|
||||
list(GET _found_sqlite_c 0 _first_sqlite_c)
|
||||
get_filename_component(_void_sqlite_dir "${_first_sqlite_c}" DIRECTORY)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(_void_sqlite_dir AND EXISTS "${_void_sqlite_dir}/sqlite3.c" AND
|
||||
EXISTS "${_void_sqlite_dir}/sqlite3.h")
|
||||
void_fetch_dependency(Threads)
|
||||
add_library(void_sqlite3_amalgamation STATIC
|
||||
"${_void_sqlite_dir}/sqlite3.c")
|
||||
set_target_properties(void_sqlite3_amalgamation PROPERTIES
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
C_STANDARD 11
|
||||
SYSTEM TRUE)
|
||||
target_include_directories(void_sqlite3_amalgamation SYSTEM PUBLIC
|
||||
"${_void_sqlite_dir}")
|
||||
target_compile_definitions(void_sqlite3_amalgamation PRIVATE
|
||||
SQLITE_THREADSAFE=1
|
||||
SQLITE_ENABLE_FTS5
|
||||
SQLITE_ENABLE_JSON1
|
||||
SQLITE_DQS=0)
|
||||
target_link_libraries(void_sqlite3_amalgamation PUBLIC
|
||||
Threads::Threads
|
||||
"$<$<NOT:$<PLATFORM_ID:Windows>>:${CMAKE_DL_LIBS};m>")
|
||||
add_library(SQLite3::SQLite3 ALIAS void_sqlite3_amalgamation)
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_package(SQLite3 REQUIRED)
|
||||
if(NOT TARGET SQLite3::SQLite3 AND TARGET SQLite::SQLite3)
|
||||
add_library(SQLite3::SQLite3 ALIAS SQLite::SQLite3)
|
||||
endif()
|
||||
|
||||
Reference in new issue
Block a user