diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 644e0a6b81..56d8fd7c0b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -2851,7 +2851,7 @@ std::string cmGeneratorTarget::GetPchHeader(std::string const& config, { "OBJCXX", ".objcxx.hxx" } }; - filename = generatorTarget->GetSupportDirectory(); + filename = generatorTarget->GetCMFSupportDirectory(); if (this->GetGlobalGenerator()->IsMultiConfig()) { filename = cmStrCat(filename, '/', config); @@ -2944,7 +2944,8 @@ std::string cmGeneratorTarget::GetPchSource(std::string const& config, this->GetGlobalGenerator()->FindGeneratorTarget(*pchReuseFrom); } - filename = cmStrCat(generatorTarget->GetSupportDirectory(), "/cmake_pch"); + filename = + cmStrCat(generatorTarget->GetCMFSupportDirectory(), "/cmake_pch"); // For GCC the source extension will be transformed into .h[xx].gch if (!this->Makefile->IsOn("CMAKE_LINK_PCH")) { @@ -5222,6 +5223,17 @@ std::string cmGeneratorTarget::GetSupportDirectory() const lg->GetTargetDirectory(this)); } +std::string cmGeneratorTarget::GetCMFSupportDirectory() const +{ + cmLocalGenerator* lg = this->GetLocalGenerator(); + if (!lg->AlwaysUsesCMFPaths()) { + return cmStrCat(lg->GetCurrentBinaryDirectory(), "/CMakeFiles/", + lg->GetTargetDirectory(this)); + } + return cmStrCat(lg->GetObjectOutputRoot(), '/', + lg->GetTargetDirectory(this)); +} + bool cmGeneratorTarget::IsLinkable() const { return (this->GetType() == cmStateEnums::STATIC_LIBRARY || diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e5a539fe0a..45f7b1fca0 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -935,6 +935,7 @@ public: /** Get a build-tree directory in which to place target support files. */ std::string GetSupportDirectory() const; + std::string GetCMFSupportDirectory() const; /** Return whether this target may be used to link another target. */ bool IsLinkable() const; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 6ec7e6d21f..bf155851c2 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -3636,7 +3636,7 @@ void cmGlobalGenerator::WriteSummary() continue; } this->WriteSummary(tgt.get()); - fout << tgt->GetSupportDirectory() << '\n'; + fout << tgt->GetCMFSupportDirectory() << '\n'; } } } @@ -3644,7 +3644,7 @@ void cmGlobalGenerator::WriteSummary() void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) { // Place the labels file in a per-target support directory. - std::string dir = target->GetSupportDirectory(); + std::string dir = target->GetCMFSupportDirectory(); std::string file = cmStrCat(dir, "/Labels.txt"); std::string json_file = cmStrCat(dir, "/Labels.json"); diff --git a/Source/cmInstallCxxModuleBmiGenerator.cxx b/Source/cmInstallCxxModuleBmiGenerator.cxx index 37d9ce53ce..5f7ea52969 100644 --- a/Source/cmInstallCxxModuleBmiGenerator.cxx +++ b/Source/cmInstallCxxModuleBmiGenerator.cxx @@ -51,7 +51,7 @@ std::string cmInstallCxxModuleBmiGenerator::GetScriptLocation( if (config.empty()) { config_name = "noconfig"; } - return cmStrCat(this->Target->GetSupportDirectory(), + return cmStrCat(this->Target->GetCMFSupportDirectory(), "/install-cxx-module-bmi-", config_name, ".cmake"); } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index db3580ff42..0440a014e5 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3323,7 +3323,7 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target) } std::string filename_base = - cmStrCat(target->GetSupportDirectory(), "/Unity/"); + cmStrCat(target->GetCMFSupportDirectory(), "/Unity/"); cmValue batchSizeString = target->GetProperty("UNITY_BUILD_BATCH_SIZE"); size_t const unityBatchSize = batchSizeString @@ -4291,6 +4291,11 @@ std::string cmLocalGenerator::GetObjectOutputRoot() const return cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles"); } +bool cmLocalGenerator::AlwaysUsesCMFPaths() const +{ + return true; +} + std::string cmLocalGenerator::GetSourceFileLanguage(cmSourceFile const& source) { return source.GetLanguage(); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 50c0854765..1c4dd4ec50 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -439,6 +439,7 @@ public: std::string const& GetCurrentSourceDirectory() const; virtual std::string GetObjectOutputRoot() const; + virtual bool AlwaysUsesCMFPaths() const; /** * Generate a macOS application bundle Info.plist file. diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index db7b8ef49a..ae953d571b 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -89,6 +89,11 @@ std::string cmLocalVisualStudioGenerator::GetObjectOutputRoot() const return this->GetCurrentBinaryDirectory(); } +bool cmLocalVisualStudioGenerator::AlwaysUsesCMFPaths() const +{ + return false; +} + std::unique_ptr cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target, std::string const& config, diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 5630d119c5..eb0e4ad437 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -52,6 +52,7 @@ public: cmGeneratorTarget const* = nullptr) override; std::string GetObjectOutputRoot() const override; + bool AlwaysUsesCMFPaths() const override; protected: virtual char const* ReportErrorLabel() const;