From 799bf33c5afcb0adc9d22331645b4112c7e03f62 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 22 Oct 2025 13:52:42 -0400 Subject: [PATCH] VS: do not create `ProgramDataBaseFileName` entries without a filepath The logic in commit f78f592b78 (pchreuse: defer target existence enforcement to generation time, 2025-06-16, v4.2.0-rc1~481^2~4) caused generator targets to always respond with something for compilation PDB files. This may be a directory as the flag supports it (the then compiler chooses the filename). However, one caller was expecting it to always be a path to a file in order to specify the `ProgramDataBaseFileName` element. However, this usage cannot be a directory. In addition to not having a PDB path at all, also verify that it is not a path to a directory before creating the `ProgramDataBaseFileName` element. This was observed in builds using `import std` in Debug mode. Fixes: #27320 --- Source/cmVisualStudio10TargetGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 23a726a1a2..3cd9c62d1f 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3765,7 +3765,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( // Specify the compiler program database file if configured. std::string pdb = this->GeneratorTarget->GetCompilePDBPath(configName); - if (!pdb.empty()) { + if (!pdb.empty() && !cmHasSuffix(pdb, '/') && !cmHasSuffix(pdb, '\\')) { if (this->GlobalGenerator->IsCudaEnabled()) { // CUDA does not quote paths with spaces correctly when forwarding // this to the host compiler. Use a relative path to avoid spaces.