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

[libspatialite] Use pkgconfig for nmake and autotools #20480

Merged
merged 8 commits into from
Nov 19, 2021
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
30 changes: 1 addition & 29 deletions ports/libspatialite/fix-linux-configure.patch
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ index ead87caff..47abb90f0 100644
AC_SUBST([GEOS_LDFLAGS])
AC_SUBST([GEOS_CFLAGS])
# Ensure that we can parse geos_c.h
@@ -335,11 +337,14 @@ if test x"$enable_geos" != "xno"; then
@@ -335,11 +337,13 @@ if test x"$enable_geos" != "xno"; then
AC_CHECK_HEADERS([geos_c.h],, [AC_MSG_ERROR([could not find geos_c.h - you may need to specify the directory of a geos-config file using --with-geosconfig])])
CPPFLAGS="$CPPFLAGS_SAVE"
# Ensure we can link against libgeos_c
Expand All @@ -29,34 +29,6 @@ index ead87caff..47abb90f0 100644
LIBS="$LIBS_SAVE"
LIBS="$LIBS $GEOS_LDFLAGS -lgeos_c"
+ fi
+ LIBS="$LIBS $GEOS_LDFLAGS"

#-----------------------------------------------------------------------
# --enable-controlpoints
@@ -358,7 +363,7 @@ if test x"$enable_geos" != "xno"; then
[--enable-geosadvanced], [enables GEOS advanced features [default=yes]])],
[], [enable_geosadvanced=yes])
if test x"$enable_geosadvanced" != "xno"; then
- AC_SEARCH_LIBS(GEOSDelaunayTriangulation,geos_c,,AC_MSG_ERROR(['libgeos_c' (>= v.3.4.0) is required but it doesn't seem to be installed on this system. You may need to try re-running configure with a --disable-geosadvanced parameter.]))
+ #AC_SEARCH_LIBS(GEOSDelaunayTriangulation,geos_c,,AC_MSG_ERROR(['libgeos_c' (>= v.3.4.0) is required but it doesn't seem to be installed on this system. You may need to try re-running configure with a --disable-geosadvanced parameter.]))
AC_DEFINE(GEOS_ADVANCED)
fi

@@ -369,7 +374,7 @@ if test x"$enable_geos" != "xno"; then
[--enable-geosreentrant], [enables GEOS reentrant (fully thread safe) [default=yes]])],
[], [enable_geosreentrant=yes])
if test x"$enable_geosreentrant" != "xno"; then
- AC_SEARCH_LIBS(GEOSContext_setErrorMessageHandler_r,geos_c,,AC_MSG_ERROR(['libgeos_c' (>= v.3.5.0) is required but it doesn't seem to be installed on this system. You may need to try re-running configure with a --disable-geosreentrant parameter.]))
+ #AC_SEARCH_LIBS(GEOSContext_setErrorMessageHandler_r,geos_c,,AC_MSG_ERROR(['libgeos_c' (>= v.3.5.0) is required but it doesn't seem to be installed on this system. You may need to try re-running configure with a --disable-geosreentrant parameter.]))
AC_DEFINE(GEOS_REENTRANT)
fi

@@ -390,7 +395,7 @@ if test x"$enable_geos" != "xno"; then
[--enable-geos370], [enables GEOS 3.7.0 features [default=yes]])],
[], [enable_geos370=yes])
if test x"$enable_geos370" != "xno"; then
- AC_SEARCH_LIBS(GEOSFrechetDistance_r,geos_c,,AC_MSG_ERROR(['libgeos_c' (>= v.3.7.0) is required but it doesn't seem to be installed on this system. You may need to try re-running configure with a --disable-geos370 parameter.]))
+ #AC_SEARCH_LIBS(GEOSFrechetDistance_r,geos_c,,AC_MSG_ERROR(['libgeos_c' (>= v.3.7.0) is required but it doesn't seem to be installed on this system. You may need to try re-running configure with a --disable-geos370 parameter.]))
AC_DEFINE(GEOS_370)
fi

31 changes: 31 additions & 0 deletions ports/libspatialite/gaiaconfig-msvc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/src/headers/spatialite/gaiaconfig-msvc.h b/src/headers/spatialite/gaiaconfig-msvc.h
index 37f0bd1..0053258 100644
--- a/src/headers/spatialite/gaiaconfig-msvc.h
+++ b/src/headers/spatialite/gaiaconfig-msvc.h
@@ -2,7 +2,7 @@
/* ./src/headers/spatialite/gaiaconfig-msvc.h.in - manually maintained */

/* Should be defined in order to enable GCP support. */
-#define ENABLE_GCP 1
+// #define ENABLE_GCP 1

/* Should be defined in order to enable GeoPackage support. */
#define ENABLE_GEOPACKAGE 1
@@ -11,7 +11,7 @@
#define ENABLE_LIBXML2 1

/* Should be defined in order to enable RTTOPO support. */
-#define ENABLE_RTTOPO 1
+// #define ENABLE_RTTOPO 1

/* Should be defined in order to enable GEOS_370 support. */
#define GEOS_370 1
@@ -32,7 +32,7 @@
/* #undef OMIT_FREEXL */

/* Should be defined in order to disable GEOCALLBACKS support. */
-#define OMIT_GEOCALLBACKS 1
+// #define OMIT_GEOCALLBACKS 1

/* Should be defined in order to disable GEOS support. */
/* #undef OMIT_GEOS */
222 changes: 155 additions & 67 deletions ports/libspatialite/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,62 +11,72 @@ vcpkg_extract_source_archive_ex(
PATCHES
fix-makefiles.patch
fix-linux-configure.patch
gaiaconfig-msvc.patch
)

if(VCPKG_TARGET_IS_WINDOWS)
if(VCPKG_CRT_LINKAGE STREQUAL "dynamic")
set(GEOS_LIBS_REL "${CURRENT_INSTALLED_DIR}/lib/geos_c.lib")
set(GEOS_LIBS_DBG "${CURRENT_INSTALLED_DIR}/debug/lib/geos_cd.lib")
set(LIBXML2_LIBS_REL "${CURRENT_INSTALLED_DIR}/lib/libxml2.lib")
set(LIBXML2_LIBS_DBG "${CURRENT_INSTALLED_DIR}/debug/lib/libxml2.lib")
set(LIBRTTOPO_LIBS_REL "${CURRENT_INSTALLED_DIR}/lib/librttopo.lib")
set(LIBRTTOPO_LIBS_DBG "${CURRENT_INSTALLED_DIR}/debug/lib/librttopo.lib")
else()
set(GEOS_LIBS_REL "${CURRENT_INSTALLED_DIR}/lib/geos_c.lib ${CURRENT_INSTALLED_DIR}/lib/geos.lib")
set(GEOS_LIBS_DBG "${CURRENT_INSTALLED_DIR}/debug/lib/geos_cd.lib ${CURRENT_INSTALLED_DIR}/debug/lib/geosd.lib")
set(LIBXML2_LIBS_REL "${CURRENT_INSTALLED_DIR}/lib/libxml2.lib ${CURRENT_INSTALLED_DIR}/lib/lzma.lib ws2_32.lib")
set(LIBXML2_LIBS_DBG "${CURRENT_INSTALLED_DIR}/debug/lib/libxml2.lib ${CURRENT_INSTALLED_DIR}/debug/lib/lzmad.lib ws2_32.lib")
set(LIBRTTOPO_LIBS_REL "${CURRENT_INSTALLED_DIR}/lib/librttopo.lib")
set(LIBRTTOPO_LIBS_DBG "${CURRENT_INSTALLED_DIR}/debug/lib/librttopo.lib")
vcpkg_check_features(OUT_FEATURE_OPTIONS unused
FEATURES
freexl ENABLE_FREEXL
gcp ENABLE_GCP
geocallbacks ENABLE_GEOCALLBACKS
rttopo ENABLE_RTTOPO
)

set(pkg_config_modules geos libxml-2.0 proj sqlite3 zlib)
if(ENABLE_FREEXL)
list(APPEND pkg_config_modules freexl)
endif()
if(ENABLE_RTTOPO)
list(APPEND pkg_config_modules rttopo)
endif()

if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
set(CL_FLAGS "")
if(NOT ENABLE_FREEXL)
string(APPEND CL_FLAGS " /DOMIT_FREEXL")
endif()
if(ENABLE_GCP)
string(APPEND CL_FLAGS " /DENABLE_GCP")
endif()
if(NOT ENABLE_GEOCALLBACKS)
string(APPEND CL_FLAGS " /DOMIT_GEOCALLBACKS")
endif()
if(ENABLE_RTTOPO)
string(APPEND CL_FLAGS " /DENABLE_RTTOPO")
endif()

set(LIBS_ALL_DBG
"${CURRENT_INSTALLED_DIR}/debug/lib/iconv.lib \
${CURRENT_INSTALLED_DIR}/debug/lib/charset.lib \
${CURRENT_INSTALLED_DIR}/debug/lib/sqlite3.lib \
${CURRENT_INSTALLED_DIR}/debug/lib/freexl.lib \
${CURRENT_INSTALLED_DIR}/debug/lib/zlibd.lib \
${LIBXML2_LIBS_DBG} \
${GEOS_LIBS_DBG} \
${LIBRTTOPO_LIBS_DBG} \
${CURRENT_INSTALLED_DIR}/debug/lib/proj_d.lib ole32.lib shell32.lib"
x_vcpkg_pkgconfig_get_modules(
PREFIX PKGCONFIG
MODULES --msvc-syntax ${pkg_config_modules}
LIBS
)
set(LIBS_ALL_REL
"${CURRENT_INSTALLED_DIR}/lib/iconv.lib \
${CURRENT_INSTALLED_DIR}/lib/charset.lib \
${CURRENT_INSTALLED_DIR}/lib/sqlite3.lib \
${CURRENT_INSTALLED_DIR}/lib/freexl.lib \
${CURRENT_INSTALLED_DIR}/lib/zlib.lib \
${LIBXML2_LIBS_REL} \
${GEOS_LIBS_REL} \
${LIBRTTOPO_LIBS_REL} \
${CURRENT_INSTALLED_DIR}/lib/proj.lib ole32.lib shell32.lib"
string(JOIN " " LIBS_ALL_DEBUG
"/LIBPATH:${CURRENT_INSTALLED_DIR}/debug/lib"
"${PKGCONFIG_LIBS_DEBUG}"
iconv.lib charset.lib
)
string(JOIN " " LIBS_ALL_RELEASE
"/LIBPATH:${CURRENT_INSTALLED_DIR}/lib"
"${PKGCONFIG_LIBS_RELEASE}"
iconv.lib charset.lib
)

string(REPLACE "/" "\\\\" INST_DIR "${CURRENT_PACKAGES_DIR}")
list(APPEND OPTIONS_RELEASE
"INST_DIR=${INST_DIR}" "LIBS_ALL=${LIBS_ALL_REL}"
)
list(APPEND OPTIONS_DEBUG
"LINK_FLAGS=/debug" "INST_DIR=${INST_DIR}\\debug" "LIBS_ALL=${LIBS_ALL_DBG}"
)

if(ENABLE_RTTOPO)
list(APPEND pkg_config_modules rttopo)
endif()
vcpkg_install_nmake(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
"CL_FLAGS=${CL_FLAGS}"
OPTIONS_RELEASE
${OPTIONS_RELEASE}
"INST_DIR=${INST_DIR}"
"LIBS_ALL=${LIBS_ALL_RELEASE}"
OPTIONS_DEBUG
${OPTIONS_DEBUG}
"INST_DIR=${INST_DIR}\\debug"
"LIBS_ALL=${LIBS_ALL_DEBUG}"
"LINK_FLAGS=/debug"
)

vcpkg_copy_pdbs()
Expand All @@ -84,39 +94,84 @@ if(VCPKG_TARGET_IS_WINDOWS)
file(RENAME "${CURRENT_PACKAGES_DIR}/lib/spatialite_i.lib" "${CURRENT_PACKAGES_DIR}/lib/spatialite.lib")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/spatialite_i.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/spatialite.lib")
endif()
else() # Build in UNIX
if(VCPKG_TARGET_IS_LINUX)
set(STDLIB stdc++)

set(infile "${SOURCE_PATH}/spatialite.pc.in")
set(VERSION "${LIBSPATIALITE_VERSION_STR}")
set(libdir [[${prefix}/lib]])
set(exec_prefix [[${prefix}]])
list(JOIN pkg_config_modules " " requires_private)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
set(includedir [[${prefix}/include]])
set(outfile "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/spatialite.pc")
configure_file("${infile}" "${outfile}" @ONLY)
vcpkg_replace_string("${outfile}" "Libs:" "Requires.private: ${requires_private}\nLibs.private: -liconv -lcharset\nLibs:")
vcpkg_replace_string("${outfile}" " -lm" " ")
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
set(includedir [[${prefix}/../include]])
set(outfile "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/spatialite.pc")
configure_file("${infile}" "${outfile}" @ONLY)
vcpkg_replace_string("${outfile}" "Libs:" "Requires.private: ${requires_private}\nLibs.private: -liconv -lcharset\nLibs:")
vcpkg_replace_string("${outfile}" " -lm" " ")
endif()
else()
if(ENABLE_FREEXL)
set(FREEXL_OPTION "--enable-freexl")
else()
set(FREEXL_OPTION "--disable-freexl")
endif()
if(ENABLE_GCP)
set(GCP_OPTION "--enable-gcp")
else()
set(STDLIB c++)
set(GCP_OPTION "--disable-gcp")
endif()
if(VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_OSX)
SET(EXTRALIBS "-lpthread")
if(ENABLE_GEOCALLBACKS)
set(GEOCALLBACKS_OPTION "--enable-geocallbacks")
else()
set(GEOCALLBACKS_OPTION "--disable-geocallbacks")
endif()
list(APPEND OPTIONS_RELEASE
"LIBXML2_LIBS=-lxml2 -llzma"
"GEOS_LDFLAGS=-lgeos_c -lgeos -l${STDLIB}"
)
list(APPEND OPTIONS_DEBUG
"LIBXML2_LIBS=-lxml2 -llzmad"
"GEOS_LDFLAGS=-lgeos_cd -lgeosd -l${STDLIB}"
if(ENABLE_RTTOPO)
set(RTTOPO_OPTION "--enable-rttopo")
else()
set(RTTOPO_OPTION "--disable-rttopo")
endif()
list(REMOVE_ITEM pkg_config_modules libxml2) # handled properly by configure
x_vcpkg_pkgconfig_get_modules(
PREFIX PKGCONFIG
MODULES ${pkg_config_modules}
LIBS
)

if(VCPKG_TARGET_IS_MINGW)
# Avoid system libs (as detected by cmake) in exported pc files
set(SYSTEM_LIBS "")
else()
set(SYSTEM_LIBS "\$LIBS")
endif()
# libspatialite needs some targets literally
if(VCPKG_TARGET_IS_ANDROID)
set(TARGET_ALIAS "--target=android")
elseif(VCPKG_TARGET_IS_MINGW)
set(TARGET_ALIAS "--target=mingw32")
elseif(VCPKG_TARGET_IS_OSX)
set(TARGET_ALIAS "--target=macosx")
else()
set(TARGET_ALIAS "")
endif()
vcpkg_configure_make(
SOURCE_PATH "${SOURCE_PATH}"
AUTOCONFIG
OPTIONS
"LIBS=${EXTRALIBS} -ldl -lm -l${STDLIB}"
"LIBXML2_CFLAGS=-I${CURRENT_INSTALLED_DIR}/include"
"--enable-rttopo"
"--enable-gcp"
"--enable-geocallbacks"
${TARGET_ALIAS}
${FREEXL_OPTION}
${GCP_OPTION}
${GEOCALLBACKS_OPTION}
${RTTOPO_OPTION}
"--disable-examples"
"--disable-minizip"
OPTIONS_DEBUG
${OPTIONS_DEBUG}
"LIBS=${PKGCONFIG_LIBS_DEBUG} ${SYSTEM_LIBS}"
OPTIONS_RELEASE
${OPTIONS_RELEASE}
"LIBS=${PKGCONFIG_LIBS_RELEASE} ${SYSTEM_LIBS}"
)

# automake adds the basedir of the generated config to `DEFAULT_INCLUDES`,
Expand All @@ -130,9 +185,42 @@ else() # Build in UNIX
endforeach()

vcpkg_install_make()
vcpkg_fixup_pkgconfig()

if(VCPKG_TARGET_IS_MINGW AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/plugins/${PORT}")
file(RENAME "${CURRENT_PACKAGES_DIR}/lib/mod_spatialite.dll" "${CURRENT_PACKAGES_DIR}/plugins/${PORT}/mod_spatialite.dll")
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/plugins/${PORT}")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/mod_spatialite.dll" "${CURRENT_PACKAGES_DIR}/debug/plugins/${PORT}/mod_spatialite.dll")
endif()
endif()
endif()

vcpkg_fixup_pkgconfig()

# Handle copyright
# With rttopo and ground control points enabled, the license is GPLv2+.
file(INSTALL "${SOURCE_PATH}/src/control_points/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
set(outfile "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright")
if(NOT ENABLE_GCP AND NOT ENABLE_RTTOPO)
file(READ "${SOURCE_PATH}/COPYING" mpl)
file(WRITE "${outfile}"
"SpatiaLite[${FEATURES}] is licensed under the MPL tri-license terms;\n"
"you are free to choose the best-fit license between:\n"
"- the MPL 1.1\n"
"- the GPL v2.0 or any subsequent version\n"
"- the LGPL v2.1 or any subsequent version.\n\n"
"# MPL 1.1 (from COPYING)\n\n"
"${mpl}\n"
)
else()
file(WRITE "${outfile}"
"SpatiaLite[${FEATURES}] is licensed under:\n"
"the GPL v2.0 or any subsequent version.\n\n"
)
endif()
file(READ "${SOURCE_PATH}/src/control_points/COPYING" gpl)
file(APPEND "${outfile}"
"# GPL v2.0 (from src/control_points/COPYING)\n\n"
"${gpl}\n"
)
30 changes: 27 additions & 3 deletions ports/libspatialite/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
{
"name": "libspatialite",
"version": "5.0.1",
"port-version": 1,
"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": [
"freexl",
"geos",
"libiconv",
"librttopo",
"libxml2",
"proj4",
"sqlite3",
"vcpkg-pkgconfig-get-modules",
"zlib"
]
],
"default-features": [
"freexl",
"geocallbacks"
],
"features": {
"freexl": {
"description": "FreeXL spreadsheet file support.",
"dependencies": [
"freexl"
]
},
"gcp": {
"description": "Ground control points support. This feature reduces the license options to GPLv2+."
},
"geocallbacks": {
"description": "Geometry callbacks support."
},
"rttopo": {
"description": "RTTOPO support. This feature reduces the license options to GPLv2+.",
"dependencies": [
"librttopo"
]
}
}
}
Loading