[sqlite3] Add more features (#23009)

* [sqlite3] Add more features

* version

* Add dependency zlib for feature zlib

* version

* Remove -DSQLITE_API=extern

* version

* Add pre-defines to pkgconfig

* Add new option CFLAGS to get all clfags

* Get pkgconfig cflags, add sqlite3 feature dependency

* version

* doc
This commit is contained in:
Jack·Boos·Yu 2022-02-17 05:00:36 +08:00 committed by GitHub
parent 55e666af39
commit 7f3e168d8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 222 additions and 35 deletions

View File

@ -10,6 +10,7 @@ Retrieve required module information from pkgconfig modules
x_vcpkg_pkgconfig_get_modules(
PREFIX <prefix>
MODULES <pkgconfig_modules>...
[CFLAGS]
[LIBS]
[LIBRARIES]
[LIBRARIES_DIRS]

View File

@ -49,7 +49,11 @@ if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
PREFIX PKGCONFIG
MODULES --msvc-syntax ${pkg_config_modules}
LIBS
CFLAGS
)
set(CL_FLAGS_RELEASE "${CL_FLAGS} ${PKGCONFIG_CFLAGS_RELEASE}")
set(CL_FLAGS_DEBUG "${CL_FLAGS} ${PKGCONFIG_CFLAGS_DEBUG}")
# vcpkg_build_nmake doesn't supply cmake's implicit link libraries
if(PKGCONFIG_LIBS_DEBUG MATCHES "libcrypto")
@ -77,12 +81,12 @@ if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
endif()
vcpkg_install_nmake(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
"CL_FLAGS=${CL_FLAGS}"
OPTIONS_RELEASE
"CL_FLAGS=${CL_FLAGS_RELEASE}"
"INST_DIR=${INST_DIR}"
"LIBS_ALL=${LIBS_ALL_RELEASE}"
OPTIONS_DEBUG
"CL_FLAGS=${CL_FLAGS_DEBUG}"
"INST_DIR=${INST_DIR}\\debug"
"LIBS_ALL=${LIBS_ALL_DEBUG}"
"LINK_FLAGS=/debug"

View File

@ -1,7 +1,7 @@
{
"name": "libspatialite",
"version": "5.0.1",
"port-version": 2,
"port-version": 3,
"description": "SpatiaLite is an open source library intended to extend the SQLite core to support fully fledged Spatial SQL capabilities.",
"homepage": "https://www.gaia-gis.it/gaia-sins/libspatialite-sources",
"dependencies": [
@ -9,7 +9,13 @@
"libiconv",
"libxml2",
"proj4",
"sqlite3",
{
"name": "sqlite3",
"default-features": false,
"features": [
"rtree"
]
},
"vcpkg-pkgconfig-get-modules",
"zlib"
],

View File

@ -1,51 +1,145 @@
cmake_minimum_required(VERSION 3.10)
project(sqlite3 C)
include_directories(.)
option(ENABLE_FTS3 "Enable the FTS3 extension" OFF)
option(ENABLE_FTS4 "Enable the FTS4 extension" OFF)
option(ENABLE_FTS5 "Enable the FTS5 extension" OFF)
option(ENABLE_MEMSYS3 "Enable MEMSYS3" OFF)
option(ENABLE_MEMSYS5 "Enable MEMSYS5" OFF)
option(ENABLE_MATH_FUNCTION "Enable math functions" OFF)
option(ENABLE_LIMIT "Enable the UPDATE/DELETE LIMIT clause" OFF)
option(ENABLE_RTREE "Enable the RTREE extension" OFF)
option(ENABLE_SESSION "Enable the SESSION extension" OFF)
option(ENABLE_OMIT_LOAD_EXT "Enable loading of external extensions" OFF)
option(WITH_GEOPOLY "Enable geopoly functionality for sqlite3" OFF)
option(WITH_JSON1 "Enable JSON functionality for sqlite3" OFF)
option(WITH_ZLIB "Build sqlite3 with zlib support" OFF)
option(SQLITE3_SKIP_TOOLS "Disable build sqlite3 executable" OFF)
if(BUILD_SHARED_LIBS)
if(UNIX)
set(API "-DSQLITE_API=__attribute__((visibility(\"default\")))")
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(API "-DSQLITE_API=__declspec(dllexport)")
set(SQLITE_API "-DSQLITE_API=__attribute__((visibility(\"default\")))")
elseif(WIN32)
set(SQLITE_API "-DSQLITE_API=__declspec(dllexport)")
else()
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
endif()
else()
set(API "-DSQLITE_API=extern")
endif()
add_library(sqlite3 sqlite3.c)
target_include_directories(sqlite3 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}> $<INSTALL_INTERFACE:include>)
target_compile_definitions(
sqlite3
PRIVATE
$<$<CONFIG:Debug>:SQLITE_DEBUG>
${API}
-DSQLITE_ENABLE_RTREE
$<$<CONFIG:Debug>:SQLITE_DEBUG=1>
$<$<CONFIG:Debug>:SQLITE_ENABLE_SELECTTRACE>
$<$<CONFIG:Debug>:SQLITE_ENABLE_WHERETRACE>
${SQLITE_API}
-DSQLITE_ENABLE_UNLOCK_NOTIFY
-DSQLITE_ENABLE_COLUMN_METADATA
)
if (BUILD_SHARED_LIBS)
if (UNIX)
string(APPEND PKGCONFIG_DEFINES " -DSQLITE_API=__attribute__((visibility(\"default\")))")
target_compile_definitions(sqlite3 INTERFACE "SQLITE_API=__attribute__((visibility(\"default\")))")
elseif (WIN32)
string(APPEND PKGCONFIG_DEFINES " -DSQLITE_API=__declspec(dllimport)")
target_compile_definitions(sqlite3 INTERFACE "SQLITE_API=__declspec(dllimport)")
endif()
endif()
if (ENABLE_FTS3)
string(APPEND PKGCONFIG_DEFINES " -DSQLITE_ENABLE_FTS3")
target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_FTS3)
endif()
if (ENABLE_FTS4)
string(APPEND PKGCONFIG_DEFINES " -DSQLITE_ENABLE_FTS4")
target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_FTS4)
endif()
if (ENABLE_FTS5)
string(APPEND PKGCONFIG_DEFINES " -DSQLITE_ENABLE_FTS5")
target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_FTS5)
endif()
if (ENABLE_MEMSYS3)
string(APPEND PKGCONFIG_DEFINES " -DSQLITE_ENABLE_MEMSYS3")
target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_MEMSYS3)
endif()
if (ENABLE_MEMSYS5)
string(APPEND PKGCONFIG_DEFINES " -DSQLITE_ENABLE_MEMSYS5")
target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_MEMSYS5)
endif()
if (ENABLE_MATH_FUNCTION)
string(APPEND PKGCONFIG_DEFINES " -DSQLITE_ENABLE_MATH_FUNCTIONS")
target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_MATH_FUNCTIONS)
endif()
if (ENABLE_LIMIT)
string(APPEND PKGCONFIG_DEFINES " -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT")
target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_UPDATE_DELETE_LIMIT)
endif()
if (ENABLE_RTREE)
string(APPEND PKGCONFIG_DEFINES " -DSQLITE_ENABLE_RTREE")
target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_RTREE)
endif()
if (ENABLE_SESSION)
string(APPEND PKGCONFIG_DEFINES " -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK")
target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_SESSION SQLITE_ENABLE_PREUPDATE_HOOK)
endif()
if (ENABLE_OMIT_LOAD_EXT)
string(APPEND PKGCONFIG_DEFINES " -DSQLITE_OMIT_LOAD_EXTENSION")
target_compile_definitions(sqlite3 PUBLIC SQLITE_OMIT_LOAD_EXTENSION)
endif()
if(WITH_GEOPOLY)
add_compile_definitions(SQLITE_ENABLE_GEOPOLY)
string(APPEND PKGCONFIG_DEFINES " -DSQLITE_ENABLE_GEOPOLY")
target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_GEOPOLY)
endif()
if(WITH_JSON1)
add_compile_definitions(SQLITE_ENABLE_JSON1)
string(APPEND PKGCONFIG_DEFINES " -DSQLITE_ENABLE_JSON1")
target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_JSON1)
endif()
if (WIN32)
string(APPEND PKGCONFIG_DEFINES " -DQLITE_OS_WIN=1")
target_compile_definitions(sqlite3 PUBLIC -DSQLITE_OS_WIN=1)
if(CMAKE_SYSTEM_NAME MATCHES "WindowsStore")
string(APPEND PKGCONFIG_DEFINES " -DSQLITE_OS_WINRT=1")
target_compile_definitions(sqlite3 PUBLIC -DSQLITE_OS_WINRT=1)
endif()
else()
string(APPEND PKGCONFIG_DEFINES " -DSQLITE_OS_UNIX=1")
target_compile_definitions(sqlite3 PUBLIC -DSQLITE_OS_UNIX=1)
endif()
target_include_directories(sqlite3 INTERFACE $<INSTALL_INTERFACE:include>)
if(NOT WIN32)
find_package(Threads REQUIRED)
target_link_libraries(sqlite3 PRIVATE Threads::Threads ${CMAKE_DL_LIBS})
target_link_libraries(sqlite3 PUBLIC Threads::Threads ${CMAKE_DL_LIBS})
endif()
if(CMAKE_SYSTEM_NAME MATCHES "WindowsStore")
target_compile_definitions(sqlite3 PRIVATE -DSQLITE_OS_WINRT=1)
if (WITH_ZLIB)
find_package(ZLIB REQUIRED)
target_link_libraries(sqlite3 PUBLIC ZLIB::ZLIB)
endif()
if(NOT SQLITE3_SKIP_TOOLS)
add_executable(sqlite3-bin shell.c)
target_link_libraries(sqlite3-bin PRIVATE sqlite3)
install(TARGETS sqlite3-bin sqlite3
RUNTIME DESTINATION tools
LIBRARY DESTINATION lib
@ -72,5 +166,6 @@ if(UNIX)
else()
set(PKGCONFIG_LIBS_PRIVATE "")
endif()
configure_file(sqlite3.pc.in sqlite3.pc @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sqlite3.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")

View File

@ -21,10 +21,21 @@ file(COPY "${CMAKE_CURRENT_LIST_DIR}/sqlite3.pc.in" DESTINATION "${SOURCE_PATH}"
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
geopoly WITH_GEOPOLY
json1 WITH_JSON1
fts3 ENABLE_FTS3
fts4 ENABLE_FTS4
fts5 ENABLE_FTS5
memsys3 ENABLE_MEMSYS3
memsys5 ENABLE_MEMSYS5
math ENABLE_MATH_FUNCTION
limit ENABLE_LIMIT
rtree ENABLE_RTREE
session ENABLE_SESSION
omit-load-extension ENABLE_OMIT_LOAD_EXT
geopoly WITH_GEOPOLY
json1 WITH_JSON1
zlib WITH_ZLIB
INVERTED_FEATURES
tool SQLITE3_SKIP_TOOLS
tool SQLITE3_SKIP_TOOLS
)
vcpkg_cmake_configure(
@ -37,6 +48,7 @@ vcpkg_cmake_configure(
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-${PORT} CONFIG_PATH share/unofficial-${PORT})
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
@ -58,4 +70,3 @@ if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
endif()
file(WRITE ${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright "SQLite is in the Public Domain.\nhttp://www.sqlite.org/copyright.html\n")
vcpkg_copy_pdbs()

View File

@ -8,4 +8,4 @@ Description: SQL database engine
Version: @PKGCONFIG_VERSION@
Libs: -L${libdir} -lsqlite3
Libs.private: @PKGCONFIG_LIBS_PRIVATE@
Cflags: -I${includedir}
Cflags: -I${includedir} @PKGCONFIG_DEFINES@

View File

@ -1,8 +1,10 @@
{
"name": "sqlite3",
"version": "3.37.1",
"version": "3.37.2",
"port-version": 1,
"description": "SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.",
"homepage": "https://sqlite.org/",
"homepage": "https://github.com/sqlite/sqlite",
"license": "blessing",
"dependencies": [
{
"name": "vcpkg-cmake",
@ -14,14 +16,50 @@
}
],
"features": {
"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"
"description": "Enable geopoly functionality for sqlite3"
},
"json1": {
"description": "enable JSON functionality for sqlite3"
"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"
},
"tool": {
"description": "sqlite3 executable"
"description": "Build sqlite3 executable"
},
"zlib": {
"description": "Build sqlite3 with zlib support",
"dependencies": [
"zlib"
]
}
}
}

View File

@ -1,6 +1,6 @@
{
"name": "vcpkg-pkgconfig-get-modules",
"version-date": "2022-01-10",
"version-date": "2022-02-10",
"dependencies": [
{
"name": "pkgconf",

View File

@ -9,6 +9,7 @@ Retrieve required module information from pkgconfig modules
x_vcpkg_pkgconfig_get_modules(
PREFIX <prefix>
MODULES <pkgconfig_modules>...
[CFLAGS]
[LIBS]
[LIBRARIES]
[LIBRARIES_DIRS]
@ -45,7 +46,7 @@ endif()
set(Z_VCPKG_PKGCONFIG_GET_MODULES_GUARD ON CACHE INTERNAL "guard variable")
function(x_vcpkg_pkgconfig_get_modules)
cmake_parse_arguments(PARSE_ARGV 0 "arg" "LIBS;LIBRARIES;LIBRARIES_DIR;INCLUDE_DIRS" "PREFIX" "MODULES")
cmake_parse_arguments(PARSE_ARGV 0 "arg" "CFLAGS;LIBS;LIBRARIES;LIBRARIES_DIR;INCLUDE_DIRS" "PREFIX" "MODULES")
if(NOT DEFINED arg_PREFIX OR arg_PREFIX STREQUAL "")
message(FATAL_ERROR "x_vcpkg_pkgconfig_get_modules requires parameter PREFIX!")
endif()
@ -95,6 +96,14 @@ function(x_vcpkg_pkgconfig_get_modules)
)
list(APPEND var_suffixes INCLUDE_DIRS_RELEASE)
endif()
if(arg_CFLAGS)
execute_process(
COMMAND "${PKGCONFIG}" --cflags ${arg_MODULES}
OUTPUT_VARIABLE ${arg_PREFIX}_CFLAGS_RELEASE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
list(APPEND var_suffixes CFLAGS_RELEASE)
endif()
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
z_vcpkg_set_pkgconfig_path("${CURRENT_INSTALLED_DIR}/debug/lib/pkgconfig${VCPKG_HOST_PATH_SEPARATOR}${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig" "${backup_PKG_CONFIG_PATH}")
@ -130,6 +139,14 @@ function(x_vcpkg_pkgconfig_get_modules)
)
list(APPEND var_suffixes INCLUDE_DIRS_DEBUG)
endif()
if(arg_CFLAGS)
execute_process(
COMMAND "${PKGCONFIG}" --cflags ${arg_MODULES}
OUTPUT_VARIABLE ${arg_PREFIX}_CFLAGS_DEBUG
OUTPUT_STRIP_TRAILING_WHITESPACE
)
list(APPEND var_suffixes CFLAGS_DEBUG)
endif()
endif()
set(ENV{PKG_CONFIG_PATH} "${backup_PKG_CONFIG_PATH}")

View File

@ -3946,7 +3946,7 @@
},
"libspatialite": {
"baseline": "5.0.1",
"port-version": 2
"port-version": 3
},
"libspnav": {
"baseline": "0.2.3",
@ -6621,8 +6621,8 @@
"port-version": 0
},
"sqlite3": {
"baseline": "3.37.1",
"port-version": 0
"baseline": "3.37.2",
"port-version": 1
},
"sqlitecpp": {
"baseline": "3.1.1",
@ -7205,7 +7205,7 @@
"port-version": 0
},
"vcpkg-pkgconfig-get-modules": {
"baseline": "2022-01-10",
"baseline": "2022-02-10",
"port-version": 0
},
"vcpkg-qmake": {

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "ad90cccc74f447ccc40309956f67092c845fe40b",
"version": "5.0.1",
"port-version": 3
},
{
"git-tree": "35cc452ea0fc43d38cfca4d340e47f13c9fd740f",
"version": "5.0.1",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "f49ad405225c6326558adb79f2082814002a8cda",
"version": "3.37.2",
"port-version": 1
},
{
"git-tree": "ac17b6f385706852a3895200764c358697c5c584",
"version": "3.37.1",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "d4f1fd82fd733b622ed83f5f502b8483e5b2ca3b",
"version-date": "2022-02-10",
"port-version": 0
},
{
"git-tree": "1fae7b16a1eb390ca9239c3e82aa0fdb41f9565b",
"version-date": "2022-01-10",