Skip to content
Permalink
Browse files
[virtual] Unlock static build support
  • Loading branch information
nirvn committed Oct 31, 2021
1 parent f3f7616 commit 6b2caab59c9639733b6079124f265e081c2e68d4
@@ -2139,6 +2139,7 @@ if (FORCE_STATIC_LIBS)
target_link_libraries(qgis_core
provider_spatialite_a
provider_wfs_a
provider_virtuallayer_a
)
endif()
if (HAVE_POSTGRESQL)
@@ -49,6 +49,7 @@
#include "qgsspatialiteprovider.h"
#include "qgswfsprovider.h"
#include "qgsoapifprovider.h"
#include "qgsvirtuallayerprovider.h"
#endif
#ifdef HAVE_POSTGRESQL
#include "qgspostgresprovider.h"
@@ -203,6 +204,7 @@ void QgsProviderRegistry::init()
mProviders[ QgsSpatiaLiteProvider::providerKey() ] = new QgsSpatiaLiteProviderMetadata();
mProviders[ QgsWFSProvider::providerKey() ] = new QgsWfsProviderMetadata();
mProviders[ QgsOapifProvider::providerKey() ] = new QgsOapifProviderMetadata();
mProviders[ QgsVirtualLayerProvider::providerKey() ] = new QgsVirtualLayerProviderMetadata();
#endif
#ifdef HAVE_POSTGRESQL
mProviders[ QgsPostgresProvider::providerKey() ] = new QgsPostgresProviderMetadata();
@@ -1550,6 +1550,7 @@ if (FORCE_STATIC_LIBS)
target_link_libraries(qgis_gui
provider_spatialite_gui_a
provider_wfs_gui_a
provider_virtuallayer_gui_a
)
endif()
if (HAVE_POSTGRESQL)
@@ -39,6 +39,7 @@
#ifdef HAVE_SPATIALITE
#include "qgsspatialiteprovidergui.h"
#include "qgswfsprovidergui.h"
#include "qgsvirtuallayerprovidergui.h"
#endif
#ifdef HAVE_POSTGRESQL
#include "qgspostgresprovidergui.h"
@@ -107,6 +108,8 @@ void QgsProviderGuiRegistry::loadStaticProviders( )
mProviders[ spatialite->key() ] = spatialite;
QgsProviderGuiMetadata *wfs = new QgsWfsProviderGuiMetadata();
mProviders[ wfs->key() ] = wfs;
QgsProviderGuiMetadata *virtuallayer = new QgsVirtualLayerProviderGuiMetadata();
mProviders[ virtuallayer->key() ] = virtuallayer;
#endif
#ifdef HAVE_POSTGRESQL
QgsProviderGuiMetadata *postgres = new QgsPostgresProviderGuiMetadata();
@@ -9,6 +9,7 @@ add_subdirectory(delimitedtext)
if (WITH_SPATIALITE)
add_subdirectory(spatialite)
add_subdirectory(wfs)
add_subdirectory(virtual)
endif()

if (POSTGRES_FOUND)
@@ -27,10 +28,6 @@ if (NOT FORCE_STATIC_LIBS)
add_subdirectory(virtualraster)
endif()

if (WITH_SPATIALITE)
add_subdirectory(virtual)
endif()

if (WITH_ORACLE)
add_subdirectory(oracle)
endif()
@@ -2,79 +2,117 @@
########################################################
# Files

set (QGIS_VLAYER_SQL_FUNCTIONS_RCCS sqlfunctionslist.qrc)
set (VLAYER_SQL_FUNCTIONS_RCCS sqlfunctionslist.qrc)

set(QGIS_VLAYER_PROVIDER_HDRS
qgsvirtuallayerprovider.h
qgsslottofunction.h
)

