Skip to content
Permalink
Browse files

Make it possible to build just core lib and providers: -DWITH_GUI=FALSE

This is useful in some cases when working on a third party app/script
that only uses qgis_core. For example, I am working on qgis 3D project
and it is useful to be able to build QGIS core lib with custom Qt version
without having to spend too much time building what I do not need.
Also may be useful for QField to simplify the build of QGIS as a dependency
(no QScintilla, Qwt) and avoid bits of code in providers that would not
be used anyway.

No real source code changes, just configuration changes, mainly in providers.
  • Loading branch information
wonder-sk committed Jul 7, 2017
1 parent eb8f91a commit a8cceff0fcbdda441d6793fcf13382a8a93c1b56
Showing with 838 additions and 296 deletions.
  1. +23 −5 CMakeLists.txt
  2. +2 −0 cmake_templates/qgsconfig.h.in
  3. +47 −28 python/CMakeLists.txt
  4. +5 −3 src/CMakeLists.txt
  5. +36 −7 src/providers/arcgisrest/CMakeLists.txt
  6. +8 −1 src/providers/arcgisrest/qgsafsdataitems.cpp
  7. +8 −0 src/providers/arcgisrest/qgsafsdataitems.h
  8. +6 −1 src/providers/arcgisrest/qgsafsproviderextern.cpp
  9. +9 −2 src/providers/arcgisrest/qgsamsdataitems.cpp
  10. +8 −0 src/providers/arcgisrest/qgsamsdataitems.h
  11. +6 −1 src/providers/arcgisrest/qgsamsproviderextern.cpp
  12. +22 −6 src/providers/db2/CMakeLists.txt
  13. +9 −1 src/providers/db2/qgsdb2dataitems.cpp
  14. +11 −1 src/providers/db2/qgsdb2dataitems.h
  15. +0 −1 src/providers/db2/qgsdb2geometrycolumns.cpp
  16. +6 −0 src/providers/db2/qgsdb2provider.cpp
  17. +0 −1 src/providers/db2/qgsdb2sourceselect.h
  18. +15 −3 src/providers/delimitedtext/CMakeLists.txt
  19. +6 −1 src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
  20. +6 −1 src/providers/gdal/CMakeLists.txt
  21. +24 −6 src/providers/grass/CMakeLists.txt
  22. +6 −1 src/providers/grass/qgsgrass.cpp
  23. +23 −3 src/providers/grass/qgsgrassprovidermodule.cpp
  24. +20 −1 src/providers/grass/qgsgrassprovidermodule.h
  25. +26 −6 src/providers/mssql/CMakeLists.txt
  26. +10 −3 src/providers/mssql/qgsmssqldataitems.cpp
  27. +10 −2 src/providers/mssql/qgsmssqldataitems.h
  28. +107 −0 src/providers/mssql/qgsmssqlgeomcolumntypethread.cpp
  29. +38 −0 src/providers/mssql/qgsmssqlgeomcolumntypethread.h
  30. +6 −2 src/providers/mssql/qgsmssqlprovider.cpp
  31. +1 −100 src/providers/mssql/qgsmssqlsourceselect.cpp
  32. +1 −30 src/providers/mssql/qgsmssqlsourceselect.h
  33. +4 −0 src/providers/mssql/qgsmssqltablemodel.h
  34. +21 −4 src/providers/oracle/CMakeLists.txt
  35. +6 −1 src/providers/oracle/qgsoracleprovider.cpp
  36. +6 −1 src/providers/ows/CMakeLists.txt
  37. +8 −0 src/providers/ows/qgsowsdataitems.cpp
  38. +8 −1 src/providers/ows/qgsowsdataitems.h
  39. +28 −7 src/providers/postgres/CMakeLists.txt
  40. +25 −13 src/providers/postgres/qgspostgresdataitems.cpp
  41. +19 −2 src/providers/postgres/qgspostgresdataitems.h
  42. +6 −1 src/providers/postgres/qgspostgresprovider.cpp
  43. +21 −6 src/providers/spatialite/CMakeLists.txt
  44. +12 −0 src/providers/spatialite/qgsspatialitedataitems.cpp
  45. +12 −1 src/providers/spatialite/qgsspatialitedataitems.h
  46. +31 −12 src/providers/virtual/CMakeLists.txt
  47. +15 −3 src/providers/wcs/CMakeLists.txt
  48. +10 −2 src/providers/wcs/qgswcsdataitems.cpp
  49. +8 −2 src/providers/wcs/qgswcsdataitems.h
  50. +20 −4 src/providers/wfs/CMakeLists.txt
  51. +11 −3 src/providers/wfs/qgswfsdataitems.cpp
  52. +8 −1 src/providers/wfs/qgswfsdataitems.h
  53. +21 −9 src/providers/wms/CMakeLists.txt
  54. +0 −1 src/providers/wms/qgswmsconnection.cpp
  55. +14 −2 src/providers/wms/qgswmsdataitems.cpp
  56. +16 −2 src/providers/wms/qgswmsdataitems.h
  57. +3 −1 tests/src/CMakeLists.txt
