[pangomm/master.msvc-meson.improvements] meson.build: Look for libsigc++ with pkg-config on MSVC too



commit c369646334e64e29763d05c34208e02ef3513b54
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Sat Feb 22 11:11:05 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 | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)
---
diff --git a/meson.build b/meson.build
index 120e0a4..7b3b5a5 100644
--- a/meson.build
+++ b/meson.build
@@ -95,8 +95,17 @@ if is_msvc
   # We must have Visual Studio 2017 15.7 or later...
   assert(cpp_compiler.version().split('.')[0].to_int() >= 19 and 
cpp_compiler.version().split('.')[1].to_int() >= 15, 'Visual Studio 2017 15.7 or later is required')
 
-  assert(cpp_compiler.has_header('sigc++-3.0/sigc++/sigc++.h') and 
cpp_compiler.has_header('sigc++-3.0/include/sigc++config.h'),
-         'sigc++-3.x headers are required')
+  # Before glibmm or cairomm gains Meson build support, look for sigc first using
+  # pkg-config and look for it manually if pkg-config cannot find it
+  sigc_maj_ver = '3'
+  sigcxx_req = '>= @0@.0.0'.format(sigc_maj_ver)
+  sigc_dep = dependency('sigc++-@0@.0'.format(sigc_maj_ver), version: sigcxx_req, required: false)
+
+  if not sigc_dep.found()
+    assert(cpp_compiler.has_header('sigc++-@0@.0/sigc++/sigc++.h'.format(sigc_maj_ver)) and 
cpp_compiler.has_header('sigc++-@0@.0/include/sigc++config.h'.format(sigc_maj_ver)),
+           'sigc++-@0@.x headers are required'.format(sigc_maj_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)),
@@ -121,7 +130,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)
@@ -130,9 +138,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@-3_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++-@3@.x .lib are required'.format(debugsuffix, 
glibmm_req_minor_ver, cairomm_req_minor_ver, sigc_maj_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_maj_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]