Navigation Menu

Skip to content

Commit

Permalink
enable static build of all auth methods
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jun 23, 2021
1 parent a42df3b commit 019976e
Show file tree
Hide file tree
Showing 27 changed files with 332 additions and 392 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Expand Up @@ -138,6 +138,11 @@ if(WITH_CORE)

set (WITH_GUI TRUE CACHE BOOL "Determines whether QGIS GUI library (and everything built on top of it) should be built")

set (WITH_OAUTH2_PLUGIN TRUE CACHE BOOL "Build OAuth2 authentication method plugin")
if(WITH_OAUTH2_PLUGIN)
set(HAVE_OAUTH2_PLUGIN TRUE)
endif()

set (WITH_AUTH TRUE CACHE BOOL "Determines whether QGIS authentication methods should be built")

set (WITH_ANALYSIS TRUE CACHE BOOL "Determines whether QGIS analysis library should be built")
Expand Down
2 changes: 2 additions & 0 deletions cmake_templates/qgsconfig.h.in
Expand Up @@ -69,6 +69,8 @@

#cmakedefine HAVE_SERVER_PYTHON_PLUGINS

#cmakedefine HAVE_OAUTH2_PLUGIN

#cmakedefine HAVE_OPENCL
#cmakedefine OPENCL_USE_NEW_HEADER

Expand Down
1 change: 0 additions & 1 deletion src/auth/CMakeLists.txt
Expand Up @@ -18,7 +18,6 @@ add_subdirectory(identcert)
add_subdirectory(pkipaths)
add_subdirectory(pkipkcs12)

set(WITH_OAUTH2_PLUGIN TRUE CACHE BOOL "Build OAuth2 authentication method plugin")
if (WITH_OAUTH2_PLUGIN)
add_subdirectory(oauth2)
endif()
54 changes: 38 additions & 16 deletions src/auth/basic/CMakeLists.txt
Expand Up @@ -10,7 +10,6 @@ set(AUTH_BASIC_UIS_H "")

if (WITH_GUI)
set(AUTH_BASIC_SRCS ${AUTH_BASIC_SRCS}
gui/qgsauthbasicmethodgui.cpp
gui/qgsauthbasicedit.cpp
)
set(AUTH_BASIC_HDRS ${AUTH_BASIC_HDRS}
Expand All @@ -20,28 +19,51 @@ if (WITH_GUI)
QT5_WRAP_UI(AUTH_BASIC_UIS_H ${AUTH_BASIC_UIS})
endif()

add_library(authmethod_basic MODULE ${AUTH_BASIC_SRCS} ${AUTH_BASIC_HDRS} ${AUTH_BASIC_UIS_H})

target_include_directories(authmethod_basic PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/core
)
# static library
add_library(authmethod_basic_a STATIC ${AUTH_BASIC_SRCS} ${AUTH_BASIC_HDRS} ${AUTH_BASIC_UIS_H})

target_include_directories(authmethod_basic_a PUBLIC ${CMAKE_SOURCE_DIR}/src/auth/basic/core)

# require c++17
target_compile_features(authmethod_basic PRIVATE cxx_std_17)
target_compile_features(authmethod_basic_a PRIVATE cxx_std_17)

target_link_libraries(authmethod_basic qgis_core)
target_link_libraries(authmethod_basic_a qgis_core)

if (WITH_GUI)
target_include_directories(authmethod_basic PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/gui
${CMAKE_CURRENT_BINARY_DIR}
target_include_directories(authmethod_basic_a PRIVATE
${CMAKE_SOURCE_DIR}/src/auth/basic/gui
${CMAKE_BINARY_DIR}/src/auth/basic
)
target_link_libraries(authmethod_basic qgis_gui)

target_link_libraries (authmethod_basic_a qgis_gui)
endif()

target_compile_definitions(authmethod_basic PRIVATE "-DQT_NO_FOREACH")
target_compile_definitions(authmethod_basic_a PRIVATE "-DQT_NO_FOREACH")

install(TARGETS authmethod_basic
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 authmethod_basic_a ARCHIVE DESTINATION ${QGIS_PLUGIN_DIR})
else()
# dynamically loaded module
add_library(authmethod_basic MODULE ${AUTH_BASIC_SRCS} ${AUTH_BASIC_HDRS} ${AUTH_BASIC_UIS_H})

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

target_link_libraries(authmethod_basic qgis_core)

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

target_compile_definitions(authmethod_basic PRIVATE "-DQT_NO_FOREACH")

install (TARGETS authmethod_basic
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR}
)
endif()
60 changes: 19 additions & 41 deletions src/auth/basic/core/qgsauthbasicmethod.cpp
Expand Up @@ -20,12 +20,16 @@
#include "qgslogger.h"
#include "qgsapplication.h"

#ifdef HAVE_GUI
#include "qgsauthbasicedit.h"
#endif

#include <QNetworkProxy>
#include <QMutexLocker>
#include <QUuid>

static const QString AUTH_METHOD_KEY = QStringLiteral( "Basic" );
static const QString AUTH_METHOD_DESCRIPTION = QStringLiteral( "Basic authentication" );
const QString QgsAuthBasicMethod::AUTH_METHOD_KEY = QStringLiteral( "Basic" );
const QString QgsAuthBasicMethod::AUTH_METHOD_DESCRIPTION = tr( "Basic authentication" );

QMap<QString, QgsAuthMethodConfig> QgsAuthBasicMethod::sAuthConfigCache = QMap<QString, QgsAuthMethodConfig>();

Expand All @@ -48,20 +52,16 @@ QgsAuthBasicMethod::QgsAuthBasicMethod()

}

