[pangomm/pangomm-2-42] Meson/Visual Studio builds: Include toolset version by default
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pangomm/pangomm-2-42] Meson/Visual Studio builds: Include toolset version by default
- Date: Mon, 29 Jun 2020 10:55:18 +0000 (UTC)
commit 2239aa52a119c109d4f96f39155769f7a5bd9d93
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 2015 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 2015-built pangomm when building
items dependening on pangomm with Visual Studio 2017 or 2019. This is
unfortunate as Microsoft did try hard to make interoperating between binaries
built with Visual Studio 2015, 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 2015, 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 | 21 +++++++++++++++++++++
meson_options.txt | 2 ++
pango/meson.build | 4 +++-
pango/pangomm-uninstalled.pc.in | 2 +-
pango/pangomm.pc.in | 2 +-
pango/pangomm/meson.build | 11 +++++++----
tools/extra_defs_gen/meson.build | 5 +++--
8 files changed, 39 insertions(+), 9 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index efae383..fa0e84e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,7 @@ AC_DISABLE_STATIC
LT_INIT([win32-dll])
AC_SUBST([PANGOMM_MODULES], ['glibmm-2.4 >= 2.48.0 cairomm-1.0 >= 1.2.2 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 b71de91..337988e 100644
--- a/meson.build
+++ b/meson.build
@@ -162,6 +162,13 @@ 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 2015 and later (default: yes)
+use_msvc14x_toolset_ver = get_option('msvc14x-parallel-installable')
+
+# Add toolset version in builds done with Visual Studio 2015 or later
+msvc14x_toolset_ver = ''
+
if is_msvc
add_project_arguments(cpp_compiler.get_supported_arguments([ '/utf-8', '/wd4828']), language: 'cpp')
@@ -183,6 +190,20 @@ if is_msvc
# were generated using a recent enough gmmproc
build_shared_libs_directly = run_command(check_gmmproc_ver_cmd).returncode() == 0
message('Using __declspec(dllexport) to build pangomm: @0@'.format(build_shared_libs_directly ? 'YES' :
'NO'))
+
+ # Put in the toolset version if the build is done with Visual Studio
+ # 2015 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'
+ elif cpp_compiler.version().version_compare('>=19.00')
+ msvc14x_toolset_ver = '-vc140'
+ else
+ message('Visual Studio toolset version not applied for pre-Visual Studio 2015 builds')
+ endif
+ endif
endif
# Set compiler warnings.
diff --git a/meson_options.txt b/meson_options.txt
index cee7a28..3c0efe9 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 2015, 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 e3361cb..045225e 100644
--- a/pango/pangomm/meson.build
+++ b/pango/pangomm/meson.build
@@ -2,7 +2,8 @@
# 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, build_shared_libs_directly,
+# msvc14x_toolset_ver
# Output: hg_ccg_basenames, extra_h_files, built_h_file_targets, built_files_root,
# pangomm_dep
@@ -198,8 +199,10 @@ if host_machine.system() == 'windows'
extra_pangomm_objects += pangomm_res
endif
+pangomm_libname = meson.project_name() + msvc14x_toolset_ver + '-' + pangomm_api_version
+
if build_shared_libs_directly
- pangomm_library = library(pangomm_pcname, extra_pangomm_objects,
+ pangomm_library = library(pangomm_libname, extra_pangomm_objects,
pango_gen_sources, built_dummy_h_file_target, extra_cc_files,
include_directories: extra_include_dirs,
cpp_args: pangomm_cpp_args,
@@ -225,7 +228,7 @@ else
depends: pango_int_lib,
command: [ gendef,
'@OUTPUT@',
- '@0@-@1@.dll'.format(pangomm_pcname,
+ '@0@-@1@.dll'.format(pangomm_libname,
libtool_soversion[0] - libtool_soversion[2]),
pango_int_lib.full_path(),
],
@@ -233,7 +236,7 @@ else
)
pangomm_extra_link_args = ['/def:@0@'.format(pangomm_def.full_path())]
- pangomm_library = library(pangomm_pcname, extra_pangomm_objects,
+ pangomm_library = library(pangomm_libname, extra_pangomm_objects,
objects: pango_int_lib.extract_all_objects(),
version: pangomm_libversion,
dependencies: pangomm_build_dep,
diff --git a/tools/extra_defs_gen/meson.build b/tools/extra_defs_gen/meson.build
index 6a758cf..57b0349 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.4',
+ 'glibmm_generate_extra_defs@0@-2.4'.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]