diff options
Diffstat (limited to 'Source/cmLocalUnixMakefileGenerator3.cxx')
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 222 |
1 files changed, 100 insertions, 122 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 713c985..c301b1a 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -40,7 +40,7 @@ // Include dependency scanners for supported languages. Only the // C/C++ scanner is needed for bootstrapping CMake. #include "cmDependsC.h" -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP # include "cmDependsFortran.h" # include "cmDependsJava.h" #endif @@ -164,11 +164,8 @@ void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles( gt->GetObjectSources( objectSources, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); // Compute full path to object file directory for this target. - std::string dir; - dir += gt->LocalGenerator->GetCurrentBinaryDirectory(); - dir += "/"; - dir += this->GetTargetDirectory(gt); - dir += "/"; + std::string dir = cmStrCat(gt->LocalGenerator->GetCurrentBinaryDirectory(), + '/', this->GetTargetDirectory(gt), '/'); // Compute the name of each object file. for (cmSourceFile const* sf : objectSources) { bool hasSourceExtension = true; @@ -365,14 +362,12 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( emitted.insert(target->GetName()); // for subdirs add a rule to build this specific target by name. - localName = this->GetRelativeTargetDirectory(target); - localName += "/rule"; + localName = cmStrCat(this->GetRelativeTargetDirectory(target), "/rule"); commands.clear(); depends.clear(); // Build the target for this pass. - std::string makefile2 = "CMakeFiles/"; - makefile2 += "Makefile2"; + std::string makefile2 = "CMakeFiles/Makefile2"; commands.push_back(this->GetRecursiveMakeCall(makefile2, localName)); this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); @@ -388,13 +383,12 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( } // Add a fast rule to build the target - std::string makefileName = this->GetRelativeTargetDirectory(target); - makefileName += "/build.make"; + std::string makefileName = + cmStrCat(this->GetRelativeTargetDirectory(target), "/build.make"); // make sure the makefile name is suitable for a makefile - std::string makeTargetName = this->GetRelativeTargetDirectory(target); - makeTargetName += "/build"; - localName = target->GetName(); - localName += "/fast"; + std::string makeTargetName = + cmStrCat(this->GetRelativeTargetDirectory(target), "/build"); + localName = cmStrCat(target->GetName(), "/fast"); depends.clear(); commands.clear(); commands.push_back( @@ -407,10 +401,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( // Add a local name for the rule to relink the target before // installation. if (target->NeedRelinkBeforeInstall(this->ConfigName)) { - makeTargetName = this->GetRelativeTargetDirectory(target); - makeTargetName += "/preinstall"; - localName = target->GetName(); - localName += "/preinstall"; + makeTargetName = + cmStrCat(this->GetRelativeTargetDirectory(target), "/preinstall"); + localName = cmStrCat(target->GetName(), "/preinstall"); depends.clear(); commands.clear(); commands.push_back( @@ -427,9 +420,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() { - std::string infoFileName = this->GetCurrentBinaryDirectory(); - infoFileName += "/CMakeFiles"; - infoFileName += "/CMakeDirectoryInformation.cmake"; + std::string infoFileName = + cmStrCat(this->GetCurrentBinaryDirectory(), + "/CMakeFiles/CMakeDirectoryInformation.cmake"); // Open the output file. cmGeneratedFileStream infoFileStream(infoFileName); @@ -485,9 +478,8 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() std::string cmLocalUnixMakefileGenerator3::ConvertToFullPath( const std::string& localPath) { - std::string dir = this->GetCurrentBinaryDirectory(); - dir += "/"; - dir += localPath; + std::string dir = + cmStrCat(this->GetCurrentBinaryDirectory(), '/', localPath); return dir; } @@ -768,19 +760,18 @@ void cmLocalUnixMakefileGenerator3::WriteSpecialTargetsBottom( std::vector<std::string> commands; cmake* cm = this->GlobalGenerator->GetCMakeInstance(); if (cm->DoWriteGlobVerifyTarget()) { - std::string rescanRule = "$(CMAKE_COMMAND) -P "; - rescanRule += this->ConvertToOutputFormat(cm->GetGlobVerifyScript(), - cmOutputConverter::SHELL); + std::string rescanRule = + cmStrCat("$(CMAKE_COMMAND) -P ", + this->ConvertToOutputFormat(cm->GetGlobVerifyScript(), + cmOutputConverter::SHELL)); commands.push_back(rescanRule); } - std::string cmakefileName = "CMakeFiles/"; - cmakefileName += "Makefile.cmake"; - std::string runRule = - "$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"; - runRule += " --check-build-system "; - runRule += - this->ConvertToOutputFormat(cmakefileName, cmOutputConverter::SHELL); - runRule += " 0"; + std::string cmakefileName = "CMakeFiles/Makefile.cmake"; + std::string runRule = cmStrCat( + "$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) " + "--check-build-system ", + this->ConvertToOutputFormat(cmakefileName, cmOutputConverter::SHELL), + " 0"); std::vector<std::string> no_depends; commands.push_back(std::move(runRule)); @@ -821,8 +812,8 @@ void cmLocalUnixMakefileGenerator3::WriteConvenienceRule( std::string cmLocalUnixMakefileGenerator3::GetRelativeTargetDirectory( cmGeneratorTarget* target) { - std::string dir = this->HomeRelativeOutputPath; - dir += this->GetTargetDirectory(target); + std::string dir = + cmStrCat(this->HomeRelativeOutputPath, this->GetTargetDirectory(target)); return dir; } @@ -853,7 +844,7 @@ void cmLocalUnixMakefileGenerator3::AppendRuleDepend( // it is specifically enabled by the user or project. const char* nodep = this->Makefile->GetDefinition("CMAKE_SKIP_RULE_DEPENDENCY"); - if (!nodep || cmSystemTools::IsOff(nodep)) { + if (!nodep || cmIsOff(nodep)) { depends.emplace_back(ruleFileName); } } @@ -963,7 +954,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand( // This command was specified as a path to a file in the // current directory. Add a leading "./" so it can run // without the current directory being in the search path. - cmd = "./" + cmd; + cmd = cmStrCat("./", cmd); } std::string launcher; @@ -1017,18 +1008,16 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand( std::string::size_type rcurly = cmd.find('}'); if (rcurly == std::string::npos || rcurly > lcurly) { // The first curly is a left curly. Use the hack. - std::string hack_cmd = cmd.substr(0, lcurly); - hack_cmd += "{{}"; - hack_cmd += cmd.substr(lcurly + 1); - cmd = hack_cmd; + cmd = + cmStrCat(cmd.substr(0, lcurly), "{{}", cmd.substr(lcurly + 1)); } } } if (launcher.empty()) { if (useCall) { - cmd = "call " + cmd; + cmd = cmStrCat("call ", cmd); } else if (this->IsNMake() && cmd[0] == '"') { - cmd = "echo >nul && " + cmd; + cmd = cmStrCat("echo >nul && ", cmd); } } commands1.push_back(std::move(cmd)); @@ -1047,10 +1036,8 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand( cmGeneratorTarget* target, const char* filename) { std::string currentBinDir = this->GetCurrentBinaryDirectory(); - std::string cleanfile = currentBinDir; - cleanfile += "/"; - cleanfile += this->GetTargetDirectory(target); - cleanfile += "/cmake_clean"; + std::string cleanfile = cmStrCat( + currentBinDir, '/', this->GetTargetDirectory(target), "/cmake_clean"); if (filename) { cleanfile += "_"; cleanfile += filename; @@ -1070,11 +1057,12 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand( fout << ")\n"; } { - std::string remove = "$(CMAKE_COMMAND) -P "; - remove += this->ConvertToOutputFormat( - this->MaybeConvertToRelativePath(this->GetCurrentBinaryDirectory(), - cleanfile), - cmOutputConverter::SHELL); + std::string remove = + cmStrCat("$(CMAKE_COMMAND) -P ", + this->ConvertToOutputFormat( + this->MaybeConvertToRelativePath( + this->GetCurrentBinaryDirectory(), cleanfile), + cmOutputConverter::SHELL)); commands.push_back(std::move(remove)); } @@ -1104,7 +1092,7 @@ void cmLocalUnixMakefileGenerator3::AppendDirectoryCleanCommand( this->Makefile->GetProperty("ADDITIONAL_CLEAN_FILES")) { cmGeneratorExpression ge; std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop_value); - cmSystemTools::ExpandListArgument( + cmExpandList( cge->Evaluate(this, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")), cleanFiles); @@ -1117,8 +1105,8 @@ void cmLocalUnixMakefileGenerator3::AppendDirectoryCleanCommand( this->GetGlobalGenerator()->GetLocalGenerators().at(0); std::string const& binaryDir = rootLG->GetCurrentBinaryDirectory(); std::string const& currentBinaryDir = this->GetCurrentBinaryDirectory(); - std::string cleanfile = currentBinaryDir; - cleanfile += "/CMakeFiles/cmake_directory_clean.cmake"; + std::string cleanfile = + cmStrCat(currentBinaryDir, "/CMakeFiles/cmake_directory_clean.cmake"); // Write clean script { std::string cleanfilePath = cmSystemTools::CollapseFullPath(cleanfile); @@ -1137,10 +1125,11 @@ void cmLocalUnixMakefileGenerator3::AppendDirectoryCleanCommand( } // Create command { - std::string remove = "$(CMAKE_COMMAND) -P "; - remove += this->ConvertToOutputFormat( - rootLG->MaybeConvertToRelativePath(binaryDir, cleanfile), - cmOutputConverter::SHELL); + std::string remove = + cmStrCat("$(CMAKE_COMMAND) -P ", + this->ConvertToOutputFormat( + rootLG->MaybeConvertToRelativePath(binaryDir, cleanfile), + cmOutputConverter::SHELL)); commands.push_back(std::move(remove)); } } @@ -1186,12 +1175,12 @@ void cmLocalUnixMakefileGenerator3::AppendEcho( std::string cmd; if (color_name.empty() && !progress) { // Use the native echo command. - cmd = "@echo "; - cmd += this->EscapeForShell(line, false, true); + cmd = cmStrCat("@echo ", this->EscapeForShell(line, false, true)); } else { // Use cmake to echo the text in color. - cmd = "@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) "; - cmd += color_name; + cmd = cmStrCat( + "@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) ", + color_name); if (progress) { cmd += "--progress-dir="; cmd += this->ConvertToOutputFormat( @@ -1227,8 +1216,7 @@ void cmLocalUnixMakefileGenerator3::AppendEcho( std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable( std::string const& s, std::string const& s2) { - std::string unmodified = s; - unmodified += s2; + std::string unmodified = cmStrCat(s, s2); // if there is no restriction on the length of make variables // and there are no "." characters in the string, then return the // unmodified combination. @@ -1346,9 +1334,9 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies( // may have changed. In this case discard all old dependencies. bool needRescanDirInfo = false; { - std::string dirInfoFile = this->GetCurrentBinaryDirectory(); - dirInfoFile += "/CMakeFiles"; - dirInfoFile += "/CMakeDirectoryInformation.cmake"; + std::string dirInfoFile = + cmStrCat(this->GetCurrentBinaryDirectory(), + "/CMakeFiles/CMakeDirectoryInformation.cmake"); int result; if (!ftc->Compare(internalDependFile, dirInfoFile, &result) || result < 0) { @@ -1390,8 +1378,8 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies( // The dependencies must be regenerated. std::string targetName = cmSystemTools::GetFilenameName(targetDir); targetName = targetName.substr(0, targetName.length() - 4); - std::string message = "Scanning dependencies of target "; - message += targetName; + std::string message = + cmStrCat("Scanning dependencies of target ", targetName); cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundMagenta | cmsysTerminal_Color_ForegroundBold, message.c_str(), true, color); @@ -1412,9 +1400,9 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( cmMakefile* mf = this->Makefile; bool haveDirectoryInfo = false; { - std::string dirInfoFile = this->GetCurrentBinaryDirectory(); - dirInfoFile += "/CMakeFiles"; - dirInfoFile += "/CMakeDirectoryInformation.cmake"; + std::string dirInfoFile = + cmStrCat(this->GetCurrentBinaryDirectory(), + "/CMakeFiles/CMakeDirectoryInformation.cmake"); if (mf->ReadListFile(dirInfoFile) && !cmSystemTools::GetErrorOccuredFlag()) { haveDirectoryInfo = true; @@ -1425,7 +1413,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( if (haveDirectoryInfo) { // Test whether we need to force Unix paths. if (const char* force = mf->GetDefinition("CMAKE_FORCE_UNIX_PATHS")) { - if (!cmSystemTools::IsOff(force)) { + if (!cmIsOff(force)) { cmSystemTools::SetForceUnixPaths(true); } } @@ -1468,8 +1456,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( // for each language we need to scan, scan it std::vector<std::string> langs; - cmSystemTools::ExpandListArgument( - mf->GetSafeDefinition("CMAKE_DEPENDS_LANGUAGES"), langs); + cmExpandList(mf->GetSafeDefinition("CMAKE_DEPENDS_LANGUAGES"), langs); for (std::string const& lang : langs) { // construct the checker // Create the scanner for this language @@ -1479,7 +1466,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( // TODO: Handle RC (resource files) dependencies correctly. scanner = cm::make_unique<cmDependsC>(this, targetDir, lang, &validDeps); } -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP else if (lang == "Fortran") { ruleFileStream << "# Note that incremental build could trigger " << "a call to cmake_copy_f90_mod on each re-build\n"; @@ -1514,7 +1501,7 @@ void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose) // Convert the string to a list and preserve empty entries. std::vector<std::string> pairs; - cmSystemTools::ExpandListArgument(pairs_string, pairs, true); + cmExpandList(pairs_string, pairs, true); for (std::vector<std::string>::const_iterator i = pairs.begin(); i != pairs.end() && (i + 1) != pairs.end();) { const std::string& depender = *i++; @@ -1627,8 +1614,8 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( std::vector<std::string> commands; // Write the all rule. - std::string recursiveTarget = this->GetCurrentBinaryDirectory(); - recursiveTarget += "/all"; + std::string recursiveTarget = + cmStrCat(this->GetCurrentBinaryDirectory(), "/all"); bool regenerate = !this->GlobalGenerator->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION"); @@ -1636,16 +1623,15 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( depends.emplace_back("cmake_check_build_system"); } - std::string progressDir = this->GetBinaryDirectory(); - progressDir += "/CMakeFiles"; + std::string progressDir = + cmStrCat(this->GetBinaryDirectory(), "/CMakeFiles"); { std::ostringstream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; progCmd << this->ConvertToOutputFormat( cmSystemTools::CollapseFullPath(progressDir), cmOutputConverter::SHELL); - std::string progressFile = "/CMakeFiles"; - progressFile += "/progress.marks"; + std::string progressFile = "/CMakeFiles/progress.marks"; std::string progressFileNameFull = this->ConvertToFullPath(progressFile); progCmd << " " << this->ConvertToOutputFormat( @@ -1653,8 +1639,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( cmOutputConverter::SHELL); commands.push_back(progCmd.str()); } - std::string mf2Dir = "CMakeFiles/"; - mf2Dir += "Makefile2"; + std::string mf2Dir = "CMakeFiles/Makefile2"; commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget)); this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); @@ -1670,8 +1655,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( commands, true); // Write the clean rule. - recursiveTarget = this->GetCurrentBinaryDirectory(); - recursiveTarget += "/clean"; + recursiveTarget = cmStrCat(this->GetCurrentBinaryDirectory(), "/clean"); commands.clear(); depends.clear(); commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget)); @@ -1686,13 +1670,12 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( depends, commands, true); // Write the preinstall rule. - recursiveTarget = this->GetCurrentBinaryDirectory(); - recursiveTarget += "/preinstall"; + recursiveTarget = cmStrCat(this->GetCurrentBinaryDirectory(), "/preinstall"); commands.clear(); depends.clear(); const char* noall = this->Makefile->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"); - if (!noall || cmSystemTools::IsOff(noall)) { + if (!noall || cmIsOff(noall)) { // Drive the build before installing. depends.emplace_back("all"); } else if (regenerate) { @@ -1714,20 +1697,19 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( commands.clear(); cmake* cm = this->GlobalGenerator->GetCMakeInstance(); if (cm->DoWriteGlobVerifyTarget()) { - std::string rescanRule = "$(CMAKE_COMMAND) -P "; - rescanRule += this->ConvertToOutputFormat(cm->GetGlobVerifyScript(), - cmOutputConverter::SHELL); + std::string rescanRule = + cmStrCat("$(CMAKE_COMMAND) -P ", + this->ConvertToOutputFormat(cm->GetGlobVerifyScript(), + cmOutputConverter::SHELL)); commands.push_back(rescanRule); } - std::string cmakefileName = "CMakeFiles/"; - cmakefileName += "Makefile.cmake"; + std::string cmakefileName = "CMakeFiles/Makefile.cmake"; { - std::string runRule = - "$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"; - runRule += " --check-build-system "; - runRule += - this->ConvertToOutputFormat(cmakefileName, cmOutputConverter::SHELL); - runRule += " 1"; + std::string runRule = cmStrCat( + "$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) " + "--check-build-system ", + this->ConvertToOutputFormat(cmakefileName, cmOutputConverter::SHELL), + " 1"); commands.push_back(std::move(runRule)); } this->CreateCDCommand(commands, this->GetBinaryDirectory(), @@ -1746,7 +1728,7 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf, return; } std::vector<std::string> files; - cmSystemTools::ExpandListArgument(infoDef, files); + cmExpandList(infoDef, files); // Each depend information file corresponds to a target. Clear the // dependencies for that target. @@ -1848,9 +1830,8 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo( cmakefileStream << " )\n"; // Tell the dependency scanner what compiler is used. - std::string cidVar = "CMAKE_"; - cidVar += implicitLang.first; - cidVar += "_COMPILER_ID"; + std::string cidVar = + cmStrCat("CMAKE_", implicitLang.first, "_COMPILER_ID"); const char* cid = this->Makefile->GetDefinition(cidVar); if (cid && *cid) { cmakefileStream << "set(CMAKE_" << implicitLang.first @@ -1914,11 +1895,11 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo( std::vector<std::string> transformRules; if (const char* xform = this->Makefile->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) { - cmSystemTools::ExpandListArgument(xform, transformRules); + cmExpandList(xform, transformRules); } if (const char* xform = target->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) { - cmSystemTools::ExpandListArgument(xform, transformRules); + cmExpandList(xform, transformRules); } if (!transformRules.empty()) { cmakefileStream << "set(CMAKE_INCLUDE_TRANSFORMS\n"; @@ -1941,10 +1922,9 @@ std::string cmLocalUnixMakefileGenerator3::GetRecursiveMakeCall( const std::string& makefile, const std::string& tgt) { // Call make on the given file. - std::string cmd; - cmd += "$(MAKE) -f "; - cmd += this->ConvertToOutputFormat(makefile, cmOutputConverter::SHELL); - cmd += " "; + std::string cmd = cmStrCat( + "$(MAKE) -f ", + this->ConvertToOutputFormat(makefile, cmOutputConverter::SHELL), ' '); cmGlobalUnixMakefileGenerator3* gg = static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); @@ -2075,8 +2055,7 @@ std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath( std::string cmLocalUnixMakefileGenerator3::GetTargetDirectory( cmGeneratorTarget const* target) const { - std::string dir = "CMakeFiles/"; - dir += target->GetName(); + std::string dir = cmStrCat("CMakeFiles/", target->GetName()); #if defined(__VMS) dir += "_dir"; #else @@ -2119,13 +2098,12 @@ void cmLocalUnixMakefileGenerator3::CreateCDCommand( // On Windows we must perform each step separately and then change // back because the shell keeps the working directory between // commands. - std::string cmd = cd_cmd; - cmd += this->ConvertToOutputForExisting(tgtDir); + std::string cmd = + cmStrCat(cd_cmd, this->ConvertToOutputForExisting(tgtDir)); commands.insert(commands.begin(), cmd); // Change back to the starting directory. - cmd = cd_cmd; - cmd += this->ConvertToOutputForExisting(relDir); + cmd = cmStrCat(cd_cmd, this->ConvertToOutputForExisting(relDir)); commands.push_back(std::move(cmd)); } else { // On UNIX we must construct a single shell command to change |