[pango/meson-msvc-cleanup: 3/3] meson: Clean up FreeType search




commit afdf144ae84fd67ad773799a93407214e5cc2261
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Feb 21 18:58:25 2022 +0800

    meson: Clean up FreeType search
    
    Use CMake's built-in support to look for FreeType2 on Visual Studio-like
    builds, by using the 'freetype' package name, since it is what CMake expects.
    This cleans the Meson build files a bit and CMake would do more comprehensive
    work to help us find FreeType.

 meson.build | 30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)
---
diff --git a/meson.build b/meson.build
index 88a13733..35464c2a 100644
--- a/meson.build
+++ b/meson.build
@@ -336,29 +336,17 @@ if not freetype_option.disabled() or freetype_required
   freetype_option = false
 endif
 
-# The first version of freetype with a pkg-config file is 2.1.5
-freetype_dep = dependency('freetype2', required: freetype_option)
+# The first version of freetype with a pkg-config file is 2.1.5,
+# CMake uses 'freetype' rather than 'freetype2' for the package name
+freetype_package_name = cc.get_argument_syntax() == 'msvc' ? \
+                        'freetype' : 'freetype2'
 
-if freetype_dep.found()
-  freetype2_pc = 'freetype2'
-else
-  if cc.get_id() == 'msvc' and cc.has_header('ft2build.h')
-    foreach ft2_lib: ['freetype', 'freetypemt']
-      if not freetype_dep.found()
-        freetype_dep = cc.find_library(ft2_lib, required: freetype_option)
-        if freetype_dep.found()
-          freetype2_lib = '-l@0@'.format(ft2_lib)
-        endif
-      endif
-    endforeach
-  endif
-endif
+freetype_dep = dependency(freetype_package_name,
+                          required: freetype_option,
+                          fallback: ['freetype2', 'freetype_dep'])
 
-# Do the fallback now if freetype2 has not been found on the system.
-freetype_option = freetype_required ? true : get_option('freetype')
-if not freetype_dep.found()
-  freetype_dep = dependency('freetype2', required: freetype_option,
-                            fallback: ['freetype2', 'freetype_dep'])
+if freetype_dep.found() and freetype_dep.type_name() == 'pkgconfig'
+  freetype2_pc = 'freetype2'
 endif
 
 # To build pangoft2, we need HarfBuzz, FontConfig and FreeType


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]