OpenGL restructure (#31748)

* OpenGL: Restructures the OpenGL packages

This provides concrete glx and osmesa packages which delegate to
virtual libglx and libosmesa packages provided by mesa. This was
necessary because GLX and OSMesa both provide gl implementations but
with mesa providing the girtual gl package there was no way to properly
distinguish which of the two opengl implementations was beiing requested
when querying the spec['gl'] dependency.  This additional level of
indirection allows for that.

* OpenGL: Adjust downstream dependents of OpenGL for the restructure

This implements the necessary fixes in the packages that depend on
OpenGL to work with the restructuring.  This also attempts to create a
consistent variant for specifying glx or osmesa.
This commit is contained in:
Chuck Atkins 2022-07-29 13:04:42 -05:00 committed by GitHub
parent 70c849f76b
commit 57af891cb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 419 additions and 328 deletions

View file

@ -25,16 +25,17 @@ packages:
fftw-api: [fftw, amdfftw]
flame: [libflame, amdlibflame]
fuse: [libfuse]
gl: [mesa+opengl, mesa18, opengl]
gl: [glx, osmesa]
glu: [mesa-glu, openglu]
glx: [mesa+glx, mesa18+glx, opengl]
golang: [gcc]
iconv: [libiconv]
ipp: [intel-ipp]
java: [openjdk, jdk, ibm-java]
jpeg: [libjpeg-turbo, libjpeg]
lapack: [openblas, amdlibflame]
libllvm: [llvm, llvm-amdgpu]
libglx: [mesa+glx, mesa18+glx]
libllvm: [llvm]
libosmesa: [mesa+osmesa, mesa18+osmesa]
lua-lang: [lua, lua-luajit-openresty, lua-luajit]
luajit: [lua-luajit-openresty, lua-luajit]
mariadb-client: [mariadb-c-client, mariadb]
@ -44,7 +45,6 @@ packages:
mysql-client: [mysql, mariadb-c-client]
opencl: [pocl]
onedal: [intel-oneapi-dal]
osmesa: [mesa+osmesa, mesa18+osmesa]
pbs: [openpbs, torque]
pil: [py-pillow]
pkgconfig: [pkgconf, pkg-config]

View file

@ -79,8 +79,8 @@ class Catalyst(CMakePackage):
depends_on('py-mpi4py', when='+python3', type=('build', 'run'))
depends_on('gl@3.2:', when='+rendering')
depends_on('osmesa', when='+rendering+osmesa')
depends_on('glx', when='+rendering~osmesa')
depends_on('osmesa', when='+osmesa')
depends_on('glx', when='~osmesa')
depends_on('cmake@3.3:', type='build')
@when('@5.5.0:5.5.2')

View file

@ -17,15 +17,23 @@ class Freeglut(CMakePackage, SourceforgePackage):
version('3.2.1', sha256='d4000e02102acaf259998c870e25214739d1f16f67f99cb35e4f46841399da68')
version('3.0.0', sha256='2a43be8515b01ea82bcfa17d29ae0d40bd128342f0930cd1f375f1ff999f76a2')
depends_on('pkgconfig', type='build')
variant('shared', default=True, description='Build shared libs instead of static')
depends_on('gl')
depends_on('glu')
depends_on('libx11')
depends_on('libxrandr')
depends_on('libxi')
depends_on('libxxf86vm')
depends_on('xrandr')
depends_on('inputproto')
# FreeGLUT does not support OSMesa
conflicts('osmesa')
# FreeGLUT only works with GLX on linux (cray is also linux)
with when('platform=linux'):
depends_on('glx')
depends_on('libx11')
depends_on('libxi')
with when('platform=cray'):
depends_on('glx')
depends_on('libx11')
depends_on('libxi')
# freeglut 3.2.1 fails to build with -fno-common (default with newer compilers)
# see https://bugs.gentoo.org/705840 and https://github.com/dcnieho/FreeGLUT/pull/76
@ -40,12 +48,19 @@ class Freeglut(CMakePackage, SourceforgePackage):
when="@3.2.1 %aocc@2.3.0:")
def cmake_args(self):
return [
'-DFREEGLUT_BUILD_DEMOS=OFF',
'-DOPENGL_gl_LIBRARY=' + self.spec['gl'].libs[0],
'-DOPENGL_glu_LIBRARY=' + self.spec['glu'].libs[0],
'-DX11_X11_LIB=' + self.spec['libx11'].libs[0],
'-DX11_Xrandr_LIB=' + self.spec['libxrandr'].libs[0],
'-DX11_Xi_LIB=' + self.spec['libxi'].libs[0],
'-DX11_Xxf86vm_LIB=' + self.spec['libxxf86vm'].libs[0],
spec = self.spec
args = [
self.define('FREEGLUT_BUILD_DEMOS', False),
self.define('FREEGLUT_GLES', False),
self.define('FREEGLUT_WAYLAND', False),
self.define('FREEGLUT_BUILD_SHARED_LIBS', '+shared' in spec),
self.define('FREEGLUT_BUILD_STATIC_LIBS', '~shared' in spec),
self.define('OpenGL_GL_PREFERENCE', 'LEGACY'),
self.define('OPENGL_INCLUDE_DIR', spec['gl'].headers.directories[0]),
self.define('OPENGL_gl_LIBRARY', spec['gl'].libs[0]),
self.define('OPENGL_opengl_LIBRARY', 'IGNORE'),
self.define('OPENGL_glx_LIBRARY', 'IGNORE'),
self.define('OPENGL_egl_LIBRARY', 'IGNORE'),
]
return args

View file

@ -22,40 +22,30 @@ class Gl2ps(CMakePackage):
variant('doc', default=False,
description='Generate documentation using pdflatex')
depends_on('cmake@2.4:', type='build')
depends_on('cmake@2.8.6:', type='build')
# X11 libraries:
depends_on('freeglut')
depends_on('gl')
depends_on('libice')
depends_on('libsm')
depends_on('libxau')
depends_on('libxdamage')
depends_on('libxdmcp')
depends_on('libxext')
depends_on('libxfixes')
depends_on('libxi')
depends_on('libxmu')
depends_on('libxt')
depends_on('libxxf86vm')
depends_on('libxcb')
depends_on('libdrm')
depends_on('expat')
depends_on('libpng', when='+png')
depends_on('zlib', when='+zlib')
depends_on('texlive', type='build', when='+doc')
def variant_to_bool(self, variant):
return 'ON' if variant in self.spec else 'OFF'
def cmake_args(self):
spec = self.spec
options = [
self.define('CMAKE_DISABLE_FIND_PACKAGE_GLUT', True),
self.define_from_variant('ENABLE_PNG', 'png'),
self.define_from_variant('ENABLE_ZLIB', 'zlib'),
self.define('OpenGL_GL_PREFERENCE', 'LEGACY'),
self.define('OPENGL_INCLUDE_DIR', spec['gl'].headers.directories[0]),
self.define('OPENGL_gl_LIBRARY', spec['gl'].libs[0]),
self.define('OPENGL_opengl_LIBRARY', 'IGNORE'),
self.define('OPENGL_glx_LIBRARY', 'IGNORE'),
self.define('OPENGL_egl_LIBRARY', 'IGNORE'),
self.define('OPENGL_glu_LIBRARY', 'IGNORE'),
]
if '~doc' in self.spec:
if '~doc' in spec:
# Make sure we don't look.
options.append('-DCMAKE_DISABLE_FIND_PACKAGE_LATEX:BOOL=ON')
options.append(self.define('CMAKE_DISABLE_FIND_PACKAGE_LATEX', True))
return options

View file

@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import sys
from spack.package import *
@ -18,18 +19,41 @@ class Glew(CMakePackage):
version('2.1.0', sha256='04de91e7e6763039bc11940095cd9c7f880baba82196a7765f727ac05a993c95')
version('2.0.0', sha256='c572c30a4e64689c342ba1624130ac98936d7af90c3103f9ce12b8a0c5736764')
variant('gl',
default='glx' if sys.platform.startswith('linux') else 'other',
values=('glx', 'osmesa', 'other'), multi=False,
description='The OpenGL provider to use')
conflicts('osmesa', when='gl=glx')
conflicts('osmesa', when='gl=other')
conflicts('glx', when='gl=osmesa')
conflicts('glx', when='gl=other')
depends_on('gl')
depends_on('glx', when='platform=linux')
depends_on('osmesa', when='gl=osmesa')
depends_on('glx', when='gl=glx')
depends_on('libx11', when='gl=glx')
depends_on('xproto', when='gl=glx')
# glu is already forcibly disabled in the CMakeLists.txt. This prevents
# it from showing up in the .pc file
patch('remove-pkgconfig-glu-dep.patch')
def cmake_args(self):
spec = self.spec
args = [
self.define('BUILD_UTILS', True),
self.define('GLEW_REGAL', False),
self.define('GLEW_OSMESA', False),
self.define('GLEW_EGL', False),
self.define('OpenGL_GL_PREFERENCE', 'LEGACY'),
self.define('OPENGL_INCLUDE_DIR', spec['gl'].headers.directories[0]),
self.define('OPENGL_gl_LIBRARY', spec['gl'].libs[0]),
self.define('OPENGL_opengl_LIBRARY', 'IGNORE'),
self.define('OPENGL_glx_LIBRARY', 'IGNORE'),
self.define('OPENGL_egl_LIBRARY', 'IGNORE'),
self.define('OPENGL_glu_LIBRARY', 'IGNORE'),
self.define('GLEW_OSMESA', 'gl=osmesa' in spec),
self.define('GLEW_X11', 'gl=glx' in spec),
self.define('CMAKE_DISABLE_FIND_PACKAGE_X11', 'gl=glx' not in spec),
]
return args

View file

@ -124,7 +124,7 @@ def yes_no(s):
'SDL_DIR={0}'.format(spec['sdl2'].prefix),
'GLEW_DIR={0}'.format(spec['glew'].prefix),
'FREETYPE_DIR={0}'.format(spec['freetype'].prefix),
'OPENGL_DIR={0}'.format(spec['gl'].prefix)]
'OPENGL_DIR={0}'.format(spec['gl'].home)]
if 'screenshots=png' in spec:
args += ['GLVIS_USE_LIBPNG=YES', 'GLVIS_USE_LIBTIFF=NO']
@ -140,7 +140,7 @@ def yes_no(s):
args += ['GL_OPTS=-I{0} -I{1} -I{2}'.format(
spec['libx11'].prefix.include,
spec['gl'].prefix.include,
spec['gl'].home.include,
spec['glu'].prefix.include),
'GL_LIBS={0}'.format(gl_libs.ld_flags)]

