[pangomm] Meson/Visual Studio builds: Include toolset version by default



commit 3998008545841af84f82f80f5385978f28c0eb52
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Jun 29 18:53:37 2020 +0800

    Meson/Visual Studio builds: Include toolset version by default
    
    This makes the built DLL and .lib's contain the toolset version if the build is
    carried out using Visual Studio 2017 or later, unless the
    'msvc14x-parallel-installable' option is set to be false during configuration.
    
    The reasoning behind this change is that there can be subtle problems when, for
    instance, one tries to link to a Visual Studio 2017-built pangomm when building
    items dependening on pangomm with Visual Studio 2019.  This is unfortunate as
    Microsoft did try hard to make interoperating between binaries built with
    Visual Studio 2017 and 2019 as easy as possible in terms of ABI and API, but
    unfortunately this can hit the corner cases where this compatibility does not
    work.
    
    As the name suggests, this attempts to make Visual Studio 2017 and 2019 builds
    share a single set of underlying C DLLs easier, while avoiding breakages caused
    by such subtle differences.

 configure.ac                     |  1 +
 meson.build                      | 19 +++++++++++++++++++
 meson_options.txt                |  2 ++
 pango/meson.build                |  4 +++-
 pango/pangomm-uninstalled.pc.in  |  2 +-
 pango/pangomm.pc.in              |  2 +-
 pango/pangomm/meson.build        |  8 +++++---
 tools/extra_defs_gen/meson.build |  5 +++--
 8 files changed, 35 insertions(+), 8 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 488d883..fd93a84 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,7 @@ AC_DISABLE_STATIC
 LT_INIT([win32-dll])
 
 AC_SUBST([PANGOMM_MODULES], ['glibmm-2.66 >= 2.65.1 cairomm-1.16 >= 1.15.1 pangocairo >= 1.41.0'])
+AC_SUBST([MSVC_TOOLSET_VER], [''])
 PKG_CHECK_MODULES([PANGOMM], [$PANGOMM_MODULES])
 
 MM_PKG_CONFIG_SUBST([GTHREAD_CFLAGS], [--cflags-only-other gthread-2.0])
diff --git a/meson.build b/meson.build
index ab3304c..4c7e2b4 100644
--- a/meson.build
+++ b/meson.build
@@ -153,6 +153,25 @@ endif
 pangomm_script_dir = project_source_root / 'tools'
 dummy_header_py = pangomm_script_dir / 'dummy-header.py'
 
+# Whether to include toolset version in .lib and DLL file names
+# on Visual Studio 2017 and later (default: yes)
+use_msvc14x_toolset_ver = get_option('msvc14x-parallel-installable')
+
+# Add toolset version in builds done with Visual Studio 2017 or later
+msvc14x_toolset_ver = ''
+
+if is_msvc
+  # Put in the toolset version if the build is done with Visual Studio
+  # 2017 or later, unless explicitly told not to
+  if use_msvc14x_toolset_ver
+    if cpp_compiler.version().version_compare('>=19.20')
+      msvc14x_toolset_ver = '-vc142'
+    elif cpp_compiler.version().version_compare('>=19.10')
+      msvc14x_toolset_ver = '-vc141'
+    endif
+  endif
+endif
+
 # Set compiler warnings.
 warning_flags = []
 if warning_level == 'min'
diff --git a/meson_options.txt b/meson_options.txt
index cee7a28..940a398 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -8,3 +8,5 @@ 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('msvc14x-parallel-installable', type: 'boolean', value: true,
+  description: 'Use separate DLL and LIB filenames for Visual Studio 2017 and 2019')
diff --git a/pango/meson.build b/pango/meson.build
index 51f66df..f2df13e 100644
--- a/pango/meson.build
+++ b/pango/meson.build
@@ -3,7 +3,8 @@
 # Input: install_prefix, install_datadir, install_includedir,
 #        pangomm_pcname, pangomm_api_version, pangomm_requires,
 #        install_pkgconfigdir, install_libdir, build_deprecated_api,
-#        pangomm_major_version, pangomm_minor_version, pangomm_micro_version
+#        pangomm_major_version, pangomm_minor_version, pangomm_micro_version,
+#        msvc14x_toolset_ver
 # Output: pkg_conf_data, install_includeconfigdir, pangommconfig_h
 
 pkg_conf_data = configuration_data()
@@ -19,6 +20,7 @@ pkg_conf_data.set('PACKAGE_VERSION', meson.project_version())
 pkg_conf_data.set('PANGOMM_MODULE_NAME', pangomm_pcname)
 pkg_conf_data.set('PANGOMM_API_VERSION', pangomm_api_version)
 pkg_conf_data.set('PANGOMM_MODULES', pangomm_requires)
