Skip to content

Commit 57135f9

Browse files
committed
Add sqlite3 3.47.2 port to fix QgsOfflineEditing regression with sqlite3 >= 3.48
1 parent 361fe1a commit 57135f9

File tree

9 files changed

+390
-0
lines changed

9 files changed

+390
-0
lines changed

vcpkg/ports/sqlite3/CMakeLists.txt

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
project(sqlite3 C)
4+
5+
option(WITH_ZLIB "Build sqlite3 with zlib support" OFF)
6+
option(SQLITE3_SKIP_TOOLS "Disable build sqlite3 executable" OFF)
7+
8+
set(PKGCONFIG_LIBS_PRIVATE "")
9+
set(PKGCONFIG_REQUIRES_PRIVATE "")
10+
11+
add_library(sqlite3 sqlite3.c sqlite3.rc)
12+
13+
target_include_directories(sqlite3 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}> $<INSTALL_INTERFACE:include>)
14+
15+
target_compile_definitions(
16+
sqlite3
17+
PRIVATE
18+
$<$<CONFIG:Debug>:SQLITE_DEBUG=1>
19+
$<$<CONFIG:Debug>:SQLITE_ENABLE_SELECTTRACE>
20+
$<$<CONFIG:Debug>:SQLITE_ENABLE_WHERETRACE>
21+
$<$<COMPILE_LANGUAGE:RC>:RC_VERONLY>
22+
)
23+
24+
if (BUILD_SHARED_LIBS)
25+
if (WIN32)
26+
target_compile_definitions(sqlite3 PRIVATE "SQLITE_API=__declspec(dllexport)")
27+
else()
28+
target_compile_definitions(sqlite3 PRIVATE "SQLITE_API=__attribute__((visibility(\"default\")))")
29+
endif()
30+
endif()
31+
32+
if (NOT WIN32)
33+
find_package(Threads REQUIRED)
34+
target_link_libraries(sqlite3 PRIVATE Threads::Threads ${CMAKE_DL_LIBS})
35+
string(APPEND PKGCONFIG_LIBS_PRIVATE " -pthread")
36+
foreach(LIB IN LISTS CMAKE_DL_LIBS)
37+
string(APPEND PKGCONFIG_LIBS_PRIVATE " -l${LIB}")
38+
endforeach()
39+
40+
if(SQLITE_ENABLE_FTS5 OR SQLITE_ENABLE_MATH_FUNCTIONS)
41+
find_library(HAVE_LIBM m)
42+
if(HAVE_LIBM)
43+
target_link_libraries(sqlite3 PRIVATE m)
44+
string(APPEND PKGCONFIG_LIBS_PRIVATE " -lm")
45+
endif()
46+
endif()
47+
endif()
48+
49+
if(SQLITE_ENABLE_ICU)
50+
find_package(ICU COMPONENTS uc i18n REQUIRED)
51+
target_link_libraries(sqlite3 PRIVATE ICU::uc ICU::i18n)
52+
53+
string(APPEND PKGCONFIG_REQUIRES_PRIVATE " icu-uc icu-i18n")
54+
endif()
55+
56+
if(NOT SQLITE3_SKIP_TOOLS)
57+
add_executable(sqlite3-bin shell.c)
58+
set_target_properties(sqlite3-bin PROPERTIES
59+
OUTPUT_NAME sqlite3
60+
PDB_NAME "sqlite3${CMAKE_EXECUTABLE_SUFFIX}.pdb"
61+
)
62+
63+
target_link_libraries(sqlite3-bin PRIVATE sqlite3)
64+
if (WITH_ZLIB)
65+
find_package(ZLIB REQUIRED)
66+
target_link_libraries(sqlite3-bin PRIVATE ZLIB::ZLIB)
67+
target_compile_definitions(sqlite3-bin PRIVATE SQLITE_HAVE_ZLIB)
68+
endif()
69+
70+
install(TARGETS sqlite3-bin sqlite3
71+
RUNTIME DESTINATION bin
72+
LIBRARY DESTINATION lib
73+
ARCHIVE DESTINATION lib
74+
)
75+
endif()
76+
77+
install(
78+
TARGETS sqlite3
79+
EXPORT unofficial-sqlite3-targets
80+
RUNTIME DESTINATION bin
81+
LIBRARY DESTINATION lib
82+
ARCHIVE DESTINATION lib
83+
)
84+
85+
install(FILES sqlite3.h sqlite3ext.h sqlite3-vcpkg-config.h DESTINATION include CONFIGURATIONS Release)
86+
install(EXPORT unofficial-sqlite3-targets NAMESPACE unofficial::sqlite3:: FILE unofficial-sqlite3-targets.cmake DESTINATION share/unofficial-sqlite3)
87+
88+
configure_file(sqlite3.pc.in sqlite3.pc @ONLY)
89+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sqlite3.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
diff --git a/sqlite3.c b/sqlite3.c
2+
index a1fbd60..68a4e21 100644
3+
--- a/sqlite3.c
4+
+++ b/sqlite3.c
5+
@@ -22,6 +22,7 @@
6+
*/
7+
#define SQLITE_CORE 1
8+
#define SQLITE_AMALGAMATION 1
9+
+#include "sqlite3-vcpkg-config.h"
10+
#ifndef SQLITE_PRIVATE
11+
# define SQLITE_PRIVATE static
12+
#endif
13+
diff --git a/sqlite3.h b/sqlite3.h
14+
index 0376113..271cf53 100644
15+
--- a/sqlite3.h
16+
+++ b/sqlite3.h
17+
@@ -32,6 +32,7 @@
18+
*/
19+
#ifndef SQLITE3_H
20+
#define SQLITE3_H
21+
+#include "sqlite3-vcpkg-config.h"
22+
#include <stdarg.h> /* Needed for the definition of va_list */
23+
24+
/*
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
diff --git a/shell.c b/shell.c
2+
index 10d8cc1..99f37a5 100644
3+
--- a/shell.c
4+
+++ b/shell.c
5+
@@ -316,7 +316,11 @@ static int hasTimer(void){
6+
*/
7+
hProcess = GetCurrentProcess();
8+
if( hProcess ){
9+
+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
10+
HINSTANCE hinstLib = LoadLibrary(TEXT("Kernel32.dll"));
11+
+#else
12+
+ HINSTANCE hinstLib = LoadPackagedLibrary(TEXT("Kernel32.dll"), 0);
13+
+#endif
14+
if( NULL != hinstLib ){
15+
getProcessTimesAddr =
16+
(GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes");
17+
@@ -2437,10 +2441,16 @@ static int writeFile(
18+
if( zUnicodeName==0 ){
19+
return 1;
20+
}
21+
+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
22+
hFile = CreateFileW(
23+
zUnicodeName, FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING,
24+
FILE_FLAG_BACKUP_SEMANTICS, NULL
25+
);
26+
+#else
27+
+ hFile = CreateFile2(
28+
+ zUnicodeName, FILE_WRITE_ATTRIBUTES, 0, OPEN_EXISTING, NULL
29+
+ );
30+
+#endif
31+
sqlite3_free(zUnicodeName);
32+
if( hFile!=INVALID_HANDLE_VALUE ){
33+
BOOL bResult = SetFileTime(hFile, NULL, &lastAccess, &lastWrite);

vcpkg/ports/sqlite3/portfile.cmake

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
string(REGEX REPLACE "^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)" "\\1,0\\2,0\\3,0\\4," SQLITE_VERSION "${VERSION}.0")
2+
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}")
3+
4+
vcpkg_download_distfile(ARCHIVE
5+
URLS "https://sqlite.org/2024/sqlite-autoconf-${SQLITE_VERSION}.tar.gz"
6+
FILENAME "sqlite-autoconf-${SQLITE_VERSION}.zip"
7+
SHA512 9f311e7834330d112a633a9ae7c211c602b36b6c44f94a7ff7463217da8f09ba2c469d1f2ca38da5ba88358c40e328a8958c1e4ad466b016f3bd2799ef2431e2
8+
)
9+
10+
vcpkg_extract_source_archive(
11+
SOURCE_PATH
12+
ARCHIVE "${ARCHIVE}"
13+
PATCHES
14+
fix-arm-uwp.patch
15+
add-config-include.patch
16+
)
17+
18+
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
19+
if(VCPKG_TARGET_IS_WINDOWS)
20+
set(SQLITE_API "__declspec(dllimport)")
21+
else()
22+
set(SQLITE_API "__attribute__((visibility(\"default\")))")
23+
endif()
24+
else()
25+
set(SQLITE_API "")
26+
endif()
27+
28+
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
29+
FEATURES
30+
fts5 SQLITE_ENABLE_FTS5
31+
math SQLITE_ENABLE_MATH_FUNCTIONS
32+
zlib WITH_ZLIB
33+
unicode SQLITE_ENABLE_ICU
34+
INVERTED_FEATURES
35+
tool SQLITE3_SKIP_TOOLS
36+
)
37+
vcpkg_check_features(OUT_FEATURE_OPTIONS none # only using the script-mode side-effects
38+
FEATURES
39+
dbstat SQLITE_ENABLE_DBSTAT_VTAB
40+
dbpage-vtab SQLITE_ENABLE_DBPAGE_VTAB
41+
fts3 SQLITE_ENABLE_FTS3
42+
fts4 SQLITE_ENABLE_FTS4
43+
memsys3 SQLITE_ENABLE_MEMSYS3
44+
memsys5 SQLITE_ENABLE_MEMSYS5
45+
limit SQLITE_ENABLE_UPDATE_DELETE_LIMIT
46+
rtree SQLITE_ENABLE_RTREE
47+
session SQLITE_ENABLE_SESSION
48+
session SQLITE_ENABLE_PREUPDATE_HOOK
49+
snapshot SQLITE_ENABLE_SNAPSHOT
50+
omit-load-extension SQLITE_OMIT_LOAD_EXTENSION
51+
geopoly SQLITE_ENABLE_GEOPOLY
52+
soundex SQLITE_SOUNDEX
53+
INVERTED_FEATURES
54+
json1 SQLITE_OMIT_JSON
55+
)
56+
57+
if(VCPKG_TARGET_IS_WINDOWS)
58+
set(SQLITE_OS_WIN "1")
59+
if(VCPKG_TARGET_IS_UWP)
60+
set(SQLITE_OS_WINRT "1")
61+
endif()
62+
else()
63+
set(SQLITE_OS_UNIX "1")
64+
endif()
65+
66+
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
67+
file(COPY "${CMAKE_CURRENT_LIST_DIR}/sqlite3.pc.in" DESTINATION "${SOURCE_PATH}")
68+
configure_file("${CMAKE_CURRENT_LIST_DIR}/sqlite3-vcpkg-config.h.in" "${SOURCE_PATH}/sqlite3-vcpkg-config.h" @ONLY)
69+
70+
vcpkg_cmake_configure(
71+
SOURCE_PATH "${SOURCE_PATH}"
72+
OPTIONS
73+
${FEATURE_OPTIONS}
74+
-DPKGCONFIG_VERSION=${VERSION}
75+
OPTIONS_DEBUG
76+
-DSQLITE3_SKIP_TOOLS=ON
77+
MAYBE_UNUSED_VARIABLES
78+
SQLITE_ENABLE_FTS5
79+
SQLITE_ENABLE_MATH_FUNCTIONS
80+
)
81+
82+
vcpkg_cmake_install()
83+
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-${PORT} CONFIG_PATH share/unofficial-${PORT})
84+
85+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
86+
87+
if("tool" IN_LIST FEATURES)
88+
vcpkg_copy_tools(TOOL_NAMES sqlite3 DESTINATION "${CURRENT_PACKAGES_DIR}/tools" AUTO_CLEAN)
89+
endif()
90+
91+
configure_file(
92+
"${CMAKE_CURRENT_LIST_DIR}/sqlite3-config.in.cmake"
93+
"${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}/unofficial-sqlite3-config.cmake"
94+
@ONLY
95+
)
96+
97+
vcpkg_fixup_pkgconfig()
98+
vcpkg_copy_pdbs()
99+
100+
file(WRITE "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" "SQLite is in the Public Domain.\nhttp://www.sqlite.org/copyright.html\n")
101+
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
if(NOT WIN32)
3+
include(CMakeFindDependencyMacro)
4+
find_dependency(Threads)
5+
endif()
6+
7+
include(${CMAKE_CURRENT_LIST_DIR}/unofficial-sqlite3-targets.cmake)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* This file was generated to inject vcpkg feature selections into the installed copy of
3+
* sqlite so that consumers need not get the values from pkgconfig or CMake configs.
4+
*
5+
* No include guard: intentionally reuses the include guard from sqlite3.h.
6+
*/
7+
8+
#ifndef SQLITE_API
9+
#cmakedefine SQLITE_API @SQLITE_API@
10+
#endif
11+
12+
#define SQLITE_ENABLE_UNLOCK_NOTIFY 1
13+
#cmakedefine SQLITE_ENABLE_FTS3
14+
#cmakedefine SQLITE_ENABLE_FTS4
15+
#cmakedefine SQLITE_ENABLE_FTS5
16+
#cmakedefine SQLITE_ENABLE_MEMSYS3
17+
#cmakedefine SQLITE_ENABLE_MEMSYS5
18+
#cmakedefine SQLITE_ENABLE_MATH_FUNCTIONS
19+
#cmakedefine SQLITE_ENABLE_UPDATE_DELETE_LIMIT
20+
#cmakedefine SQLITE_ENABLE_DBPAGE_VTAB
21+
#cmakedefine SQLITE_ENABLE_RTREE
22+
#cmakedefine SQLITE_ENABLE_SESSION
23+
#cmakedefine SQLITE_ENABLE_SNAPSHOT
24+
#cmakedefine SQLITE_ENABLE_PREUPDATE_HOOK
25+
#cmakedefine SQLITE_OMIT_LOAD_EXTENSION
26+
#cmakedefine SQLITE_ENABLE_GEOPOLY
27+
#cmakedefine SQLITE_OMIT_JSON
28+
#cmakedefine SQLITE_OS_WIN @SQLITE_OS_WIN@
29+
#cmakedefine SQLITE_OS_WINRT @SQLITE_OS_WINRT@
30+
#define SQLITE_ENABLE_COLUMN_METADATA 1
31+
#cmakedefine SQLITE_OS_UNIX @SQLITE_OS_UNIX@
32+
#cmakedefine SQLITE_ENABLE_DBSTAT_VTAB
33+
#cmakedefine SQLITE_ENABLE_ICU

vcpkg/ports/sqlite3/sqlite3.pc.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
prefix=@CMAKE_INSTALL_PREFIX@
2+
exec_prefix=${prefix}
3+
libdir=${prefix}/lib
4+
includedir=${prefix}/include
5+
6+
Name: SQLite
7+
Description: SQL database engine
8+
Version: @PKGCONFIG_VERSION@
9+
Libs: -L${libdir} -lsqlite3
10+
Libs.private: @PKGCONFIG_LIBS_PRIVATE@
11+
Requires.private: @PKGCONFIG_REQUIRES_PRIVATE@
12+
Cflags: -I${includedir}

vcpkg/ports/sqlite3/usage

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sqlite3 provides pkgconfig bindings.
2+
sqlite3 provides CMake targets:
3+
4+
find_package(unofficial-sqlite3 CONFIG REQUIRED)
5+
target_link_libraries(main PRIVATE unofficial::sqlite3::sqlite3)

vcpkg/ports/sqlite3/vcpkg.json

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"name": "sqlite3",
3+
"version": "3.47.2",
4+
"description": "SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.",
5+
"homepage": "https://sqlite.org/",
6+
"license": "blessing",
7+
"dependencies": [
8+
{
9+
"name": "vcpkg-cmake",
10+
"host": true
11+
},
12+
{
13+
"name": "vcpkg-cmake-config",
14+
"host": true
15+
}
16+
],
17+
"default-features": [
18+
"json1"
19+
],
20+
"features": {
21+
"dbpage-vtab": {
22+
"description": "Enable the recovery extension"
23+
},
24+
"dbstat": {
25+
"description": "Enable the DBSTAT virtual table"
26+
},
27+
"fts3": {
28+
"description": "Enable the FTS3 extension"
29+
},
30+
"fts4": {
31+
"description": "Enable the FTS4 extension"
32+
},
33+
"fts5": {
34+
"description": "Enable the FTS5 extension"
35+
},
36+
"geopoly": {
37+
"description": "Enable geopoly functionality for sqlite3"
38+
},
39+
"json1": {
40+
"description": "Enable JSON functionality for sqlite3"
41+
},
42+
"limit": {
43+
"description": "Enable the UPDATE/DELETE LIMIT clause"
44+
},
45+
"math": {
46+
"description": "Enable math functions"
47+
},
48+
"memsys3": {
49+
"description": "Enable MEMSYS3"
50+
},
51+
"memsys5": {
52+
"description": "Enable MEMSYS5"
53+
},
54+
"omit-load-extension": {
55+
"description": "Enable loading of external extensions"
56+
},
57+
"rtree": {
58+
"description": "Enable the RTREE extension"
59+
},
60+
"session": {
61+
"description": "Enable the SESSION extension"
62+
},
63+
"snapshot": {
64+
"description": "Enable the snapshot function"
65+
},
66+
"soundex": {
67+
"description": "Enable the SOUNDEX scalar function"
68+
},
69+
"tool": {
70+
"description": "Build sqlite3 executable",
71+
"supports": "!uwp"
72+
},
73+
"unicode": {
74+
"description": "Enable unicode support",
75+
"dependencies": [
76+
"icu"
77+
]
78+
},
79+
"zlib": {
80+
"description": "Build sqlite3 command line tool with zlib support; has no effect on the library itself",
81+
"dependencies": [
82+
"zlib"
83+
]
84+
}
85+
}
86+
}

0 commit comments

Comments
 (0)