@@ -58,6 +58,8 @@ IF(WITH_CORE)
ENDIF (WITH_GRASS${GRASS_CACHE_VERSION})
ENDFOREACH (GRASS_SEARCH_VERSION)

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

SET (WITH_DESKTOP TRUE CACHE BOOL "Determines whether QGIS desktop should be built")

# server disabled default because it needs FastCGI (which is optional dependency)
@@ -74,6 +76,16 @@ IF(WITH_CORE)
# Custom widgets
SET (WITH_CUSTOM_WIDGETS FALSE CACHE BOOL "Determines whether QGIS custom widgets for Qt Designer should be built")

IF (NOT WITH_GUI)
SET (HAVE_GUI FALSE) # used in qgsconfig.h
# force value of some options
SET(WITH_DESKTOP FALSE)
SET(WITH_CUSTOM_WIDGETS FALSE)
SET(WITH_SERVER FALSE) # for some reason server also uses GUI library
ELSE ()
SET (HAVE_GUI TRUE) # used in qgsconfig.h
ENDIF()

# try to configure and build POSTGRESQL support
SET (WITH_POSTGRESQL TRUE CACHE BOOL "Determines whether POSTGRESQL support should be built")
IF (WITH_POSTGRESQL)
@@ -103,9 +115,11 @@ IF(WITH_CORE)
SET (WITH_STAGED_PLUGINS TRUE CACHE BOOL "Stage-install core Python plugins to run from build directory? (utilities and console are always staged)")
SET (WITH_PY_COMPILE FALSE CACHE BOOL "Determines whether Python modules in staged or installed locations are byte-compiled")
# concatenate QScintilla2 API files
SET (WITH_QSCIAPI TRUE CACHE BOOL "Whether to generate PyQGIS QScintilla2 API file. (For devs) run 'make qsci-pap-src' in between QGIS build and install to regenerate .pap file in source tree for console auto-completion.")
# keep casual users from updating their source tree via WITH_QSCIAPI
MARK_AS_ADVANCED (WITH_QSCIAPI)
IF (WITH_GUI)
SET (WITH_QSCIAPI TRUE CACHE BOOL "Whether to generate PyQGIS QScintilla2 API file. (For devs) run 'make qsci-pap-src' in between QGIS build and install to regenerate .pap file in source tree for console auto-completion.")
# keep casual users from updating their source tree via WITH_QSCIAPI
MARK_AS_ADVANCED (WITH_QSCIAPI)
ENDIF (WITH_GUI)
ADD_DEFINITIONS(-DWITH_BINDINGS)
ENDIF (WITH_BINDINGS)

@@ -196,7 +210,9 @@ IF(WITH_CORE)
FIND_PACKAGE(GDAL)
FIND_PACKAGE(Expat REQUIRED)
FIND_PACKAGE(Spatialindex REQUIRED)
FIND_PACKAGE(Qwt REQUIRED)
IF (WITH_GUI)
FIND_PACKAGE(Qwt REQUIRED)
ENDIF (WITH_GUI)

IF (WITH_INTERNAL_QEXTSERIALPORT)
SET(QEXTSERIALPORT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/core/gps/qextserialport)
@@ -274,7 +290,9 @@ IF(WITH_CORE)
ENDIF (WITH_QTMOBILITY)

# search for QScintilla2 (C++ lib)
FIND_PACKAGE(QScintilla REQUIRED)
IF (WITH_GUI)
FIND_PACKAGE(QScintilla REQUIRED)
ENDIF (WITH_GUI)

