mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
Add cmake flag to optionally disable spatialite support
If turned off, disables the spatialite, wfs, virtual providers and the offline editing plugin as a result. Intended for development purposes only, as the spatialite linkage can be problematic when building against non-system proj/gdal versions
This commit is contained in:
parent
3248cc5786
commit
ef9dd06d3e
@ -233,7 +233,11 @@ if(WITH_CORE)
|
||||
set (POSTGRESQL_PREFIX "" CACHE PATH "Path to POSTGRESQL base directory")
|
||||
endif()
|
||||
|
||||
set (WITH_QSPATIALITE FALSE CACHE BOOL "Determines whether QSPATIALITE sql driver should be built")
|
||||
# try to configure and build POSTGRESQL support
|
||||
set (WITH_SPATIALITE TRUE CACHE BOOL "Determines whether Spatialite support should be built (required for spatialite, virtual, wfs providers)")
|
||||
if (WITH_SPATIALITE)
|
||||
set (WITH_QSPATIALITE FALSE CACHE BOOL "Determines whether QSPATIALITE sql driver should be built")
|
||||
endif()
|
||||
|
||||
set (WITH_ORACLE FALSE CACHE BOOL "Determines whether Oracle support should be built")
|
||||
if(WITH_ORACLE)
|
||||
@ -390,7 +394,10 @@ if(WITH_CORE)
|
||||
find_package(Poly2Tri REQUIRED)
|
||||
endif()
|
||||
|
||||
find_package(SpatiaLite REQUIRED)
|
||||
if (WITH_SPATIALITE)
|
||||
find_package(SpatiaLite REQUIRED)
|
||||
set (HAVE_SPATIALITE TRUE)
|
||||
endif()
|
||||
|
||||
if (NOT PROJ_FOUND OR NOT GEOS_FOUND OR NOT GDAL_FOUND)
|
||||
message (SEND_ERROR "Some dependencies were not found! Proj: ${PROJ_FOUND}, Geos: ${GEOS_FOUND}, GDAL: ${GDAL_FOUND}")
|
||||
|
@ -57,6 +57,8 @@
|
||||
|
||||
#cmakedefine HAVE_GUI
|
||||
|
||||
#cmakedefine HAVE_SPATIALITE
|
||||
|
||||
#cmakedefine HAVE_POSTGRESQL
|
||||
|
||||
#cmakedefine HAVE_ORACLE
|
||||
|
@ -226,8 +226,6 @@ set(QGIS_APP_SRCS
|
||||
pluginmanager/qgspluginsortfilterproxymodel.cpp
|
||||
pluginmanager/qgspluginitemdelegate.cpp
|
||||
|
||||
qgsnewspatialitelayerdialog.cpp
|
||||
|
||||
qgssettingstree.cpp
|
||||
qgsvariantdelegate.cpp
|
||||
qgscrashhandler.cpp
|
||||
@ -235,6 +233,13 @@ set(QGIS_APP_SRCS
|
||||
mesh/qgsmeshcalculatordialog.cpp
|
||||
)
|
||||
|
||||
if (WITH_SPATIALITE)
|
||||
set(QGIS_APP_SRCS
|
||||
${QGIS_APP_SRCS}
|
||||
qgsnewspatialitelayerdialog.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if (WITH_GEOREFERENCER)
|
||||
set(QGIS_APP_SRCS
|
||||
${QGIS_APP_SRCS}
|
||||
|
@ -472,11 +472,14 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
#ifdef HAVE_SPATIALITE
|
||||
extern "C"
|
||||
{
|
||||
#include <spatialite.h>
|
||||
}
|
||||
#include "qgsnewspatialitelayerdialog.h"
|
||||
#endif
|
||||
|
||||
#include "qgsnewgeopackagelayerdialog.h"
|
||||
|
||||
#ifdef WITH_BINDINGS
|
||||
@ -2648,7 +2651,9 @@ void QgisApp::createActions()
|
||||
|
||||
connect( mActionDataSourceManager, &QAction::triggered, this, [ = ]() { dataSourceManager(); } );
|
||||
connect( mActionNewVectorLayer, &QAction::triggered, this, &QgisApp::newVectorLayer );
|
||||
#ifdef HAVE_SPATIALITE
|
||||
connect( mActionNewSpatiaLiteLayer, &QAction::triggered, this, &QgisApp::newSpatialiteLayer );
|
||||
#endif
|
||||
connect( mActionNewGeoPackageLayer, &QAction::triggered, this, &QgisApp::newGeoPackageLayer );
|
||||
connect( mActionNewMemoryLayer, &QAction::triggered, this, &QgisApp::newMemoryLayer );
|
||||
connect( mActionNewVirtualLayer, &QAction::triggered, this, &QgisApp::addVirtualLayer );
|
||||
@ -2661,7 +2666,9 @@ void QgisApp::createActions()
|
||||
connect( mActionAddRasterLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "gdal" ) ); } );
|
||||
connect( mActionAddMeshLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "mdal" ) ); } );
|
||||
connect( mActionAddPgLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "postgres" ) ); } );
|
||||
#ifdef HAVE_SPATIALITE
|
||||
connect( mActionAddSpatiaLiteLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "spatialite" ) ); } );
|
||||
#endif
|
||||
connect( mActionAddMssqlLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "mssql" ) ); } );
|
||||
connect( mActionAddDb2Layer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "DB2" ) ); } );
|
||||
connect( mActionAddOracleLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "oracle" ) ); } );
|
||||
@ -2671,7 +2678,9 @@ void QgisApp::createActions()
|
||||
connect( mActionAddVectorTileLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "vectortile" ) ); } );
|
||||
connect( mActionAddPointCloudLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "ept" ) ); } );
|
||||
connect( mActionAddWcsLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "wcs" ) ); } );
|
||||
#ifdef HAVE_SPATIALITE
|
||||
connect( mActionAddWfsLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "WFS" ) ); } );
|
||||
#endif
|
||||
connect( mActionAddAfsLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "arcgisfeatureserver" ) ); } );
|
||||
connect( mActionAddDelimitedText, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "delimitedtext" ) ); } );
|
||||
connect( mActionAddVirtualLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "virtual" ) ); } );
|
||||
@ -3428,7 +3437,9 @@ void QgisApp::createToolBars()
|
||||
bt = new QToolButton();
|
||||
bt->setPopupMode( QToolButton::MenuButtonPopup );
|
||||
bt->addAction( mActionNewVectorLayer );
|
||||
#ifdef HAVE_SPATIALITE
|
||||
bt->addAction( mActionNewSpatiaLiteLayer );
|
||||
#endif
|
||||
bt->addAction( mActionNewGeoPackageLayer );
|
||||
bt->addAction( mActionNewMemoryLayer );
|
||||
|
||||
@ -3929,8 +3940,10 @@ void QgisApp::setTheme( const QString &themeName )
|
||||
#ifdef HAVE_POSTGRESQL
|
||||
mActionAddPgLayer->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddPostgisLayer.svg" ) ) );
|
||||
#endif
|
||||
#ifdef HAVE_SPATIALITE
|
||||
mActionNewSpatiaLiteLayer->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionNewSpatiaLiteLayer.svg" ) ) );
|
||||
mActionAddSpatiaLiteLayer->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddSpatiaLiteLayer.svg" ) ) );
|
||||
#endif
|
||||
mActionAddMssqlLayer->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddMssqlLayer.svg" ) ) );
|
||||
mActionAddDb2Layer->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddDb2Layer.svg" ) ) );
|
||||
#ifdef HAVE_ORACLE
|
||||
@ -4052,7 +4065,9 @@ void QgisApp::setTheme( const QString &themeName )
|
||||
mActionAddXyzLayer->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddXyzLayer.svg" ) ) );
|
||||
mActionAddVectorTileLayer->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddVectorTileLayer.svg" ) ) );
|
||||
mActionAddWcsLayer->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddWcsLayer.svg" ) ) );
|
||||
#ifdef HAVE_SPATIALITE
|
||||
mActionAddWfsLayer->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddWfsLayer.svg" ) ) );
|
||||
#endif
|
||||
mActionAddAfsLayer->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddAfsLayer.svg" ) ) );
|
||||
mActionAddToOverview->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionInOverview.svg" ) ) );
|
||||
mActionAnnotation->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAnnotation.svg" ) ) );
|
||||
@ -5279,8 +5294,13 @@ void QgisApp::about()
|
||||
versionString += QStringLiteral( "</td></tr><tr>" );
|
||||
|
||||
// spatialite
|
||||
versionString += QStringLiteral( "<td>%1</td><td colspan=\"3\">%2</td>" ).arg( tr( "SpatiaLite version" ), spatialite_version() );
|
||||
versionString += QLatin1String( "</tr><tr>" );
|
||||
versionString += QStringLiteral( "<td>%1</td><td colspan=\"3\">" ).arg( tr( "SpatiaLite version" ) );
|
||||
#ifdef HAVE_SPATIALITE
|
||||
versionString += QStringLiteral( "%1</td>" ).arg( spatialite_version() );
|
||||
#else
|
||||
versionString += tr( "No support" );
|
||||
#endif
|
||||
versionString += QStringLiteral( "</td></tr><tr>" );
|
||||
|
||||
// QWT
|
||||
versionString += QStringLiteral( "<td>%1</td><td colspan=\"3\">%2</td>" ).arg( tr( "QWT version" ), QWT_VERSION_STR );
|
||||
@ -6732,11 +6752,13 @@ void QgisApp::newMemoryLayer()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_SPATIALITE
|
||||
void QgisApp::newSpatialiteLayer()
|
||||
{
|
||||
QgsNewSpatialiteLayerDialog spatialiteDialog( this, QgsGuiUtils::ModalDialogFlags, QgsProject::instance()->defaultCrsForNewLayers() );
|
||||
spatialiteDialog.exec();
|
||||
}
|
||||
#endif
|
||||
|
||||
void QgisApp::newGeoPackageLayer()
|
||||
{
|
||||
|
@ -539,18 +539,30 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
|
||||
|
||||
QAction *actionDataSourceManager() { return mActionDataSourceManager; }
|
||||
QAction *actionNewVectorLayer() { return mActionNewVectorLayer; }
|
||||
#ifdef HAVE_SPATIALITE
|
||||
QAction *actionNewSpatialLiteLayer() { return mActionNewSpatiaLiteLayer; }
|
||||
#else
|
||||
QAction *actionNewSpatialLiteLayer() { return nullptr; }
|
||||
#endif
|
||||
QAction *actionEmbedLayers() { return mActionEmbedLayers; }
|
||||
QAction *actionAddOgrLayer() { return mActionAddOgrLayer; }
|
||||
QAction *actionAddRasterLayer() { return mActionAddRasterLayer; }
|
||||
QAction *actionAddPgLayer() { return mActionAddPgLayer; }
|
||||
#ifdef HAVE_SPATIALITE
|
||||
QAction *actionAddSpatiaLiteLayer() { return mActionAddSpatiaLiteLayer; }
|
||||
#else
|
||||
QAction *actionAddSpatiaLiteLayer() { return nullptr; }
|
||||
#endif
|
||||
QAction *actionAddWmsLayer() { return mActionAddWmsLayer; }
|
||||
QAction *actionAddXyzLayer() { return mActionAddXyzLayer; }
|
||||
QAction *actionAddVectorTileLayer() { return mActionAddVectorTileLayer; }
|
||||
QAction *actionAddPointCloudLayer() { return mActionAddPointCloudLayer; }
|
||||
QAction *actionAddWcsLayer() { return mActionAddWcsLayer; }
|
||||
#ifdef HAVE_SPATIALITE
|
||||
QAction *actionAddWfsLayer() { return mActionAddWfsLayer; }
|
||||
#else
|
||||
QAction *actionAddWfsLayer() { return nullptr; }
|
||||
#endif
|
||||
QAction *actionAddAfsLayer() { return mActionAddAfsLayer; }
|
||||
QAction *actionCopyLayerStyle() { return mActionCopyStyle; }
|
||||
QAction *actionPasteLayerStyle() { return mActionPasteStyle; }
|
||||
@ -1561,8 +1573,10 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
|
||||
void newVectorLayer();
|
||||
//! Create a new memory layer
|
||||
void newMemoryLayer();
|
||||
#ifdef HAVE_SPATIALITE
|
||||
//! Create a new empty SpatiaLite layer
|
||||
void newSpatialiteLayer();
|
||||
#endif
|
||||
//! Create a new empty GeoPackage layer
|
||||
void newGeoPackageLayer();
|
||||
|
||||
|
@ -1774,7 +1774,6 @@ target_include_directories(qgis_core SYSTEM PUBLIC
|
||||
${GEOS_INCLUDE_DIR}
|
||||
${EXPAT_INCLUDE_DIR}
|
||||
${SQLITE3_INCLUDE_DIR}
|
||||
${SPATIALITE_INCLUDE_DIR}
|
||||
${QCA_INCLUDE_DIR}
|
||||
${QTKEYCHAIN_INCLUDE_DIR}
|
||||
${${QT_VERSION_BASE}SerialPort_INCLUDE_DIRS}
|
||||
@ -1782,6 +1781,12 @@ target_include_directories(qgis_core SYSTEM PUBLIC
|
||||
${ZLIB_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
if (WITH_SPATIALITE)
|
||||
target_include_directories(qgis_core SYSTEM PUBLIC
|
||||
${SPATIALITE_INCLUDE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
target_include_directories(qgis_core PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
@ -1941,12 +1946,15 @@ target_link_libraries(qgis_core
|
||||
${SPATIALINDEX_LIBRARY}
|
||||
${EXPAT_LIBRARY}
|
||||
${SQLITE3_LIBRARY}
|
||||
${SPATIALITE_LIBRARY}
|
||||
${LIBZIP_LIBRARY}
|
||||
${Protobuf_LITE_LIBRARY}
|
||||
${ZLIB_LIBRARIES}
|
||||
)
|
||||
|
||||
if (WITH_SPATIALITE)
|
||||
target_link_libraries(qgis_core ${SPATIALITE_LIBRARY})
|
||||
endif()
|
||||
|
||||
if (WITH_QT6)
|
||||
target_link_libraries(qgis_core Qt6::Core5Compat)
|
||||
endif()
|
||||
|
@ -53,8 +53,14 @@
|
||||
extern "C"
|
||||
{
|
||||
#include <sqlite3.h>
|
||||
}
|
||||
|
||||
#ifdef HAVE_SPATIALITE
|
||||
extern "C"
|
||||
{
|
||||
#include <spatialite.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
#define CUSTOM_PROPERTY_IS_OFFLINE_EDITABLE "isOfflineEditable"
|
||||
#define CUSTOM_PROPERTY_REMOTE_SOURCE "remoteSource"
|
||||
@ -368,6 +374,7 @@ void QgsOfflineEditing::synchronize()
|
||||
|
||||
void QgsOfflineEditing::initializeSpatialMetadata( sqlite3 *sqlite_handle )
|
||||
{
|
||||
#ifdef HAVE_SPATIALITE
|
||||
// attempting to perform self-initialization for a newly created DB
|
||||
if ( !sqlite_handle )
|
||||
return;
|
||||
@ -425,6 +432,9 @@ void QgsOfflineEditing::initializeSpatialMetadata( sqlite3 *sqlite_handle )
|
||||
return;
|
||||
}
|
||||
spatial_ref_sys_init( sqlite_handle, 0 );
|
||||
#else
|
||||
( void )sqlite_handle;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool QgsOfflineEditing::createOfflineDb( const QString &offlineDbPath, ContainerType containerType )
|
||||
@ -557,6 +567,7 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit
|
||||
{
|
||||
case SpatiaLite:
|
||||
{
|
||||
#ifdef HAVE_SPATIALITE
|
||||
// create table
|
||||
QString sql = QStringLiteral( "CREATE TABLE '%1' (" ).arg( tableName );
|
||||
QString delim;
|
||||
@ -669,7 +680,13 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit
|
||||
newLayer = new QgsVectorLayer( connectionString,
|
||||
layer->name() + layerNameSuffix, QStringLiteral( "spatialite" ), options );
|
||||
break;
|
||||
|
||||
#else
|
||||
showWarning( tr( "No Spatialite support available" ) );
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
case GPKG:
|
||||
{
|
||||
// Set options
|
||||
|
@ -20,7 +20,10 @@
|
||||
#include "qgslogger.h"
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
#ifdef HAVE_SPATIALITE
|
||||
#include <spatialite.h>
|
||||
#endif
|
||||
|
||||
// Define this variable to print all spatialite SQL statements
|
||||
#ifdef SPATIALITE_PRINT_ALL_SQL
|
||||
@ -40,15 +43,19 @@ static int trace_callback( unsigned, void *ctx, void *p, void * )
|
||||
|
||||
int spatialite_database_unique_ptr::open( const QString &path )
|
||||
{
|
||||
#ifdef HAVE_SPATIALITE
|
||||
auto &deleter = get_deleter();
|
||||
deleter.mSpatialiteContext = spatialite_alloc_connection();
|
||||
#endif
|
||||
|
||||
sqlite3 *database = nullptr;
|
||||
int result = sqlite3_open( path.toUtf8(), &database );
|
||||
std::unique_ptr< sqlite3, QgsSpatialiteCloser>::reset( database );
|
||||
|
||||
#ifdef HAVE_SPATIALITE
|
||||
if ( result == SQLITE_OK )
|
||||
spatialite_init_ex( database, deleter.mSpatialiteContext, 0 );
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -60,15 +67,19 @@ void spatialite_database_unique_ptr::reset()
|
||||
|
||||
int spatialite_database_unique_ptr::open_v2( const QString &path, int flags, const char *zVfs )
|
||||
{
|
||||
#ifdef HAVE_SPATIALITE
|
||||
auto &deleter = get_deleter();
|
||||
deleter.mSpatialiteContext = spatialite_alloc_connection();
|
||||
#endif
|
||||
|
||||
sqlite3 *database = nullptr;
|
||||
int result = sqlite3_open_v2( path.toUtf8(), &database, flags, zVfs );
|
||||
std::unique_ptr< sqlite3, QgsSpatialiteCloser>::reset( database );
|
||||
|
||||
#ifdef HAVE_SPATIALITE
|
||||
if ( result == SQLITE_OK )
|
||||
spatialite_init_ex( database, deleter.mSpatialiteContext, 0 );
|
||||
#endif
|
||||
|
||||
#ifdef SPATIALITE_PRINT_ALL_SQL
|
||||
// Log all queries
|
||||
@ -107,6 +118,8 @@ void QgsSpatialiteCloser::operator()( sqlite3 *handle )
|
||||
QgsDebugMsg( QStringLiteral( "sqlite3_close_v2() failed: %1" ).arg( res ) );
|
||||
}
|
||||
|
||||
#ifdef HAVE_SPATIALITE
|
||||
spatialite_cleanup_ex( mSpatialiteContext );
|
||||
#endif
|
||||
mSpatialiteContext = nullptr;
|
||||
}
|
||||
|
@ -8,9 +8,12 @@ set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDI
|
||||
|
||||
add_subdirectory(gps_importer)
|
||||
add_subdirectory(topology)
|
||||
add_subdirectory(offline_editing)
|
||||
add_subdirectory(geometry_checker)
|
||||
|
||||
if (WITH_SPATIALITE)
|
||||
add_subdirectory(offline_editing)
|
||||
endif()
|
||||
|
||||
if (GRASS_FOUND)
|
||||
add_subdirectory(grass)
|
||||
endif()
|
||||
|
@ -16,12 +16,15 @@ if (NOT FORCE_STATIC_PROVIDERS)
|
||||
add_subdirectory(ows)
|
||||
add_subdirectory(wcs)
|
||||
add_subdirectory(gpx)
|
||||
add_subdirectory(wfs)
|
||||
add_subdirectory(spatialite)
|
||||
add_subdirectory(virtual)
|
||||
add_subdirectory(db2)
|
||||
add_subdirectory(mdal)
|
||||
|
||||
if (WITH_SPATIALITE)
|
||||
add_subdirectory(spatialite)
|
||||
add_subdirectory(virtual)
|
||||
add_subdirectory(wfs)
|
||||
endif()
|
||||
|
||||
if (WITH_ORACLE)
|
||||
add_subdirectory(oracle)
|
||||
endif()
|
||||
|
Loading…
x
Reference in New Issue
Block a user