View file

@ -0,0 +1,38 @@
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.package import *
class Glx(BundlePackage):
"""Shim package for the GLX library."""
homepage = 'https://www.khronos.org/registry/OpenGL/index_gl.php'
version('1.4')
depends_on('libglx')
provides('gl@4.5')
@property
def home(self):
return self.spec['libglx'].home
@property
def headers(self):
return self.spec['libglx'].headers
@property
def libs(self):
return self.spec['libglx'].libs
@property
def gl_headers(self):
return find_headers('GL/gl',
root=self.gl_home,
recursive=True)
@property
def gl_libs(self):
return self.spec['libglx'].libs

View file

@ -36,12 +36,9 @@ class Memsurfer(PythonPackage):
depends_on('cgal@4.13 +shared~core~demos~imageio')
# vtk needs to know whether to build with mesa or opengl
vtk_conf = '~ffmpeg~mpi+opengl2~qt~xdmf+python'
depends_on('vtk@8.1.2 ' + vtk_conf + ' ~osmesa', when='~osmesa')
depends_on('vtk@8.1.2 ' + vtk_conf + ' +osmesa', when='+osmesa')
# needed only to resolve the conflict between the default and netcdf's spec
depends_on('hdf5 +hl')
depends_on('vtk@8.1.2 ~ffmpeg~mpi+opengl2~qt~xdmf+python')
depends_on('vtk ~osmesa', when='~osmesa')
depends_on('vtk +osmesa', when='+osmesa')
# memsurfer's setup needs path to these deps to build extension modules
def setup_build_environment(self, env):

