diff options
author | Brad King <brad.king@kitware.com> | 2024-01-10 15:19:04 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-01-10 15:19:12 (GMT) |
commit | 4a9599927f750972f16f6e7615853a971f0913da (patch) | |
tree | 4ab5ae4d22ad7b5e4cdc208ebbe674e540c58f1d /Source | |
parent | 8dc079581e52f37105a9ffae917a1288e6c7a684 (diff) | |
parent | 63d4e4ec2865b85a60f3f26d14be2c7116da79f0 (diff) | |
download | CMake-4a9599927f750972f16f6e7615853a971f0913da.zip CMake-4a9599927f750972f16f6e7615853a971f0913da.tar.gz CMake-4a9599927f750972f16f6e7615853a971f0913da.tar.bz2 |
Merge topic 'orkun_refactor_09_01_2024'
63d4e4ec28 Makefile: Reduce string copies
4d928592eb Makefile: Remove redundant push_back
3e533bd64f Makefile: Improve const correctness
c2dd5dfbe8 Makefile: Remove no-op call
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9142
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 9ea611a..ff509ce 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -139,7 +139,7 @@ void cmMakefileTargetGenerator::GetTargetLinkFlags( this->LocalGenerator->AppendFlags( flags, this->GeneratorTarget->GetSafeProperty("LINK_FLAGS")); - std::string linkFlagsConfig = + std::string const linkFlagsConfig = cmStrCat("LINK_FLAGS_", cmSystemTools::UpperCase(this->GetConfigName())); this->LocalGenerator->AppendFlags( flags, this->GeneratorTarget->GetSafeProperty(linkFlagsConfig)); @@ -236,7 +236,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() } // Look for ISPC extra object files generated by this target - auto ispcAdditionalObjs = + auto const ispcAdditionalObjs = this->GeneratorTarget->GetGeneratedISPCObjects(this->GetConfigName()); for (std::string const& ispcObj : ispcAdditionalObjs) { this->CleanFiles.insert( @@ -244,7 +244,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() } // add custom commands to the clean rules? - bool clean = cmIsOff(this->Makefile->GetProperty("CLEAN_NO_CUSTOM")); + bool const clean = cmIsOff(this->Makefile->GetProperty("CLEAN_NO_CUSTOM")); // First generate the object rule files. Save a list of all object // files for this target. @@ -1799,7 +1799,6 @@ void cmMakefileTargetGenerator::WriteObjectsVariable( *this->BuildFileStream << "# Object files for target " << this->GeneratorTarget->GetName() << "\n" << variableName << " ="; - std::string object; const auto& lineContinue = this->GlobalGenerator->LineContinueDirective; cmValue pchExtension = this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION"); @@ -1827,7 +1826,6 @@ void cmMakefileTargetGenerator::WriteObjectsVariable( << variableNameExternal << " ="; /* clang-format on */ for (std::string const& obj : this->ExternalObjects) { - object = this->LocalGenerator->MaybeRelativeToCurBinDir(obj); *this->BuildFileStream << " " << lineContinue; *this->BuildFileStream << cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath( @@ -1907,7 +1905,7 @@ void cmMakefileTargetGenerator::WriteObjectsStrings( for (std::string const& obj : this->ExternalObjects) { helper.Feed(obj); } - auto ispcAdditionalObjs = + auto const ispcAdditionalObjs = this->GeneratorTarget->GetGeneratedISPCObjects(this->GetConfigName()); for (std::string const& obj : ispcAdditionalObjs) { helper.Feed(obj); @@ -1922,13 +1920,12 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule( std::string dir = this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget); std::string buildTargetRuleName = - cmStrCat(dir, relink ? "/preinstall" : "/build"); + cmStrCat(std::move(dir), relink ? "/preinstall" : "/build"); buildTargetRuleName = this->LocalGenerator->MaybeRelativeToTopBinDir(buildTargetRuleName); // Build the list of target outputs to drive. - std::vector<std::string> depends; - depends.push_back(main_output); + std::vector<std::string> depends{ main_output }; const char* comment = nullptr; if (relink) { @@ -1971,7 +1968,7 @@ void cmMakefileTargetGenerator::AppendTargetDepends( } // Loop over all library dependencies. - if (cmComputeLinkInformation* cli = + if (cmComputeLinkInformation const* cli = this->GeneratorTarget->GetLinkInformation(cfg)) { cm::append(depends, cli->GetDepends()); } @@ -2196,16 +2193,17 @@ void cmMakefileTargetGenerator::CreateLinkLibs( std::string responseFlag = this->GetResponseFlag(responseMode); // Create this response file. - std::string responseFileName = + std::string const responseFileName = (responseMode == Link) ? "linkLibs.rsp" : "deviceLinkLibs.rsp"; - std::string responseLang = (responseMode == Link) ? linkLanguage : "CUDA"; + std::string const responseLang = + (responseMode == Link) ? linkLanguage : "CUDA"; std::string link_rsp = this->CreateResponseFile( responseFileName, linkLibs, makefile_depends, responseLang); // Reference the response file. - linkLibs = cmStrCat(responseFlag, + linkLibs = cmStrCat(std::move(responseFlag), this->LocalGenerator->ConvertToOutputFormat( - link_rsp, cmOutputConverter::SHELL)); + std::move(link_rsp), cmOutputConverter::SHELL)); } } @@ -2229,7 +2227,7 @@ void cmMakefileTargetGenerator::CreateObjectLists( responseFileLimit); // Lookup the response file reference flag. - std::string responseFlag = this->GetResponseFlag(responseMode); + std::string const responseFlag = this->GetResponseFlag(responseMode); // Write a response file for each string. const char* sep = ""; @@ -2269,15 +2267,15 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, const std::string& lang, const std::string& /*config*/) { - std::string responseVar = + std::string const responseVar = cmStrCat("CMAKE_", lang, "_USE_RESPONSE_FILE_FOR_INCLUDES"); - bool useResponseFile = this->Makefile->IsOn(responseVar); + bool const useResponseFile = this->Makefile->IsOn(responseVar); std::vector<std::string> includes; this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, lang, this->GetConfigName()); - std::string includeFlags = this->LocalGenerator->GetIncludeFlags( + std::string const includeFlags = this->LocalGenerator->GetIncludeFlags( includes, this->GeneratorTarget, lang, this->GetConfigName(), useResponseFile); if (includeFlags.empty()) { @@ -2292,8 +2290,8 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, if (responseFlag.empty()) { responseFlag = "@"; } - std::string name = cmStrCat("includes_", lang, ".rsp"); - std::string arg = std::move(responseFlag) + + std::string const name = cmStrCat("includes_", lang, ".rsp"); + std::string const arg = std::move(responseFlag) + this->CreateResponseFile(name, includeFlags, this->FlagFileDepends[lang], lang); this->LocalGenerator->AppendFlags(flags, arg); @@ -2322,7 +2320,7 @@ void cmMakefileTargetGenerator::GenDefFile( cmd += this->LocalGenerator->ConvertToOutputFormat( this->LocalGenerator->MaybeRelativeToCurBinDir(objlist_file), cmOutputConverter::SHELL); - cmValue nm_executable = this->Makefile->GetDefinition("CMAKE_NM"); + cmValue const nm_executable = this->Makefile->GetDefinition("CMAKE_NM"); if (cmNonempty(nm_executable)) { cmd += " --nm="; cmd += this->LocalCommonGenerator->ConvertToOutputFormat( @@ -2362,7 +2360,7 @@ std::string cmMakefileTargetGenerator::GetResponseFlag( responseFlagVar = "CMAKE_CUDA_RESPONSE_FILE_DEVICE_LINK_FLAG"; } - if (cmValue p = this->Makefile->GetDefinition(responseFlagVar)) { + if (cmValue const p = this->Makefile->GetDefinition(responseFlagVar)) { responseFlag = *p; } return responseFlag; |