# Password helper
FIND_PACKAGE(QtKeychain REQUIRED)
@@ -44,6 +44,8 @@

#cmakedefine USING_NINJA

#cmakedefine HAVE_GUI

#cmakedefine HAVE_POSTGRESQL

#cmakedefine HAVE_ORACLE
@@ -64,7 +64,9 @@ MACRO(PY_2TO3 TARGET_NAME RESOURCE_PATHS)
ENDMACRO(PY_2TO3)

ADD_SUBDIRECTORY(plugins)
ADD_SUBDIRECTORY(qsci_apis)
IF (WITH_GUI)
ADD_SUBDIRECTORY(qsci_apis)
ENDIF ()
ADD_SUBDIRECTORY(console)
ADD_SUBDIRECTORY(PyQt)
ADD_SUBDIRECTORY(pyplugin_installer)
@@ -87,11 +89,17 @@ INCLUDE_DIRECTORIES(SYSTEM
${GEOS_INCLUDE_DIR}
${QWT_INCLUDE_DIR}
${QEXTSERIALPORT_INCLUDE_DIR}
${QSCINTILLA_INCLUDE_DIR}
${QCA_INCLUDE_DIR}
${QTKEYCHAIN_INCLUDE_DIR}
${SQLITE3_INCLUDE_DIR}
)

IF (WITH_GUI)
INCLUDE_DIRECTORIES(SYSTEM
${QSCINTILLA_INCLUDE_DIR}
)
ENDIF ()

INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/core
${CMAKE_SOURCE_DIR}/src/core/annotations
@@ -114,26 +122,32 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/core/raster
${CMAKE_SOURCE_DIR}/src/core/scalebar
${CMAKE_SOURCE_DIR}/src/core/symbology-ng
${CMAKE_SOURCE_DIR}/src/gui
${CMAKE_SOURCE_DIR}/src/gui/symbology-ng
${CMAKE_SOURCE_DIR}/src/gui/raster
${CMAKE_SOURCE_DIR}/src/gui/attributetable
${CMAKE_SOURCE_DIR}/src/gui/auth
${CMAKE_SOURCE_DIR}/src/gui/editorwidgets
${CMAKE_SOURCE_DIR}/src/gui/editorwidgets/core
${CMAKE_SOURCE_DIR}/src/gui/effects
${CMAKE_SOURCE_DIR}/src/gui/layertree
${CMAKE_SOURCE_DIR}/src/gui/layout
${CMAKE_SOURCE_DIR}/src/gui/locator
${CMAKE_SOURCE_DIR}/src/plugins

${CMAKE_BINARY_DIR} # qgsconfig.h, qgsversion.h
${CMAKE_BINARY_DIR}/src/core
${CMAKE_BINARY_DIR}/src/gui
${CMAKE_BINARY_DIR}/src/ui
${CMAKE_BINARY_DIR}/src/analysis
)

IF (WITH_GUI)
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/gui
${CMAKE_SOURCE_DIR}/src/gui/symbology-ng
${CMAKE_SOURCE_DIR}/src/gui/raster
${CMAKE_SOURCE_DIR}/src/gui/attributetable
${CMAKE_SOURCE_DIR}/src/gui/auth
${CMAKE_SOURCE_DIR}/src/gui/editorwidgets
${CMAKE_SOURCE_DIR}/src/gui/editorwidgets/core
${CMAKE_SOURCE_DIR}/src/gui/effects
${CMAKE_SOURCE_DIR}/src/gui/layertree
${CMAKE_SOURCE_DIR}/src/gui/layout
${CMAKE_SOURCE_DIR}/src/gui/locator

${CMAKE_BINARY_DIR}/src/gui
)
ENDIF ()

IF(NOT ENABLE_TESTS)
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} TESTS)
ENDIF(NOT ENABLE_TESTS)
@@ -159,26 +173,31 @@ GENERATE_SIP_PYTHON_MODULE_CODE(qgis._core core/core.sip cpp_files)
BUILD_SIP_PYTHON_MODULE(qgis._core core/core.sip ${cpp_files} "" qgis_core)
SET(SIP_CORE_CPP_FILES ${cpp_files})