QString QgsAuthBasicMethod::key() const
QString QgsAuthBasicMethod::key()
{
return AUTH_METHOD_KEY;
}

QString QgsAuthBasicMethod::description() const
QString QgsAuthBasicMethod::description()
{
return AUTH_METHOD_DESCRIPTION;
}

QString QgsAuthBasicMethod::displayDescription() const
{
return tr( "Basic authentication" );
}

bool QgsAuthBasicMethod::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg,
const QString &dataprovider )
Expand Down Expand Up @@ -313,6 +313,13 @@ void QgsAuthBasicMethod::updateMethodConfig( QgsAuthMethodConfig &mconfig )
// TODO: add updates as method version() increases due to config storage changes
}

#ifdef HAVE_GUI
QWidget *QgsAuthBasicMethod::editWidget( QWidget *parent ) const
{
return new QgsAuthBasicEdit( parent );
}
#endif

void QgsAuthBasicMethod::clearCachedConfig( const QString &authcfg )
{
removeMethodConfig( authcfg );
Expand Down Expand Up @@ -375,42 +382,13 @@ QString QgsAuthBasicMethod::escapeUserPass( const QString &val, QChar delim ) co
// Plugin externals
//////////////////////////////////////////////

/**
* Required class factory to return a pointer to a newly created object
*/
QGISEXTERN QgsAuthBasicMethod *classFactory()
{
return new QgsAuthBasicMethod();
}

/**
* Required key function (used to map the plugin to a data store type)
*/
QGISEXTERN QString authMethodKey()
#ifndef HAVE_STATIC_PROVIDERS
QGISEXTERN QgsAuthMethodMetadata *authMethodMetadataFactory()
{
return AUTH_METHOD_KEY;
return new QgsAuthBasicMethodMetadata();
}
#endif

/**
* Required description function
*/
QGISEXTERN QString description()
{
return AUTH_METHOD_DESCRIPTION;
}

/**
* Required isAuthMethod function. Used to determine if this shared library
* is an authentication method plugin
*/
QGISEXTERN bool isAuthMethod()
{
return true;
}

/**
* Required cleanup function
*/
QGISEXTERN void cleanupAuthMethod() // pass QgsAuthMethod *method, then delete method ?
{
}
28 changes: 24 additions & 4 deletions src/auth/basic/core/qgsauthbasicmethod.h
Expand Up @@ -22,21 +22,25 @@

#include "qgsauthconfig.h"
#include "qgsauthmethod.h"
#include "qgsauthmethodmetadata.h"

class QWidget;

class QgsAuthBasicMethod : public QgsAuthMethod
{
Q_OBJECT

public:

static const QString AUTH_METHOD_KEY;
static const QString AUTH_METHOD_DESCRIPTION;

explicit QgsAuthBasicMethod();

// QgsAuthMethod interface
QString key() const override;

QString description() const override;
static QString key();

QString displayDescription() const override;
static QString description();

bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg,
const QString &dataprovider = QString() ) override;
Expand All @@ -52,6 +56,10 @@ class QgsAuthBasicMethod : public QgsAuthMethod

void updateMethodConfig( QgsAuthMethodConfig &mconfig ) override;

#ifdef HAVE_GUI
QWidget *editWidget( QWidget *parent )const override;
#endif

private:
QgsAuthMethodConfig getMethodConfig( const QString &authcfg, bool fullconfig = true );

Expand All @@ -62,7 +70,19 @@ class QgsAuthBasicMethod : public QgsAuthMethod
QString escapeUserPass( const QString &val, QChar delim = '\'' ) const;

static QMap<QString, QgsAuthMethodConfig> sAuthConfigCache;
};

