From 3e533bd64ffda57a6d0e6af1d361913a2a948873 Mon Sep 17 00:00:00 2001 From: Orkun Tokdemir Date: Tue, 9 Jan 2024 12:26:09 +0100 Subject: Makefile: Improve const correctness --- Source/cmMakefileTargetGenerator.cxx | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 8122f0f..756e5aa 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. @@ -1906,7 +1906,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); @@ -1970,7 +1970,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()); } @@ -2195,9 +2195,10 @@ 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); @@ -2228,7 +2229,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 = ""; @@ -2268,15 +2269,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 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()) { @@ -2291,8 +2292,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); @@ -2321,7 +2322,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( @@ -2361,7 +2362,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; -- cgit v0.12