diff --git a/Source/cmGlobalFastbuildGenerator.cxx b/Source/cmGlobalFastbuildGenerator.cxx index 8dc735be1e..b4c3259259 100644 --- a/Source/cmGlobalFastbuildGenerator.cxx +++ b/Source/cmGlobalFastbuildGenerator.cxx @@ -91,41 +91,6 @@ static std::map const compilerIdToFastbuildFamily = { static std::set const supportedLanguages = { "C", "CXX", "CUDA", "OBJC", "OBJCXX" }; -static void ReadCompilerOptions(FastbuildCompiler& compiler, cmMakefile* mf) -{ - if (compiler.CompilerFamily == "custom") { - return; - } - - if (cmIsOn(mf->GetSafeDefinition(FASTBUILD_USE_LIGHTCACHE))) { - compiler.UseLightCache = true; - } - if (cmIsOn(mf->GetSafeDefinition(FASTBUILD_USE_RELATIVE_PATHS))) { - compiler.UseRelativePaths = true; - } - if (cmIsOn(mf->GetSafeDefinition(FASTBUILD_USE_DETERMINISTIC_PATHS))) { - compiler.UseDeterministicPaths = true; - } - std::string sourceMapping = mf->GetSafeDefinition(FASTBUILD_SOURCE_MAPPING); - if (!sourceMapping.empty()) { - compiler.SourceMapping = std::move(sourceMapping); - } - auto const clangRewriteIncludesDef = - mf->GetDefinition(FASTBUILD_CLANG_REWRITE_INCLUDES); - if (clangRewriteIncludesDef.IsSet() && clangRewriteIncludesDef.IsOff()) { - compiler.ClangRewriteIncludes = false; - } - if (cmIsOn(mf->GetSafeDefinition(FASTBUILD_CLANG_GCC_UPDATE_XLANG_ARG))) { - compiler.ClangGCCUpdateXLanguageArg = true; - } - if (cmIsOn(mf->GetSafeDefinition(FASTBUILD_ALLOW_RESPONSE_FILE))) { - compiler.AllowResponseFile = true; - } - if (cmIsOn(mf->GetSafeDefinition(FASTBUILD_FORCE_RESPONSE_FILE))) { - compiler.ForceResponseFile = true; - } -} - template FastbuildAliasNode generateAlias(std::string const& name, char const* postfix, T const& nodes) @@ -232,6 +197,43 @@ cmGlobalFastbuildGenerator::cmGlobalFastbuildGenerator(cmake* cm) cm->GetState()->SetIsGeneratorMultiConfig(false); } +void cmGlobalFastbuildGenerator::ReadCompilerOptions( + FastbuildCompiler& compiler, cmMakefile* mf) +{ + if (compiler.CompilerFamily == "custom") { + return; + } + + if (cmIsOn(mf->GetSafeDefinition(FASTBUILD_USE_LIGHTCACHE))) { + compiler.UseLightCache = true; + } + if (cmIsOn(mf->GetSafeDefinition(FASTBUILD_USE_RELATIVE_PATHS))) { + compiler.UseRelativePaths = true; + UsingRelativePaths = true; + } + if (cmIsOn(mf->GetSafeDefinition(FASTBUILD_USE_DETERMINISTIC_PATHS))) { + compiler.UseDeterministicPaths = true; + } + std::string sourceMapping = mf->GetSafeDefinition(FASTBUILD_SOURCE_MAPPING); + if (!sourceMapping.empty()) { + compiler.SourceMapping = std::move(sourceMapping); + } + auto const clangRewriteIncludesDef = + mf->GetDefinition(FASTBUILD_CLANG_REWRITE_INCLUDES); + if (clangRewriteIncludesDef.IsSet() && clangRewriteIncludesDef.IsOff()) { + compiler.ClangRewriteIncludes = false; + } + if (cmIsOn(mf->GetSafeDefinition(FASTBUILD_CLANG_GCC_UPDATE_XLANG_ARG))) { + compiler.ClangGCCUpdateXLanguageArg = true; + } + if (cmIsOn(mf->GetSafeDefinition(FASTBUILD_ALLOW_RESPONSE_FILE))) { + compiler.AllowResponseFile = true; + } + if (cmIsOn(mf->GetSafeDefinition(FASTBUILD_FORCE_RESPONSE_FILE))) { + compiler.ForceResponseFile = true; + } +} + void cmGlobalFastbuildGenerator::ProcessEnvironment() { bool const CaptureSystemEnv = @@ -1178,6 +1180,9 @@ void cmGlobalFastbuildGenerator::WriteUnity(FastbuildUnityNode const& Unity) WriteArray("UnityInputIsolatedFiles", Wrap(Unity.UnityInputIsolatedFiles), 2); } + if (UsingRelativePaths) { + WriteVariable("UseRelativePaths_Experimental", "true", 2); + } } Indent(1); *BuildFileStream << "}\n"; diff --git a/Source/cmGlobalFastbuildGenerator.h b/Source/cmGlobalFastbuildGenerator.h index 280a283331..a456ce4fcf 100644 --- a/Source/cmGlobalFastbuildGenerator.h +++ b/Source/cmGlobalFastbuildGenerator.h @@ -347,6 +347,7 @@ class cmGlobalFastbuildGenerator : public cmGlobalCommonGenerator public: cmGlobalFastbuildGenerator(cmake* cm); + void ReadCompilerOptions(FastbuildCompiler& compiler, cmMakefile* mf); void ProcessEnvironment(); static std::unique_ptr NewFactory(); @@ -614,6 +615,7 @@ public: // configuration (like .objs files used to create module definition from // objects). std::unordered_set AllFilesToKeep; + bool UsingRelativePaths = false; private: std::unordered_set AllFilesToClean; diff --git a/Source/cmLocalFastbuildGenerator.cxx b/Source/cmLocalFastbuildGenerator.cxx index fc4916051b..fcfa040f0a 100644 --- a/Source/cmLocalFastbuildGenerator.cxx +++ b/Source/cmLocalFastbuildGenerator.cxx @@ -16,6 +16,7 @@ #include "cmObjectLocation.h" #include "cmSystemTools.h" #include "cmValue.h" +#include "cmake.h" class cmGlobalGenerator; @@ -96,3 +97,16 @@ void cmLocalFastbuildGenerator::AdditionalCleanFiles(std::string const& config) } } } + +std::string cmLocalFastbuildGenerator::ConvertToIncludeReference( + std::string const& path, cmOutputConverter::OutputFormat format) +{ + std::string converted = this->ConvertToOutputForExisting(path, format); + cmGlobalFastbuildGenerator const* GG = this->GetGlobalFastbuildGenerator(); + if (GG->UsingRelativePaths && cmSystemTools::FileIsFullPath(path)) { + std::string const& binDir = + GG->GetCMakeInstance()->GetHomeOutputDirectory(); + return cmSystemTools::RelativePath(binDir, converted); + } + return converted; +} diff --git a/Source/cmLocalFastbuildGenerator.h b/Source/cmLocalFastbuildGenerator.h index 8c9c27da51..3af7573dfd 100644 --- a/Source/cmLocalFastbuildGenerator.h +++ b/Source/cmLocalFastbuildGenerator.h @@ -6,6 +6,7 @@ #include #include "cmLocalCommonGenerator.h" +#include "cmOutputConverter.h" class cmGeneratorTarget; class cmGlobalFastbuildGenerator; @@ -32,4 +33,8 @@ public: cmGlobalFastbuildGenerator* GetGlobalFastbuildGenerator(); void AdditionalCleanFiles(std::string const& config); + +private: + std::string ConvertToIncludeReference( + std::string const& path, cmOutputConverter::OutputFormat format) override; };