diff options
| author | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
|---|---|---|
| committer | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
| commit | 54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch) | |
| tree | d915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/sqlite3 | |
Diffstat (limited to 'vcpkg/ports/sqlite3')
| -rw-r--r-- | vcpkg/ports/sqlite3/CMakeLists.txt | 93 | ||||
| -rw-r--r-- | vcpkg/ports/sqlite3/add-config-include.patch | 24 | ||||
| -rw-r--r-- | vcpkg/ports/sqlite3/fix-arm-uwp.patch | 33 | ||||
| -rw-r--r-- | vcpkg/ports/sqlite3/portfile.cmake | 104 | ||||
| -rw-r--r-- | vcpkg/ports/sqlite3/sqlite3-config.in.cmake | 10 | ||||
| -rw-r--r-- | vcpkg/ports/sqlite3/sqlite3-vcpkg-config.h.in | 33 | ||||
| -rw-r--r-- | vcpkg/ports/sqlite3/sqlite3.pc.in | 12 | ||||
| -rw-r--r-- | vcpkg/ports/sqlite3/usage | 5 | ||||
| -rw-r--r-- | vcpkg/ports/sqlite3/vcpkg-cmake-wrapper.cmake | 35 | ||||
| -rw-r--r-- | vcpkg/ports/sqlite3/vcpkg.json | 86 |
10 files changed, 435 insertions, 0 deletions
diff --git a/vcpkg/ports/sqlite3/CMakeLists.txt b/vcpkg/ports/sqlite3/CMakeLists.txt new file mode 100644 index 0000000..83c2225 --- /dev/null +++ b/vcpkg/ports/sqlite3/CMakeLists.txt @@ -0,0 +1,93 @@ +cmake_minimum_required(VERSION 3.10) + +project(sqlite3 C CXX) + +option(WITH_ZLIB "Build sqlite3 with zlib support" OFF) +option(SQLITE3_SKIP_TOOLS "Disable build sqlite3 executable" OFF) + +set(PKGCONFIG_LIBS_PRIVATE "") +set(PKGCONFIG_REQUIRES_PRIVATE "") + +add_library(sqlite3 sqlite3.c sqlite3.rc) + +target_include_directories(sqlite3 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}> $<INSTALL_INTERFACE:include>) + +target_compile_definitions( + sqlite3 + PRIVATE + $<$<CONFIG:Debug>:SQLITE_DEBUG=1> + $<$<CONFIG:Debug>:SQLITE_ENABLE_SELECTTRACE> + $<$<CONFIG:Debug>:SQLITE_ENABLE_WHERETRACE> + $<$<COMPILE_LANGUAGE:RC>:RC_VERONLY> +) + +if (BUILD_SHARED_LIBS) + if (WIN32) + target_compile_definitions(sqlite3 PRIVATE "SQLITE_API=__declspec(dllexport)") + else() + target_compile_definitions(sqlite3 PRIVATE "SQLITE_API=__attribute__((visibility(\"default\")))") + endif() +endif() + +if (NOT WIN32) + find_package(Threads REQUIRED) + target_link_libraries(sqlite3 PRIVATE Threads::Threads ${CMAKE_DL_LIBS}) + string(APPEND PKGCONFIG_LIBS_PRIVATE " -pthread") + foreach(LIB IN LISTS CMAKE_DL_LIBS) + string(APPEND PKGCONFIG_LIBS_PRIVATE " -l${LIB}") + endforeach() + + if(SQLITE_ENABLE_FTS5 OR SQLITE_ENABLE_MATH_FUNCTIONS) + find_library(HAVE_LIBM m) + if(HAVE_LIBM) + target_link_libraries(sqlite3 PRIVATE m) + string(APPEND PKGCONFIG_LIBS_PRIVATE " -lm") + endif() + endif() +endif() + +if(SQLITE_ENABLE_ICU) + find_package(ICU COMPONENTS uc i18n REQUIRED) + target_link_libraries(sqlite3 PRIVATE ICU::uc ICU::i18n) + + string(APPEND PKGCONFIG_REQUIRES_PRIVATE " icu-uc icu-i18n") +endif() + +if(NOT SQLITE3_SKIP_TOOLS) + add_executable(sqlite3-bin shell.c) + set_target_properties(sqlite3-bin PROPERTIES + RUNTIME_OUTPUT_NAME sqlite3 + ) + + target_link_libraries(sqlite3-bin PRIVATE sqlite3) + if (WITH_ZLIB) + find_package(ZLIB REQUIRED) + target_link_libraries(sqlite3-bin PRIVATE ZLIB::ZLIB) + target_compile_definitions(sqlite3-bin PRIVATE SQLITE_HAVE_ZLIB) + endif() + + find_library(HAVE_LIBM m) + if(HAVE_LIBM) + target_link_libraries(sqlite3-bin PRIVATE m) + endif() + + install(TARGETS sqlite3-bin + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + ) +endif() + +install( + TARGETS sqlite3 + EXPORT unofficial-sqlite3-targets + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) + +install(FILES sqlite3.h sqlite3ext.h sqlite3-vcpkg-config.h DESTINATION include CONFIGURATIONS Release) +install(EXPORT unofficial-sqlite3-targets NAMESPACE unofficial::sqlite3:: FILE unofficial-sqlite3-targets.cmake DESTINATION share/unofficial-sqlite3) + +configure_file(sqlite3.pc.in sqlite3.pc @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sqlite3.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig") diff --git a/vcpkg/ports/sqlite3/add-config-include.patch b/vcpkg/ports/sqlite3/add-config-include.patch new file mode 100644 index 0000000..1b9183d --- /dev/null +++ b/vcpkg/ports/sqlite3/add-config-include.patch @@ -0,0 +1,24 @@ +diff --git a/sqlite3.c b/sqlite3.c +index 80433f6..cfd213b 100644 +--- a/sqlite3.c ++++ b/sqlite3.c +@@ -25,6 +25,7 @@ + #ifndef SQLITE_AMALGAMATION + #define SQLITE_CORE 1 + #define SQLITE_AMALGAMATION 1 ++#include "sqlite3-vcpkg-config.h" + #ifndef SQLITE_PRIVATE + # define SQLITE_PRIVATE static + #endif +diff --git a/sqlite3.h b/sqlite3.h +index 4ed8428..f1cf6d4 100644 +--- a/sqlite3.h ++++ b/sqlite3.h +@@ -32,6 +32,7 @@ + */ + #ifndef SQLITE3_H + #define SQLITE3_H ++#include "sqlite3-vcpkg-config.h" + #include <stdarg.h> /* Needed for the definition of va_list */ + + /* diff --git a/vcpkg/ports/sqlite3/fix-arm-uwp.patch b/vcpkg/ports/sqlite3/fix-arm-uwp.patch new file mode 100644 index 0000000..03e0929 --- /dev/null +++ b/vcpkg/ports/sqlite3/fix-arm-uwp.patch @@ -0,0 +1,33 @@ +diff --git a/shell.c b/shell.c +index 10d8cc1..99f37a5 100644 +--- a/shell.c ++++ b/shell.c +@@ -316,7 +316,11 @@ static int hasTimer(void){ + */ + hProcess = GetCurrentProcess(); + if( hProcess ){ ++#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) + HINSTANCE hinstLib = LoadLibrary(TEXT("Kernel32.dll")); ++#else ++ HINSTANCE hinstLib = LoadPackagedLibrary(TEXT("Kernel32.dll"), 0); ++#endif + if( NULL != hinstLib ){ + getProcessTimesAddr = + (GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes"); +@@ -2437,10 +2441,16 @@ static int writeFile( + if( zUnicodeName==0 ){ + return 1; + } ++#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) + hFile = CreateFileW( + zUnicodeName, FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, NULL + ); ++#else ++ hFile = CreateFile2( ++ zUnicodeName, FILE_WRITE_ATTRIBUTES, 0, OPEN_EXISTING, NULL ++ ); ++#endif + sqlite3_free(zUnicodeName); + if( hFile!=INVALID_HANDLE_VALUE ){ + BOOL bResult = SetFileTime(hFile, NULL, &lastAccess, &lastWrite); diff --git a/vcpkg/ports/sqlite3/portfile.cmake b/vcpkg/ports/sqlite3/portfile.cmake new file mode 100644 index 0000000..767263d --- /dev/null +++ b/vcpkg/ports/sqlite3/portfile.cmake @@ -0,0 +1,104 @@ +string(REGEX REPLACE "^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)" "\\1,0\\2,0\\3,0\\4," SQLITE_VERSION "${VERSION}.0") +string(REGEX REPLACE "^([0-9]+),0*([0-9][0-9]),0*([0-9][0-9]),0*([0-9][0-9])," "\\1\\2\\3\\4" SQLITE_VERSION "${SQLITE_VERSION}") + +vcpkg_download_distfile(ARCHIVE + URLS "https://sqlite.org/2025/sqlite-autoconf-${SQLITE_VERSION}.tar.gz" + FILENAME "sqlite-autoconf-${SQLITE_VERSION}.tar.gz" + SHA512 44aec8688ed017f694854fed9250cdeb68c853e74b0e0f78d5e3ccb271dde5c1dbed701fba188489e4f220c969c9ed61dc328242e39829ed151d185d7b58829b +) + +vcpkg_extract_source_archive( + SOURCE_PATH + ARCHIVE "${ARCHIVE}" + PATCHES + fix-arm-uwp.patch + add-config-include.patch +) + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + if(VCPKG_TARGET_IS_WINDOWS) + set(SQLITE_API "__declspec(dllimport)") + else() + set(SQLITE_API "__attribute__((visibility(\"default\")))") + endif() +else() + set(SQLITE_API "") +endif() + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + fts5 SQLITE_ENABLE_FTS5 + math SQLITE_ENABLE_MATH_FUNCTIONS + zlib WITH_ZLIB + unicode SQLITE_ENABLE_ICU + INVERTED_FEATURES + tool SQLITE3_SKIP_TOOLS +) +vcpkg_check_features(OUT_FEATURE_OPTIONS none # only using the script-mode side-effects + FEATURES + dbstat SQLITE_ENABLE_DBSTAT_VTAB + dbpage-vtab SQLITE_ENABLE_DBPAGE_VTAB + fts3 SQLITE_ENABLE_FTS3 + fts4 SQLITE_ENABLE_FTS4 + memsys3 SQLITE_ENABLE_MEMSYS3 + memsys5 SQLITE_ENABLE_MEMSYS5 + limit SQLITE_ENABLE_UPDATE_DELETE_LIMIT + rtree SQLITE_ENABLE_RTREE + session SQLITE_ENABLE_SESSION + session SQLITE_ENABLE_PREUPDATE_HOOK + snapshot SQLITE_ENABLE_SNAPSHOT + omit-load-extension SQLITE_OMIT_LOAD_EXTENSION + geopoly SQLITE_ENABLE_GEOPOLY + soundex SQLITE_SOUNDEX + INVERTED_FEATURES + json1 SQLITE_OMIT_JSON +) + +if(VCPKG_TARGET_IS_WINDOWS) + set(SQLITE_OS_WIN "1") + if(VCPKG_TARGET_IS_UWP) + set(SQLITE_OS_WINRT "1") + endif() +else() + set(SQLITE_OS_UNIX "1") +endif() + +file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") +file(COPY "${CMAKE_CURRENT_LIST_DIR}/sqlite3.pc.in" DESTINATION "${SOURCE_PATH}") +configure_file("${CMAKE_CURRENT_LIST_DIR}/sqlite3-vcpkg-config.h.in" "${SOURCE_PATH}/sqlite3-vcpkg-config.h" @ONLY) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${FEATURE_OPTIONS} + -DPKGCONFIG_VERSION=${VERSION} + OPTIONS_DEBUG + -DSQLITE3_SKIP_TOOLS=ON + MAYBE_UNUSED_VARIABLES + SQLITE_ENABLE_FTS5 + SQLITE_ENABLE_MATH_FUNCTIONS +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-${PORT} CONFIG_PATH share/unofficial-${PORT}) + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") + +if("tool" IN_LIST FEATURES) + vcpkg_copy_tools(TOOL_NAMES sqlite3 DESTINATION "${CURRENT_PACKAGES_DIR}/tools" AUTO_CLEAN) +endif() + +configure_file( + "${CMAKE_CURRENT_LIST_DIR}/sqlite3-config.in.cmake" + "${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}/unofficial-sqlite3-config.cmake" + @ONLY +) +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + configure_file("${CURRENT_PORT_DIR}/vcpkg-cmake-wrapper.cmake" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY) +endif() + +vcpkg_fixup_pkgconfig() +vcpkg_copy_pdbs() + +file(WRITE "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" "SQLite is in the Public Domain.\nhttp://www.sqlite.org/copyright.html\n") +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") diff --git a/vcpkg/ports/sqlite3/sqlite3-config.in.cmake b/vcpkg/ports/sqlite3/sqlite3-config.in.cmake new file mode 100644 index 0000000..7a2b4fb --- /dev/null +++ b/vcpkg/ports/sqlite3/sqlite3-config.in.cmake @@ -0,0 +1,10 @@ +
+include(CMakeFindDependencyMacro)
+if(NOT WIN32)
+ find_dependency(Threads)
+endif()
+if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static")
+ find_package(ICU COMPONENTS uc i18n)
+endif()
+
+include(${CMAKE_CURRENT_LIST_DIR}/unofficial-sqlite3-targets.cmake)
diff --git a/vcpkg/ports/sqlite3/sqlite3-vcpkg-config.h.in b/vcpkg/ports/sqlite3/sqlite3-vcpkg-config.h.in new file mode 100644 index 0000000..47b0f4a --- /dev/null +++ b/vcpkg/ports/sqlite3/sqlite3-vcpkg-config.h.in @@ -0,0 +1,33 @@ +/* + * This file was generated to inject vcpkg feature selections into the installed copy of + * sqlite so that consumers need not get the values from pkgconfig or CMake configs. + * + * No include guard: intentionally reuses the include guard from sqlite3.h. + */ + +#ifndef SQLITE_API +#cmakedefine SQLITE_API @SQLITE_API@ +#endif + +#define SQLITE_ENABLE_UNLOCK_NOTIFY 1 +#cmakedefine SQLITE_ENABLE_FTS3 +#cmakedefine SQLITE_ENABLE_FTS4 +#cmakedefine SQLITE_ENABLE_FTS5 +#cmakedefine SQLITE_ENABLE_MEMSYS3 +#cmakedefine SQLITE_ENABLE_MEMSYS5 +#cmakedefine SQLITE_ENABLE_MATH_FUNCTIONS +#cmakedefine SQLITE_ENABLE_UPDATE_DELETE_LIMIT +#cmakedefine SQLITE_ENABLE_DBPAGE_VTAB +#cmakedefine SQLITE_ENABLE_RTREE +#cmakedefine SQLITE_ENABLE_SESSION +#cmakedefine SQLITE_ENABLE_SNAPSHOT +#cmakedefine SQLITE_ENABLE_PREUPDATE_HOOK +#cmakedefine SQLITE_OMIT_LOAD_EXTENSION +#cmakedefine SQLITE_ENABLE_GEOPOLY +#cmakedefine SQLITE_OMIT_JSON +#cmakedefine SQLITE_OS_WIN @SQLITE_OS_WIN@ +#cmakedefine SQLITE_OS_WINRT @SQLITE_OS_WINRT@ +#define SQLITE_ENABLE_COLUMN_METADATA 1 +#cmakedefine SQLITE_OS_UNIX @SQLITE_OS_UNIX@ +#cmakedefine SQLITE_ENABLE_DBSTAT_VTAB +#cmakedefine SQLITE_ENABLE_ICU diff --git a/vcpkg/ports/sqlite3/sqlite3.pc.in b/vcpkg/ports/sqlite3/sqlite3.pc.in new file mode 100644 index 0000000..6f0e809 --- /dev/null +++ b/vcpkg/ports/sqlite3/sqlite3.pc.in @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: SQLite +Description: SQL database engine +Version: @PKGCONFIG_VERSION@ +Libs: -L${libdir} -lsqlite3 +Libs.private: @PKGCONFIG_LIBS_PRIVATE@ +Requires.private: @PKGCONFIG_REQUIRES_PRIVATE@ +Cflags: -I${includedir} diff --git a/vcpkg/ports/sqlite3/usage b/vcpkg/ports/sqlite3/usage new file mode 100644 index 0000000..7f79c6d --- /dev/null +++ b/vcpkg/ports/sqlite3/usage @@ -0,0 +1,5 @@ +sqlite3 provides pkgconfig bindings. +sqlite3 provides CMake targets: + + find_package(unofficial-sqlite3 CONFIG REQUIRED) + target_link_libraries(main PRIVATE unofficial::sqlite3::sqlite3) diff --git a/vcpkg/ports/sqlite3/vcpkg-cmake-wrapper.cmake b/vcpkg/ports/sqlite3/vcpkg-cmake-wrapper.cmake new file mode 100644 index 0000000..0b311fc --- /dev/null +++ b/vcpkg/ports/sqlite3/vcpkg-cmake-wrapper.cmake @@ -0,0 +1,35 @@ +string(COMPARE EQUAL "${SQLite3_LIBRARIES}" "" z_vcpkg_sqlite3_fixup_libraries) +_find_package(${ARGS}) +if(SQLite3_FOUND) + set(z_vcpkg_sqlite3_libraries "") + set(z_vcpkg_sqlite3_link_libs "") + if("@SQLITE_ENABLE_ICU@") + find_package(ICU COMPONENTS uc i18n) + if(ICU_FOUND) + list(APPEND z_vcpkg_sqlite3_libraries ${ICU_LIBRARIES}) + list(APPEND z_vcpkg_sqlite3_link_libs $<LINK_ONLY:ICU::uc> $<LINK_ONLY:ICU::i18n>) + endif() + endif() + if(NOT WIN32) + find_package(Threads) + if(Threads_FOUND) + list(APPEND z_vcpkg_sqlite3_libraries ${CMAKE_THREAD_LIBS_INIT}) + list(APPEND z_vcpkg_sqlite3_link_libs $<LINK_ONLY:Threads::Threads>) + endif() + list(APPEND z_vcpkg_sqlite3_libraries ${CMAKE_DL_LIBS}) + list(APPEND z_vcpkg_sqlite3_link_libs ${CMAKE_DL_LIBS}) + if("@SQLITE_ENABLE_FTS5@" OR "@SQLITE_ENABLE_MATH_FUNCTIONS@") + find_library(z_vcpkg_sqlite3_have_libm m) + if(z_vcpkg_sqlite3_have_libm) + list(APPEND z_vcpkg_sqlite3_libraries m) + list(APPEND z_vcpkg_sqlite3_link_libs $<LINK_ONLY:m>) + endif() + endif() + endif() + if(z_vcpkg_sqlite3_fixup_libraries) + list(APPEND SQLite3_LIBRARIES ${z_vcpkg_sqlite3_libraries}) + endif() + if(TARGET SQLite::SQLite3) + set_target_properties(SQLite::SQLite3 PROPERTIES INTERFACE_LINK_LIBRARIES "${z_vcpkg_sqlite3_link_libs}") + endif() +endif() diff --git a/vcpkg/ports/sqlite3/vcpkg.json b/vcpkg/ports/sqlite3/vcpkg.json new file mode 100644 index 0000000..7b0982e --- /dev/null +++ b/vcpkg/ports/sqlite3/vcpkg.json @@ -0,0 +1,86 @@ +{ + "name": "sqlite3", + "version": "3.51.0", + "description": "SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.", + "homepage": "https://sqlite.org/", + "license": "blessing", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + "json1" + ], + "features": { + "dbpage-vtab": { + "description": "Enable the recovery extension" + }, + "dbstat": { + "description": "Enable the DBSTAT virtual table" + }, + "fts3": { + "description": "Enable the FTS3 extension" + }, + "fts4": { + "description": "Enable the FTS4 extension" + }, + "fts5": { + "description": "Enable the FTS5 extension" + }, + "geopoly": { + "description": "Enable geopoly functionality for sqlite3" + }, + "json1": { + "description": "Enable JSON functionality for sqlite3" + }, + "limit": { + "description": "Enable the UPDATE/DELETE LIMIT clause" + }, + "math": { + "description": "Enable math functions" + }, + "memsys3": { + "description": "Enable MEMSYS3" + }, + "memsys5": { + "description": "Enable MEMSYS5" + }, + "omit-load-extension": { + "description": "Enable loading of external extensions" + }, + "rtree": { + "description": "Enable the RTREE extension" + }, + "session": { + "description": "Enable the SESSION extension" + }, + "snapshot": { + "description": "Enable the snapshot function" + }, + "soundex": { + "description": "Enable the SOUNDEX scalar function" + }, + "tool": { + "description": "Build sqlite3 executable", + "supports": "!uwp" + }, + "unicode": { + "description": "Enable unicode support", + "dependencies": [ + "icu" + ] + }, + "zlib": { + "description": "Build sqlite3 command line tool with zlib support; has no effect on the library itself", + "dependencies": [ + "zlib" + ] + } + } +} |