Repository: spack/spack

Issue:
Installation issue: vtk - 'vtkFreeTypeToolsFaceRequester' was not declared in this scope
I am encountering some odd errors like
.../spack-src/Rendering/FreeType/vtkFreeTypeTools.cxx:1251:26: error: 'vtkFreeTypeToolsFaceRequester' was not declared in this scope

when attempting to compile vtk with freetype@2.10.4 as a dependency.

In a web search of the error message, I encountered https://gitlab.kitware.com/vtk/vtk/-/issues/18033
which seems to match the situation I  am experiencing, and claims the issue is due to freetype@2.10.3: no longer exporting FT_CALLBACK_DEF.  The commentor provided patches to either:

1. update the vtk code to not use FT_CALLBACK_DEF, --or--
2. define FT_CALLBACK_DEF in vtk

### Steps to reproduce the issue

```console
$ spack install  vtk@8.1.2%gcc +ffmpeg+ipo+mpi+opengl2~osmesa+python+qt+xdmf build_type=RelWithDebInfo ^freetype@2.10.4
...
/lustre/jn10/devspackswinst/spack-stage/spack-stage-vtk-8.1.2-d72ko7o34eumc5di5tk37h3btbxkqfr5/spack-src/Rendering/FreeType/vtkFreeTypeTools.cxx:390:1: error: expected constructor, destructor, or type conversion before 'vtkFreeTypeToolsFaceRequester'
 vtkFreeTypeToolsFaceRequester(FTC_FaceID face_id,
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/lustre/jn10/devspackswinst/spack-stage/spack-stage-vtk-8.1.2-d72ko7o34eumc5di5tk37h3btbxkqfr5/spack-src/Rendering/FreeType/vtkFreeTypeTools.cxx: In member function 'virtual FT_Error vtkFreeTypeTools::CreateFTCManager()':
/lustre/jn10/devspackswinst/spack-stage/spack-stage-vtk-8.1.2-d72ko7o34eumc5di5tk37h3btbxkqfr5/spack-src/Rendering/FreeType/vtkFreeTypeTools.cxx:1251:26: error: 'vtkFreeTypeToolsFaceRequester' was not declared in this scope
                          vtkFreeTypeToolsFaceRequester,
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/lustre/jn10/devspackswinst/spack-stage/spack-stage-vtk-8.1.2-d72ko7o34eumc5di5tk37h3btbxkqfr5/spack-src/Rendering/FreeType/vtkFreeTypeTools.cxx:1251:26: note: suggested alternative: 'vtkFreeTypeToolsCleanupCounter'
                          vtkFreeTypeToolsFaceRequester,
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                          vtkFreeTypeToolsCleanupCounter
```

### Information on your system
```console
> spack debug report
* **Spack:** 0.16.1-2429-f5e6c32495
* **Python:** 3.6.8
* **Platform:** linux-rhel8-x86_64
* **Concretizer:** original
```

### Additional information

<!-- Please upload the following files. They should be present in the stage directory of the failing build. Also upload any config.log or similar file if one exists. -->
* [spack-build-env.txt](https://github.com/spack/spack/files/6632148/spack-build-env.txt)
* [spack-build-out.txt](https://github.com/spack/spack/files/6632149/spack-build-out.txt)

Maintainers: @chuckatkins  @danlipsa

### General information

- [x ] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [ x] I have run `spack maintainers <name-of-the-package>` and @mentioned any maintainers
- [ x] I have uploaded the build log and environment files
- [x ] I have searched the issues of this repo and believe this is not a duplicate



Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/vtk/package.py b/var/spack/repos/builtin/packages/vtk/package.py
--- a/var/spack/repos/builtin/packages/vtk/package.py
+++ b/var/spack/repos/builtin/packages/vtk/package.py
@@ -109,6 +109,12 @@ class Vtk(CMakePackage):
 
     # For finding Fujitsu-MPI wrapper commands
     patch('find_fujitsu_mpi.patch', when='@:8.2.0%fj')
+    # Freetype@2.10.3 no longer exports FT_CALLBACK_DEF, this
+    # patch replaces FT_CALLBACK_DEF with simple extern "C"
+    # See https://gitlab.kitware.com/vtk/vtk/-/issues/18033
+    patch('https://gitlab.kitware.com/vtk/vtk/uploads/c6fa799a1a028b8f8a728a40d26d3fec/vtk-freetype-2.10.3-replace-FT_CALLBACK_DEF.patch',
+          sha256='eefda851f844e8a1dfb4ebd8a9ff92d2b78efc57f205774052c5f4c049cc886a',
+          when='^freetype@2.10.3:')
 
     def url_for_version(self, version):
         url = "http://www.vtk.org/files/release/{0}/VTK-{1}.tar.gz"


Test patch: