[pangomm/pangomm-2-42.meson-msvc: 1/3] meson.build: Look for libsigc++ with pkg-config on MSVC too



commit d9aea4e69b134c5531c4044bdf5068b4180dcef3
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Thu Feb 27 10:42:37 2020 +0800

    meson.build: Look for libsigc++ with pkg-config on MSVC too
    
    libsigc++ gained Meson build support for Visual Studio, so we can first
    try to look for libsigc++ with pkg-config first, and then fall back to
    manual searching if that cannot be found.
    
    This will eventually be replaced when glibmm and/or cairomm gains Meson
    build support, since Meson support in cairomm and glibmm will cover this
    part.

 meson.build | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/meson.build b/meson.build
index 5b1c3e4..3a86590 100644
--- a/meson.build
+++ b/meson.build
@@ -95,8 +95,13 @@ if is_msvc
   # We must have Visual Studio 2013 or later...
   assert(cpp_compiler.version().split('.')[0].to_int() >= 18, 'Visual Studio 2013 or later is required')
 
-  assert(cpp_compiler.has_header('sigc++-2.0/sigc++/sigc++.h') and 
cpp_compiler.has_header('sigc++-2.0/include/sigc++config.h'),
-         'sigc++-2.x headers are required')
+  sigc_major_ver = '2'
+  sigcxx_req = '>=@0@.10.0'.format(sigc_major_ver)
+  sigc_dep = dependency('sigc++-@0@.0'.format(sigc_major_ver), required: false)
+  if not sigc_dep.found()
+    assert(cpp_compiler.has_header('sigc++-@0@.0/sigc++/sigc++.h'.format(sigc_major_ver)) and 
cpp_compiler.has_header('sigc++-@0@.0/include/sigc++config.h'.format(sigc_major_ver)),
+           'sigc++-@0@.x headers are required'.format(sigc_major_ver))
+  endif
   assert(cpp_compiler.has_header('glibmm-2.@0@/glibmm.h'.format(glibmm_req_minor_ver)) and 
cpp_compiler.has_header('glibmm-2.@0@/include/glibmmconfig.h'.format(glibmm_req_minor_ver)),
          'glibmm-2.@0@ headers are required'.format(glibmm_req_minor_ver))
   assert(cpp_compiler.has_header('cairomm-1.@0@/cairomm/cairomm.h'.format(cairomm_req_minor_ver)) and 
cpp_compiler.has_header('cairomm-1.@0@/include/cairommconfig.h'.format(cairomm_req_minor_ver)),
@@ -126,7 +131,6 @@ if is_msvc
   # versions are really found
   glibmm_dep = dependency('', required: false)
   cairomm_dep = dependency('', required: false)
-  sigc_dep = dependency('', required: false)
 
   foreach v : msvc_check_range
     glibmm_dep = glibmm_dep.found() ? glibmm_dep : 
cpp_compiler.find_library('glibmm-vc@0@0@1@-2_@2@'.format(v.to_string(), debugsuffix, glibmm_req_minor_ver), 
required: false)
@@ -135,9 +139,19 @@ if is_msvc
   endforeach
 
   # Now make sure the appropriate -mm libraries are found
-  assert(glibmm_dep.found() and cairomm_dep.found() and sigc_dep.found(), 'Appropriate 
glibmm-vcxx0@0@-2_@1@.lib, cairomm-vcxx0@0@-1_@2@.lib and sigc-vcxx0@0@-2_0.lib are 
required'.format(debugsuffix, glibmm_req_minor_ver, cairomm_req_minor_ver))
+  assert(glibmm_dep.found() and cairomm_dep.found() and sigc_dep.found(), 'Appropriate 
glibmm-vcxx0@0@-2_@1@.lib, cairomm-vcxx0@0@-1_@2@.lib and sigc-vcxx0@0@-@3@_0.lib are 
required'.format(debugsuffix, glibmm_req_minor_ver, cairomm_req_minor_ver, sigc_major_ver))
+
+  # Put libsigc++ in the required packages if we find it by pkg-config, for now
+  # When glibmm and cairomm gains Meson build support, we can replace
+  # this with what is done on other build systems.
+  mm_lib_requires = ''
+  if sigc_dep.type_name() == 'pkgconfig'
+    mm_lib_requires += ' '.join([
+      'sigc++-@0@.0'.format(sigc_major_ver), sigcxx_req,
+    ]) + ' '
+  endif
 
-  pangomm_requires = ' '.join([
+  pangomm_requires = mm_lib_requires + ' '.join([
     'pangocairo', pangocairo_req,
   ])
 


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