[pangomm/pangomm-2-42] Meson: Use pkg-config to find glibmm and cairomm for all builds



commit 5dc3f543cf929ab750e7be86f903fed93f44cb1c
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Jun 29 18:37:07 2020 +0800

    Meson: Use pkg-config to find glibmm and cairomm for all builds
    
    Stop manually looking for glibmm and cairomm for better consistency, as:
    
    -Items that depended on glibmm which added Meson build support after glibmm,
     such as gtkmm and libxml++ also required glibmm to be found via pkg-config
     files, and they still had NMake Makefile support for Visual Studio builds.
     For items that use cairomm directly, this will be the case as well.
    -There could be corner cases on the glibmm and cairomm libraries that pangomm
     links to in  terms of ABI compatibility between Visual Studio 2015, 2017 and
     2019.

 meson.build       | 141 ++++++------------------------------------------------
 meson_options.txt |   2 -
 2 files changed, 14 insertions(+), 129 deletions(-)
---
diff --git a/meson.build b/meson.build
index 781c47c..b71de91 100644
--- a/meson.build
+++ b/meson.build
@@ -88,8 +88,8 @@ install_pkgconfigdir = install_libdir / 'pkgconfig'
 # pangomm_dep (created in pango/pangomm/meson.build):
 #   Dependencies when using the pangomm library.
 
-# cairomm and glibmm recently gained Meson build support, so we can try looking
-# for its pkg-config files on Visual Studio as well
+# cairomm and glibmm recently gained Meson build support, so we look
+# for their pkg-config files on Visual Studio, too
 cairomm_req = '>= 1.2.2'
 glibmm_req = '>= 2.48.0'
 
@@ -98,143 +98,30 @@ glibmm_req = '>= 2.48.0'
 pangocairo_req = '>= 1.41.0'
 pangocairo_dep = dependency('pangocairo', version: pangocairo_req)
 
-# The -mm libraries may have pkg-config files for MSVC builds,
-# so check for them manually, if needed
 glibmm_req_minor_ver = '4'
 cairomm_req_minor_ver = '0'
 
-cairomm_dep = dependency('cairomm-1.@0@'.format(cairomm_req_minor_ver), version: cairomm_req, required: not 
is_msvc)
-glibmm_dep = dependency('glibmm-2.@0@'.format(glibmm_req_minor_ver), version: glibmm_req, required: not 
is_msvc)
+cairomm_dep = dependency('cairomm-1.@0@'.format(cairomm_req_minor_ver), version: cairomm_req)
+glibmm_dep = dependency('glibmm-2.@0@'.format(glibmm_req_minor_ver), version: glibmm_req)
 
 # Where to find gmmproc and generate_wrap_init.pl.
-if glibmm_dep.found() and glibmm_dep.type_name() == 'pkgconfig'
-  gmmproc_dir = glibmm_dep.get_pkgconfig_variable('gmmprocdir')
-else
-  # We don't have a pkg-config file for glibmm, so use build option.
-  gmmproc_dir = get_option('gmmproc-dir')
-endif
+gmmproc_dir = glibmm_dep.get_pkgconfig_variable('gmmprocdir')
 
 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')
-
-  sigc_major_ver = '2'
-
-  # The glibmm and cairomm pkg-config files pulls in libsigc++,
-  # so only look for libsigc++ if glibmm's nor cairomm's pkg-config
-  # files can't be found
-  if not glibmm_dep.found() and not cairomm_dep.found()
-    sigc_required_headers = [
-      'sigc++-@0@.0/sigc++/sigc++.h'.format(sigc_major_ver),
-      'sigc++-@0@.0/include/sigc++config.h'.format(sigc_major_ver)
-    ]
-  endif
-
-  # cairomm/glibmm covers for libsigc++ in their pkg-config files,
-  # so we only look for libsigc++ if needed
-  sigc_dep = dependency('', required: false)
-
-  if not glibmm_dep.found()
-    glibmm_required_headers = [
-      'glibmm-2.@0@/glibmm.h'.format(glibmm_req_minor_ver),
-      'glibmm-2.@0@/include/glibmmconfig.h'.format(glibmm_req_minor_ver)
-    ]
-  endif
-
-  if not cairomm_dep.found()
-    cairomm_required_headers = [
-      'cairomm-1.@0@/cairomm/cairomm.h'.format(cairomm_req_minor_ver),
-      'cairomm-1.@0@/include/cairommconfig.h'.format(cairomm_req_minor_ver)
-    ]
-  endif
-
-  if not glibmm_dep.found() or not cairomm_dep.found()
-    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))
-  endif
-
-  # We need to look for appropriate versions of Visual
-  # Studio since those built by NMake and the former
-  # Visual Studio projects are versioned by the VS versions
-  if cpp_compiler.version().split('.')[0].to_int() == 18
-    msvc_check_range = [12] # Visual Studio 2013
-    warning('Visual Studio 2013 must configure without -Dwarnings=fatal, which is the default')
-  elif cpp_compiler.version().split('.')[0].to_int() == 19
-    # Visual Studio 2019 can consume libraries built with 2017 and 2015
-    # and Visual Studio 2017 can consume libraries built with 2015
-    msvc_check_range = [14] # Visual Studio 2015, 2017, 2019
-    message('It is safe to ignore warnings from Meson that MSVC does not support C++11')
-  endif
-
-  debugsuffix = ''
-  if get_option('buildtype') == 'debug'
-    debugsuffix = '-d'
-  endif
-
-  # 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
-
-  foreach v : msvc_check_range
-    if not 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,
-                                             has_headers: glibmm_required_headers)
-    endif
-    if not 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,
-                                              has_headers: cairomm_required_headers)
-    endif
-  endforeach
-
-  # Check whether we compile pangomm without using gendef
+  # Check later whether we compile pangomm without using gendef
   build_shared_libs_directly = false
