From b2ebfd7709e20095dee5a899a1123eaa4ab8ba48 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 17 Sep 2025 14:36:29 -0400 Subject: [PATCH] shortobj: properly force long names when computing long names The arguments need to be able to force a long name computation so that install paths can use the intended long paths. Use this computed state rather than asking the generator for its base state. Also force long paths for Visual Studio generators when computing it. Fixes: #27233 --- Source/cmLocalGenerator.cxx | 2 +- Source/cmLocalVisualStudioGenerator.cxx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index ec9cd1a8ca..50a55d849b 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -4507,7 +4507,7 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( } // Strip source file extension when shortening object file paths - if (this->UseShortObjectNames()) { + if (useShortObjectNames) { objectName = cmSystemTools::GetFilenameWithoutExtension(objectName); } // Store the new extension. diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index c45a957976..b699e1f698 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -99,8 +99,9 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames( if (counts[cmSystemTools::LowerCase(longObjectName)] > 1) { const_cast(gt)->AddExplicitObjectName(sf); bool keptSourceExtension; + bool forceShortObjectName = false; longObjectName = this->GetObjectFileNameWithoutTarget( - *sf, dir_max, &keptSourceExtension, custom_ext); + *sf, dir_max, &keptSourceExtension, custom_ext, &forceShortObjectName); } si.second.ShortLoc.emplace(shortObjectName); si.second.LongLoc.Update(longObjectName);