# gui module
FILE(GLOB_RECURSE sip_files_gui gui/*.sip)
SET(SIP_EXTRA_FILES_DEPEND ${sip_files_core} ${sip_files_gui})
SET(SIP_EXTRA_OPTIONS ${PYQT_SIP_FLAGS} -o -a ${CMAKE_BINARY_DIR}/python/qgis.gui.api)
IF(QSCI_SIP_DIR)
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -I ${QSCI_SIP_DIR})
ELSE(QSCI_SIP_DIR)
MESSAGE(STATUS "Qsci sip file not found - disabling bindings for derived classes")
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} HAVE_QSCI_SIP)
ENDIF(QSCI_SIP_DIR)

IF(UNIX AND NOT SIP_VERSION_NUM LESS 265984)
SET(SIP_EXTRA_OPTIONS -P ${SIP_EXTRA_OPTIONS})
ADD_DEFINITIONS(-Dprotected=public)
ENDIF(UNIX AND NOT SIP_VERSION_NUM LESS 265984)

GENERATE_SIP_PYTHON_MODULE_CODE(qgis._gui gui/gui.sip cpp_files)
BUILD_SIP_PYTHON_MODULE(qgis._gui gui/gui.sip ${cpp_files} "" qgis_core qgis_gui)
SET(PY_MODULES core analysis)

SET(PY_MODULES core gui analysis)
# gui module
IF (WITH_GUI)
SET(PY_MODULES ${PY_MODULES} gui)

FILE(GLOB_RECURSE sip_files_gui gui/*.sip)
SET(SIP_EXTRA_FILES_DEPEND ${sip_files_core} ${sip_files_gui})
SET(SIP_EXTRA_OPTIONS ${PYQT_SIP_FLAGS} -o -a ${CMAKE_BINARY_DIR}/python/qgis.gui.api)

IF(QSCI_SIP_DIR)
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -I ${QSCI_SIP_DIR})
ELSE(QSCI_SIP_DIR)
MESSAGE(STATUS "Qsci sip file not found - disabling bindings for derived classes")
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} HAVE_QSCI_SIP)
ENDIF(QSCI_SIP_DIR)

GENERATE_SIP_PYTHON_MODULE_CODE(qgis._gui gui/gui.sip cpp_files)
BUILD_SIP_PYTHON_MODULE(qgis._gui gui/gui.sip ${cpp_files} "" qgis_core qgis_gui)
ENDIF (WITH_GUI)

# server module
IF (WITH_SERVER AND WITH_SERVER_PLUGINS)
@@ -2,9 +2,11 @@ ADD_SUBDIRECTORY(native)

ADD_SUBDIRECTORY(core)
ADD_SUBDIRECTORY(analysis)
ADD_SUBDIRECTORY(ui)
ADD_SUBDIRECTORY(gui)
ADD_SUBDIRECTORY(auth)
IF (WITH_GUI)
ADD_SUBDIRECTORY(ui)
ADD_SUBDIRECTORY(gui)
ADD_SUBDIRECTORY(auth)
ENDIF (WITH_GUI)
ADD_SUBDIRECTORY(providers)
ADD_SUBDIRECTORY(crssync)
ADD_SUBDIRECTORY(test)
@@ -14,9 +14,14 @@ INCLUDE_DIRECTORIES(

INCLUDE_DIRECTORIES(SYSTEM
${GEOS_INCLUDE_DIR}
${QSCINTILLA_INCLUDE_DIR}
)

IF (WITH_GUI)
INCLUDE_DIRECTORIES(SYSTEM
${QSCINTILLA_INCLUDE_DIR}
)
ENDIF ()

###############################################################################

SET (AFS_SRCS
@@ -25,26 +30,38 @@ SET (AFS_SRCS
qgsafsfeatureiterator.cpp
qgsafsprovider.cpp
qgsafsproviderextern.cpp
qgsafssourceselect.cpp
qgsafsshareddata.cpp
)
SET (AFS_MOC_HDRS
qgsarcgisrestutils.h
qgsafsdataitems.h
qgsafsprovider.h
qgsafssourceselect.h
qgsafsshareddata.h
)

IF (WITH_GUI)
SET(AFS_SRCS ${AFS_SRCS}
qgsafssourceselect.cpp
)
SET(AFS_MOC_HDRS ${AFS_MOC_HDRS}
qgsafssourceselect.h
)
ENDIF ()

QT5_WRAP_CPP (AFS_MOC_SRCS ${AFS_MOC_HDRS})

ADD_LIBRARY(arcgisfeatureserverprovider MODULE ${AFS_SRCS} ${AFS_MOC_SRCS})

TARGET_LINK_LIBRARIES(arcgisfeatureserverprovider
qgis_core
qgis_gui
)

IF (WITH_GUI)
TARGET_LINK_LIBRARIES(arcgisfeatureserverprovider
qgis_gui
)
ENDIF ()

INSTALL (TARGETS arcgisfeatureserverprovider
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
@@ -56,24 +73,36 @@ SET (AMS_SRCS
qgsamsdataitems.cpp
qgsamsprovider.cpp
qgsamsproviderextern.cpp
qgsamssourceselect.cpp
)
SET (AMS_MOC_HDRS
qgsarcgisrestutils.h
qgsamsdataitems.h
qgsamsprovider.h
qgsamssourceselect.h
)

IF (WITH_GUI)
SET(AMS_SRCS ${AMS_SRCS}
qgsamssourceselect.cpp
)
SET(AMS_MOC_HDRS ${AMS_MOC_HDRS}
qgsamssourceselect.h
)
ENDIF ()

QT5_WRAP_CPP (AMS_MOC_SRCS ${AMS_MOC_HDRS})

ADD_LIBRARY(arcgismapserverprovider MODULE ${AMS_SRCS} ${AMS_MOC_SRCS})

TARGET_LINK_LIBRARIES(arcgismapserverprovider
qgis_core
qgis_gui
)

IF (WITH_GUI)
TARGET_LINK_LIBRARIES(arcgismapserverprovider
qgis_gui
)
ENDIF ()

INSTALL (TARGETS arcgismapserverprovider
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
@@ -13,12 +13,15 @@
* *
***************************************************************************/
#include "qgslogger.h"
#include "qgsnewhttpconnection.h"
#include "qgsowsconnection.h"
#include "qgsafsdataitems.h"
#include "qgsafsprovider.h"
#include "qgsarcgisrestutils.h"

#ifdef HAVE_GUI
#include "qgsnewhttpconnection.h"
#include "qgsafssourceselect.h"
#endif

#include <QCoreApplication>
#include <QSettings>
@@ -46,6 +49,7 @@ QVector<QgsDataItem *> QgsAfsRootItem::createChildren()
return connections;
}