View file

@ -0,0 +1,26 @@
diff --git a/src/osdemos/osdemo16.c b/src/osdemos/osdemo16.c
index f1bfccef..4b7a765d 100644
--- a/src/osdemos/osdemo16.c
+++ b/src/osdemos/osdemo16.c
@@ -12,7 +12,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "GL/osmesa.h"
-#include "glut_wrap.h"
+#include "GL/glu.h"
#define SAVE_TARGA
diff --git a/src/osdemos/osdemo32.c b/src/osdemos/osdemo32.c
index db01db6d..3411e34c 100644
--- a/src/osdemos/osdemo32.c
+++ b/src/osdemos/osdemo32.c
@@ -11,7 +11,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "GL/osmesa.h"
-#include "glut_wrap.h"
+#include "GL/glu.h"
#define SAVE_TARGA

View file

@ -11,18 +11,21 @@ class MesaDemos(AutotoolsPackage):
"""This package provides some demo applications for testing Mesa."""
homepage = "https://www.mesa3d.org"
url = "https://github.com/freedesktop/mesa-demos/archive/mesa-demos-8.3.0.tar.gz"
url = "https://gitlab.freedesktop.org/mesa/demos/-/archive/mesa-demos-8.4.0/demos-mesa-demos-8.4.0.tar.gz"
version('8.4.0', sha256='e9d235e6dad69d6b00877bf07e6d1859e368c0873e5401ec68a6ddb43375e900')
version('8.3.0', sha256='9bc1b37f4fc7bfc3f818f2d3851ffde28e8167ef11dca87f4781e9ef6206901f')
version('8.2.0', sha256='5a9f71b815d968d0c3b77edfcc3782d0211f8520b00da9e554ccfed80c8889f6')
version('8.1.0', sha256='cc5826105355830208c90047fc38c5b09fa3ab0045366e7e859104935b00b76d')
variant('osmesa', default=False, description="Enable the OSMesa frontend.")
is_linux = sys.platform.startswith('linux')
variant('glx', default=is_linux, description="Enable the GLX frontend.")
conflicts('+osmesa', when='+glx')
variant('gl',
default='glx' if sys.platform.startswith('linux') else 'osmesa',
values=('glx', 'osmesa', 'other'), multi=False,
description='The OpenGL provider to use')
conflicts('osmesa', when='gl=glx')
conflicts('osmesa', when='gl=other')
conflicts('glx', when='gl=osmesa')
conflicts('glx', when='gl=other')
depends_on('autoconf', type='build')
depends_on('automake', type='build')
@ -31,17 +34,19 @@ class MesaDemos(AutotoolsPackage):
depends_on('pkgconfig', type='build')
depends_on('gl')
depends_on('glx', when='+glx')
depends_on('libx11', when='+glx')
depends_on('libxext', when='+glx')
depends_on('osmesa', when='+osmesa')
depends_on('osmesa', when='gl=osmesa')
depends_on('glx', when='gl=glx')
depends_on('libx11', when='gl=glx')
depends_on('libxext', when='gl=glx')
depends_on('glu', when='~osmesa')
depends_on('mesa-glu+osmesa', when='+osmesa')
depends_on('freeglut')
depends_on('glu')
depends_on('glew@1.5.4:')
# OSMesa demos don't actually use glut
patch('osmesa-glut.patch')
def configure_args(self):
spec = self.spec
args = [
'--disable-egl',
'--disable-gles1',
@ -52,8 +57,15 @@ def configure_args(self):
'--disable-gbm',
'--disable-freetype2',
'--disable-rbug',
self.enable_or_disable('osmesa'),
self.enable_or_disable('x11', variant='glx'),
'--without-glut',
]
if 'gl=glx' in spec:
args.append('--enable-x11')
else:
args.append('--disable-x11')
if 'gl=osmesa' in spec:
args.append('--enable-osmesa')
else:
args.append('--disable-osmesa')
return args

View file