+pkg_conf_data.set('MSVC_TOOLSET_VER', msvc14x_toolset_ver)
 
 if not build_deprecated_api
   pkg_conf_data.set('PANGOMM_DISABLE_DEPRECATED', true)
diff --git a/pango/pangomm-uninstalled.pc.in b/pango/pangomm-uninstalled.pc.in
index 95eb8b6..4eaea77 100644
--- a/pango/pangomm-uninstalled.pc.in
+++ b/pango/pangomm-uninstalled.pc.in
@@ -6,5 +6,5 @@ Description: C++ binding for Pango, not installed
 Version: @PACKAGE_VERSION@
 URL: http://www.gtkmm.org/
 Requires: @PANGOMM_MODULES@
-Libs: ${pc_top_builddir}/${pcfiledir}/pangomm/libpangomm-@PANGOMM_API_VERSION@.la
+Libs: ${pc_top_builddir}/${pcfiledir}/pangomm/libpangomm@MSVC_TOOLSET_VER@-@PANGOMM_API_VERSION@.la
 Cflags: -I${pc_top_builddir}/${pcfiledir} -I${pc_top_builddir}/${pcfiledir}/@srcdir@
diff --git a/pango/pangomm.pc.in b/pango/pangomm.pc.in
index b02734b..979450e 100644
--- a/pango/pangomm.pc.in
+++ b/pango/pangomm.pc.in
@@ -17,5 +17,5 @@ Description: C++ binding for Pango
 Version: @PACKAGE_VERSION@
 URL: http://www.gtkmm.org/
 Requires: @PANGOMM_MODULES@
-Libs: -L${libdir} -lpangomm-@PANGOMM_API_VERSION@
+Libs: -L${libdir} -lpangomm@MSVC_TOOLSET_VER@-@PANGOMM_API_VERSION@
 Cflags: -I${includedir}/@PANGOMM_MODULE_NAME@  -I${libdir}/@PANGOMM_MODULE_NAME@/include
diff --git a/pango/pangomm/meson.build b/pango/pangomm/meson.build
index 34c68f2..7a2511a 100644
--- a/pango/pangomm/meson.build
+++ b/pango/pangomm/meson.build
@@ -2,7 +2,7 @@
 
 # Input: pangomm_build_dep, pangomm_pcname, maintainer_mode, project_source_root,
 #        generate_binding_py, m4_files, pangomm_libversion, install_includedir,
-#        python3, pangomm_rc, dummy_header_py, gmmproc_dir
+#        python3, pangomm_rc, dummy_header_py, gmmproc_dir, msvc14x_toolset_ver
 # Output: hg_ccg_basenames, extra_h_files, built_h_file_targets, built_files_root,
 #         pangomm_dep
 
@@ -76,6 +76,8 @@ if host_machine.system() == 'windows'
   extra_pangomm_objects += pangomm_res
 endif
 
+pangomm_libname = meson.project_name() + msvc14x_toolset_ver + '-' + pangomm_api_version
+
 if maintainer_mode
 
   # Maintainer mode. Generate .h and .cc files from .hg and .ccg files in ../src.
@@ -151,7 +153,7 @@ if maintainer_mode
 
   extra_include_dirs = ['..']
 
-  pangomm_library = library(pangomm_pcname, extra_pangomm_objects,
+  pangomm_library = library(pangomm_libname, extra_pangomm_objects,
     built_cc_file_targets, extra_cc_files, built_dummy_h_file_target,
     version: pangomm_libversion,
     include_directories: extra_include_dirs,
@@ -194,7 +196,7 @@ else # not maintainer_mode
 
   extra_include_dirs = [ '..', '..' / '..' / 'untracked' / 'pango' ]
 
-  pangomm_library = library(pangomm_pcname, extra_pangomm_objects,
+  pangomm_library = library(pangomm_libname, extra_pangomm_objects,
     built_cc_files, extra_cc_files,
     version: pangomm_libversion,
     include_directories: extra_include_dirs,
diff --git a/tools/extra_defs_gen/meson.build b/tools/extra_defs_gen/meson.build
index fcff20b..4693fd4 100644
--- a/tools/extra_defs_gen/meson.build
+++ b/tools/extra_defs_gen/meson.build
@@ -1,10 +1,11 @@
 # tools/extra_defs_gen
 
-# Input: cpp_compiler, pangomm_build_dep, install_libdir, pangomm_pcname
+# Input: cpp_compiler, pangomm_build_dep, install_libdir, pangomm_pcname,
+#        msvc14x_toolset_ver
 # Output: m4_files, install_m4dir
 
 glibmm_generate_extra_defs_dep = cpp_compiler.find_library(
-  'glibmm_generate_extra_defs-2.66',
+  'glibmm_generate_extra_defs@0@-2.66'.format(msvc14x_toolset_ver),
 )
 
 executable('generate_extra_defs', 'generate_defs_pango.cc',


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