[gjs/meson.msvc: 2/8] meson.build: Look for Cairo manually on MSVC builds



commit 5cf4cdd568cef8189a4e537c170b60a77575f7c7
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Fri Oct 25 12:27:51 2019 +0800

    meson.build: Look for Cairo manually on MSVC builds
    
    ...if necessary, as the MSVC build files for Cairo do not generate
    pkg-config files for us.
    
    Note that we do not check for cairo-xlib here since cairo-xlib is likely
    not ever going to be usable on Windows in a native manner.
    
    Also ensure that we add the dependencies into Gjs's pkg-config file
    properly as a result.

 meson.build | 47 ++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 44 insertions(+), 3 deletions(-)
---
diff --git a/meson.build b/meson.build
index 1a4f9571..fe4b21e0 100644
--- a/meson.build
+++ b/meson.build
@@ -113,9 +113,39 @@ ffi = dependency('libffi', fallback: ['libffi', 'ffi_dep'])
 gi = dependency('gobject-introspection-1.0', version: '>= 1.61.2',
     fallback: ['gobject-introspection', 'girepo_dep'])
 spidermonkey = dependency('mozjs-60')
-cairo = dependency('cairo', required: get_option('cairo'))
-cairo_gobject = dependency('cairo-gobject', required: cairo.found())
+
+# We might need to look for the headers and lib's for Cairo
+# manually on MSVC builds...
+cairo = dependency('cairo', required: get_option('cairo').enabled() and cxx.get_id() != 'msvc')
+cairo_gobject = dependency('cairo-gobject', required: cairo.found() and cxx.get_id() != 'msvc')
 cairo_xlib = dependency('cairo-xlib', required: false)
+
+# Cairo's MSVC build files do not generate pkg-config files
+# for us, so look for them manually if they are not found
+if cairo.found()
+    cairo_found_type = 'pkg'
+endif
+if cairo_gobject.found()
+    cairo_gobject_found_type = 'pkg'
+endif
+
+if cxx.get_id() == 'msvc'
+    if not cairo.found()
+        assert(cc.has_header('cairo.h') or not get_option('cairo').enabled(), 'Cairo headers are required 
when enabling \'cairo\'')
+        cairo = cc.find_library('cairo', required: get_option('cairo'))
+        if cairo.found()
+            cairo_found_type = 'manual'
+        endif
+    endif
+    if not cairo_gobject.found()
+        assert(cc.has_header('cairo-gobject.h') or not cairo.found(), 'Cairo-GObject headers are required 
when Cairo support is being built')
+        cairo_gobject = cc.find_library('cairo-gobject', required: cairo.found())
+        if cairo_gobject.found()
+            cairo_gobject_found_type = 'manual'
+        endif
+    endif
+endif
+
 sysprof_capture = dependency('sysprof-capture-3', version: '>= 3.33.32',
     required: get_option('profiler'),
     fallback: ['sysprof', 'libsysprof_capture_dep'])
@@ -427,11 +457,21 @@ module_resource_srcs = gnome.compile_resources('modules-resources',
 libgjs_dependencies = [glib, gobject, gthread, gio, gi, ffi, spidermonkey,
     readline]
 pkg_dependencies = [glib, gobject, gthread, gio, gi, ffi, spidermonkey]
+libraries_private = []
 
 if build_cairo
     libgjs_sources += module_cairo_srcs
     libgjs_dependencies += [cairo, cairo_gobject]
-    pkg_dependencies += [cairo, cairo_gobject]
+    if cairo_found_type == 'pkg'
+        pkg_dependencies += [cairo]
+    elif cairo_found_type == 'manual'
+        libraries_private += [cairo]
+    endif
+    if cairo_gobject_found_type == 'pkg'
+        pkg_dependencies += [cairo_gobject]
+    elif cairo_gobject_found_type == 'manual'
+        libraries_private += [cairo_gobject]
+    endif
     if cairo_xlib.found()
         libgjs_dependencies += cairo_xlib
         pkg_dependencies += cairo_xlib
@@ -518,6 +558,7 @@ endif
 
 pkg.generate(libgjs, name: api_name, description: 'JS bindings for GObjects',
     requires: [glib, gobject, gio], requires_private: pkg_dependencies,
+    libraries_private: libraries_private,
     subdirs: api_name,
     variables: [
         'exec_prefix=${prefix}',


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