@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import sys
from spack.package import *
@ -16,25 +18,31 @@ class MesaGlu(AutotoolsPackage):
version('9.0.1', sha256='f6f484cfcd51e489afe88031afdea1e173aa652697e4c19ddbcb8260579a10f7')
version('9.0.0', sha256='4387476a1933f36fec1531178ea204057bbeb04cc2d8396c9ea32720a1f7e264')
variant('osmesa', default=False, description='Enable OSMesa instead of libGL')
variant('gl',
default='glx' if sys.platform.startswith('linux') else 'other',
values=('glx', 'osmesa', 'other'), multi=False,
description='The OpenGL provider to use')
conflicts('osmesa', when='gl=glx')
conflicts('osmesa', when='gl=other')
conflicts('glx', when='gl=osmesa')
conflicts('glx', when='gl=other')
depends_on('gl@3:')
depends_on('osmesa', when='+osmesa')
depends_on('osmesa', when='gl=osmesa')
depends_on('glx', when='gl=glx')
# Since pacakges like mesa provide both gl and osmesa this will prevent
# consuming packages from getting a glu tied to a differnt gl library
provides('glu@1.3', when='~osmesa')
provides('glu@1.3')
def configure_args(self):
args = []
args.extend(self.enable_or_disable('osmesa'))
args = ['--disable-libglvnd']
if 'gl=osmesa' in self.spec:
args.append('--enable-osmesa')
else:
args.append('--disable-osmesa')
return args
@property
def libs(self):
for dir in ['lib64', 'lib']:
libs = find_libraries('libGLU', join_path(self.prefix, dir),
shared=True, recursive=False)
if libs:
return libs
return find_libraries('libGLU', self.prefix, recursive=True)

View file

