diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CPack/cmCPackGenerator.cxx | 8 | ||||
-rw-r--r-- | Source/cmFileAPICodemodel.cxx | 3 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 29 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 9 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 29 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 16 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 1 |
7 files changed, 64 insertions, 31 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 153f328..7a6c50b 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -605,14 +605,6 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cmExpandList(buildConfig, buildConfigs); } - // Try get configurations requested by the user explicitly - { - const char* const configsCstr = - this->GetOption("CPACK_INSTALL_CMAKE_CONFIGURATIONS"); - auto configs = configsCstr ? configsCstr : std::string{}; - cmExpandList(configs, buildConfigs); - } - // Remove duplicates std::sort(buildConfigs.begin(), buildConfigs.end()); buildConfigs.erase(std::unique(buildConfigs.begin(), buildConfigs.end()), diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 48561de..d7993c7 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -875,7 +875,7 @@ CompileData Target::BuildCompileData(cmSourceFile* sf) if (!pchSource.empty() && !sf->GetProperty("SKIP_PRECOMPILE_HEADERS")) { std::string pchOptions; - if (sf->GetFullPath() == pchSource) { + if (sf->ResolveFullPath() == pchSource) { pchOptions = this->GT->GetPchCreateCompileOptions(this->Config, fd.Language); } else { @@ -1081,6 +1081,7 @@ Json::Value Target::DumpSource(cmGeneratorTarget::SourceAndKind const& sk, case cmGeneratorTarget::SourceKindModuleDefinition: case cmGeneratorTarget::SourceKindResx: case cmGeneratorTarget::SourceKindXaml: + case cmGeneratorTarget::SourceKindUnityBatched: break; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index f235af9..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")) { @@ -3360,14 +3362,8 @@ 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" }, @@ -3594,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 diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1f824b1..493eafc 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -10,6 +10,7 @@ #include <set> #include <string> #include <unordered_map> +#include <unordered_set> #include <utility> #include <vector> @@ -98,7 +99,8 @@ public: SourceKindModuleDefinition, SourceKindObjectSource, SourceKindResx, - SourceKindXaml + SourceKindXaml, + SourceKindUnityBatched }; /** A source file paired with a kind (classification). */ @@ -471,6 +473,9 @@ public: std::string GetPchUseCompileOptions(const std::string& config, const std::string& language); + void AddSourceFileToUnityBatch(const std::string& sourceFilename); + bool IsSourceFilePartOfUnityBatch(const std::string& sourceFilename) const; + bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config, const std::string& language) const; @@ -893,6 +898,8 @@ private: mutable std::map<std::string, std::string> PchCreateCompileOptions; mutable std::map<std::string, std::string> PchUseCompileOptions; + std::unordered_set<std::string> UnityBatchedSourceFiles; + void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, const cmGeneratorTarget* headTarget, diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index adeb065..6cbd4f3 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1174,7 +1174,9 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( headerFiles.push_back(xsf); } else if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource) { resourceFiles.push_back(xsf); - } else if (!sourceFile->GetPropertyAsBool("HEADER_FILE_ONLY")) { + } else if (!sourceFile->GetPropertyAsBool("HEADER_FILE_ONLY") && + !gtgt->IsSourceFilePartOfUnityBatch( + sourceFile->ResolveFullPath())) { // Include this file in the build if it has a known language // and has not been listed as an ignored extension for this // generator. @@ -2220,7 +2222,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, // extract C++ stdlib for (auto const& language : languages) { - if (language != "CXX") { + if (language != "CXX" && language != "OBJCXX") { continue; } std::string& flags = cflags[language]; @@ -2229,8 +2231,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, this->ExtractFlagRegex("(^| )(-stdlib=[^ ]+)( |$)", 2, flags); if (stdlib.size() > 8) { const auto cxxLibrary = stdlib.substr(8); - buildSettings->AddAttribute("CLANG_CXX_LIBRARY", - this->CreateString(cxxLibrary)); + if (language == "CXX" || + !buildSettings->GetObject("CLANG_CXX_LIBRARY")) { + buildSettings->AddAttribute("CLANG_CXX_LIBRARY", + this->CreateString(cxxLibrary)); + } } } @@ -2244,16 +2249,22 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, this->CreateString("NO")); buildSettings->AddAttribute("GCC_INLINES_ARE_PRIVATE_EXTERN", this->CreateString("NO")); + for (auto const& language : languages) { std::string flags = cflags[language] + " " + defFlags; - if (language == "CXX") { - buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS", - this->CreateString(flags)); + if (language == "CXX" || language == "OBJCXX") { + if (language == "CXX" || + !buildSettings->GetObject("OTHER_CPLUSPLUSFLAGS")) { + buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS", + this->CreateString(flags)); + } } else if (language == "Fortran") { buildSettings->AddAttribute("IFORT_OTHER_FLAGS", this->CreateString(flags)); - } else if (language == "C") { - buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(flags)); + } else if (language == "C" || language == "OBJC") { + if (language == "C" || !buildSettings->GetObject("OTHER_CFLAGS")) { + buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(flags)); + } } else if (language == "Swift") { buildSettings->AddAttribute("OTHER_SWIFT_FLAGS", this->CreateString(flags)); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index cae47e0..b79eb1d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2441,6 +2441,7 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target) std::back_inserter(filtered_sources), [&](cmSourceFile* sf) { return sf->GetLanguage() == lang && !sf->GetPropertyAsBool("SKIP_UNITY_BUILD_INCLUSION") && + !sf->GetPropertyAsBool("HEADER_FILE_ONLY") && !sf->GetProperty("COMPILE_OPTIONS") && !sf->GetProperty("COMPILE_DEFINITIONS") && !sf->GetProperty("COMPILE_FLAGS") && @@ -2475,11 +2476,10 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target) cmSourceFile* sf = filtered_sources[begin]; // Only in Visual Studio generator we keep the source files - // for explicit processing. For the rest the source files will - // not be included in the project. + // for explicit processing. if (!this->GetGlobalGenerator()->IsMultiConfig() || this->GetGlobalGenerator()->IsXcode()) { - sf->SetProperty("HEADER_FILE_ONLY", "ON"); + target->AddSourceFileToUnityBatch(sf->ResolveFullPath()); } sf->SetProperty("UNITY_SOURCE_FILE", filename.c_str()); @@ -2487,7 +2487,7 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target) file << beforeInclude << "\n"; } - file << "#include \"" << sf->GetFullPath() << "\"\n"; + file << "#include \"" << sf->ResolveFullPath() << "\"\n"; if (afterInclude) { file << afterInclude << "\n"; @@ -3123,6 +3123,14 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( const char* pchExtension = source.GetProperty("PCH_EXTENSION"); if (pchExtension) { customOutputExtension = pchExtension; + + // Make sure that for the CMakeFiles/<target>.dir/cmake_pch.h|xx.c|xx + // source file, we don't end up having + // CMakeFiles/<target>.dir/CMakeFiles/<target>.dir/cmake_pch.h|xx.pch + cmsys::RegularExpression var("(CMakeFiles/[^/]+.dir/)"); + while (var.find(objectName)) { + objectName.erase(var.start(), var.end() - var.start()); + } } // Remove the source extension if it is to be replaced. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 3843bf2..94b6495 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2141,6 +2141,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) this->WriteExtraSource(e1, si.Source); break; case cmGeneratorTarget::SourceKindHeader: + case cmGeneratorTarget::SourceKindUnityBatched: this->WriteHeaderSource(e1, si.Source); break; case cmGeneratorTarget::SourceKindIDL: |