Skip to content
Permalink
Browse files
[delimited text] Unlock static build support
  • Loading branch information
nirvn committed Oct 30, 2021
1 parent c94c741 commit 4e504615f9d1fe8766db26d0b2fec1e269a10265
@@ -2134,6 +2134,7 @@ if (FORCE_STATIC_LIBS)
target_link_libraries(qgis_core
provider_wms_a
provider_postgres_a
provider_delimitedtext_a
)

if (WITH_AUTH)
@@ -45,6 +45,7 @@
#ifdef HAVE_STATIC_PROVIDERS
#include "qgswmsprovider.h"
#include "qgspostgresprovider.h"
#include "qgsdelimitedtextprovider.h"
#endif

#include <QString>
@@ -191,6 +192,7 @@ void QgsProviderRegistry::init()
#ifdef HAVE_STATIC_PROVIDERS
mProviders[ QgsWmsProvider::providerKey() ] = new QgsWmsProviderMetadata();
mProviders[ QgsPostgresProvider::providerKey() ] = new QgsPostgresProviderMetadata();
mProviders[ QgsDelimitedTextProvider::providerKey() ] = new QgsDelimitedTextProviderMetadata();
#endif

// add dynamic providers
@@ -1545,6 +1545,7 @@ if (FORCE_STATIC_LIBS)
target_link_libraries(qgis_gui
provider_wms_gui_a
provider_postgres_gui_a
provider_delimitedtext_gui_a
)
endif()

@@ -36,6 +36,7 @@
#ifdef HAVE_STATIC_PROVIDERS
#include "qgswmsprovidergui.h"
#include "qgspostgresprovidergui.h"
#include "qgsdelimitedtextprovidergui.h"
#endif

/**
@@ -95,6 +96,9 @@ void QgsProviderGuiRegistry::loadStaticProviders( )

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

QgsProviderGuiMetadata *delimitedtext = new QgsDelimitedTextProviderGuiMetadata();
mProviders[ delimitedtext->key() ] = delimitedtext;
#endif
}

@@ -4,13 +4,13 @@ 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 (POSTGRES_FOUND)
add_subdirectory(postgres)
endif()

if (NOT FORCE_STATIC_LIBS)
add_subdirectory(arcgisrest)
add_subdirectory(delimitedtext)
add_subdirectory(geonode)
add_subdirectory(mssql)
add_subdirectory(wcs)
@@ -1,57 +1,97 @@

########################################################
# Files

set (DTEXT_SRCS
qgsdelimitedtextfeatureiterator.cpp
qgsdelimitedtextprovider.cpp
qgsdelimitedtextfile.cpp
)

if (WITH_GUI)
set(DTEXT_SRCS ${DTEXT_SRCS}
set(DTEXT_GUI_SRCS
qgsdelimitedtextprovidergui.cpp
qgsdelimitedtextsourceselect.cpp
)
endif()

########################################################
# Build
set(DTEXT_UIS qgsdelimitedtextsourceselectbase.ui)
endif()

include_directories(
# static library
add_library(provider_delimitedtext_a STATIC ${DTEXT_SRCS})

${CMAKE_BINARY_DIR}/src/ui
target_include_directories(provider_delimitedtext_a PUBLIC
${CMAKE_SOURCE_DIR}/src/providers/delimitedtext
)

add_library(provider_delimitedtext MODULE ${DTEXT_SRCS})
target_link_libraries(provider_delimitedtext_a
qgis_core
)

# require c++17
target_compile_features(provider_delimitedtext PRIVATE cxx_std_17)
target_compile_features(provider_delimitedtext_a PRIVATE cxx_std_17)

target_link_libraries(provider_delimitedtext
qgis_core
)
target_compile_definitions(provider_delimitedtext_a PRIVATE "-DQT_NO_FOREACH")

if (WITH_GUI)
target_link_libraries (provider_delimitedtext
if (WITH_QT6)
QT6_WRAP_UI(DTEXT_UIS_H ${DTEXT_UIS})
else()
QT5_WRAP_UI(DTEXT_UIS_H ${DTEXT_UIS})
endif()

add_library(provider_delimitedtext_gui_a STATIC ${DTEXT_GUI_SRCS} ${DTEXT_UIS_H})

target_include_directories(provider_delimitedtext_gui_a PUBLIC
${CMAKE_BINARY_DIR}/src/providers/delimitedtext
)

target_link_libraries(provider_delimitedtext_gui_a
qgis_gui
)
add_dependencies(provider_delimitedtext ui)
endif()

target_compile_definitions(provider_delimitedtext PRIVATE "-DQT_NO_FOREACH")
# require c++17
target_compile_features(provider_delimitedtext_gui_a PRIVATE cxx_std_17)

# clang-tidy
if(CLANG_TIDY_EXE)
set_target_properties(
provider_delimitedtext PROPERTIES
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
)
target_compile_definitions(provider_delimitedtext_gui_a PRIVATE "-DQT_NO_FOREACH")

add_dependencies(provider_delimitedtext_gui_a ui)
endif()

########################################################
# Install
if (FORCE_STATIC_LIBS)
# for (external) mobile apps to be able to pick up provider for linking
install (TARGETS provider_delimitedtext_a ARCHIVE DESTINATION ${QGIS_PLUGIN_DIR})
if (WITH_GUI)
install (TARGETS provider_delimitedtext_a ARCHIVE DESTINATION ${QGIS_PLUGIN_DIR})
endif()
else()
add_library(provider_delimitedtext MODULE ${DTEXT_SRCS} ${DTEXT_GUI_SRCS})

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

target_link_libraries(provider_delimitedtext
qgis_core
)

if (WITH_GUI)
target_link_libraries (provider_delimitedtext
qgis_gui
)
add_dependencies(provider_delimitedtext ui)
endif()

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

install (TARGETS provider_delimitedtext
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
install (TARGETS provider_delimitedtext
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})

target_compile_definitions(provider_delimitedtext PRIVATE "-DQT_NO_FOREACH")
endif()
@@ -1257,6 +1257,11 @@ QString QgsDelimitedTextProvider::name() const
return TEXT_PROVIDER_KEY;
}

QString QgsDelimitedTextProvider::providerKey()
{
return TEXT_PROVIDER_KEY;
}

QString QgsDelimitedTextProvider::description() const
{
return TEXT_PROVIDER_DESCRIPTION;
@@ -1330,7 +1335,9 @@ QgsDelimitedTextProviderMetadata::QgsDelimitedTextProviderMetadata():
{
}

#ifndef HAVE_STATIC_PROVIDERS
QGISEXTERN QgsProviderMetadata *providerMetadataFactory()
{
return new QgsDelimitedTextProviderMetadata();
}
#endif
@@ -135,6 +135,8 @@ class QgsDelimitedTextProvider final: public QgsVectorDataProvider
*/
QStringList readCsvtFieldTypes( const QString &filename, QString *message = nullptr );

static QString providerKey();

private slots:

void onFileUpdated();
@@ -13,6 +13,8 @@
* *
***************************************************************************/

#include "qgsdelimitedtextprovidergui.h"

#include "qgsapplication.h"
#include "qgsproviderguimetadata.h"
#include "qgssourceselectprovider.h"
@@ -36,24 +38,21 @@ class QgsDelimitedTextSourceSelectProvider : public QgsSourceSelectProvider
};


class QgsDelimitedTextProviderGuiMetadata: public QgsProviderGuiMetadata
QgsDelimitedTextProviderGuiMetadata::QgsDelimitedTextProviderGuiMetadata()
: QgsProviderGuiMetadata( QgsDelimitedTextProvider::TEXT_PROVIDER_KEY )
{
public:
QgsDelimitedTextProviderGuiMetadata()
: QgsProviderGuiMetadata( QgsDelimitedTextProvider::TEXT_PROVIDER_KEY )
{
}

QList<QgsSourceSelectProvider *> sourceSelectProviders() override
{
QList<QgsSourceSelectProvider *> providers;
providers << new QgsDelimitedTextSourceSelectProvider;
return providers;
}
};
}

QList<QgsSourceSelectProvider *> QgsDelimitedTextProviderGuiMetadata::sourceSelectProviders()
{
QList<QgsSourceSelectProvider *> providers;
providers << new QgsDelimitedTextSourceSelectProvider;
return providers;
}

#ifndef HAVE_STATIC_PROVIDERS
QGISEXTERN QgsProviderGuiMetadata *providerGuiMetadataFactory()
{
return new QgsDelimitedTextProviderGuiMetadata();
}
#endif
@@ -0,0 +1,26 @@
/***************************************************************************
qgsdelimitedtextprovidergui.h
--------------------------------------
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 "qgsdelimitedtextsourceselect.h"

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

QList<QgsSourceSelectProvider *> sourceSelectProviders() override;
};
@@ -25,6 +25,7 @@
#include "qgspostgresdataitemguiprovider.h"
#include "raster/qgspostgresrastertemporalsettingswidget.h"


//! Provider for postgres source select
class QgsPostgresSourceSelectProvider : public QgsSourceSelectProvider //#spellok
{

0 comments on commit 4e50461

Please sign in to comment.