Skip to content
Permalink
Browse files
[spatialite] Unlock static build support
(includes some fixes with postgresql-less static builds)
  • Loading branch information
nirvn committed Oct 31, 2021
1 parent 5ad6aa2 commit 72403567ae2aa452264cb1b16bf8d9f14f32408b
@@ -2133,9 +2133,18 @@ endif()
if (FORCE_STATIC_LIBS)
target_link_libraries(qgis_core
provider_wms_a
provider_postgres_a
provider_delimitedtext_a
)
if (HAVE_SPATIALITE)
target_link_libraries(qgis_core
provider_spatialite_a
)
endif()
if (HAVE_POSTGRESQL)
target_link_libraries(qgis_core
provider_postgres_a
)
endif()

if (WITH_AUTH)
target_link_libraries(qgis_core
@@ -44,10 +44,13 @@

#ifdef HAVE_STATIC_PROVIDERS
#include "qgswmsprovider.h"
#include "qgsdelimitedtextprovider.h"
#ifdef HAVE_SPATIALITE
#include "qgsspatialiteprovider.h"
#endif
#ifdef HAVE_POSTGRESQL
#include "qgspostgresprovider.h"
#endif
#include "qgsdelimitedtextprovider.h"
#endif

#include <QString>
@@ -193,10 +196,13 @@ void QgsProviderRegistry::init()

#ifdef HAVE_STATIC_PROVIDERS
mProviders[ QgsWmsProvider::providerKey() ] = new QgsWmsProviderMetadata();
mProviders[ QgsDelimitedTextProvider::providerKey() ] = new QgsDelimitedTextProviderMetadata();
#ifdef HAVE_SPATIALITE
mProviders[ QgsSpatiaLiteProvider::providerKey() ] = new QgsSpatiaLiteProviderMetadata();
#endif
#ifdef HAVE_POSTGRESQL
mProviders[ QgsPostgresProvider::providerKey() ] = new QgsPostgresProviderMetadata();
#endif
mProviders[ QgsDelimitedTextProvider::providerKey() ] = new QgsDelimitedTextProviderMetadata();
#endif

// add dynamic providers
@@ -1544,9 +1544,18 @@ endif()
if (FORCE_STATIC_LIBS)
target_link_libraries(qgis_gui
provider_wms_gui_a
provider_postgres_gui_a
provider_delimitedtext_gui_a
)
if (HAVE_SPATIALITE)
target_link_libraries(qgis_gui
provider_spatialite_gui_a
)
endif()
if (HAVE_POSTGRESQL)
target_link_libraries(qgis_gui
provider_postgres_gui_a
)
endif()
endif()

if(ENABLE_MODELTEST)
@@ -35,8 +35,13 @@

#ifdef HAVE_STATIC_PROVIDERS
#include "qgswmsprovidergui.h"
#include "qgspostgresprovidergui.h"
#include "qgsdelimitedtextprovidergui.h"
#ifdef HAVE_SPATIALITE
#include "qgsspatialiteprovidergui.h"
#endif
#ifdef HAVE_POSTGRESQL
#include "qgspostgresprovidergui.h"
#endif
#endif

/**
@@ -94,11 +99,16 @@ void QgsProviderGuiRegistry::loadStaticProviders( )
QgsProviderGuiMetadata *wms = new QgsWmsProviderGuiMetadata();
mProviders[ wms->key() ] = wms;

QgsProviderGuiMetadata *postgres = new QgsPostgresProviderGuiMetadata();
mProviders[ postgres->key() ] = postgres;

QgsProviderGuiMetadata *delimitedtext = new QgsDelimitedTextProviderGuiMetadata();
mProviders[ delimitedtext->key() ] = delimitedtext;
#ifdef HAVE_SPATIALITE
QgsProviderGuiMetadata *spatialite = new QgsSpatiaLiteProviderGuiMetadata();
mProviders[ spatialite->key() ] = spatialite;
#endif
#ifdef HAVE_POSTGRESQL
QgsProviderGuiMetadata *postgres = new QgsPostgresProviderGuiMetadata();
mProviders[ postgres->key() ] = postgres;
#endif
#endif
}

@@ -5,6 +5,11 @@ set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDI
# providers with implemented both static and dynamic building
add_subdirectory(wms)
add_subdirectory(delimitedtext)

if (WITH_SPATIALITE)
add_subdirectory(spatialite)
endif()

if (POSTGRES_FOUND)
add_subdirectory(postgres)
endif()
@@ -22,7 +27,6 @@ if (NOT FORCE_STATIC_LIBS)
endif()

if (WITH_SPATIALITE)
add_subdirectory(spatialite)
add_subdirectory(virtual)
add_subdirectory(wfs)
endif()
@@ -17,56 +17,99 @@ set(SPATIALITE_SRCS
)

if (WITH_GUI)
set(SPATIALITE_SRCS ${SPATIALITE_SRCS}
set(SPATIALITE_GUI_SRCS
qgsspatialiteprovidergui.cpp
qgsspatialitedataitemguiprovider.cpp
qgsspatialitesourceselect.cpp
)

set(SPATIALITE_UIS qgsdbsourceselectbase.ui)
endif()


########################################################
# Build

if (WITH_GUI)
include_directories(SYSTEM
${QSCINTILLA_INCLUDE_DIR}
)
endif()

include_directories(
# Static
add_library(provider_spatialite_a STATIC ${SPATIALITE_SRCS})

${CMAKE_BINARY_DIR}/src/ui
target_include_directories(provider_spatialite_a PUBLIC
${CMAKE_SOURCE_DIR}/src/providers/spatialite
)

add_library (provider_spatialite MODULE ${SPATIALITE_SRCS})

# require c++17
target_compile_features(provider_spatialite PRIVATE cxx_std_17)

target_link_libraries(provider_spatialite
target_link_libraries(provider_spatialite_a
qgis_core
${SPATIALITE_LIBRARY}
)

# require c++17
target_compile_features(provider_spatialite_a PRIVATE cxx_std_17)

target_compile_definitions(provider_spatialite_a PRIVATE "-DQT_NO_FOREACH")

if (WITH_GUI)
target_link_libraries (provider_spatialite
if (WITH_QT6)
QT6_WRAP_UI(SPATIALITE_UIS_H ${SPATIALITE_UIS})
else()
QT5_WRAP_UI(SPATIALITE_UIS_H ${SPATIALITE_UIS})
endif()

add_library(provider_spatialite_gui_a STATIC ${SPATIALITE_GUI_SRCS} ${SPATIALITE_UIS_H})

target_include_directories(provider_spatialite_gui_a PUBLIC
${CMAKE_BINARY_DIR}/src/providers/spatialite
)

target_link_libraries(provider_spatialite_gui_a
qgis_gui
)
add_dependencies(provider_spatialite ui)
endif()

# clang-tidy
if(CLANG_TIDY_EXE)
set_target_properties(
provider_spatialite PROPERTIES
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
# require c++17
target_compile_features(provider_spatialite_gui_a PRIVATE cxx_std_17)

target_compile_definitions(provider_spatialite_gui_a PRIVATE "-DQT_NO_FOREACH")

add_dependencies(provider_spatialite_gui_a ui)

include_directories(SYSTEM
${QSCINTILLA_INCLUDE_DIR}
${CMAKE_BINARY_DIR}/src/ui
)
endif()

########################################################
# Install
if (FORCE_STATIC_LIBS)
# for (external) mobile apps to be able to pick up provider for linking
install (TARGETS provider_spatialite_a ARCHIVE DESTINATION ${QGIS_PLUGIN_DIR})
if (WITH_GUI)
install (TARGETS provider_spatialite_gui_a ARCHIVE DESTINATION ${QGIS_PLUGIN_DIR})
endif()
else()
add_library(provider_spatialite MODULE ${SPATIALITE_SRCS} ${SPATIALITE_GUI_SRCS})

# require c++17
target_compile_features(provider_spatialite PRIVATE cxx_std_17)

target_compile_definitions(provider_spatialite PRIVATE "-DQT_NO_FOREACH")

target_link_libraries(provider_spatialite
qgis_core
${SPATIALITE_LIBRARY}
)

install(TARGETS provider_spatialite
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
if (WITH_GUI)
target_link_libraries (provider_spatialite
qgis_gui
)
add_dependencies(provider_spatialite ui)
endif()

# clang-tidy
if(CLANG_TIDY_EXE)
set_target_properties(
provider_spatialite PROPERTIES
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
)
endif()

install(TARGETS provider_spatialite
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
endif()
@@ -3788,6 +3788,10 @@ QString QgsSpatiaLiteProvider::name() const
return SPATIALITE_KEY;
} // QgsSpatiaLiteProvider::name()

QString QgsSpatiaLiteProvider::providerKey()
{
return SPATIALITE_KEY;
}

QString QgsSpatiaLiteProvider::description() const
{
@@ -6476,8 +6480,9 @@ void QgsSpatiaLiteProviderMetadata::saveConnection( const QgsAbstractProviderCon
}


#ifndef HAVE_STATIC_PROVIDERS
QGISEXTERN QgsProviderMetadata *providerMetadataFactory()
{
return new QgsSpatiaLiteProviderMetadata();
}

#endif
@@ -146,6 +146,8 @@ class QgsSpatiaLiteProvider final: public QgsVectorDataProvider
void invalidateConnections( const QString &connection ) override;
QList<QgsRelation> discoverRelations( const QgsVectorLayer *self, const QList<QgsVectorLayer *> &layers ) const override;

static QString providerKey();

// static functions
static void convertToGeosWKB( const unsigned char *blob, int blob_size,
unsigned char **wkb, int *geom_size );
@@ -38,30 +38,28 @@ class QgsSpatialiteSourceSelectProvider : public QgsSourceSelectProvider
};


class QgsSpatiaLiteProviderGuiMetadata: public QgsProviderGuiMetadata
{
public:
QgsSpatiaLiteProviderGuiMetadata()
: QgsProviderGuiMetadata( QgsSpatiaLiteProvider::SPATIALITE_KEY )
{
}

QList<QgsSourceSelectProvider *> sourceSelectProviders() override
{
QList<QgsSourceSelectProvider *> providers;
providers << new QgsSpatialiteSourceSelectProvider;
return providers;
}
QgsSpatiaLiteProviderGuiMetadata::QgsSpatiaLiteProviderGuiMetadata()
: QgsProviderGuiMetadata( QgsSpatiaLiteProvider::SPATIALITE_KEY )
{
}

QList<QgsDataItemGuiProvider *> dataItemGuiProviders() override
{
return QList<QgsDataItemGuiProvider *>()
<< new QgsSpatiaLiteDataItemGuiProvider;
}
};
QList<QgsSourceSelectProvider *> QgsSpatiaLiteProviderGuiMetadata::sourceSelectProviders() override
{
QList<QgsSourceSelectProvider *> providers;
providers << new QgsSpatialiteSourceSelectProvider;
return providers;
}

QList<QgsDataItemGuiProvider *> QgsSpatiaLiteProviderGuiMetadata::dataItemGuiProviders() override
{
return QList<QgsDataItemGuiProvider *>()
<< new QgsSpatiaLiteDataItemGuiProvider;
}

#ifndef HAVE_STATIC_PROVIDERS
QGISEXTERN QgsProviderGuiMetadata *providerGuiMetadataFactory()
{
return new QgsSpatiaLiteProviderGuiMetadata();
}
#endif
@@ -0,0 +1,31 @@
/***************************************************************************
qgsspatialiteprovidergui.cpp
--------------------------------------
Date : June 2019
Copyright : (C) 2019 by Martin Dobias
Email : wonder dot sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgsproviderguimetadata.h"
#include "qgssourceselectprovider.h"

#include "qgsspatialitesourceselect.h"
#include "qgsspatialiteprovider.h"


class QgsSpatiaLiteProviderGuiMetadata: public QgsProviderGuiMetadata
{
public:
QgsSpatiaLiteProviderGuiMetadata();

QList<QgsSourceSelectProvider *> sourceSelectProviders() override;
QList<QgsDataItemGuiProvider *> dataItemGuiProviders() override;
};

0 comments on commit 7240356

Please sign in to comment.