Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sqlite3] Add more features #23009

Merged
merged 11 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 6 additions & 2 deletions ports/libspatialite/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 8 additions & 2 deletions ports/libspatialite/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
{
"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": [
"geos",
"libiconv",
"libxml2",
"proj4",
"sqlite3",
{
"name": "sqlite3",
"default-features": false,
"features": [
"rtree"
]
},
"vcpkg-pkgconfig-get-modules",
"zlib"
],
Expand Down
125 changes: 110 additions & 15 deletions ports/sqlite3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason:

F:\vcpkg\buildtrees\sqlite3\src\3370100-a1573e1602.clean\sqlite3.c(172381): error C2159: more than one storage class specified
F:\vcpkg\buildtrees\sqlite3\src\3370100-a1573e1602.clean\sqlite3.c(214917): error C2159: more than one storage class specified

Souce code:

#ifdef SQLITE_DEBUG
SQLITE_API extern int sqlite3_fts5_may_be_corrupt;
# define assert_nc(x) assert(sqlite3_fts5_may_be_corrupt || (x))
#else
# define assert_nc(x) assert(x)
#endif

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
Expand All @@ -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")
19 changes: 15 additions & 4 deletions ports/sqlite3/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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")
Expand All @@ -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()
2 changes: 1 addition & 1 deletion ports/sqlite3/sqlite3.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@
48 changes: 43 additions & 5 deletions ports/sqlite3/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"
]
}
}
}
2 changes: 1 addition & 1 deletion ports/vcpkg-pkgconfig-get-modules/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vcpkg-pkgconfig-get-modules",
"version-date": "2022-01-10",
"version-date": "2022-02-10",
"dependencies": [
{
"name": "pkgconf",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -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}")

Expand Down
Loading