From 522217d9c56e0db0f1c247f52909ba0e99150b8c Mon Sep 17 00:00:00 2001 From: Oli Date: Wed, 23 Apr 2025 13:27:06 +0100 Subject: [PATCH] Projucer (MSVC): Fix multi-arch PCH project generation Co-authored-by: Ryaan Ahmed --- .../ProjectSaving/jucer_ProjectExport_MSVC.h | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h index 022e96688e..3e1d1a5e5e 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h @@ -1350,38 +1350,38 @@ public: auto& config = *static_cast (&*i); - for (const auto& arch : config.getArchitectures()) + auto pchFileContent = config.getPrecompiledHeaderFileContent(); + + if (pchFileContent.isEmpty()) + continue; + + auto pchFile = owner.getTargetFolder().getChildFile (config.getPrecompiledHeaderFilename()) + .withFileExtension (".h"); + + build_tools::writeStreamToFile (pchFile, [&] (MemoryOutputStream& mo) { - auto pchFileContent = config.getPrecompiledHeaderFileContent(); + mo << pchFileContent; + }); - if (pchFileContent.isEmpty()) - continue; + auto pchSourceFile = pchFile.withFileExtension (".cpp"); - auto pchFile = owner.getTargetFolder().getChildFile (config.getPrecompiledHeaderFilename()).withFileExtension (".h"); + build_tools::writeStreamToFile (pchSourceFile, [this] (MemoryOutputStream& mo) + { + mo.setNewLineString (owner.getNewLineString()); - build_tools::writeStreamToFile (pchFile, [&] (MemoryOutputStream& mo) - { - mo << pchFileContent; - }); + writeAutoGenWarningComment (mo); - auto pchSourceFile = pchFile.withFileExtension (".cpp"); + mo << " This is an empty source file generated by JUCE required for Visual Studio PCH." << newLine + << newLine + << "*/" << newLine + << newLine; + }); - build_tools::writeStreamToFile (pchSourceFile, [this] (MemoryOutputStream& mo) - { - mo.setNewLineString (owner.getNewLineString()); + auto* pchSourceElement = cpps.createNewChildElement ("ClCompile"); + pchSourceElement->setAttribute ("Include", prependDot (pchSourceFile.getFileName())); - writeAutoGenWarningComment (mo); - - mo << " This is an empty source file generated by JUCE required for Visual Studio PCH." << newLine - << newLine - << "*/" << newLine - << newLine; - }); - - auto* pchSourceElement = cpps.createNewChildElement ("ClCompile"); - pchSourceElement->setAttribute ("Include", prependDot (pchSourceFile.getFileName())); + for (const auto& arch : config.getArchitectures()) setSourceFilePCHSettings (*pchSourceElement, pchFile, "Create", config, arch); - } } }