diff options
Diffstat (limited to 'Source')
24 files changed, 211 insertions, 109 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index dc4f5fd..63d5f3d 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 14) -set(CMake_VERSION_PATCH 20190517) +set(CMake_VERSION_PATCH 20190520) #set(CMake_VERSION_RC 1) diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 2f62db1..f12ef0b 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -122,8 +122,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, } } - const char* sourceDirectory = argv[2].c_str(); - const char* projectName = nullptr; + std::string sourceDirectory = argv[2]; + std::string projectName; std::string targetName; std::vector<std::string> cmakeFlags(1, "CMAKE_FLAGS"); // fake argv[0] std::vector<std::string> compileDefs; @@ -309,7 +309,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, doing = DoingNone; } else if (i == 3) { this->SrcFileSignature = false; - projectName = argv[i].c_str(); + projectName = argv[i]; } else if (i == 4 && !this->SrcFileSignature) { targetName = argv[i]; } else { @@ -480,7 +480,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, // we need to create a directory and CMakeLists file etc... // first create the directories - sourceDirectory = this->BinaryDirectory.c_str(); + sourceDirectory = this->BinaryDirectory; // now create a CMakeLists.txt file in that directory FILE* fout = cmsys::SystemTools::Fopen(outFileName, "w"); @@ -950,7 +950,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, << " '" << copyFile << "'\n"; /* clang-format on */ if (!this->FindErrorMessage.empty()) { - emsg << this->FindErrorMessage.c_str(); + emsg << this->FindErrorMessage; } if (copyFileError.empty()) { this->Makefile->IssueMessage(MessageType::FATAL_ERROR, emsg.str()); diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 93ff8f4..c6e44e3 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -280,8 +280,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( xml.StartElement("Build"); - this->AppendTarget(xml, "all", nullptr, make.c_str(), lgs[0], - compiler.c_str(), makeArgs); + this->AppendTarget(xml, "all", nullptr, make, lgs[0], compiler, makeArgs); // add all executable and library targets and some of the GLOBAL // and UTILITY targets @@ -294,8 +293,8 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs if (lg->GetCurrentBinaryDirectory() == lg->GetBinaryDirectory()) { - this->AppendTarget(xml, targetName, nullptr, make.c_str(), lg, - compiler.c_str(), makeArgs); + this->AppendTarget(xml, targetName, nullptr, make, lg, compiler, + makeArgs); } } break; case cmStateEnums::UTILITY: @@ -310,8 +309,8 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( break; } - this->AppendTarget(xml, targetName, nullptr, make.c_str(), lg, - compiler.c_str(), makeArgs); + this->AppendTarget(xml, targetName, nullptr, make, lg, compiler, + makeArgs); break; case cmStateEnums::EXECUTABLE: case cmStateEnums::STATIC_LIBRARY: @@ -319,12 +318,12 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( case cmStateEnums::MODULE_LIBRARY: case cmStateEnums::OBJECT_LIBRARY: { cmGeneratorTarget* gt = target; - this->AppendTarget(xml, targetName, gt, make.c_str(), lg, - compiler.c_str(), makeArgs); + this->AppendTarget(xml, targetName, gt, make, lg, compiler, + makeArgs); std::string fastTarget = targetName; fastTarget += "/fast"; - this->AppendTarget(xml, fastTarget, gt, make.c_str(), lg, - compiler.c_str(), makeArgs); + this->AppendTarget(xml, fastTarget, gt, make, lg, compiler, + makeArgs); } break; default: break; @@ -378,7 +377,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( std::string const& fullPath = s->GetFullPath(); // Check file position relative to project root dir. - const std::string& relative = + const std::string relative = cmSystemTools::RelativePath(lg->GetSourceDirectory(), fullPath); // Do not add this file if it has ".." in relative path and // if CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES variable is on. @@ -454,7 +453,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( } // Add CMakeLists.txt - tree.BuildUnit(xml, std::string(mf->GetHomeDirectory()) + "/"); + tree.BuildUnit(xml, mf->GetHomeDirectory() + "/"); xml.EndElement(); // Project xml.EndElement(); // CodeBlocks_project_file @@ -489,8 +488,8 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile( // Generate the xml code for one target. void cmExtraCodeBlocksGenerator::AppendTarget( cmXMLWriter& xml, const std::string& targetName, cmGeneratorTarget* target, - const char* make, const cmLocalGenerator* lg, const char* compiler, - const std::string& makeFlags) + const std::string& make, const cmLocalGenerator* lg, + const std::string& compiler, const std::string& makeFlags) { cmMakefile const* makefile = lg->GetMakefile(); std::string makefileName = lg->GetCurrentBinaryDirectory(); @@ -613,25 +612,23 @@ void cmExtraCodeBlocksGenerator::AppendTarget( xml.StartElement("Build"); xml.Attribute( "command", - this->BuildMakeCommand(make, makefileName.c_str(), targetName, makeFlags)); + this->BuildMakeCommand(make, makefileName, targetName, makeFlags)); xml.EndElement(); xml.StartElement("CompileFile"); - xml.Attribute("command", - this->BuildMakeCommand(make, makefileName.c_str(), "\"$file\"", - makeFlags)); + xml.Attribute( + "command", + this->BuildMakeCommand(make, makefileName, "\"$file\"", makeFlags)); xml.EndElement(); xml.StartElement("Clean"); xml.Attribute( - "command", - this->BuildMakeCommand(make, makefileName.c_str(), "clean", makeFlags)); + "command", this->BuildMakeCommand(make, makefileName, "clean", makeFlags)); xml.EndElement(); xml.StartElement("DistClean"); xml.Attribute( - "command", - this->BuildMakeCommand(make, makefileName.c_str(), "clean", makeFlags)); + "command", this->BuildMakeCommand(make, makefileName, "clean", makeFlags)); xml.EndElement(); xml.EndElement(); // MakeCommands @@ -725,8 +722,8 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmGeneratorTarget* target) // Create the command line for building the given target using the selected // make std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( - const std::string& make, const char* makefile, const std::string& target, - const std::string& makeFlags) + const std::string& make, const std::string& makefile, + const std::string& target, const std::string& makeFlags) { std::string command = make; if (!makeFlags.empty()) { @@ -747,7 +744,7 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( } else if (generator == "MinGW Makefiles") { // no escaping of spaces in this case, see // https://gitlab.kitware.com/cmake/cmake/issues/10014 - std::string makefileName = makefile; + std::string const& makefileName = makefile; command += " -f \""; command += makefileName; command += "\" "; diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h index be3af25..173e284 100644 --- a/Source/cmExtraCodeBlocksGenerator.h +++ b/Source/cmExtraCodeBlocksGenerator.h @@ -42,12 +42,13 @@ private: std::string GetCBCompilerId(const cmMakefile* mf); int GetCBTargetType(cmGeneratorTarget* target); - std::string BuildMakeCommand(const std::string& make, const char* makefile, + std::string BuildMakeCommand(const std::string& make, + const std::string& makefile, const std::string& target, const std::string& makeFlags); void AppendTarget(cmXMLWriter& xml, const std::string& targetName, - cmGeneratorTarget* target, const char* make, - const cmLocalGenerator* lg, const char* compiler, + cmGeneratorTarget* target, const std::string& make, + const cmLocalGenerator* lg, const std::string& compiler, const std::string& makeFlags); }; diff --git a/Source/cmFileCopier.cxx b/Source/cmFileCopier.cxx index 8913e6d..972cd6e 100644 --- a/Source/cmFileCopier.cxx +++ b/Source/cmFileCopier.cxx @@ -31,6 +31,7 @@ cmFileCopier::cmFileCopier(cmFileCommand* command, const char* name) , UseGivenPermissionsFile(false) , UseGivenPermissionsDir(false) , UseSourcePermissions(true) + , FollowSymlinkChain(false) , Doing(DoingNone) { } @@ -249,6 +250,9 @@ bool cmFileCopier::CheckKeyword(std::string const& arg) this->Doing = DoingPattern; } else if (arg == "REGEX") { this->Doing = DoingRegex; + } else if (arg == "FOLLOW_SYMLINK_CHAIN") { + this->FollowSymlinkChain = true; + this->Doing = DoingNone; } else if (arg == "EXCLUDE") { // Add this property to the current match rule. if (this->CurrentMatchRule) { @@ -464,16 +468,69 @@ bool cmFileCopier::Install(const std::string& fromFile, if (cmSystemTools::SameFile(fromFile, toFile)) { return true; } - if (cmSystemTools::FileIsSymlink(fromFile)) { - return this->InstallSymlink(fromFile, toFile); + + std::string newFromFile = fromFile; + std::string newToFile = toFile; + + if (this->FollowSymlinkChain && + !this->InstallSymlinkChain(newFromFile, newToFile)) { + return false; } - if (cmSystemTools::FileIsDirectory(fromFile)) { - return this->InstallDirectory(fromFile, toFile, match_properties); + + if (cmSystemTools::FileIsSymlink(newFromFile)) { + return this->InstallSymlink(newFromFile, newToFile); } - if (cmSystemTools::FileExists(fromFile)) { - return this->InstallFile(fromFile, toFile, match_properties); + if (cmSystemTools::FileIsDirectory(newFromFile)) { + return this->InstallDirectory(newFromFile, newToFile, match_properties); } - return this->ReportMissing(fromFile); + if (cmSystemTools::FileExists(newFromFile)) { + return this->InstallFile(newFromFile, newToFile, match_properties); + } + return this->ReportMissing(newFromFile); +} + +bool cmFileCopier::InstallSymlinkChain(std::string& fromFile, + std::string& toFile) +{ + std::string newFromFile; + std::string toFilePath = cmSystemTools::GetFilenamePath(toFile); + while (cmSystemTools::ReadSymlink(fromFile, newFromFile)) { + if (!cmSystemTools::FileIsFullPath(newFromFile)) { + std::string fromFilePath = cmSystemTools::GetFilenamePath(fromFile); + newFromFile = fromFilePath + "/" + newFromFile; + } + + std::string symlinkTarget = cmSystemTools::GetFilenameName(newFromFile); + + bool copy = true; + if (!this->Always) { + std::string oldSymlinkTarget; + if (cmSystemTools::ReadSymlink(toFile, oldSymlinkTarget)) { + if (symlinkTarget == oldSymlinkTarget) { + copy = false; + } + } + } + + this->ReportCopy(toFile, TypeLink, copy); + + if (copy) { + cmSystemTools::RemoveFile(toFile); + cmSystemTools::MakeDirectory(toFilePath); + + if (!cmSystemTools::CreateSymlink(symlinkTarget, toFile)) { + std::ostringstream e; + e << this->Name << " cannot create symlink \"" << toFile << "\"."; + this->FileCommand->SetError(e.str()); + return false; + } + } + + fromFile = newFromFile; + toFile = toFilePath + "/" + symlinkTarget; + } + + return true; } bool cmFileCopier::InstallSymlink(const std::string& fromFile, diff --git a/Source/cmFileCopier.h b/Source/cmFileCopier.h index 003b8f6..a79a60b 100644 --- a/Source/cmFileCopier.h +++ b/Source/cmFileCopier.h @@ -64,6 +64,7 @@ protected: // Translate an argument to a permissions bit. bool CheckPermissions(std::string const& arg, mode_t& permissions); + bool InstallSymlinkChain(std::string& fromFile, std::string& toFile); bool InstallSymlink(const std::string& fromFile, const std::string& toFile); bool InstallFile(const std::string& fromFile, const std::string& toFile, MatchProperties match_properties); @@ -86,6 +87,7 @@ protected: bool UseGivenPermissionsFile; bool UseGivenPermissionsDir; bool UseSourcePermissions; + bool FollowSymlinkChain; std::string Destination; std::string FilesFromDir; std::vector<std::string> Files; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 8c6fb34..709355a 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -981,6 +981,51 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode } } languageNode; +static const struct CompileLanguageAndIdNode : public cmGeneratorExpressionNode +{ + CompileLanguageAndIdNode() {} // NOLINT(modernize-use-equals-default) + + int NumExpectedParameters() const override { return 2; } + + std::string Evaluate( + const std::vector<std::string>& parameters, + cmGeneratorExpressionContext* context, + const GeneratorExpressionContent* content, + cmGeneratorExpressionDAGChecker* dagChecker) const override + { + if (!context->HeadTarget || context->Language.empty()) { + // reportError(context, content->GetOriginalExpression(), ""); + reportError( + context, content->GetOriginalExpression(), + "$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets " + "to specify include directories, compile definitions, and compile " + "options. It may not be used with the add_custom_command, " + "add_custom_target, or file(GENERATE) commands."); + return std::string(); + } + cmGlobalGenerator* gg = context->LG->GetGlobalGenerator(); + std::string genName = gg->GetName(); + if (genName.find("Makefiles") == std::string::npos && + genName.find("Ninja") == std::string::npos && + genName.find("Visual Studio") == std::string::npos && + genName.find("Xcode") == std::string::npos && + genName.find("Watcom WMake") == std::string::npos) { + reportError( + context, content->GetOriginalExpression(), + "$<COMPILE_LANG_AND_ID:lang,id> not supported for this generator."); + return std::string(); + } + + const std::string& lang = context->Language; + if (lang == parameters.front()) { + std::vector<std::string> idParameter = { parameters[1] }; + return CompilerIdNode{ lang.c_str() }.EvaluateWithLanguage( + idParameter, context, content, dagChecker, lang); + } + return "0"; + } +} languageAndIdNode; + #define TRANSITIVE_PROPERTY_NAME(PROPERTY) , "INTERFACE_" #PROPERTY static const char* targetPropertyTransitiveWhitelist[] = { @@ -2285,6 +2330,7 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode( { "INSTALL_PREFIX", &installPrefixNode }, { "JOIN", &joinNode }, { "LINK_ONLY", &linkOnlyNode }, + { "COMPILE_LANG_AND_ID", &languageAndIdNode }, { "COMPILE_LANGUAGE", &languageNode }, { "SHELL_PATH", &shellPathNode } }; diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx index 606febe..7b58389 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.cxx +++ b/Source/cmGlobalMSYSMakefileGenerator.cxx @@ -48,7 +48,7 @@ void cmGlobalMSYSMakefileGenerator::EnableLanguage( const std::string& makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); std::vector<std::string> locations; - std::string makeloc = cmSystemTools::GetProgramPath(makeProgram.c_str()); + std::string makeloc = cmSystemTools::GetProgramPath(makeProgram); locations.push_back(this->FindMinGW(makeloc)); locations.push_back(makeloc); locations.push_back("/mingw/bin"); @@ -77,8 +77,8 @@ void cmGlobalMSYSMakefileGenerator::EnableLanguage( if (!mf->IsSet("CMAKE_AR") && !this->CMakeInstance->GetIsInTryCompile() && !(1 == l.size() && l[0] == "NONE")) { cmSystemTools::Error( - "CMAKE_AR was not found, please set to archive program. ", - mf->GetDefinition("CMAKE_AR")); + "CMAKE_AR was not found, please set to archive program. " + + mf->GetSafeDefinition("CMAKE_AR")); } } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 00276f8..5ddaaa3 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -574,7 +574,7 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures() static std::string const k_DYNDEP_ = ".dyndep-"; std::string::size_type pos = this->NinjaVersion.find(k_DYNDEP_); if (pos != std::string::npos) { - const char* fv = this->NinjaVersion.c_str() + pos + k_DYNDEP_.size(); + const char* fv = &this->NinjaVersion[pos + k_DYNDEP_.size()]; cmSystemTools::StringToULong(fv, &this->NinjaSupportsDyndeps); } } @@ -1254,7 +1254,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) for (std::string const& i : unknownExplicitDepends) { // verify the file is in the build directory std::string const absDepPath = - cmSystemTools::CollapseFullPath(i, rootBuildDirectory.c_str()); + cmSystemTools::CollapseFullPath(i, rootBuildDirectory); bool const inBuildDir = cmSystemTools::IsSubDirectory(absDepPath, rootBuildDirectory); if (inBuildDir) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 65d816e..1ea3673 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -169,7 +169,7 @@ void cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand( { if (this->CommandDatabase == nullptr) { std::string commandDatabaseName = - std::string(this->GetCMakeInstance()->GetHomeOutputDirectory()) + + this->GetCMakeInstance()->GetHomeOutputDirectory() + "/compile_commands.json"; this->CommandDatabase = new cmGeneratedFileStream(commandDatabaseName); *this->CommandDatabase << "[" << std::endl; diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index c31dbf4..8764ee4 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -45,7 +45,6 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( cmake* cm, std::string const& platformInGeneratorName) : cmGlobalVisualStudioGenerator(cm, platformInGeneratorName) { - this->IntelProjectVersion = 0; this->DevEnvCommandInitialized = false; this->MasmEnabled = false; this->NasmEnabled = false; @@ -54,21 +53,20 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator() { - free(this->IntelProjectVersion); } // Package GUID of Intel Visual Fortran plugin to VS IDE #define CM_INTEL_PLUGIN_GUID "{B68A201D-CB9B-47AF-A52F-7EEC72E217E4}" -const char* cmGlobalVisualStudio7Generator::GetIntelProjectVersion() +const std::string& cmGlobalVisualStudio7Generator::GetIntelProjectVersion() { - if (!this->IntelProjectVersion) { + if (this->IntelProjectVersion.empty()) { // Compute the version of the Intel plugin to the VS IDE. // If the key does not exist then use a default guess. std::string intelVersion; std::string vskey = this->GetRegistryBase(); vskey += "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion"; - cmSystemTools::ReadRegistryValue(vskey.c_str(), intelVersion, + cmSystemTools::ReadRegistryValue(vskey, intelVersion, cmSystemTools::KeyWOW64_32); unsigned int intelVersionNumber = ~0u; sscanf(intelVersion.c_str(), "%u", &intelVersionNumber); @@ -81,7 +79,7 @@ const char* cmGlobalVisualStudio7Generator::GetIntelProjectVersion() } else { // Version <= 9: use ProductVersion from registry. } - this->IntelProjectVersion = strdup(intelVersion.c_str()); + this->IntelProjectVersion = intelVersion; } return this->IntelProjectVersion; } @@ -237,7 +235,7 @@ cmGlobalVisualStudio7Generator::GenerateBuildCommand( GeneratedMakeCommand makeCommand; makeCommand.RequiresOutputForward = requiresOutputForward; makeCommand.Add(makeProgramSelected); - makeCommand.Add(std::string(projectName) + ".sln"); + makeCommand.Add(projectName + ".sln"); makeCommand.Add((clean ? "/clean" : "/build")); makeCommand.Add((config.empty() ? "Debug" : config)); makeCommand.Add("/project"); @@ -270,7 +268,7 @@ bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s, cmMakefile* mf) { mf->AddDefinition("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION", - this->GetIntelProjectVersion()); + this->GetIntelProjectVersion().c_str()); return this->cmGlobalVisualStudioGenerator::SetSystemName(s, mf); } @@ -615,7 +613,7 @@ std::string cmGlobalVisualStudio7Generator::GetGUID(std::string const& name) { std::string const& guidStoreName = name + "_GUID_CMAKE"; if (const char* storedGUID = - this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str())) { + this->CMakeInstance->GetCacheDefinition(guidStoreName)) { return std::string(storedGUID); } // Compute a GUID that is deterministic but unique to the build tree. diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 1e76383..f004afb 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -86,7 +86,7 @@ public: return false; } - const char* GetIntelProjectVersion(); + const std::string& GetIntelProjectVersion(); bool FindMakeProgram(cmMakefile* mf) override; @@ -163,7 +163,7 @@ protected: bool NasmEnabled; private: - char* IntelProjectVersion; + std::string IntelProjectVersion; std::string DevEnvCommand; bool DevEnvCommandInitialized; std::string GetVSMakeProgram() override { return this->GetDevEnvCommand(); } diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 21abdf7..0da9986 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -188,8 +188,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() commandLine.push_back("--check-stamp-list"); commandLine.push_back(stampList.c_str()); commandLine.push_back("--vs-solution-file"); - std::string const sln = std::string(lg->GetBinaryDirectory()) + "/" + - lg->GetProjectName() + ".sln"; + std::string const sln = + lg->GetBinaryDirectory() + "/" + lg->GetProjectName() + ".sln"; commandLine.push_back(sln); cmCustomCommandLines commandLines; commandLines.push_back(commandLine); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d5a59c7..f2eb0ce 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -202,7 +202,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator( } } } - if (!versionFile.empty() && cmSystemTools::FileExists(versionFile.c_str())) { + if (!versionFile.empty() && cmSystemTools::FileExists(versionFile)) { parser.ParseFile(versionFile.c_str()); } else if (cmSystemTools::FileExists( "/Applications/Xcode.app/Contents/version.plist")) { @@ -479,7 +479,7 @@ void cmGlobalXCodeGenerator::SetGenerationRoot(cmLocalGenerator* root) this->CurrentXCodeHackMakefile = root->GetCurrentBinaryDirectory(); this->CurrentXCodeHackMakefile += "/CMakeScripts"; - cmSystemTools::MakeDirectory(this->CurrentXCodeHackMakefile.c_str()); + cmSystemTools::MakeDirectory(this->CurrentXCodeHackMakefile); this->CurrentXCodeHackMakefile += "/XCODE_DEPEND_HELPER.make"; } @@ -600,7 +600,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( this->CurrentReRunCMakeMakefile = root->GetCurrentBinaryDirectory(); this->CurrentReRunCMakeMakefile += "/CMakeScripts"; - cmSystemTools::MakeDirectory(this->CurrentReRunCMakeMakefile.c_str()); + cmSystemTools::MakeDirectory(this->CurrentReRunCMakeMakefile); this->CurrentReRunCMakeMakefile += "/ReRunCMake.make"; cmGeneratedFileStream makefileStream(this->CurrentReRunCMakeMakefile); makefileStream.SetCopyIfDifferent(true); @@ -1026,8 +1026,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath( std::string path = this->RelativeToSource(fullpath); std::string name = cmSystemTools::GetFilenameName(path); const char* sourceTree = - (cmSystemTools::FileIsFullPath(path.c_str()) ? "<absolute>" - : "SOURCE_ROOT"); + cmSystemTools::FileIsFullPath(path) ? "<absolute>" : "SOURCE_ROOT"; fileRef->AddAttribute("name", this->CreateString(name)); fileRef->AddAttribute("path", this->CreateString(path)); fileRef->AddAttribute("sourceTree", this->CreateString(sourceTree)); @@ -1588,7 +1587,7 @@ std::string cmGlobalXCodeGenerator::ExtractFlagRegex(const char* exp, std::string::size_type offset = 0; - while (regex.find(flags.c_str() + offset)) { + while (regex.find(&flags[offset])) { const std::string::size_type startPos = offset + regex.start(matchIndex); const std::string::size_type endPos = offset + regex.end(matchIndex); const std::string::size_type size = endPos - startPos; @@ -1641,7 +1640,7 @@ void cmGlobalXCodeGenerator::AddCommandsToBuildPhase( { std::string dir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory(); dir += "/CMakeScripts"; - cmSystemTools::MakeDirectory(dir.c_str()); + cmSystemTools::MakeDirectory(dir); std::string makefile = dir; makefile += "/"; makefile += target->GetName(); @@ -1700,7 +1699,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile( } else { std::ostringstream str; str << "_buildpart_" << count++; - tname[&ccg.GetCC()] = std::string(target->GetName()) + str.str(); + tname[&ccg.GetCC()] = target->GetName() + str.str(); makefileStream << "\\\n\t" << tname[&ccg.GetCC()]; } } @@ -1824,8 +1823,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, std::string llang = gtgt->GetLinkerLanguage(configName); if (binary && llang.empty()) { cmSystemTools::Error( - "CMake can not determine linker language for target: ", - gtgt->GetName().c_str()); + "CMake can not determine linker language for target: " + + gtgt->GetName()); return; } std::string const& langForPreprocessor = llang; @@ -3014,10 +3013,11 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( cmXCodeObject* group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO")); cmXCodeObject* listObjs = this->CreateObject(cmXCodeObject::OBJECT_LIST); - for (auto& CurrentConfigurationType : this->CurrentConfigurationTypes) { + for (const std::string& CurrentConfigurationType : + this->CurrentConfigurationTypes) { cmXCodeObject* buildStyle = this->CreateObject(cmXCodeObject::PBXBuildStyle); - const char* name = CurrentConfigurationType.c_str(); + const std::string& name = CurrentConfigurationType; buildStyle->AddAttribute("name", this->CreateString(name)); buildStyle->SetComment(name); cmXCodeObject* sgroup = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); @@ -3263,8 +3263,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( { cmGeneratedFileStream makefileStream(this->CurrentXCodeHackMakefile); if (!makefileStream) { - cmSystemTools::Error("Could not create", - this->CurrentXCodeHackMakefile.c_str()); + cmSystemTools::Error("Could not create " + this->CurrentXCodeHackMakefile); return; } makefileStream.SetCopyIfDifferent(true); @@ -3401,7 +3400,7 @@ void cmGlobalXCodeGenerator::OutputXCodeProject( xcodeDir += "/"; xcodeDir += root->GetProjectName(); xcodeDir += ".xcodeproj"; - cmSystemTools::MakeDirectory(xcodeDir.c_str()); + cmSystemTools::MakeDirectory(xcodeDir); std::string xcodeProjFile = xcodeDir + "/project.pbxproj"; cmGeneratedFileStream fout(xcodeProjFile); fout.SetCopyIfDifferent(true); diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 7f7ee71..9b651a4 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -70,7 +70,7 @@ void cmLocalNinjaGenerator::Generate() this->WritePools(this->GetRulesFileStream()); - const std::string showIncludesPrefix = + const std::string& showIncludesPrefix = this->GetMakefile()->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX"); if (!showIncludesPrefix.empty()) { cmGlobalNinjaGenerator::WriteComment(this->GetRulesFileStream(), diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index beabf91..9b21739 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -108,7 +108,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule( // Get the language to use for linking this library. std::string linkLanguage = "CUDA"; - std::string const objExt = + std::string const& objExt = this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION"); // Build list of dependencies. diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index a751b24..e62b107 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1430,7 +1430,7 @@ void cmMakefileTargetGenerator::AppendTargetDepends( } // Loop over all library dependencies. - const char* cfg = this->LocalGenerator->GetConfigName().c_str(); + const std::string& cfg = this->LocalGenerator->GetConfigName(); if (cmComputeLinkInformation* cli = this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector<std::string> const& libDeps = cli->GetDepends(); @@ -1635,7 +1635,8 @@ void cmMakefileTargetGenerator::CreateLinkLibs( { std::string frameworkPath; std::string linkPath; - std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); + const std::string& config = + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); cmComputeLinkInformation* pcli = this->GeneratorTarget->GetLinkInformation(config); this->LocalGenerator->OutputLinkLibraries(pcli, linkLineComputer, linkLibs, diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 680f881..dd63a54 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -605,7 +605,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() // First and very important step is to make sure while inside this // step our link language is set to CUDA std::string cudaLinkLanguage = "CUDA"; - std::string const objExt = + std::string const& objExt = this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION"); std::string const cfgName = this->GetConfigName(); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 8afac70..e5f5bf2 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -813,7 +813,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() << cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()) << " target " << this->GetTargetName() << "\n\n"; - std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); + const std::string& config = + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); std::vector<cmSourceFile const*> customCommands; this->GeneratorTarget->GetCustomCommands(customCommands, config); for (cmSourceFile const* sf : customCommands) { @@ -1093,7 +1094,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( if (compilePP) { // In case compilation requires flags that are incompatible with // preprocessing, include them here. - std::string const postFlag = this->Makefile->GetSafeDefinition( + std::string const& postFlag = this->Makefile->GetSafeDefinition( "CMAKE_" + language + "_POSTPROCESS_FLAG"); this->LocalGenerator->AppendFlags(vars["FLAGS"], postFlag); } @@ -1342,8 +1343,7 @@ void cmNinjaTargetGenerator::EnsureDirectoryExists( cmSystemTools::MakeDirectory(path); } else { cmGlobalNinjaGenerator* gg = this->GetGlobalGenerator(); - std::string fullPath = - std::string(gg->GetCMakeInstance()->GetHomeOutputDirectory()); + std::string fullPath = gg->GetCMakeInstance()->GetHomeOutputDirectory(); // Also ensures their is a trailing slash. gg->StripNinjaOutputPathPrefixAsSuffix(fullPath); fullPath += path; diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index cb9433f..4ed5581 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -293,8 +293,8 @@ protected: // Make sure we don't visit the same file more than once. info->DependDone = true; - const char* path = info->FullPath.c_str(); - if (!path) { + const std::string& path = info->FullPath; + if (path.empty()) { cmSystemTools::Error( "Attempt to find dependencies for file without path!"); return; @@ -356,7 +356,7 @@ protected: if (!found) { // Couldn't find any dependency information. if (this->ComplainFileRegularExpression.find(info->IncludeName)) { - cmSystemTools::Error("error cannot find dependencies for ", path); + cmSystemTools::Error("error cannot find dependencies for " + path); } else { // Destroy the name of the file so that it won't be output as a // dependency. diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 38f39fb..a5e0f32 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -52,12 +52,6 @@ static std::size_t GetParallelCPUCount() return count; } -static void AddCleanFile(cmMakefile* makefile, std::string const& fileName) -{ - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", fileName.c_str(), - false); -} - static std::string FileProjectRelativePath(cmMakefile* makefile, std::string const& fileName) { @@ -320,7 +314,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets() } cmSystemTools::ConvertToUnixSlashes(this->Dir.Build); // Cleanup build directory - AddCleanFile(makefile, this->Dir.Build); + this->AddCleanFile(this->Dir.Build); // Working directory this->Dir.Work = cbd; @@ -381,15 +375,15 @@ bool cmQtAutoGenInitializer::InitCustomTargets() std::string& filename = this->AutogenTarget.ConfigSettingsFile[cfg]; filename = AppendFilenameSuffix(this->AutogenTarget.SettingsFile, "_" + cfg); - AddCleanFile(makefile, filename); + this->AddCleanFile(filename); } } else { - AddCleanFile(makefile, this->AutogenTarget.SettingsFile); + this->AddCleanFile(this->AutogenTarget.SettingsFile); } this->AutogenTarget.ParseCacheFile = this->Dir.Info; this->AutogenTarget.ParseCacheFile += "/ParseCache.txt"; - AddCleanFile(makefile, this->AutogenTarget.ParseCacheFile); + this->AddCleanFile(this->AutogenTarget.ParseCacheFile); } // Autogen target: Compute user defined dependencies @@ -1528,6 +1522,12 @@ bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName, return true; } +void cmQtAutoGenInitializer::AddCleanFile(std::string const& fileName) +{ + Target->Target->AppendProperty("ADDITIONAL_CLEAN_FILES", fileName.c_str(), + false); +} + static unsigned int CharPtrToUInt(const char* const input) { unsigned long tmp = 0; diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index 153f56d..6d2dcb6 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -145,6 +145,7 @@ private: bool prepend = false); bool AddToSourceGroup(std::string const& fileName, std::string const& genNameUpper); + void AddCleanFile(std::string const& fileName); bool GetQtExecutable(GenVarsT& genVars, const std::string& executable, bool ignoreMissingTarget, std::string* output) const; diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 4b0707b..a92c2a0 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -146,7 +146,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv, const char* compileOutput = this->Makefile->GetDefinition(this->OutputVariable); if (compileOutput) { - runOutputContents = std::string(compileOutput) + runOutputContents; + runOutputContents = compileOutput + runOutputContents; } this->Makefile->AddDefinition(this->OutputVariable, runOutputContents.c_str()); @@ -167,7 +167,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, int retVal = -1; std::string finalCommand; - const std::string emulator = + const std::string& emulator = this->Makefile->GetSafeDefinition("CMAKE_CROSSCOMPILING_EMULATOR"); if (!emulator.empty()) { std::vector<std::string> emulatorWithArgs; @@ -233,7 +233,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, this->RunResultVariable + "__TRYRUN_OUTPUT"; bool error = false; - if (this->Makefile->GetDefinition(this->RunResultVariable) == nullptr) { + if (!this->Makefile->GetDefinition(this->RunResultVariable)) { // if the variables doesn't exist, create it with a helpful error text // and mark it as advanced std::string comment; @@ -255,8 +255,8 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, } // is the output from the executable used ? - if (out != nullptr) { - if (this->Makefile->GetDefinition(internalRunOutputName) == nullptr) { + if (out) { + if (!this->Makefile->GetDefinition(internalRunOutputName)) { // if the variables doesn't exist, create it with a helpful error text // and mark it as advanced std::string comment; @@ -304,7 +304,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, comment += " to\n" " the exit code (in many cases 0 for success), otherwise " "enter \"FAILED_TO_RUN\".\n"; - if (out != nullptr) { + if (out) { comment += internalRunOutputName; comment += "\n contains the text the executable " @@ -335,7 +335,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, << this->Makefile->GetDefinition(this->RunResultVariable) << "\"\n CACHE STRING \"Result from TRY_RUN\" FORCE)\n\n"; - if (out != nullptr) { + if (out) { file << "set( " << internalRunOutputName << " \n \"" << this->Makefile->GetDefinition(internalRunOutputName) << "\"\n CACHE STRING \"Output from TRY_RUN\" FORCE)\n\n"; @@ -348,7 +348,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, "please set the following cache variables " "appropriately:\n"; errorMessage += " " + this->RunResultVariable + " (advanced)\n"; - if (out != nullptr) { + if (out) { errorMessage += " " + internalRunOutputName + " (advanced)\n"; } errorMessage += detailsString; @@ -356,7 +356,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, return; } - if (out != nullptr) { + if (out) { (*out) = this->Makefile->GetDefinition(internalRunOutputName); } } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index c60706d..ab9ef79 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2858,7 +2858,7 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions( // Get compile flags for CUDA in this directory. std::string CONFIG = cmSystemTools::UpperCase(configName); - std::string configFlagsVar = std::string("CMAKE_CUDA_FLAGS_") + CONFIG; + std::string configFlagsVar = "CMAKE_CUDA_FLAGS_" + CONFIG; std::string flags = this->Makefile->GetSafeDefinition("CMAKE_CUDA_FLAGS") + " " + this->Makefile->GetSafeDefinition(configFlagsVar); this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, "CUDA", @@ -3075,7 +3075,7 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions( Options& masmOptions = *pOptions; std::string CONFIG = cmSystemTools::UpperCase(configName); - std::string configFlagsVar = std::string("CMAKE_ASM_MASM_FLAGS_") + CONFIG; + std::string configFlagsVar = "CMAKE_ASM_MASM_FLAGS_" + CONFIG; std::string flags = this->Makefile->GetSafeDefinition("CMAKE_ASM_MASM_FLAGS") + " " + this->Makefile->GetSafeDefinition(configFlagsVar); @@ -3428,7 +3428,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::string standardLibsVar = "CMAKE_"; standardLibsVar += linkLanguage; standardLibsVar += "_STANDARD_LIBRARIES"; - std::string const libs = this->Makefile->GetSafeDefinition(standardLibsVar); + std::string const& libs = this->Makefile->GetSafeDefinition(standardLibsVar); cmSystemTools::ParseWindowsCommandLine(libs.c_str(), libVec); linkOptions.AddFlag("AdditionalDependencies", libVec); |