easyblock = 'CMakeMake'

name = 'QGIS'
version = '2.14.12'
versionsuffix = '-Python-2.7.12'

homepage = 'http://www.qgis.org/'
description = "QGIS is a user friendly Open Source Geographic Information System (GIS)"

toolchain = {'name': 'intel', 'version': '2016b'}
toolchainopts = {'pic': True, 'cstd': 'gnu++11'}

source_urls = ['http://qgis.org/downloads/']
sources = [SOURCELOWER_TAR_BZ2]

patches = ['QGIS-%(version)s_fix-SIP-macro.patch']

dependencies = [
    ('Qt', '4.8.7'),
    ('PROJ', '4.9.3'),
    ('GEOS', '3.6.1', versionsuffix),
    ('SQLite', '3.13.0'),  # stick to this version for compatibility with Python 2.7.12
    ('libspatialite', '4.3.0a'),
    ('libspatialindex', '1.8.5'),
    ('GDAL', '2.1.3', versionsuffix),
    ('Qwt', '6.1.3'),
    ('QwtPolar', '1.1.1'),
    ('expat', '2.2.0'),
    ('QCA', '2.1.3'),
    ('PyQt', '4.12', versionsuffix),
    # QScintilla must be listed after PyQt4 due to Python bindings 'overriding' those of PyQt4
    ('QScintilla', '2.10', versionsuffix),
    ('GSL', '2.3'),
    ('QJson', '0.9.0'),
    ('requests', '2.13.0', versionsuffix),
    ('psycopg2', '2.7', versionsuffix),
]
builddependencies = [
    ('CMake', '3.7.2'),
    ('flex', '2.6.3'),
    ('Bison', '3.0.4'),
]

separate_build_dir = True

# specify locations that CMake can't figure out correctly
configopts = "-DCMAKE_PREFIX_PATH=$EBROOTQT -DQJSON_DIR=$EBROOTQJSON/lib/cmake/qjson "
configopts += "-DQSCINTILLA_LIBRARY=$EBROOTQSCINTILLA/lib/libqscintilla2_qt4.so "
configopts += "-DPYQT4_SIP_DIR=$EBROOTPYQT/share/sip/PyQt4 -DQSCI_SIP_DIR=$EBROOTQSCINTILLA/share/sip/PyQt4"

sanity_check_paths = {
    'files': ['bin/qbrowser', 'bin/qgis', 'bin/qgis_bench', 'lib/libqgis_analysis.%s' % SHLIB_EXT,
              'lib/libqgis_app.%s' % SHLIB_EXT, 'lib/libqgis_core.%s' % SHLIB_EXT, 'lib/libqgis_gui.%s' % SHLIB_EXT,
              'lib/libqgis_networkanalysis.%s' % SHLIB_EXT, 'lib/libqgispython.%s' % SHLIB_EXT],
    'dirs': ['include/qgis', 'man', 'share/qgis'],
}

moduleclass = 'geo'
