[atkmm/atkmm-2-28] Meson/Visual Studio builds: Include toolset version by default
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [atkmm/atkmm-2-28] Meson/Visual Studio builds: Include toolset version by default
- Date: Mon, 29 Jun 2020 09:37:44 +0000 (UTC)
commit 9d273d7a8e40f74db56f62400800b7eb5dae522a
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Mon Jun 29 17:33:16 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 atkmm when building
items dependening on atkmm 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.
atk/atkmm-uninstalled.pc.in | 2 +-
atk/atkmm.pc.in | 2 +-
atk/atkmm/meson.build | 11 +++++++----
atk/meson.build | 4 +++-
configure.ac | 1 +
meson.build | 19 +++++++++++++++++++
meson_options.txt | 2 ++
7 files changed, 34 insertions(+), 7 deletions(-)
---
diff --git a/atk/atkmm-uninstalled.pc.in b/atk/atkmm-uninstalled.pc.in
index 3937f99..1947560 100644
--- a/atk/atkmm-uninstalled.pc.in
+++ b/atk/atkmm-uninstalled.pc.in
@@ -6,5 +6,5 @@ Description: C++ binding for the ATK accessibility toolkit, uninstalled
Version: @PACKAGE_VERSION@
URL: http://www.gtkmm.org/
Requires: @ATKMM_MODULES@
-Libs: ${pc_top_builddir}/${pcfiledir}/atkmm/libatkmm-@ATKMM_API_VERSION@.la
+Libs: ${pc_top_builddir}/${pcfiledir}/atkmm/libatkmm@MSVC_TOOLSET_VER@-@ATKMM_API_VERSION@.la
Cflags: -I${pc_top_builddir}/${pcfiledir} -I${pc_top_builddir}/${pcfiledir}/@srcdir@
diff --git a/atk/atkmm.pc.in b/atk/atkmm.pc.in
index eeb2dea..764ee88 100644
--- a/atk/atkmm.pc.in
+++ b/atk/atkmm.pc.in
@@ -17,5 +17,5 @@ Description: C++ binding for the ATK accessibility toolkit
Version: @PACKAGE_VERSION@
URL: http://www.gtkmm.org/
Requires: @ATKMM_MODULES@
-Libs: -L${libdir} -latkmm-@ATKMM_API_VERSION@
+Libs: -L${libdir} -latkmm@MSVC_TOOLSET_VER@-@ATKMM_API_VERSION@
Cflags: -I${includedir}/@ATKMM_MODULE_NAME@ -I${libdir}/@ATKMM_MODULE_NAME@/include
diff --git a/atk/atkmm/meson.build b/atk/atkmm/meson.build
index e3e217e..c98bb36 100644
--- a/atk/atkmm/meson.build
+++ b/atk/atkmm/meson.build
@@ -2,7 +2,8 @@
# Input: atkmm_build_dep, atkmm_pcname, maintainer_mode, project_source_root,
# generate_binding_py, m4_files, atkmm_libversion, install_includedir,
-# python3, atkmm_rc, dummy_header_py, gmmproc_dir, build_shared_libs_directly
+# python3, atkmm_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,
# atkmm_dep
@@ -192,8 +193,10 @@ if host_machine.system() == 'windows'
extra_atkmm_objects += atkmm_res
endif
+atkmm_libname = meson.project_name() + msvc14x_toolset_ver + '-' + atkmm_api_version
+
if build_shared_libs_directly
- atkmm_library = library(atkmm_pcname, extra_atkmm_objects,
+ atkmm_library = library(atkmm_libname, extra_atkmm_objects,
atk_gen_sources, built_dummy_h_file_target, extra_cc_files,
include_directories: extra_include_dirs,
cpp_args: atkmm_cpp_args,
@@ -219,14 +222,14 @@ else
depends: atk_int_lib,
command: [ gendef,
'@OUTPUT@',
- '@0@-@1@.dll'.format(atkmm_pcname, atkmm_libversion.split('.')[0]),
+ '@0@-@1@.dll'.format(atkmm_libname, atkmm_libversion.split('.')[0]),
atk_int_lib.full_path(),
],
install: false,
)
atkmm_extra_link_args = ['/def:@0@'.format(atkmm_def.full_path())]
- atkmm_library = library(atkmm_pcname, extra_atkmm_objects,
+ atkmm_library = library(atkmm_libname, extra_atkmm_objects,
objects: atk_int_lib.extract_all_objects(),
version: atkmm_libversion,
dependencies: atkmm_build_dep,
diff --git a/atk/meson.build b/atk/meson.build
index ba29d23..dc34911 100644
--- a/atk/meson.build
+++ b/atk/meson.build
@@ -3,7 +3,8 @@
# Input: install_prefix, install_datadir, install_includedir,
# atkmm_pcname, atkmm_api_version, atkmm_requires,
# install_pkgconfigdir, install_libdir, build_deprecated_api,
-# atkmm_major_version, atkmm_minor_version, atkmm_micro_version
+# atkmm_major_version, atkmm_minor_version, atkmm_micro_version,
+# msvc14x_toolset_ver
# Output: pkg_conf_data, install_includeconfigdir, atkmmconfig_h
pkg_conf_data = configuration_data()
@@ -25,6 +26,7 @@ endif
pkg_conf_data.set('ATKMM_MAJOR_VERSION', atkmm_major_version)
pkg_conf_data.set('ATKMM_MINOR_VERSION', atkmm_minor_version)
pkg_conf_data.set('ATKMM_MICRO_VERSION', atkmm_micro_version)
+pkg_conf_data.set('MSVC_TOOLSET_VER', msvc14x_toolset_ver)
library_build_type = get_option('default_library')
diff --git a/configure.ac b/configure.ac
index bddad4a..e3419f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,6 +44,7 @@ MM_CONFIG_DOCTOOL_DIR([doc])
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
AC_SUBST([ATKMM_SO_VERSION], [2:0:1])
+AC_SUBST([MSVC_TOOLSET_VER], [''])
AC_PROG_CXX
MM_AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
diff --git a/meson.build b/meson.build
index 15ab6bc..c81e507 100644
--- a/meson.build
+++ b/meson.build
@@ -159,6 +159,13 @@ endif
atkmm_script_dir = project_source_root / 'codegen'
dummy_header_py = atkmm_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')
@@ -180,6 +187,18 @@ 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 atkmm: @0@'.format(build_shared_libs_directly ? 'YES' :
'NO'))
+
+ 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')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]