Qt: add options to disable docs and gui (#20078)

* Qt: add options to disable docs and gui

- Add `~gui` option for minimal build
- Add `+doc` option to install docs, and attempt to disable the implicit
  llvm dependency if not
- Removes the 'freetype' option which hasn't worked reliably in qt5, as
  many of the gui components implicitly rely on freetype.
- Add and test version 5.15 (and skip qtlocation if disabling opengl)
- Refactor some of the dependency logic

I've tested this on linux with 5.15.2 and 4.8.7 in a couple of different
configurations.

* Address reviewer feedback and correctly disable llvm

* Fix qt doc generation
This commit is contained in:
Seth R. Johnson 2020-11-28 20:10:25 -05:00 committed by GitHub
parent 795611b652
commit 58babe81e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 106 additions and 116 deletions

View File

@ -24,6 +24,7 @@ class Qt(Package):
phases = ['configure', 'build', 'install'] phases = ['configure', 'build', 'install']
version('5.15.2', sha256='3a530d1b243b5dec00bc54937455471aaa3e56849d2593edb8ded07228202240')
version('5.14.2', sha256='c6fcd53c744df89e7d3223c02838a33309bd1c291fcb6f9341505fe99f7f19fa') version('5.14.2', sha256='c6fcd53c744df89e7d3223c02838a33309bd1c291fcb6f9341505fe99f7f19fa')
version('5.14.1', sha256='6f17f488f512b39c2feb57d83a5e0a13dcef32999bea2e2a8f832f54a29badb8') version('5.14.1', sha256='6f17f488f512b39c2feb57d83a5e0a13dcef32999bea2e2a8f832f54a29badb8')
version('5.14.0', sha256='be9a77cd4e1f9d70b58621d0753be19ea498e6b0da0398753e5038426f76a8ba') version('5.14.0', sha256='be9a77cd4e1f9d70b58621d0753be19ea498e6b0da0398753e5038426f76a8ba')
@ -51,30 +52,32 @@ class Qt(Package):
variant('debug', default=False, variant('debug', default=False,
description="Build debug version.") description="Build debug version.")
variant('gtk', default=False, variant('dbus', default=False,
description="Build with gtkplus.") description="Build with D-Bus support.")
variant('webkit', default=False, variant('doc', default=False,
description="Build the Webkit extension") description="Build QDoc and documentation.")
variant('examples', default=False, variant('examples', default=False,
description="Build examples.") description="Build examples.")
variant('framework', default=bool(MACOS_VERSION), variant('framework', default=bool(MACOS_VERSION),
description="Build as a macOS Framework package.") description="Build as a macOS Framework package.")
variant('tools', default=True, variant('gtk', default=False,
description="Build tools, including Qt Designer.") description="Build with gtkplus.")
variant('dbus', default=False, variant('gui', default=True,
description="Build with D-Bus support.") description='Build the Qt GUI module and dependencies')
variant('phonon', default=False,
description="Build with phonon support.")
variant('opengl', default=False, variant('opengl', default=False,
description="Build with OpenGL support.") description="Build with OpenGL support.")
variant('sql', default=True, variant('phonon', default=False,
description="Build with SQL support.") description="Build with phonon support.")
variant('shared', default=True, variant('shared', default=True,
description='Build shared libraries.') description='Build shared libraries.')
variant('sql', default=True,
description="Build with SQL support.")
variant('ssl', default=True, variant('ssl', default=True,
description="Build with OpenSSL support.") description="Build with OpenSSL support.")
variant('freetype', default='spack', description='Freetype2 support', variant('tools', default=True,
values=('spack', 'qt', 'none'), multi=False) description="Build tools, including Qt Designer.")
variant('webkit', default=False,
description="Build the Webkit extension")
# Patches for qt@3 # Patches for qt@3
patch('qt3-accept.patch', when='@3') patch('qt3-accept.patch', when='@3')
@ -103,7 +106,7 @@ class Qt(Package):
# https://bugreports.qt.io/browse/QTBUG-57656 # https://bugreports.qt.io/browse/QTBUG-57656
patch('qt5-8-framework.patch', when='@5.8.0 +framework') patch('qt5-8-framework.patch', when='@5.8.0 +framework')
# https://bugreports.qt.io/browse/QTBUG-58038 # https://bugreports.qt.io/browse/QTBUG-58038
patch('qt5-8-freetype.patch', when='@5.8.0 freetype=spack') patch('qt5-8-freetype.patch', when='@5.8.0 +gui')
# https://codereview.qt-project.org/c/qt/qtbase/+/245425 # https://codereview.qt-project.org/c/qt/qtbase/+/245425
patch('https://github.com/qt/qtbase/commit/a52d7861edfb5956de38ba80015c4dd0b596259b.patch', patch('https://github.com/qt/qtbase/commit/a52d7861edfb5956de38ba80015c4dd0b596259b.patch',
sha256='c49b228c27e3ad46ec3af4bac0e9985af5b5b28760f238422d32e14f98e49b1e', sha256='c49b228c27e3ad46ec3af4bac0e9985af5b5b28760f238422d32e14f98e49b1e',
@ -117,7 +120,7 @@ class Qt(Package):
# https://bugreports.qt.io/browse/QTBUG-78937 # https://bugreports.qt.io/browse/QTBUG-78937
patch('qt5-12-configure.patch', when='@5.12') patch('qt5-12-configure.patch', when='@5.12')
# https://bugreports.qt.io/browse/QTBUG-93402 # https://bugreports.qt.io/browse/QTBUG-93402
patch('qt5-15-gcc-10.patch', when='@5.12.7:5.15 %gcc@10:') patch('qt5-15-gcc-10.patch', when='@5.12.7:5.15 %gcc@8:')
conflicts('%gcc@10:', when='@5.9:5.12.6 +opengl') conflicts('%gcc@10:', when='@5.9:5.12.6 +opengl')
# Build-only dependencies # Build-only dependencies
@ -133,7 +136,7 @@ class Qt(Package):
depends_on("libtiff") depends_on("libtiff")
depends_on("libxml2") depends_on("libxml2")
depends_on("zlib") depends_on("zlib")
depends_on("freetype", when='freetype=spack') depends_on("freetype", when='+gui')
depends_on("gperf", when='+webkit') depends_on("gperf", when='+webkit')
depends_on("gtkplus", when='+gtk') depends_on("gtkplus", when='+gtk')
depends_on("openssl", when='+ssl') depends_on("openssl", when='+ssl')
@ -153,6 +156,7 @@ class Qt(Package):
depends_on("harfbuzz", when='@5:') depends_on("harfbuzz", when='@5:')
depends_on("double-conversion", when='@5.7:') depends_on("double-conversion", when='@5.7:')
depends_on("pcre2+multibyte", when='@5.9:') depends_on("pcre2+multibyte", when='@5.9:')
depends_on("llvm", when='@5.11: +doc')
# gcc@4 is not supported as of Qt@5.14 # gcc@4 is not supported as of Qt@5.14
# https://doc.qt.io/qt-5.14/supported-platforms.html # https://doc.qt.io/qt-5.14/supported-platforms.html
@ -160,17 +164,17 @@ class Qt(Package):
# Non-macOS dependencies and special macOS constraints # Non-macOS dependencies and special macOS constraints
if MACOS_VERSION is None: if MACOS_VERSION is None:
depends_on("fontconfig", when='freetype=spack') depends_on("fontconfig", when='+gui')
depends_on("libsm") depends_on("libsm", when='+gui')
depends_on("libx11") depends_on("libx11", when='+gui')
depends_on("libxcb") depends_on("libxcb", when='+gui')
depends_on("libxkbcommon") depends_on("libxkbcommon", when='+gui')
depends_on("xcb-util-image") depends_on("xcb-util-image", when='+gui')
depends_on("xcb-util-keysyms") depends_on("xcb-util-keysyms", when='+gui')
depends_on("xcb-util-renderutil") depends_on("xcb-util-renderutil", when='+gui')
depends_on("xcb-util-wm") depends_on("xcb-util-wm", when='+gui')
depends_on("libxext") depends_on("libxext", when='+gui')
depends_on("libxrender") depends_on("libxrender", when='+gui')
conflicts('+framework', conflicts('+framework',
msg="QT cannot be built as a framework except on macOS.") msg="QT cannot be built as a framework except on macOS.")
else: else:
@ -225,6 +229,15 @@ def url_for_version(self, version):
def setup_build_environment(self, env): def setup_build_environment(self, env):
env.set('MAKEFLAGS', '-j{0}'.format(make_jobs)) env.set('MAKEFLAGS', '-j{0}'.format(make_jobs))
if self.version >= Version('5.11'):
# QDoc uses LLVM as of 5.11; remove the LLVM_INSTALL_DIR to
# disable
try:
llvm_path = self.spec['llvm'].prefix
except KeyError:
# Prevent possibly incompatible system LLVM from being found
llvm_path = "/spack-disable-llvm"
env.set('LLVM_INSTALL_DIR', llvm_path)
def setup_run_environment(self, env): def setup_run_environment(self, env):
env.set('QTDIR', self.prefix) env.set('QTDIR', self.prefix)
@ -368,122 +381,92 @@ def patch(self):
@property @property
def common_config_args(self): def common_config_args(self):
spec = self.spec
version = self.version
# incomplete list is here http://doc.qt.io/qt-5/configure-options.html # incomplete list is here http://doc.qt.io/qt-5/configure-options.html
config_args = [ config_args = [
'-prefix', self.prefix, '-prefix', self.prefix,
'-v', '-v',
'-opensource', '-opensource',
'-{0}opengl'.format('' if '+opengl' in self.spec else 'no-'), '-{0}opengl'.format('' if '+opengl' in spec else 'no-'),
'-{0}'.format('debug' if '+debug' in self.spec else 'release'), '-{0}'.format('debug' if '+debug' in spec else 'release'),
'-confirm-license', '-confirm-license',
'-optimized-qmake', '-optimized-qmake',
'-no-pch', '-no-pch',
] ]
if self.spec.variants['freetype'].value == 'spack': def use_spack_dep(spack_pkg, qt_name=None):
config_args.extend([ pkg = spec[spack_pkg]
'-system-freetype' config_args.append('-system-' + (qt_name or spack_pkg))
]) if not pkg.external:
config_args.extend( config_args.extend(pkg.libs.search_flags.split())
self.spec['freetype'].headers.include_flags.split() config_args.extend(pkg.headers.include_flags.split())
)
if '+gui' in spec:
use_spack_dep('freetype')
if not MACOS_VERSION: if not MACOS_VERSION:
config_args.append('-fontconfig') config_args.append('-fontconfig')
elif version < Version('5.15'):
elif self.spec.variants['freetype'].value == 'qt': # Linux-only QT5 dependencies
config_args.append('-qt-freetype') config_args.append('-system-xcb')
else: else:
config_args.append('-no-freetype') config_args.append('-no-freetype')
config_args.append('-no-gui')
if '+ssl' in self.spec: if '+ssl' in spec:
openssl = self.spec['openssl'] pkg = spec['openssl']
config_args.extend([ config_args.append('-openssl-linked')
'-openssl-linked', config_args.extend(pkg.libs.search_flags.split())
openssl.libs.search_flags, config_args.extend(pkg.headers.include_flags.split())
openssl.headers.include_flags,
])
else: else:
config_args.append('-no-openssl') config_args.append('-no-openssl')
if '+sql' in self.spec: if '+sql' in spec:
sqlite = self.spec['sqlite'] use_spack_dep('sqlite')
config_args.extend([
'-system-sqlite',
'-R', sqlite.prefix.lib,
])
else: else:
comps = ['db2', 'ibase', 'oci', 'tds', 'mysql', 'odbc', 'psql', comps = ['db2', 'ibase', 'oci', 'tds', 'mysql', 'odbc', 'psql',
'sqlite', 'sqlite2'] 'sqlite', 'sqlite2']
config_args.extend("-no-sql-" + component for component in comps) config_args.extend("-no-sql-" + component for component in comps)
if '+shared' in self.spec: if '+shared' in spec:
config_args.append('-shared') config_args.append('-shared')
else: else:
config_args.append('-static') config_args.append('-static')
if self.spec.satisfies('@5:'): if version >= Version('5'):
pcre = self.spec['pcre'] if self.spec.satisfies('@5.0:5.8') \ use_spack_dep('pcre' if spec.satisfies('@5.0:5.8') else 'pcre2',
else self.spec['pcre2'] 'pcre')
harfbuzz = self.spec['harfbuzz'] use_spack_dep('harfbuzz')
config_args.extend([
'-system-harfbuzz',
harfbuzz.libs.search_flags,
harfbuzz.headers.include_flags,
'-system-pcre',
pcre.libs.search_flags,
pcre.headers.include_flags
])
if self.spec.satisfies('@5.7:'): if version >= Version('5.7'):
dc = self.spec['double-conversion'] use_spack_dep('double-conversion', 'doubleconversion')
config_args.extend([
'-system-doubleconversion',
dc.libs.search_flags,
dc.headers.include_flags
])
if '@:5.7.1' in self.spec: if version <= Version('5.7.1'):
config_args.append('-no-openvg') config_args.append('-no-openvg')
else: else:
# FIXME: those could work for other versions # FIXME: those could work for other versions
png = self.spec['libpng'] use_spack_dep('libpng')
config_args.append('-system-libpng') use_spack_dep('jpeg', 'libjpeg')
if not png.external: use_spack_dep('zlib')
config_args.extend([
png.libs.search_flags,
png.headers.include_flags
])
jpeg = self.spec['jpeg'] if '@:5.7.0' in spec:
config_args.append('-system-libjpeg')
if not jpeg.external:
config_args.extend([
jpeg.libs.search_flags,
jpeg.headers.include_flags,
])
zlib = self.spec['zlib']
config_args.append('-system-zlib')
if not zlib.external:
config_args.extend([
zlib.libs.search_flags,
zlib.headers.include_flags
])
if '@:5.7.0' in self.spec:
config_args.extend([ config_args.extend([
# NIS is deprecated in more recent glibc, # NIS is deprecated in more recent glibc,
# but qt-5.7.1 does not recognize this option # but qt-5.7.1 does not recognize this option
'-no-nis', '-no-nis',
]) ])
if '~examples' in self.spec: # COMPONENTS
if '~examples' in spec:
config_args.extend(['-nomake', 'examples']) config_args.extend(['-nomake', 'examples'])
if '~tools' in self.spec: if '~tools' in spec:
config_args.extend(['-nomake', 'tools']) config_args.extend(['-nomake', 'tools'])
if '+dbus' in self.spec: if '+dbus' in spec:
dbus = self.spec['dbus'].prefix dbus = spec['dbus'].prefix
config_args.append('-dbus-linked') config_args.append('-dbus-linked')
config_args.append('-I%s/dbus-1.0/include' % dbus.lib) config_args.append('-I%s/dbus-1.0/include' % dbus.lib)
config_args.append('-I%s/dbus-1.0' % dbus.include) config_args.append('-I%s/dbus-1.0' % dbus.include)
@ -493,7 +476,7 @@ def common_config_args(self):
if MACOS_VERSION: if MACOS_VERSION:
config_args.append('-{0}framework'.format( config_args.append('-{0}framework'.format(
'' if '+framework' in self.spec else 'no-')) '' if '+framework' in spec else 'no-'))
(_, qtplat) = self.get_mkspec() (_, qtplat) = self.get_mkspec()
if qtplat is not None: if qtplat is not None:
@ -568,9 +551,6 @@ def configure(self, spec, prefix):
]) ])
if version < Version('5.12'): if version < Version('5.12'):
config_args.append('-no-xinput2') config_args.append('-no-xinput2')
else:
# Linux-only QT5 dependencies
config_args.append('-system-xcb')
if '~webkit' in spec: if '~webkit' in spec:
config_args.extend([ config_args.extend([
@ -587,16 +567,18 @@ def configure(self, spec, prefix):
# https://wiki.qt.io/QtWayland # https://wiki.qt.io/QtWayland
config_args.extend(['-skip', 'wayland']) config_args.extend(['-skip', 'wayland'])
if version >= Version('5.10') and '~opengl' in spec: if '~opengl' in spec:
config_args.extend([ if version >= Version('5.10'):
'-skip', 'webglplugin', config_args.extend([
'-skip', 'qt3d', '-skip', 'webglplugin',
]) '-skip', 'qt3d',
])
if version >= Version('5.14') and '~opengl' in spec: if version >= Version('5.14'):
config_args.extend([ config_args.extend(['-skip', 'qtquick3d'])
'-skip', 'qtquick3d',
]) if version >= Version('5.15'):
config_args.extend(['-skip', 'qtlocation'])
configure(*config_args) configure(*config_args)
@ -605,3 +587,11 @@ def build(self, spec, prefix):
def install(self, spec, prefix): def install(self, spec, prefix):
make("install") make("install")
# Documentation generation requires the doc tools to be installed.
# @when @run_after currently seems to ignore the 'when' restriction.
@run_after('install')
def install_docs(self):
if '+doc' in self.spec:
make('docs')
make('install_docs')

View File

@ -180,8 +180,8 @@ class Visit(CMakePackage):
depends_on('vtk+python', when='+python @3.0:,develop') depends_on('vtk+python', when='+python @3.0:,develop')
depends_on('vtk~mpi', when='~mpi') depends_on('vtk~mpi', when='~mpi')
depends_on('vtk+qt', when='+gui') depends_on('vtk+qt', when='+gui')
depends_on('qt@4.8.6:4.999', when='+gui @:2.999') depends_on('qt+gui@4.8.6:4.999', when='+gui @:2.999')
depends_on('qt@5.10:', when='+gui @3.0:,develop') depends_on('qt+gui@5.10:', when='+gui @3.0:,develop')
depends_on('qwt', when='+gui') depends_on('qwt', when='+gui')
depends_on('python@2.6:2.8', when='+python') depends_on('python@2.6:2.8', when='+python')
# VisIt uses Silo's 'ghost zone' data structures, which are only available # VisIt uses Silo's 'ghost zone' data structures, which are only available