summaryrefslogtreecommitdiff
path: root/mesonbuild/cmake/toolchain.py
diff options
context:
space:
mode:
authorL. E. Segovia <amy@amyspark.me>2025-08-03 22:26:07 -0300
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-09-06 16:58:56 +0300
commitc3ea8d5aa1b48fbc4137ef783c567a32cd596993 (patch)
treea1c729133a5e92ad516623192fd48c742db31fa2 /mesonbuild/cmake/toolchain.py
parent4b7a23c047ef5139f84cf96da37d132fe5fd84bc (diff)
downloadmeson-c3ea8d5aa1b48fbc4137ef783c567a32cd596993.tar.gz
compilers: Enable out-of-the-box MSVC compatibility with ccache
ccache has been for a long time compatible with MSVC (since 4.6) but when using debug mode, the /Z7 flag must be passed instead of /Zi. See https://ccache.dev/releasenotes.html#_ccache_4_6
Diffstat (limited to 'mesonbuild/cmake/toolchain.py')
-rw-r--r--mesonbuild/cmake/toolchain.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/mesonbuild/cmake/toolchain.py b/mesonbuild/cmake/toolchain.py
index 11a00be5d..902d6b088 100644
--- a/mesonbuild/cmake/toolchain.py
+++ b/mesonbuild/cmake/toolchain.py
@@ -174,6 +174,16 @@ class CMakeToolchain:
return p
# Set the compiler variables
+ comp_obj = self.compilers.get('c', self.compilers.get('cpp', None))
+ if comp_obj and comp_obj.get_id() == 'msvc':
+ debug_args = comp_obj.get_debug_args(True)
+ if '/Z7' in debug_args:
+ defaults['CMAKE_MSVC_DEBUG_INFORMATION_FORMAT'] = ['Embedded']
+ elif '/Zi' in debug_args:
+ defaults['CMAKE_MSVC_DEBUG_INFORMATION_FORMAT'] = ['ProgramDatabase']
+ elif '/ZI' in debug_args:
+ defaults['CMAKE_MSVC_DEBUG_INFORMATION_FORMAT'] = ['EditAndContinue']
+
for lang, comp_obj in self.compilers.items():
language = language_map.get(lang, None)