[pangomm/pangomm-2-42.meson-msvc: 9/10] meson.build: Look for glibmm with pkg-config on MSVC too



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

    meson.build: Look for glibmm with pkg-config on MSVC too
    
    glibmm gained Meson build support for Visual Studio, so we can first
    try to look for glibmm with pkg-config first, and then fall back to
    manual searching if that cannot be found.
    
    Note that libsigc++ also has a Meson build system as well, but either we
    look for it via glibmm's pkg-config files, or we look for both glibmm
    and libsigc++ manually.
    
    Also support looking for Meson-built libsigc++ .lib's as well if glibmm
    is to be looked for manually.

 meson.build | 51 ++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 38 insertions(+), 13 deletions(-)
---
diff --git a/meson.build b/meson.build
index f93f8da..357784f 100644
--- a/meson.build
+++ b/meson.build
@@ -77,6 +77,10 @@ install_pkgconfigdir = install_libdir / 'pkgconfig'
 # pangomm_dep (created in pango/pangomm/meson.build):
 #   Dependencies when using the pangomm library.
 
+# glibmm recently gained Meson build support, so we can try looking
+# for its pkg-config files on Visual Studio as well
+glibmm_req = '>= 2.48.0'
+
 # Pango supported pkg-config files on MSVC files for a good while,
 # so just use that
 pangocairo_req = '>= 1.41.0'
@@ -91,10 +95,17 @@ 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')
-  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))
+  sigc_major_ver = '2'
+
+  glibmm_dep = dependency('glibmm-2.@0@'.format(glibmm_req_minor_ver), required: false, version: glibmm_req)
+  if not glibmm_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))
+    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))
+  else
+    sigc_dep = dependency('', required: false) # glibmm covers for libsigc++ in its pkg-config file
+  endif
   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)),
          'cairomm-1.@0@ headers are required'.format(cairomm_req_minor_ver))
   message('Ensure your INCLUDE and LIB contain the paths that lead to the appropriate headers and .lib\'s 
for glibmm-2.@0@, cairomm-1.@1@ and libsigc++-2.x'.format(glibmm_req_minor_ver, cairomm_req_minor_ver))
@@ -117,29 +128,43 @@ if is_msvc
     debugsuffix = '-d'
   endif
 
-  # We can be looking for MSVC 2017-built libraries on 2019 builds as well,
-  # so we can't just assume that libraries exist, but check that compatible
-  # versions are really found
-  glibmm_dep = dependency('', required: false)
+  # We can be looking for MSVC 2015-built libraries on 2017 and 2019 builds as well,
+  # as well as 2017-built libraries on 2019 as well, so we can't just assume that
+  # libraries exist, but check that compatible versions are really found
   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)
     cairomm_dep = cairomm_dep.found() ? cairomm_dep : 
cpp_compiler.find_library('cairomm-vc@0@0@1@-1_@2@'.format(v.to_string(), debugsuffix, 
cairomm_req_minor_ver), required: false)
-    sigc_dep = sigc_dep.found() ? sigc_dep : 
cpp_compiler.find_library('sigc-vc@0@0@1@-2_0'.format(v.to_string(), debugsuffix), required: false)
   endforeach
 
+  if glibmm_dep.type_name() == 'library'
+    warning('Note: Be sure to check that this finds the same libsigc++ .lib your glibmm is linked to')
+    sigc_dep = cpp_compiler.find_library('sigc-@0@.0'.format(sigc_major_ver), required: false)
+    foreach v : msvc_check_range
+      sigc_dep = sigc_dep.found() ? sigc_dep : 
cpp_compiler.find_library('sigc-vc@0@0@1@-2_0'.format(v.to_string(), debugsuffix), required: false)
+    endforeach
+  endif
+
   # 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 (glibmm_dep.type_name() == 'pkgconfig' or 
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 glibmm in the required packages if we find it by pkg-config
+  # When cairomm gains Meson build support, we can replace
+  # this with what is done on other build systems.
+  mm_lib_requires = ''
+  if glibmm_dep.type_name() == 'pkgconfig'
+    mm_lib_requires += ' '.join([
+      'glibmm-2.@0@'.format(glibmm_req_minor_ver), glibmm_req,
+    ]) + ' '
+  endif
 
-  pangomm_requires = ' '.join([
+  pangomm_requires = mm_lib_requires + ' '.join([
     'pangocairo', pangocairo_req,
   ])
 
   pangomm_build_dep = [glibmm_dep, cairomm_dep, sigc_dep, pangocairo_dep]
 else
-  glibmm_req = '>= 2.48.0'
   cairomm_req = '>= 1.2.2'
   glibmm_dep = dependency('glibmm-2.@0@'.format(glibmm_req_minor_ver), version: glibmm_req)
   cairomm_dep = dependency('cairomm-1.@0@'.format(cairomm_req_minor_ver), version: cairomm_req)


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