#ifdef HAVE_GUI
QList<QAction *> QgsAfsRootItem::actions()
{
QAction *actionNew = new QAction( tr( "New Connection..." ), this );
@@ -75,6 +79,7 @@ void QgsAfsRootItem::newConnection()
refresh();
}
}
#endif

///////////////////////////////////////////////////////////////////////////////

@@ -114,6 +119,7 @@ bool QgsAfsConnectionItem::equal( const QgsDataItem *other )
return ( type() == other->type() && o != 0 && mPath == o->mPath && mName == o->mName );
}

#ifdef HAVE_GUI
QList<QAction *> QgsAfsConnectionItem::actions()
{
QList<QAction *> lst;
@@ -145,6 +151,7 @@ void QgsAfsConnectionItem::deleteConnection()
QgsOwsConnection::deleteConnection( QStringLiteral( "arcgisfeatureserver" ), mName );
mParent->refresh();
}
#endif

///////////////////////////////////////////////////////////////////////////////

@@ -25,12 +25,16 @@ class QgsAfsRootItem : public QgsDataCollectionItem
public:
QgsAfsRootItem( QgsDataItem *parent, const QString &name, const QString &path );
QVector<QgsDataItem *> createChildren() override;
#ifdef HAVE_GUI
QList<QAction *> actions() override;
QWidget *paramWidget() override;
#endif

public slots:
#ifdef HAVE_GUI
void connectionsChanged();
void newConnection();
#endif
};


@@ -41,11 +45,15 @@ class QgsAfsConnectionItem : public QgsDataCollectionItem
QgsAfsConnectionItem( QgsDataItem *parent, const QString &name, const QString &path, const QString &url );
QVector<QgsDataItem *> createChildren() override;
bool equal( const QgsDataItem *other ) override;
#ifdef HAVE_GUI
QList<QAction *> actions() override;
#endif

public slots:
#ifdef HAVE_GUI
void editConnection();
void deleteConnection();
#endif

private:
QString mUrl;

0 comments on commit a8cceff

Please sign in to comment.
You can’t perform that action at this time.