@ -18,8 +18,9 @@ class Mesa(MesonPackage):
git = "https://gitlab.freedesktop.org/mesa/mesa.git"
url = "https://archive.mesa3d.org/mesa-20.2.1.tar.xz"
version('master', tag='master')
version('22.0.2', sha256='df4fa560dcce6680133067cd15b0505fc424ca703244ce9ab247c74d2fab6885', preferred=True)
version('main', tag='main')
version('22.1.2', sha256='df4fa560dcce6680133067cd15b0505fc424ca703244ce9ab247c74d2fab6885', preferred=True)
version('22.0.2', sha256='df4fa560dcce6680133067cd15b0505fc424ca703244ce9ab247c74d2fab6885')
version('21.3.8', sha256='e70d273bdc53a4e931871bb5550ba3900e6a3deab2fff64184107c33e92d9da7')
version('21.3.7', sha256='b4fa9db7aa61bf209ef0b40bef83080999d86ad98df8b8b4fada7c128a1efc3d')
version('21.3.1', sha256='2b0dc2540cb192525741d00f706dbc4586349185dafc65729c7fda0800cc474d')
@ -71,10 +72,12 @@ class Mesa(MesonPackage):
)
# Front ends
variant('osmesa', default=True, description="Enable the OSMesa frontend.")
variant('osmesa', default=True, description="Enable the OSMesa frontend.",
when='+opengl')
is_linux = sys.platform.startswith('linux')
variant('glx', default=is_linux, description="Enable the GLX frontend.")
variant('glx', default=is_linux, description="Enable the GLX frontend.",
when='+opengl')
# TODO: effectively deal with EGL. The implications of this have not been
# worked through yet
@ -89,14 +92,16 @@ class Mesa(MesonPackage):
variant('opengles', default=False, description="Enable OpenGL ES support.")
# Provides
provides('gl@4.5', when='+opengl')
provides('glx@1.4', when='+glx')
provides('libglx', when='+glx')
# provides('egl@1.5', when='+egl')
provides('osmesa', when='+osmesa')
provides('libosmesa', when='+osmesa')
# Variant dependencies
depends_on('libllvm@6:', when='+llvm')
depends_on('libllvm@:13', when='@:21 +llvm')
with when('+llvm'):
depends_on('libllvm@6:')
depends_on('libllvm@:11', when='@:20')
depends_on('libllvm@:12', when='@:21')
depends_on('libx11', when='+glx')
depends_on('libxcb', when='+glx')
depends_on('libxext', when='+glx')
@ -119,11 +124,10 @@ class Mesa(MesonPackage):
# OpenGL ES requires OpenGL
conflicts('~opengl +opengles')
# https://gitlab.freedesktop.org/mesa/mesa/-/issues/5455
conflicts('llvm@13.0.0:', when='@:21.3.1 +llvm')
# requires native to be added to llvm_modules when using gallium swrast
patch('https://cgit.freedesktop.org/mesa/mesa/patch/meson.build?id=054dd668a69acc70d47c73abe4646e96a1f23577', sha256='36096a178070e40217945e12d542dfe80016cb897284a01114d616656c577d73', when='@21.0.0:21.0.3')
patch('https://cgit.freedesktop.org/mesa/mesa/patch/meson.build?id=054dd668a69acc70d47c73abe4646e96a1f23577',
sha256='36096a178070e40217945e12d542dfe80016cb897284a01114d616656c577d73',
when='@21.0.0:21.0.3')
patch('mesa_check_llvm_version_suffix.patch', when='@21.2.3:')
@ -260,43 +264,29 @@ def meson_args(self):
return args
@property
def libs(self):
spec = self.spec
libs_to_seek = set()
if '+osmesa' in spec:
libs_to_seek.add('libOSMesa')
if '+glx' in spec:
libs_to_seek.add('libGL')
if '+opengl' in spec:
libs_to_seek.add('libGL')
if '+opengles' in spec:
libs_to_seek.add('libGLES')
libs_to_seek.add('libGLES2')
if libs_to_seek:
return find_libraries(list(libs_to_seek),
root=self.spec.prefix,
recursive=True)
return LibraryList()
def libglx_headers(self):
return find_headers('GL/glx',
root=self.spec.prefix.include,
recursive=False)
@property
def osmesa_libs(self):
return find_libraries('libOSMesa',
root=self.spec.prefix,
recursive=True)
@property
def glx_libs(self):
def libglx_libs(self):
return find_libraries('libGL',
root=self.spec.prefix,
recursive=True)
@property
def gl_libs(self):
return find_libraries('libGL',
def libosmesa_headers(self):
return find_headers('GL/osmesa',
root=self.spec.prefix.include,
recursive=False)
@property
def libosmesa_libs(self):
if 'platform=windows' in self.spec:
lib_name = 'osmesa'
else:
lib_name = 'libOSMesa'
return find_libraries(lib_name,
root=self.spec.prefix,
recursive=True)

View file

@ -64,9 +64,8 @@ class Mesa18(AutotoolsPackage):
variant('opengles', default=False, description="Enable OpenGL ES support.")
# Provides
provides('gl@4.5')
provides('glx@1.4', when='+glx')
provides('osmesa', when='+osmesa')
provides('libglx', when='+glx')
provides('libosmesa', when='+osmesa')
# Variant dependencies
depends_on('libllvm@6:10', when='+llvm')
@ -189,43 +188,49 @@ def configure_args(self):
def libs(self):
spec = self.spec
libs_to_seek = set()
if '+osmesa' in spec:
libs_to_seek.add('libOSMesa')
if '+glx' in spec:
if 'platform=windows' in spec:
libs_to_seek.add('opengl32')
if '+osmesa' in spec:
libs_to_seek.add('osmesa')
else:
libs_to_seek.add('libGL')
libs_to_seek.add('libGL')
if '+osmesa' in spec:
libs_to_seek.add('libOSMesa')
if '+glx' in spec:
libs_to_seek.add('libGL')
if '+opengles' in spec:
libs_to_seek.add('libGLES')
libs_to_seek.add('libGLES2')
libs_to_seek.add('libGLESv1_CM')
libs_to_seek.add('libGLESv2')
if libs_to_seek:
return find_libraries(list(libs_to_seek),
root=self.spec.prefix,
shared=True,
recursive=True)
return LibraryList()
@property
def osmesa_libs(self):
return find_libraries('libOSMesa',
return find_libraries(list(libs_to_seek),
root=self.spec.prefix,
shared=True,
recursive=True)
@property
def glx_libs(self):
def libglx_headers(self):
return find_headers('GL/glx',
root=self.spec.prefix.include,
recursive=False)
@property
def libglx_libs(self):
return find_libraries('libGL',
root=self.spec.prefix,
shared=True,
recursive=True)
@property
def gl_libs(self):
return find_libraries('libGL',
def libosmesa_headers(self):
return find_headers('GL/osmesa',
root=self.spec.prefix.include,
recursive=False)
@property
def libosmesa_libs(self):
if 'platform=windows' in self.spec:
lib_name = 'osmesa'
else:
lib_name = 'libOSMesa'
return find_libraries(lib_name,
root=self.spec.prefix,
shared=True,
recursive=True)

View file

@ -14,38 +14,24 @@ class Opengl(BundlePackage):
homepage = "https://www.opengl.org/"
# Supported OpenGL versions:
# 1.0 1.1 1.2 1.3 1.4 1.5
# 2.0 2.1
# 3.0 3.1 3.2 3.3
# 4.0 4.1 4.2 4.3 4.4 4.5 4.6
for ver_major in [
(1, [0, 1, 2, 3, 4, 5]),
(2, [0, 1]),
(3, [0, 1, 2, 3]),
(4, [0, 1, 2, 3, 4, 5]),
]:
for ver_minor in ver_major[1]:
ver = "{0}.{1}".format(ver_major[0], ver_minor)
version(ver)
provides("gl@:{0}".format(ver), when="@{0}".format(ver))
# The last version needs to be open-ended
version('4.6')
provides("gl@:4.6", when="@4.6:")
version('4.5')
# This should really be when='platform=linux' but can't because of a
# current bug in when and how ArchSpecs are constructed
if sys.platform == "linux":
provides("glx@1.4")
executables = ["^glxinfo$"]
if sys.platform.startswith('linux'):
provides('libglx')
executables = ['^glxinfo$']
else: # windows and mac
provides('gl@4.5')
@classmethod
def determine_version(cls, exe):
output = Executable(exe)(output=str, error=str)
match = re.search(r"OpenGL version string: (\S+)", output)
return match.group(1) if match else None
if exe:
output = Executable(exe)(output=str, error=str)
match = re.search(r"OpenGL version string: (\S+)", output)
return match.group(1) if match else None
else:
return None
# Override the fetcher method to throw a useful error message;
# fixes GitHub issue (#7061) in which this package threw a
@ -98,20 +84,27 @@ def fetcher(self):
@property
def libs(self):
if "platform=windows" in self.spec:
return find_libraries("opengl32", self.prefix, shared=True, recursive=True)
else:
return find_libraries("libGL", self.prefix, shared=True, recursive=True)
return self.gl_libs
@property
def glx_libs(self):
return find_libraries("libGL",
root=self.spec.prefix,
recursive=True)
def gl_headers(self):
if 'platform=darwin':
header_name = 'OpenGL/gl.h'
else:
header_name = 'GL/gl.h'
return find_headers(header_name,
root=self.prefix,
recursive=True)
@property
def gl_libs(self):
if "platform=windows" in self.spec:
return find_libraries("opengl32", self.prefix, shared=True, recursive=True)
else:
return find_libraries("libGL", self.prefix, shared=True, recursive=True)
spec = self.spec
if 'platform=windows' in spec:
lib_name = 'opengl32'
elif 'platform=darwin' in spec:
lib_name = 'libOpenGL'
else: # linux and cray
lib_name = 'libGL'
return find_libraries(lib_name,
root=self.prefix,
recursive=True)

View file

@ -0,0 +1,38 @@
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.package import *
class Osmesa(BundlePackage):
"""Shim package for the OSMesa OpenGL library."""
homepage = 'https://www.mesa3d.org'
version('11.2.0')
depends_on('libosmesa')
provides('gl@4.5')
@property
def home(self):
return self.spec['libosmesa'].home
@property
def headers(self):
return self.spec['libosmesa'].headers
@property
def libs(self):
return self.spec['libosmesa'].libs
@property
def gl_headers(self):
return find_headers('GL/gl',
root=self.gl_home,
recursive=True)
@property
def gl_libs(self):
return self.spec['libosmesa'].libs

View file

@ -150,10 +150,13 @@ class Paraview(CMakePackage, CudaPackage):
depends_on('qt~opengl', when='@5.3.0:+qt~opengl2')
depends_on('qt@:4', when='@:5.2.0+qt')
depends_on('osmesa', when='+osmesa')
depends_on('gl@3.2:', when='+opengl2')
depends_on('gl@1.2:', when='~opengl2')
depends_on('libxt', when='~osmesa platform=linux')
depends_on('glew')
depends_on('osmesa', when='+osmesa')
for p in ['linux', 'cray']:
depends_on('glx', when='~osmesa platform={}'.format(p))
depends_on('libxt', when='~osmesa platform={}'.format(p))
conflicts('+qt', when='+osmesa')
depends_on('bzip2')
@ -388,7 +391,6 @@ def nvariant_bool(feature):
'-DPARAVIEW_ENABLE_EXAMPLES:BOOL=%s' % variant_bool(
'+examples'),
'-DVTK_MODULE_USE_EXTERNAL_ParaView_cgns=OFF',
'-DVTK_MODULE_USE_EXTERNAL_VTK_glew=OFF',
'-DVTK_MODULE_USE_EXTERNAL_VTK_gl2ps=OFF',
'-DVTK_MODULE_USE_EXTERNAL_VTK_libharu=OFF',
'-DVTK_MODULE_USE_EXTERNAL_VTK_utf8=OFF'])
@ -401,7 +403,6 @@ def nvariant_bool(feature):
'-DVTK_USE_SYSTEM_LIBRARIES:BOOL=ON',
'-DVTK_USE_SYSTEM_CGNS:BOOL=OFF',
'-DVTK_USE_SYSTEM_DIY2:BOOL=OFF',
'-DVTK_USE_SYSTEM_GLEW:BOOL=OFF',
'-DVTK_USE_SYSTEM_GL2PS:BOOL=OFF',
'-DVTK_USE_SYSTEM_ICET:BOOL=OFF',
'-DVTK_USE_SYSTEM_LIBHARU:BOOL=OFF',

View file

@ -52,7 +52,7 @@ class RRgl(RPackage):
def configure_args(self):
args = ['--x-includes=%s' % self.spec['libx11'].prefix.include,
'--x-libraries=%s' % self.spec['libx11'].prefix.lib,
'--with-gl-includes=%s' % self.spec['gl'].prefix.include,
'--with-gl-libraries=%s' % self.spec['gl'].prefix.lib,
'--with-gl-prefix=%s' % self.spec['gl'].prefix]
'--with-gl-includes=%s' % self.spec['gl'].headers.directories[0],
'--with-gl-libraries=%s' % self.spec['gl'].libs.directories[0],
'--with-gl-prefix=%s' % self.spec['gl'].home]
return args

