freetype: add CMake support (#35107)

This commit is contained in:
John W. Parent 2023-01-28 13:32:17 -05:00 committed by GitHub
parent 57d6b70226
commit 28c4809a8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,10 +3,12 @@
# #
# SPDX-License-Identifier: (Apache-2.0 OR MIT) # SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.build_systems.autotools import AutotoolsBuilder
from spack.build_systems.cmake import CMakeBuilder
from spack.package import * from spack.package import *
class Freetype(AutotoolsPackage): class Freetype(AutotoolsPackage, CMakePackage):
"""FreeType is a freely available software library to render fonts. """FreeType is a freely available software library to render fonts.
It is written in C, designed to be small, efficient, highly customizable, It is written in C, designed to be small, efficient, highly customizable,
and portable while capable of producing high-quality output (glyph images) and portable while capable of producing high-quality output (glyph images)
@ -28,9 +30,12 @@ class Freetype(AutotoolsPackage):
version("2.7", sha256="7b657d5f872b0ab56461f3bd310bd1c5ec64619bd15f0d8e08282d494d9cfea4") version("2.7", sha256="7b657d5f872b0ab56461f3bd310bd1c5ec64619bd15f0d8e08282d494d9cfea4")
version("2.5.3", sha256="41217f800d3f40d78ef4eb99d6a35fd85235b64f81bc56e4812d7672fca7b806") version("2.5.3", sha256="41217f800d3f40d78ef4eb99d6a35fd85235b64f81bc56e4812d7672fca7b806")
build_system("cmake", "autotools", default="autotools")
depends_on("bzip2") depends_on("bzip2")
depends_on("libpng") depends_on("libpng")
depends_on("pkgconfig", type="build") for plat in ["linux", "darwin", "cray"]:
depends_on("pkgconfig", type="build", when="platform=%s" % plat)
conflicts( conflicts(
"%intel", "%intel",
@ -47,6 +52,8 @@ def headers(self):
headers.directories = [self.prefix.include.freetype2] headers.directories = [self.prefix.include.freetype2]
return headers return headers
class AutotoolsBuilder(AutotoolsBuilder):
def configure_args(self): def configure_args(self):
args = [ args = [
"--with-brotli=no", "--with-brotli=no",
@ -58,3 +65,14 @@ def configure_args(self):
if self.spec.satisfies("@2.9.1:"): if self.spec.satisfies("@2.9.1:"):
args.append("--enable-freetype-config") args.append("--enable-freetype-config")
return args return args
class CMakeBuilder(CMakeBuilder):
def cmake_args(self):
return [
self.define("FT_DISABLE_ZLIB", True),
self.define("FT_DISABLE_BROTLI", True),
self.define("FT_DISABLE_HARFBUZZ", True),
self.define("FT_REQUIRE_PNG", True),
self.define("FT_REQUIRE_BZIP2", True),
]