class QgsAuthBasicMethodMetadata : public QgsAuthMethodMetadata
{
public:
QgsAuthBasicMethodMetadata()
: QgsAuthMethodMetadata( QgsAuthBasicMethod::AUTH_METHOD_KEY, QgsAuthBasicMethod::AUTH_METHOD_DESCRIPTION )
{}
QgsAuthBasicMethod *createAuthMethod() const override {return new QgsAuthBasicMethod;}
//QStringList supportedDataProviders() const override;
};




#endif // QGSAUTHBASICMETHOD_H
25 changes: 0 additions & 25 deletions src/auth/basic/gui/qgsauthbasicmethodgui.cpp

This file was deleted.

52 changes: 36 additions & 16 deletions src/auth/esritoken/CMakeLists.txt
Expand Up @@ -10,7 +10,6 @@ set(AUTH_ESRITOKEN_UIS_H "")

if (WITH_GUI)
set(AUTH_ESRITOKEN_SRCS ${AUTH_ESRITOKEN_SRCS}
gui/qgsauthesritokenmethodgui.cpp
gui/qgsauthesritokenedit.cpp
)
set(AUTH_ESRITOKEN_HDRS ${AUTH_ESRITOKEN_HDRS}
Expand All @@ -20,28 +19,49 @@ if (WITH_GUI)
QT5_WRAP_UI(AUTH_ESRITOKEN_UIS_H ${AUTH_ESRITOKEN_UIS})
endif()

add_library(authmethod_esritoken MODULE ${AUTH_ESRITOKEN_SRCS} ${AUTH_ESRITOKEN_HDRS} ${AUTH_ESRITOKEN_UIS_H})

target_include_directories(authmethod_esritoken PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/core
)
# static library
add_library(authmethod_esritoken_a STATIC ${AUTH_ESRITOKEN_SRCS} ${AUTH_ESRITOKEN_HDRS} ${AUTH_ESRITOKEN_UIS_H})

target_include_directories(authmethod_esritoken_a PUBLIC ${CMAKE_SOURCE_DIR}/src/auth/esritoken/core)

# require c++17
target_compile_features(authmethod_esritoken PRIVATE cxx_std_17)
target_compile_features(authmethod_esritoken_a PRIVATE cxx_std_17)

target_link_libraries(authmethod_esritoken qgis_core)
target_link_libraries(authmethod_esritoken_a qgis_core)

if (WITH_GUI)
target_include_directories(authmethod_esritoken PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/gui
${CMAKE_CURRENT_BINARY_DIR}
target_include_directories(authmethod_esritoken_a PRIVATE
${CMAKE_SOURCE_DIR}/src/auth/esritoken/gui
${CMAKE_BINARY_DIR}/src/auth/esritoken
)
target_link_libraries(authmethod_esritoken qgis_gui)

target_link_libraries (authmethod_esritoken_a qgis_gui)
endif()

target_compile_definitions(authmethod_esritoken PRIVATE "-DQT_NO_FOREACH")
target_compile_definitions(authmethod_esritoken_a PRIVATE "-DQT_NO_FOREACH")

install(TARGETS authmethod_esritoken
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 authmethod_esritoken_a ARCHIVE DESTINATION ${QGIS_PLUGIN_DIR})
else()
# dynamically loaded module
add_library(authmethod_esritoken MODULE ${AUTH_ESRITOKEN_SRCS} ${AUTH_ESRITOKEN_HDRS} ${AUTH_ESRITOKEN_UIS_H})

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

target_link_libraries(authmethod_esritoken qgis_core)

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

target_compile_definitions(authmethod_esritoken PRIVATE "-DQT_NO_FOREACH")

install (TARGETS authmethod_esritoken
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR}
)
endif()

0 comments on commit 019976e

Please sign in to comment.