diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2020-06-25 10:39:04 +0800 |
---|---|---|
committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2020-06-25 10:39:04 +0800 |
commit | 7ce9498b2420ed44893c302b118d61386e6bc4b3 (patch) | |
tree | cde0073ca8b37081cbe1d4a7e854d5e96f6ef71d | |
parent | 9c901080099226d86ed4bc8f4d611500c1febf1b (diff) |
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 may be subtle problems
when, for instance, one tries to link to a Visual Studio 2015-built
cairomm 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 may 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 possible breakages caused by such subtle differences.
-rw-r--r-- | MSVC_NMake/README | 3 | ||||
-rw-r--r-- | cairomm/meson.build | 4 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | data/cairomm-1.0.pc.in | 2 | ||||
-rw-r--r-- | data/meson.build | 3 | ||||
-rw-r--r-- | meson.build | 18 | ||||
-rw-r--r-- | meson_options.txt | 2 |
7 files changed, 29 insertions, 4 deletions
diff --git a/MSVC_NMake/README b/MSVC_NMake/README index 3064f92..1568e43 100644 --- a/MSVC_NMake/README +++ b/MSVC_NMake/README @@ -11,6 +11,9 @@ Building cairomm with Visual Studio .NET 2015 or later 'vc142' (2019) in the output DLL and .lib filenames, as per the toolset version as Microsoft defined. If using
'vc140' in the DLL and .lib names are desired (such as when rebuilding software that depends on cairomm is
not convenient), pass in 'USE_COMPAT_LIBS=1' in your NMake command line (note that doing this is not recommended).
+ For the Meson builds, pass in the option '-Dmsvc14x-parallel-installable=false' to the Meson configure command line
+ to avoid having the toolset version in the final DLL and .lib filenames; again, this is only recommended if it is
+ inconvenient to re-build the dependent code.
* In a Visual Studio command prompt, go to $(srcroot)\MSVC_NMake
* Build using nmake /f Makefile.vc CFG=[release|debug].
* Run the tests
diff --git a/cairomm/meson.build b/cairomm/meson.build index afc724f..e12343b 100644 --- a/cairomm/meson.build +++ b/cairomm/meson.build @@ -1,7 +1,7 @@ # cairomm # Input: cairomm_build_dep, cairomm_pcname, cairomm_libversion, cairomm_rc, -# is_msvc +# is_msvc, cairomm_libname # Output: source_h_files, cairomm_dep # There are no built source files in cairomm. @@ -79,7 +79,7 @@ endif extra_include_dirs = ['..'] -cairomm_library = library(cairomm_pcname, +cairomm_library = library(cairomm_libname, cairomm_cc, extra_cairomm_objects, version: cairomm_libversion, include_directories: extra_include_dirs, diff --git a/configure.ac b/configure.ac index b452111..623c647 100644 --- a/configure.ac +++ b/configure.ac @@ -48,6 +48,7 @@ PKG_PROG_PKG_CONFIG AC_SUBST([CAIROMM_EXTRA_LIBS], ['']) AC_SUBST([CAIROMM_MODULES], ['cairo >= 1.10.0 sigc++-2.0 >= 2.5.1']) +AC_SUBST([MSVC_TOOLSET_VER], ['']) cairomm_allmodules=$CAIROMM_MODULES CAIROMM_INSTALL_PC='data/cairomm-1.0.pc' diff --git a/data/cairomm-1.0.pc.in b/data/cairomm-1.0.pc.in index f7c2d69..b6d19a2 100644 --- a/data/cairomm-1.0.pc.in +++ b/data/cairomm-1.0.pc.in @@ -15,5 +15,5 @@ Description: C++ binding for the cairo graphics library Version: @PACKAGE_VERSION@ URL: http://www.cairographics.org/cairomm/ Requires: @CAIROMM_MODULES@ -Libs: -L${libdir} -lcairomm-@CAIROMM_API_VERSION@ @CAIROMM_EXTRA_LIBS@ +Libs: -L${libdir} -lcairomm@MSVC_TOOLSET_VER@-@CAIROMM_API_VERSION@ @CAIROMM_EXTRA_LIBS@ Cflags: -I${includedir}/@CAIROMM_MODULE_NAME@ -I${libdir}/@CAIROMM_MODULE_NAME@/include diff --git a/data/meson.build b/data/meson.build index f8e1659..775035b 100644 --- a/data/meson.build +++ b/data/meson.build @@ -2,7 +2,7 @@ # Input: install_prefix, install_libdir, install_datadir, install_includedir, # install_pkgconfigdir, cairomm_pcname, cairomm_api_version, -# cairomm_requires, cairo_dep +# cairomm_requires, cairo_dep, msvc14x_toolset_ver # Output: - pkg_conf_data = configuration_data() @@ -17,6 +17,7 @@ pkg_conf_data.set('CAIROMM_MODULE_NAME', cairomm_pcname) pkg_conf_data.set('CAIROMM_API_VERSION', cairomm_api_version) pkg_conf_data.set('CAIROMM_MODULES', cairomm_requires) pkg_conf_data.set('CAIROMM_EXTRA_LIBS', cairomm_extra_libs) +pkg_conf_data.set('MSVC_TOOLSET_VER', msvc14x_toolset_ver) configure_file( input: cairomm_pcname + '.pc.in', diff --git a/meson.build b/meson.build index 837a1ae..853ebe6 100644 --- a/meson.build +++ b/meson.build @@ -79,6 +79,8 @@ build_documentation = build_documentation_opt == 'true' or \ build_examples = get_option('build-examples') build_tests_opt = get_option('build-tests') +use_msvc14x_toolset_ver = get_option('msvc14x-parallel-installable') + # Installation directories are relative to {prefix}. install_prefix = get_option('prefix') install_includedir = get_option('includedir') @@ -200,6 +202,9 @@ endif warning_flags = cpp_compiler.get_supported_arguments(warning_flags) add_project_arguments(warning_flags, language: 'cpp') +# Add toolset version in builds done with Visual Studio 2015 or later +msvc14x_toolset_ver = '' + # MSVC: Ignore warnings that aren't really harmful, but make those # that should not be overlooked stand out. if is_msvc @@ -207,8 +212,21 @@ if is_msvc disabled_warning = cpp_compiler.get_supported_arguments(wd) add_project_arguments(disabled_warning, language: 'cpp') endforeach + 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 +cairomm_libname = meson.project_name() + msvc14x_toolset_ver + '-' + cairomm_api_version + # Create cairommconfig.h. mm_conf_data = configuration_data() if not build_deprecated_api diff --git a/meson_options.txt b/meson_options.txt index 4ada13e..9d0a235 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -16,3 +16,5 @@ option('build-tests', type: 'combo', choices: ['false', 'if-dependencies-found', value: 'if-dependencies-found', description: 'Build test programs (requires Boost Test and Fontconfig or Windows)') option('boost-shared', type: 'boolean', value: false, description: 'Use shared version of boost') +option('msvc14x-parallel-installable', type: 'boolean', value: true, + description: 'Use separate DLL and LIB filenames for Visual Studio 2015, 2017 and 2019') |