diff options
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 949d9d9..d38e9e1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1569,6 +1569,8 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files, kind = SourceKindCustomCommand; } else if (this->Target->GetType() == cmStateEnums::UTILITY) { kind = SourceKindExtra; + } else if (this->IsSourceFilePartOfUnityBatch(sf->ResolveFullPath())) { + kind = SourceKindUnityBatched; } else if (sf->GetPropertyAsBool("HEADER_FILE_ONLY")) { kind = SourceKindHeader; } else if (sf->GetPropertyAsBool("EXTERNAL_OBJECT")) { @@ -3334,9 +3336,11 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetPrecompileHeaders( std::string cmGeneratorTarget::GetPchHeader(const std::string& config, const std::string& language) const { - if (language != "C" && language != "CXX") { + if (language != "C" && language != "CXX" && language != "OBJC" && + language != "OBJCXX") { return std::string(); } + if (this->GetPropertyAsBool("DISABLE_PRECOMPILE_HEADERS")) { return std::string(); } @@ -3358,17 +3362,18 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config, this->GetGlobalGenerator()->FindGeneratorTarget(pchReuseFrom); } - if (this->GetGlobalGenerator()->IsMultiConfig()) { - filename = cmStrCat( - generatorTarget->LocalGenerator->GetCurrentBinaryDirectory(), "/"); - } else { - // For GCC we need to have the header file .h[xx] - // next to the .h[xx].gch file - filename = generatorTarget->ObjectDirectory; - } + filename = cmStrCat( + generatorTarget->LocalGenerator->GetCurrentBinaryDirectory(), "/"); + + const std::map<std::string, std::string> languageToExtension = { + { "C", ".h" }, + { "CXX", ".hxx" }, + { "OBJC", ".objc.h" }, + { "OBJCXX", ".objcxx.hxx" } + }; filename = cmStrCat(filename, "CMakeFiles/", generatorTarget->GetName(), - ".dir/cmake_pch", ((language == "C") ? ".h" : ".hxx")); + ".dir/cmake_pch", languageToExtension.at(language)); const std::string filename_tmp = cmStrCat(filename, ".tmp"); if (!pchReuseFrom) { @@ -3418,7 +3423,8 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config, std::string cmGeneratorTarget::GetPchSource(const std::string& config, const std::string& language) const { - if (language != "C" && language != "CXX") { + if (language != "C" && language != "CXX" && language != "OBJC" && + language != "OBJCXX") { return std::string(); } const auto inserted = @@ -3444,9 +3450,20 @@ std::string cmGeneratorTarget::GetPchSource(const std::string& config, // For GCC the source extension will be tranformed into .h[xx].gch if (!this->Makefile->IsOn("CMAKE_LINK_PCH")) { - filename += ((language == "C") ? ".h.c" : ".hxx.cxx"); + const std::map<std::string, std::string> languageToExtension = { + { "C", ".h.c" }, + { "CXX", ".hxx.cxx" }, + { "OBJC", ".objc.h.m" }, + { "OBJCXX", ".objcxx.hxx.mm" } + }; + + filename += languageToExtension.at(language); } else { - filename += ((language == "C") ? ".c" : ".cxx"); + const std::map<std::string, std::string> languageToExtension = { + { "C", ".c" }, { "CXX", ".cxx" }, { "OBJC", ".m" }, { "OBJCXX", ".mm" } + }; + + filename += languageToExtension.at(language); } const std::string filename_tmp = cmStrCat(filename, ".tmp"); @@ -3464,7 +3481,8 @@ std::string cmGeneratorTarget::GetPchSource(const std::string& config, std::string cmGeneratorTarget::GetPchFileObject(const std::string& config, const std::string& language) { - if (language != "C" && language != "CXX") { + if (language != "C" && language != "CXX" && language != "OBJC" && + language != "OBJCXX") { return std::string(); } const auto inserted = @@ -3572,6 +3590,23 @@ std::string cmGeneratorTarget::GetPchUseCompileOptions( return inserted.first->second; } +void cmGeneratorTarget::AddSourceFileToUnityBatch( + const std::string& sourceFilename) +{ + this->UnityBatchedSourceFiles.insert(sourceFilename); +} + +bool cmGeneratorTarget::IsSourceFilePartOfUnityBatch( + const std::string& sourceFilename) const +{ + if (!this->GetPropertyAsBool("UNITY_BUILD")) { + return false; + } + + return this->UnityBatchedSourceFiles.find(sourceFilename) != + this->UnityBatchedSourceFiles.end(); +} + void cmGeneratorTarget::GetLinkOptions(std::vector<std::string>& result, const std::string& config, const std::string& language) const |