-
-  if glibmm_dep.type_name() == 'library' and \
-     cairomm_dep.type_name() == 'library'
-    warning('Note: Be sure to check that this finds the same libsigc++ .lib your glibmm is linked to')
-    foreach v : msvc_check_range
-      if not sigc_dep.found()
-        sigc_dep = cpp_compiler.find_library('sigc-vc@0@0@1@-2_0'.format(v.to_string(), debugsuffix),
-                                             required: false,
-                                             has_headers: sigc_required_headers)
-      endif
-    endforeach
-  endif
-
-  # Now make sure the appropriate -mm libraries are found
-  assert(glibmm_dep.found() and cairomm_dep.found() and (glibmm_dep.type_name() == 'pkgconfig' or 
cairomm_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 and cairomm in the required packages if we find it by pkg-config
-  mm_lib_requires = ''
-  if glibmm_dep.type_name() == 'pkgconfig'
-    mm_lib_requires += ' '.join([
-      'glibmm-2.@0@'.format(glibmm_req_minor_ver), glibmm_req,
-    ]) + ' '
-  endif
-  if cairomm_dep.type_name() == 'pkgconfig'
-    mm_lib_requires += ' '.join([
-      'cairomm-1.@0@'.format(cairomm_req_minor_ver), cairomm_req,
-    ]) + ' '
-  endif
-
-  pangomm_requires = mm_lib_requires + ' '.join([
-    'pangocairo', pangocairo_req,
-  ])
-
-  pangomm_build_dep = [glibmm_dep, cairomm_dep, sigc_dep, pangocairo_dep]
 else
-  # not MSVC
-  pangomm_build_dep = [glibmm_dep, cairomm_dep, pangocairo_dep]
-  pangomm_requires = ' '.join([
-    'glibmm-2.@0@'.format(glibmm_req_minor_ver), glibmm_req,
-    'cairomm-1.@0@'.format(cairomm_req_minor_ver), cairomm_req,
-    'pangocairo', pangocairo_req,
-  ])
-
+  # not MSVC: gendef is not used at all
   build_shared_libs_directly = true
 endif
 
+pangomm_build_dep = [glibmm_dep, cairomm_dep, pangocairo_dep]
+pangomm_requires = ' '.join([
+  'glibmm-2.@0@'.format(glibmm_req_minor_ver), glibmm_req,
+  'cairomm-1.@0@'.format(cairomm_req_minor_ver), cairomm_req,
+  'pangocairo', pangocairo_req,
+])
+
 # Some dependencies are required only in maintainer mode and/or if
 # reference documentation shall be built.
 mm_common_get = find_program('mm-common-get', required: false)
diff --git a/meson_options.txt b/meson_options.txt
index 0a88938..cee7a28 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -8,5 +8,3 @@ option('build-deprecated-api', type: 'boolean', value: true,
   description: 'Build deprecated API and include it in the library')
 option('build-documentation', type: 'combo', choices: ['false', 'if-maintainer-mode', 'true'],
   value: 'if-maintainer-mode', description: 'Build and install the documentation')
-option('gmmproc-dir', type: 'string', value: '',
-  description: 'Directory containing gmmproc and its PERL modules (for MSVC builds only)')


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