set(QGIS_VLAYER_PROVIDER_SRCS
set(VLAYER_PROVIDER_SRCS
qgsvirtuallayerprovider.cpp
qgsvirtuallayerfeatureiterator.cpp
qgsvirtuallayerblob.cpp
qgsvirtuallayersqlitemodule.cpp
qgsvirtuallayersqlitehelper.cpp
qgsvirtuallayerqueryparser.cpp
)
set(VLAYER_PROVIDER_HDRS
qgsvirtuallayerprovider.h
qgsslottofunction.h
)

if (WITH_GUI)
set(QGIS_VLAYER_PROVIDER_SRCS ${QGIS_VLAYER_PROVIDER_SRCS}
set(VLAYER_PROVIDER_GUI_SRCS
qgsvirtuallayerprovidergui.cpp
qgsvirtuallayersourceselect.cpp
qgsembeddedlayerselectdialog.cpp
)
set(QGIS_VLAYER_PROVIDER_HDRS ${QGIS_VLAYER_PROVIDER_HDRS}
set(VLAYER_PROVIDER_GUI_HDRS
qgsvirtuallayerprovidergui.h
qgsvirtuallayersourceselect.h
qgsembeddedlayerselectdialog.h
)
endif()

if (WITH_GUI)
if (WITH_QT6)
QT6_WRAP_UI(vlayer_provider_UI_H qgsvirtuallayersourceselectbase.ui qgsembeddedlayerselect.ui)
else()
QT5_WRAP_UI(vlayer_provider_UI_H qgsvirtuallayersourceselectbase.ui qgsembeddedlayerselect.ui)
endif()
endif()

include_directories(

${CMAKE_BINARY_DIR}/src/ui

${CMAKE_CURRENT_BINARY_DIR} # ui_xxx_dlg.h
)

include_directories(SYSTEM
${POSTGRES_INCLUDE_DIR}
)
########################################################
# Static
add_library(provider_virtuallayer_a STATIC ${VLAYER_PROVIDER_SRCS} ${VLAYER_PROVIDER_HDRS} ${VLAYER_SQL_FUNCTIONS_RCCS})

add_library(provider_virtuallayer MODULE
${QGIS_VLAYER_PROVIDER_SRCS}
${QGIS_VLAYER_PROVIDER_HDRS}
${vlayer_provider_UI_H}
${QGIS_VLAYER_SQL_FUNCTIONS_RCCS}
target_include_directories(provider_virtuallayer_a PUBLIC
${CMAKE_SOURCE_DIR}/src/providers/virtual
)

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

target_link_libraries(provider_virtuallayer
target_link_libraries(provider_virtuallayer_a
qgis_core
${QT_VERSION_BASE}::Core
${QT_VERSION_BASE}::Gui
${QT_VERSION_BASE}::Widgets
${SQLITE3_LIBRARY}
${SPATIALITE_LIBRARY}
)

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

target_compile_definitions(provider_virtuallayer_a PRIVATE "-DQT_NO_FOREACH")

if (WITH_GUI)
target_link_libraries (provider_virtuallayer
if (WITH_QT6)
QT6_WRAP_UI(VLAYER_PROVIDER_UIS_H qgsvirtuallayersourceselectbase.ui qgsembeddedlayerselect.ui)
else()
QT5_WRAP_UI(VLAYER_PROVIDER_UIS_H qgsvirtuallayersourceselectbase.ui qgsembeddedlayerselect.ui)
endif()
add_library(provider_virtuallayer_gui_a STATIC ${VLAYER_PROVIDER_GUI_SRCS} ${VLAYER_PROVIDER_GUI_HDRS} ${VLAYER_PROVIDER_UIS_H})

target_include_directories(provider_virtuallayer_gui_a PUBLIC
${CMAKE_BINARY_DIR}/src/providers/virtual
)

target_link_libraries(provider_virtuallayer_gui_a
qgis_gui
)
add_dependencies(provider_virtuallayer ui)

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

target_compile_definitions(provider_virtuallayer_gui_a PRIVATE "-DQT_NO_FOREACH")

add_dependencies(provider_virtuallayer_gui_a ui)

include_directories(
${CMAKE_BINARY_DIR}/src/ui
${CMAKE_CURRENT_BINARY_DIR} # ui_xxx_dlg.h
)
endif()

install(TARGETS provider_virtuallayer
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR}

if (FORCE_STATIC_LIBS)
# for (external) mobile apps to be able to pick up provider for linking
install (TARGETS provider_virtuallayer_a ARCHIVE DESTINATION ${QGIS_PLUGIN_DIR})
if (WITH_GUI)
install (TARGETS provider_virtuallayer_gui_a ARCHIVE DESTINATION ${QGIS_PLUGIN_DIR})
endif()
else()
add_library(provider_virtuallayer MODULE ${VLAYER_PROVIDER_SRCS} ${VLAYER_PROVIDER_HDRS} ${VLAYER_PROVIDER_UIS_H} ${VLAYER_SQL_FUNCTIONS_RCCS})

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

target_compile_definitions(provider_virtuallayer PRIVATE "-DQT_NO_FOREACH")

target_link_libraries(provider_virtuallayer
qgis_core
${QT_VERSION_BASE}::Core
${QT_VERSION_BASE}::Widgets
${SQLITE3_LIBRARY}
${SPATIALITE_LIBRARY}
)

if (WITH_GUI)
target_link_libraries (provider_virtuallayer
qgis_gui
${QT_VERSION_BASE}::Gui
)
add_dependencies(provider_virtuallayer ui)
endif()

install(TARGETS provider_virtuallayer
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR}
)
endif()
@@ -36,11 +36,6 @@ extern "C"
#include "qgsvirtuallayersqlitemodule.h"
#include "qgsvirtuallayerqueryparser.h"

#ifdef HAVE_GUI
#include "qgssourceselectprovider.h"
#include "qgsvirtuallayersourceselect.h"
#endif

const QString VIRTUAL_LAYER_KEY = QStringLiteral( "virtual" );
const QString VIRTUAL_LAYER_DESCRIPTION = QStringLiteral( "Virtual layer data provider" );

@@ -629,6 +624,11 @@ QString QgsVirtualLayerProvider::name() const
return VIRTUAL_LAYER_KEY;
}

QString QgsVirtualLayerProvider::providerKey()
{
return VIRTUAL_LAYER_KEY;
}

QString QgsVirtualLayerProvider::description() const
{
return VIRTUAL_LAYER_DESCRIPTION;
@@ -672,53 +672,15 @@ QgsVirtualLayerProvider *QgsVirtualLayerProviderMetadata::createProvider(
return new QgsVirtualLayerProvider( uri, options, flags );
}


#ifdef HAVE_GUI

//! Provider for virtual layers source select
class QgsVirtualSourceSelectProvider : public QgsSourceSelectProvider
{
public:

QString providerKey() const override { return QStringLiteral( "virtual" ); }
QString text() const override { return QObject::tr( "Virtual Layer" ); }
int ordering() const override { return QgsSourceSelectProvider::OrderDatabaseProvider + 60; }
QString toolTip() const override { return QObject::tr( "Add Virtual Layer" ); }
QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddVirtualLayer.svg" ) ); }
QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
return new QgsVirtualLayerSourceSelect( parent, fl, widgetMode );
}
};


QgsVirtualLayerProviderGuiMetadata::QgsVirtualLayerProviderGuiMetadata()
: QgsProviderGuiMetadata( VIRTUAL_LAYER_KEY )
{
}

QList<QgsSourceSelectProvider *> QgsVirtualLayerProviderGuiMetadata::sourceSelectProviders()
{
QList<QgsSourceSelectProvider *> providers;
providers << new QgsVirtualSourceSelectProvider;
return providers;
}
#endif

QgsVirtualLayerProviderMetadata::QgsVirtualLayerProviderMetadata():
QgsProviderMetadata( VIRTUAL_LAYER_KEY, VIRTUAL_LAYER_DESCRIPTION )
{
}


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

#ifdef HAVE_GUI
QGISEXTERN QgsProviderGuiMetadata *providerGuiMetadataFactory()
{
return new QgsVirtualLayerProviderGuiMetadata();
}
#endif
@@ -1,5 +1,5 @@
/***************************************************************************
qgsvirtuallayerprovider.cpp Virtual layer data provider
qgsvirtuallayerprovider.h Virtual layer data provider
begin : Jan, 2015
copyright : (C) 2015 Hugo Mercier, Oslandia
email : hugo dot mercier at oslandia dot com
@@ -25,9 +25,6 @@ email : hugo dot mercier at oslandia dot com
#include "qgsvirtuallayersqlitehelper.h"

#include "qgsprovidermetadata.h"
#ifdef HAVE_GUI
#include "qgsproviderguimetadata.h"
#endif

class QgsVirtualLayerFeatureIterator;

@@ -62,6 +59,8 @@ class QgsVirtualLayerProvider final: public QgsVectorDataProvider
QSet<QgsMapLayerDependency> dependencies() const override;
bool cancelReload() override;

static QString providerKey();

private:

// file on disk
@@ -137,15 +136,6 @@ class QgsVirtualLayerProviderMetadata final: public QgsProviderMetadata
QgsVirtualLayerProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() ) override;
};

#ifdef HAVE_GUI
class QgsVirtualLayerProviderGuiMetadata final: public QgsProviderGuiMetadata
{
public:
QgsVirtualLayerProviderGuiMetadata();
QList<QgsSourceSelectProvider *> sourceSelectProviders() override;
};
#endif

// clazy:excludeall=qstring-allocations

#endif
Loading

0 comments on commit 6b2caab

Please sign in to comment.