Many projects (e.g., fontconfig, cairo) hardcode the `freetype_dep`
variable name to use FreeType as subproject because that was the
variable name in Centricular's Meson port of FreeType. While they
should stop hardcoding that variable name, it does not cost us
anything to keep using that name to ease transition.
* meson.build (harfbuzz_dep): Do not fall back to HarfBuzz by
default.
Otherwise it causes a dependency cycle:
cairo => fontconfig => freetype2 => harfbuzz => cairo
Meson will still fall back to HarfBuzz subprojects if the `harfbuzz`
option is set to `enabled` instead of `auto` and a
`subprojects/harfbuzz.wrap` file is present. In that case it is the
responsibility of the main project to set the proper options on each
subproject to break the dependency cycle.
Fixes: #1028.
[meson] Fix dependency lookup and generate `ftconfig.h`.
- zlib: If not found on the system, meson can build it as a
subproject. We thus never use the (outdated) zlib support that
comes with FreeType. Doing so has the additional advantage that
the zlib code can be shared with other projects like GLib if both
are subprojects of an application.
- harfbuzz: Build as a subproject if not found on the system.
- 'QUESTION: What if the compiler doesn't support `-D` but uses `/D`
instead as on Windows?' Answer: Meson translate arguments for us.
- visibility: Replace self-made code with meson-specific solution.
* meson.build (ft2_defines): Rewrite logic to set and handle it.
(process_header_command): New variable, previously called
`ftoption_command`.
(ftoption_command, ftconfig_command): New variables.
(zlib_option): Removed.
(zlib_dep): New variable.
(ft2_deps): Updated.
(harfbuzz_dep): Updated.
(ftconfig_h_in, ftconfig_h): New variables.
(ft2_sources): Updated.
(ft2_lib): Updated, handle visibility.
(summary): Updted.
* meson_options.txt (zlib): Updated.
This is copied from GStreamer's meson port of FreeType.
(ft2_sources): Add both debug and resource file (the latter for
Windows only).
(ft2_debug_src): Removed.
This is a new meson mechanism to avoid other projects to hard-code
the `freetype2_dep` variable name in their build definition. It
also ensures that meson does not mix system and subproject versions
of FreeType inside of the same project.
Also remove outdated TODO because `declare_dependency` was already
there.
We remove `static:false` from `find_library('bz2')`.
I don't know whether the previous code was a workaround for an old
meson bug, but at least with version >=0.55.0 (which FreeType uses)
it picks the shared library when both are available.
With this commit, file `freetype2.pc` no longer contains the full path to
file `libbz2.so`; instead, it correctly uses `-lbz2`. Note that this is a
meson bug is still present in the current version (0.57.0).
This is needed to make commit f1f9705f9 work.
* CMakeLists.txt (HARFBUZZ_MIN_VERSION), builds/unix/configure.raw
(harfbuzz_pkg), meson.build (harfbuzz_dep): Updated.
Example usage:
# Configure Meson build in directory `build-meson` to generate
# release binaries comparable to to the ones from the
# autotools/make build system.
meson setup build-meson \
--prefix=/usr/local \
--buildtype=debugoptimized \
--strip \
-Db_ndebug=true
# After configuring the Meson build with the above command,
# compile and install to `/usr/local/`; this includes a pkg-config
# file.
ninja -C build-meson install
# Alternatively, compile and install to `/tmp/aa/usr/local/...`
# for packaging.
DESTDIR=/tmp/aa ninja -C build-meson install
# Generate documentation under `build-meson/docs`.
ninja -C build-meson docs
Library size comparison for stripped `libfreetype.so` generated by
all three build systems:
- Default build (autotools + libtool): 712 KiB
- CMake build (RelWithDebInfo): 712 KiB
- Meson build: 712 KiB
* meson.build: New top-level Meson build file for the library.
* meson_options.txt: New file. It holds user-selectable options for
the build, which can be printed with `meson configure`, and selected
at `meson setup` or `meson --reconfigure` time with
`-D<option>=<value>`.
* scripts/parse_modules_cfg.py: A script invoked by `meson.build` to
parse `modules.cfg` and extract important information out of it
(i.e., the list of modules).
* scripts/process_ftoption_h.py: New script invoked by `meson.build`
to process the original `ftoption.h` file. It enables or disables
configuration macro variables based on the available dependencies.
This is similar to what other build systems are using (i.e., Meson's
`configure_file()` command is not used here).
* scripts/extract_freetype_version.py: New script invoked by
`meson.build` to extract the FreeType version number from
`<freetype/freetype.h>`.
* scripts/extract_libtool_version.py: New script invoked by
`meson.build` to extract the libtool `revision_info` data from
`builds/unix/configure.raw`, and to generate the corresponding
shared library suffix.
* scripts/generate_reference_docs.py: New script invoked by
`meson.build` to generate the FreeType 2 reference documentation
(using the `docwriter` and `mkdocs` packages, which must be already
installed).