View file

@ -10,19 +10,7 @@
class Visit(CMakePackage):
"""VisIt is an Open Source, interactive, scalable, visualization,
animation and analysis tool. See comments in VisIt's package.py
for tips about building VisIt with spack. Building VisIt with
Spack is still experimental and many standard features are likely
disabled
LINUX-------------------------------------------------------------------
spack install visit ^python+shared ^glib@2.56.3 ^py-setuptools@44.1.0
LINUX-W/O-OPENGL--------------------------------------------------------
spack install visit ^python+shared ^glib@2.56.3 ^py-setuptools@44.1.0 \\
^mesa+opengl
MACOS-------------------------------------------------------------------
spack install visit ^python+shared ^glib@2.56.3 ^py-setuptools@44.1.0 \\
^qt~framework
animation and analysis tool.
"""
############################
# Suggestions for building:
@ -92,97 +80,12 @@ class Visit(CMakePackage):
patch('parallel-hdf5.patch', when='@3.0.1:3.2.2+hdf5+mpi')
patch('parallel-hdf5-3.3.patch', when='@3.3.0:+hdf5+mpi')
# Fix pthread and librt link errors
patch('visit32-missing-link-libs.patch', when='@3.2')
# Exactly one of 'gui' or 'osmesa' has to be enabled
conflicts('+gui', when='+osmesa')
#############################################
# Full List of dependencies from build_visit
#############################################
# cyrush note:
# I added these here to give folks details
# to help eventually build up to full
# support for visit
#############################################
# =====================================
# core:
# =====================================
# cmake (build)
# vtk
# qt
# qwt
# python
# mpi
#
# =====================================
# rendering (optional):
# =====================================
# icet
# vtk-m
# vtk-h
# llvm
# mesagl
# osmesa
# tbb
# embree
# ispc
# ospray
#
# =====================================
# python modules:
# =====================================
# numpy
# pillow
# mpi4py
# seedme
# sphinx (build, docs)
# sphinx rtd theme (build, docs)
# pyqt (visit support deprecated)
# pyside (note: we want pyside 2)
#
# =====================================
# testing related:
# =====================================
# p7zip (build, test)
#
# =====================================
# io libs:
# =====================================
# adios
# adios2
# advio
# boost
# boxlib
# cfitsio
# cgns
# conduit
# damaris
# fastbit
# fastquery
# gdal
# h5part
# hdf4
# hdf5
# mdsplus
# mfem
# mili
# moab
# mxml
# nektarpp
# netcdf
# openexr
# pidx
# silo
# stripack
# szip
# tbb
# uintah
# xdmf
# xercesc
# xsd
# zlib
#
# =====================================
depends_on('cmake@3.14.7:', type='build')
depends_on('ninja', type='build')
@ -197,14 +100,14 @@ class Visit(CMakePackage):
depends_on('vtk ~mpi', when='~mpi')
# Necessary VTK patches
depends_on('vtk', patches=[patch('vtk_compiler_visibility.patch')])
depends_on('vtk', patches=[patch('vtk_compiler_visibility.patch')],
when='^vtk@8')
depends_on('vtk', patches=[patch('vtk_rendering_opengl2_x11.patch')],
when='~osmesa platform=linux')
when='~osmesa platform=linux ^vtk@8')
depends_on('vtk', patches=[patch('vtk_wrapping_python_x11.patch')],
when='+python')
when='+python ^vtk@8')
depends_on('glu', when='~osmesa')
depends_on('mesa-glu+osmesa', when='+osmesa')
depends_on('glu')
# VisIt doesn't work with later versions of qt.
depends_on('qt+gui+opengl@5:5.14', when='+gui')
@ -258,12 +161,18 @@ def flag_handler(self, name, flags):
if '+hdf5' in self.spec and '@1.10:' in self.spec['hdf5']:
flags.append('-DH5_USE_18_API')
elif name == 'ldlibs':
# Python support is missing a pthread dependency
if '@3 +python' in self.spec:
flags.append('-lpthread')
return (flags, None, None)
def cmake_args(self):
spec = self.spec
args = [
self.define('CMAKE_SKIP_COMPATIBILITY_TESTS', True),
self.define('CMAKE_POSITION_INDEPENDENT_CODE', True),
self.define('VTK_MAJOR_VERSION', spec['vtk'].version[0]),
self.define('VTK_MINOR_VERSION', spec['vtk'].version[1]),
@ -271,7 +180,7 @@ def cmake_args(self):
self.define('VISIT_ZLIB_DIR', spec['zlib'].prefix),
self.define('VISIT_USE_GLEW', False),
self.define('VISIT_CONFIG_SITE', 'NONE'),
self.define('VISIT_INSTALL_THIRD_PARTY', True),
self.define('VISIT_INSTALL_THIRD_PARTY', False),
]
if '@3.1: platform=darwin' in spec:
@ -305,14 +214,27 @@ def cmake_args(self):
self.define('VISIT_ENGINE_ONLY', True),
])
# No idea why this is actually needed
if '^mesa' in spec:
args.append(self.define('VISIT_MESAGL_DIR', spec['mesa'].prefix))
if '+llvm' in spec['mesa']:
args.append(self.define('VISIT_LLVM_DIR', spec['libllvm'].prefix))
# OpenGL args
args.extend([
self.define('VISIT_USE_X', 'glx' in spec),
self.define('VISIT_MESAGL_DIR', 'IGNORE'),
self.define('VISIT_OPENGL_DIR', 'IGNORE'),
self.define('VISIT_OSMESA_DIR', 'IGNORE'),
self.define('OpenGL_GL_PREFERENCE', 'LEGACY'),
self.define('OPENGL_INCLUDE_DIR', spec['gl'].headers.directories[0]),
self.define('OPENGL_glu_LIBRARY', spec['glu'].libs[0]),
])
if '+osmesa' in spec:
args.extend([
self.define('HAVE_OSMESA', True),
self.define('OSMESA_LIBRARIES', spec['osmesa'].libs[0]),
self.define('OPENGL_gl_LIBRARY', spec['osmesa'].libs[0]),
])
else:
args.append(self.define('OPENGL_gl_LIBRARY', spec['gl'].libs[0]))
if '+hdf5' in spec:
args.append(self.define('VISIT_HDF5_DIR', spec['hdf5'].prefix))
args.append(self.define('HDF5_DIR', spec['hdf5'].prefix))
if '+mpi' in spec and '+mpi' in spec['hdf5']:
args.append(self.define('VISIT_HDF5_MPI_DIR', spec['hdf5'].prefix))

View file

@ -0,0 +1,36 @@
diff --git a/src/avt/Queries/CMakeLists.txt b/src/avt/Queries/CMakeLists.txt
index 162ed1c439..7ddd0a7144 100644
--- a/src/avt/Queries/CMakeLists.txt
+++ b/src/avt/Queries/CMakeLists.txt
@@ -210,6 +210,9 @@ ENDIF(VISIT_PYTHON_FILTERS)
#********************************* SERIAL ************************************
ADD_LIBRARY(avtquery_ser ${AVTQUERY_SOURCES})
TARGET_LINK_LIBRARIES(avtquery_ser visitcommon avtmath avtshapelets avtexpressions_ser avtfilters_ser visit_vtk)
+IF(CMAKE_SYSTEM_NAME MATCHES Linux)
+ TARGET_LINK_LIBRARIES(avtquery_ser rt)
+ENDIF(CMAKE_SYSTEM_NAME MATCHES Linux)
IF(VISIT_PYTHON_FILTERS)
TARGET_LINK_LIBRARIES(avtquery_ser avtpythonfilters_ser)
ENDIF(VISIT_PYTHON_FILTERS)
@@ -219,6 +222,9 @@ VISIT_INSTALL_TARGETS(avtquery_ser)
IF(VISIT_PARALLEL)
ADD_PARALLEL_LIBRARY(avtquery_par ${AVTQUERY_SOURCES})
TARGET_LINK_LIBRARIES(avtquery_par visitcommon avtmath avtshapelets avtexpressions_par avtfilters_par visit_vtk)
+ IF(CMAKE_SYSTEM_NAME MATCHES Linux)
+ TARGET_LINK_LIBRARIES(avtquery_ser rt)
+ ENDIF(CMAKE_SYSTEM_NAME MATCHES Linux)
IF(VISIT_PYTHON_FILTERS)
TARGET_LINK_LIBRARIES(avtquery_par avtpythonfilters_par)
ENDIF(VISIT_PYTHON_FILTERS)
diff --git a/src/visitpy/CMakeLists.txt b/src/visitpy/CMakeLists.txt
index 06f31ce1da..e5083d8087 100644
--- a/src/visitpy/CMakeLists.txt
+++ b/src/visitpy/CMakeLists.txt
@@ -385,6 +385,7 @@ avtdbatts
viewerrpc
visitcommon
${PYTHON_LIBRARIES}
+${CMAKE_THREAD_LIBS}
)
# Create the CLI

View file

@ -5,7 +5,6 @@
import os
import sys
from spack.package import *
from spack.pkg.builtin.boost import Boost
@ -48,12 +47,12 @@ class Vtk(CMakePackage):
patch('gcc.patch', when='@6.1.0')
# patch to fix some missing stl includes
# which lead to build errors on newer compilers
# version range to be updated once the linked patch is released
patch('https://gitlab.kitware.com/vtk/vtk/-/commit/e066c3f4fbbfe7470c6207db0fc3f3952db633c.diff',
when="@9:", sha256='0546696bd02f3a99fccb9b7c49533377bf8179df16d901cefe5abf251173716d')
# We cannot build with both osmesa and qt prior to VTK 8.1
conflicts('+osmesa', when='@:8.0 +qt')
patch('https://gitlab.kitware.com/vtk/vtk/-/commit/e066c3f4fbbfe7470c6207db0fc3f3952db633c.diff',
when="@9:9.0", sha256='0546696bd02f3a99fccb9b7c49533377bf8179df16d901cefe5abf251173716d')
# We cannot build with both osmesa and qt in spack
conflicts('+osmesa', when='+qt')
extends('python', when='+python')
@ -87,12 +86,12 @@ class Vtk(CMakePackage):
depends_on('gl@3.2:', when='+opengl2')
depends_on('gl@1.2:', when='~opengl2')
if sys.platform != 'darwin':
depends_on('glx', when='~osmesa')
depends_on('libxt', when='~osmesa')
with when('~osmesa'):
depends_on('glx', when='platform=linux')
depends_on('glx', when='platform=cray')
depends_on('libxt', when='platform=linux')
depends_on('libxt', when='platform=cray')
# Note: it is recommended to use mesa+llvm, if possible.
# mesa default is software rendering, llvm makes it faster
depends_on('osmesa', when='+osmesa')
# VTK will need Qt5OpenGL, and qt needs '-opengl' for that
@ -236,7 +235,7 @@ def cmake_args(self):
'-DVTK_USE_MPI=ON'
])
else:
'-DVTK_USE_MPI=OFF'
cmake_args.append('-DVTK_USE_MPI=OFF')
if '+ffmpeg' in spec:
if spec.satisfies('@:8'):
@ -337,9 +336,6 @@ def cmake_args(self):
cmake_args.append('-DVTK_RENDERING_BACKEND:STRING=' + opengl_ver)
if spec.satisfies('@:8.1.0') and '+osmesa' not in spec:
cmake_args.append('-DVTK_USE_SYSTEM_GLEW:BOOL=ON')
if '+osmesa' in spec:
cmake_args.extend([
'-DVTK_USE_X:BOOL=OFF',
@ -352,12 +348,12 @@ def cmake_args(self):
# This option is gone in VTK 8.1.2
cmake_args.append('-DOpenGL_GL_PREFERENCE:STRING=LEGACY')
if 'darwin' in spec.architecture:
if 'platform=darwin' in spec:
cmake_args.extend([
'-DVTK_USE_X:BOOL=OFF',
'-DVTK_USE_COCOA:BOOL=ON'])
elif 'linux' in spec.architecture:
elif 'platform=linux' in spec:
cmake_args.extend([
'-DVTK_USE_X:BOOL=ON',
'-DVTK_USE_COCOA:BOOL=OFF'])