summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmCustomCommandGenerator.cxx2
-rw-r--r--Source/cmExportFileGenerator.cxx4
-rw-r--r--Source/cmExportFileGenerator.h2
-rw-r--r--Source/cmExtraSublimeTextGenerator.cxx6
-rw-r--r--Source/cmExtraSublimeTextGenerator.h3
-rw-r--r--Source/cmGeneratorTarget.cxx22
-rw-r--r--Source/cmGeneratorTarget.h6
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx11
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx8
-rw-r--r--Source/cmGlobalVisualStudio71Generator.h7
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx14
-rw-r--r--Source/cmGlobalVisualStudio7Generator.h11
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx2
-rw-r--r--Source/cmGlobalVisualStudio8Generator.h2
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx6
-rw-r--r--Source/cmIncludeExternalMSProjectCommand.cxx4
-rw-r--r--Source/cmLocalGenerator.cxx8
-rw-r--r--Source/cmLocalGenerator.h16
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx10
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.h2
-rw-r--r--Source/cmLocalVisualStudio10Generator.cxx3
-rw-r--r--Source/cmMakefile.h4
-rw-r--r--Source/cmTarget.cxx12
-rw-r--r--Source/cmTargetPropertyComputer.h12
-rw-r--r--Source/cmake.cxx2
25 files changed, 85 insertions, 94 deletions
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index 34f815f..2432d2b 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -139,7 +139,7 @@ const char* cmCustomCommandGenerator::GetArgv0Location(unsigned int c) const
(target->IsImported() ||
target->GetProperty("CROSSCOMPILING_EMULATOR") ||
!this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING"))) {
- return target->GetLocation(this->Config);
+ return target->GetLocation(this->Config).c_str();
}
return nullptr;
}
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 27e9906..6441e6f 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -61,9 +61,9 @@ void cmExportFileGenerator::SetExportFile(const char* mainFile)
cmSystemTools::GetFilenameLastExtension(this->MainImportFile);
}
-const char* cmExportFileGenerator::GetMainExportFileName() const
+const std::string& cmExportFileGenerator::GetMainExportFileName() const
{
- return this->MainImportFile.c_str();
+ return this->MainImportFile;
}
bool cmExportFileGenerator::GenerateImportFile()
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index 0d69779..e9d0da7 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -46,7 +46,7 @@ public:
/** Set the full path to the export file to generate. */
void SetExportFile(const char* mainFile);
- const char* GetMainExportFileName() const;
+ const std::string& GetMainExportFileName() const;
/** Set the namespace in which to place exported target names. */
void SetNamespace(const std::string& ns) { this->Namespace = ns; }
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 603fea3..413449c 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -297,8 +297,7 @@ void cmExtraSublimeTextGenerator::AppendTarget(
fout << "\t{\n\t\t\t\"name\": \"" << lg->GetProjectName() << " - "
<< targetName << "\",\n";
fout << "\t\t\t\"cmd\": ["
- << this->BuildMakeCommand(make, makefileName.c_str(), targetName)
- << "],\n";
+ << this->BuildMakeCommand(make, makefileName, targetName) << "],\n";
fout << "\t\t\t\"working_dir\": \"${project_path}\",\n";
fout << "\t\t\t\"file_regex\": \""
"^(..[^:]*)(?::|\\\\()([0-9]+)(?::|\\\\))(?:([0-9]+):)?\\\\s*(.*)"
@@ -309,7 +308,8 @@ void cmExtraSublimeTextGenerator::AppendTarget(
// Create the command line for building the given target using the selected
// make
std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
- const std::string& make, const char* makefile, const std::string& target)
+ const std::string& make, const std::string& makefile,
+ const std::string& target)
{
std::string command = cmStrCat('"', make, '"');
std::string generator = this->GlobalGenerator->GetName();
diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h
index 7e8f2d4..078cfe7 100644
--- a/Source/cmExtraSublimeTextGenerator.h
+++ b/Source/cmExtraSublimeTextGenerator.h
@@ -44,7 +44,8 @@ private:
/** Returns the build command that needs to be executed to build the
* specified 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);
/** Appends the specified target to the generated project file as a Sublime
* Text build system.
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index c525a6e..4dfc33d 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -54,11 +54,11 @@ const char* cmTargetPropertyComputer::GetSources<cmGeneratorTarget>(
cmGeneratorTarget const* tgt, cmMessenger* /* messenger */,
cmListFileBacktrace const& /* context */)
{
- return tgt->GetSourcesProperty();
+ return tgt->GetSourcesProperty().c_str();
}
template <>
-const char*
+const std::string&
cmTargetPropertyComputer::ComputeLocationForBuild<cmGeneratorTarget>(
cmGeneratorTarget const* tgt)
{
@@ -66,7 +66,8 @@ cmTargetPropertyComputer::ComputeLocationForBuild<cmGeneratorTarget>(
}
template <>
-const char* cmTargetPropertyComputer::ComputeLocation<cmGeneratorTarget>(
+const std::string&
+cmTargetPropertyComputer::ComputeLocation<cmGeneratorTarget>(
cmGeneratorTarget const* tgt, const std::string& config)
{
return tgt->GetLocation(config);
@@ -310,7 +311,7 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg)
cmGeneratorTarget::~cmGeneratorTarget() = default;
-const char* cmGeneratorTarget::GetSourcesProperty() const
+const std::string& cmGeneratorTarget::GetSourcesProperty() const
{
std::vector<std::string> values;
for (auto& se : this->SourceEntries) {
@@ -319,7 +320,7 @@ const char* cmGeneratorTarget::GetSourcesProperty() const
static std::string value;
value.clear();
value = cmJoin(values, ";");
- return value.c_str();
+ return value;
}
cmGlobalGenerator* cmGeneratorTarget::GetGlobalGenerator() const
@@ -996,7 +997,8 @@ void cmGeneratorTarget::GetXamlSources(std::vector<cmSourceFile const*>& data,
IMPLEMENT_VISIT(SourceKindXaml);
}
-const char* cmGeneratorTarget::GetLocation(const std::string& config) const
+const std::string& cmGeneratorTarget::GetLocation(
+ const std::string& config) const
{
static std::string location;
if (this->IsImported()) {
@@ -1005,7 +1007,7 @@ const char* cmGeneratorTarget::GetLocation(const std::string& config) const
} else {
location = this->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact);
}
- return location.c_str();
+ return location;
}
std::vector<cmCustomCommand> const& cmGeneratorTarget::GetPreBuildCommands()
@@ -1036,13 +1038,13 @@ bool cmGeneratorTarget::IsImportedGloballyVisible() const
return this->Target->IsImportedGloballyVisible();
}
-const char* cmGeneratorTarget::GetLocationForBuild() const
+const std::string& cmGeneratorTarget::GetLocationForBuild() const
{
static std::string location;
if (this->IsImported()) {
location = this->Target->ImportedGetFullPath(
"", cmStateEnums::RuntimeBinaryArtifact);
- return location.c_str();
+ return location;
}
// Now handle the deprecated build-time configuration location.
@@ -1062,7 +1064,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const
}
location += "/";
location += this->GetFullName("", cmStateEnums::RuntimeBinaryArtifact);
- return location.c_str();
+ return location;
}
bool cmGeneratorTarget::IsSystemIncludeDirectory(
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index ac254c1..b647b25 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -46,7 +46,7 @@ public:
bool IsImported() const;
bool IsImportedGloballyVisible() const;
- const char* GetLocation(const std::string& config) const;
+ const std::string& GetLocation(const std::string& config) const;
std::vector<cmCustomCommand> const& GetPreBuildCommands() const;
std::vector<cmCustomCommand> const& GetPreLinkCommands() const;
@@ -65,7 +65,7 @@ public:
/** Get the location of the target in the build tree with a placeholder
referencing the configuration in the native build system. This
location is suitable for use as the LOCATION target property. */
- const char* GetLocationForBuild() const;
+ const std::string& GetLocationForBuild() const;
cmComputeLinkInformation* GetLinkInformation(
const std::string& config) const;
@@ -770,7 +770,7 @@ public:
std::string GetFortranModuleDirectory(std::string const& working_dir) const;
- const char* GetSourcesProperty() const;
+ const std::string& GetSourcesProperty() const;
private:
void AddSourceCommon(const std::string& src, bool before = false);
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index a720cc3..fd65584 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -615,7 +615,7 @@ void cmGlobalVisualStudio10Generator::Generate()
"To avoid this problem CMake must use a full path for this file "
"which then triggers the VS 10 property dialog bug.";
/* clang-format on */
- lg->IssueMessage(MessageType::WARNING, e.str().c_str());
+ lg->IssueMessage(MessageType::WARNING, e.str());
}
}
@@ -836,7 +836,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
// Prepare the work directory.
if (!cmSystemTools::MakeDirectory(wd)) {
std::string e = "Failed to make directory:\n " + wd;
- mf->IssueMessage(MessageType::FATAL_ERROR, e.c_str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -957,7 +957,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
if (ret != 0) {
e << "Exit code: " << ret << "\n";
}
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str().c_str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -1131,8 +1131,7 @@ std::string cmGlobalVisualStudio10Generator::GenerateRuleFile(
// Hide them away under the CMakeFiles directory.
std::string ruleDir = cmStrCat(
this->GetCMakeInstance()->GetHomeOutputDirectory(), "/CMakeFiles/",
- cmSystemTools::ComputeStringMD5(
- cmSystemTools::GetFilenamePath(output).c_str()));
+ cmSystemTools::ComputeStringMD5(cmSystemTools::GetFilenamePath(output)));
std::string ruleFile =
cmStrCat(ruleDir, '/', cmSystemTools::GetFilenameName(output), ".rule");
return ruleFile;
@@ -1326,7 +1325,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable(
e << "JSON flag table \"" << filename <<
"\" could not be loaded.\n";
/* clang-format on */
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str().c_str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
}
return ret;
}
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index e8e9ece..ec1380b 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -87,7 +87,7 @@ void cmGlobalVisualStudio71Generator::WriteSolutionConfigurations(
// the libraries it uses are also done here
void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
const std::string& dspname,
- const char* dir,
+ const std::string& dir,
cmGeneratorTarget const* t)
{
// check to see if this is a fortran build
@@ -109,7 +109,7 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
std::string guid = this->GetGUID(dspname);
fout << project << dspname << "\", \"" << this->ConvertToSolutionPath(dir)
- << (dir[0] ? "\\" : "") << dspname << ext << "\", \"{" << guid
+ << (!dir.empty() ? "\\" : "") << dspname << ext << "\", \"{" << guid
<< "}\"\n";
fout << "\tProjectSection(ProjectDependencies) = postProject\n";
this->WriteProjectDepends(fout, dspname, dir, t);
@@ -138,7 +138,7 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
// Note, that dependencies from executables to
// the libraries it uses are also done here
void cmGlobalVisualStudio71Generator::WriteProjectDepends(
- std::ostream& fout, const std::string&, const char*,
+ std::ostream& fout, const std::string&, const std::string&,
cmGeneratorTarget const* target)
{
VSDependSet const& depends = this->VSTargetDepends[target];
@@ -156,7 +156,7 @@ void cmGlobalVisualStudio71Generator::WriteProjectDepends(
// Write a dsp file into the SLN file, Note, that dependencies from
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio71Generator::WriteExternalProject(
- std::ostream& fout, const std::string& name, const char* location,
+ std::ostream& fout, const std::string& name, const std::string& location,
const char* typeGuid, const std::set<BT<std::string>>& depends)
{
fout << "Project(\"{"
diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h
index 85755af..61a2f6f 100644
--- a/Source/cmGlobalVisualStudio71Generator.h
+++ b/Source/cmGlobalVisualStudio71Generator.h
@@ -22,9 +22,10 @@ protected:
virtual void WriteSolutionConfigurations(
std::ostream& fout, std::vector<std::string> const& configs);
void WriteProject(std::ostream& fout, const std::string& name,
- const char* path, const cmGeneratorTarget* t) override;
+ const std::string& path,
+ const cmGeneratorTarget* t) override;
void WriteProjectDepends(std::ostream& fout, const std::string& name,
- const char* path,
+ const std::string& path,
cmGeneratorTarget const* t) override;
void WriteProjectConfigurations(
std::ostream& fout, const std::string& name,
@@ -32,7 +33,7 @@ protected:
const std::set<std::string>& configsPartOfDefaultBuild,
const std::string& platformMapping = "") override;
void WriteExternalProject(std::ostream& fout, const std::string& name,
- const char* path, const char* typeGuid,
+ const std::string& path, const char* typeGuid,
const std::set<BT<std::string>>& depends) override;
// Folders are not supported by VS 7.1.
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 04ec7b3..9799124 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -186,7 +186,7 @@ std::string cmGlobalVisualStudio7Generator::FindDevEnvCommand()
}
const char* cmGlobalVisualStudio7Generator::ExternalProjectType(
- const char* location)
+ const std::string& location)
{
std::string extension = cmSystemTools::GetFilenameLastExtension(location);
if (extension == ".vbproj") {
@@ -346,8 +346,8 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
if (expath) {
std::set<std::string> allConfigurations(configs.begin(), configs.end());
const char* mapping = target->GetProperty("VS_PLATFORM_MAPPING");
- this->WriteProjectConfigurations(fout, target->GetName().c_str(),
- *target, configs, allConfigurations,
+ this->WriteProjectConfigurations(fout, target->GetName(), *target,
+ configs, allConfigurations,
mapping ? mapping : "");
} else {
const std::set<std::string>& configsPartOfDefaultBuild =
@@ -380,7 +380,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
std::string project = target->GetName();
std::string location = expath;
- this->WriteExternalProject(fout, project.c_str(), location.c_str(),
+ this->WriteExternalProject(fout, project, location,
target->GetProperty("VS_PROJECT_TYPE"),
target->GetUtilities());
written = true;
@@ -389,11 +389,11 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
if (vcprojName) {
cmLocalGenerator* lg = target->GetLocalGenerator();
std::string dir = lg->GetCurrentBinaryDirectory();
- dir = root->MaybeConvertToRelativePath(rootBinaryDir, dir.c_str());
+ dir = root->MaybeConvertToRelativePath(rootBinaryDir, dir);
if (dir == ".") {
dir.clear(); // msbuild cannot handle ".\" prefix
}
- this->WriteProject(fout, vcprojName, dir.c_str(), target);
+ this->WriteProject(fout, vcprojName, dir, target);
written = true;
}
}
@@ -483,7 +483,7 @@ void cmGlobalVisualStudio7Generator::WriteFoldersContent(std::ostream& fout)
}
std::string cmGlobalVisualStudio7Generator::ConvertToSolutionPath(
- const char* path)
+ const std::string& path)
{
// Convert to backslashes. Do not use ConvertToOutputPath because
// we will add quoting ourselves, and we know these projects always
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index 974bb1d..699f091 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -110,16 +110,17 @@ protected:
std::string const& GetDevEnvCommand();
virtual std::string FindDevEnvCommand();
- static const char* ExternalProjectType(const char* location);
+ static const char* ExternalProjectType(const std::string& location);
virtual void OutputSLNFile(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators) = 0;
virtual void WriteProject(std::ostream& fout, const std::string& name,
- const char* path, const cmGeneratorTarget* t) = 0;
+ const std::string& path,
+ const cmGeneratorTarget* t) = 0;
virtual void WriteProjectDepends(std::ostream& fout, const std::string& name,
- const char* path,
+ const std::string& path,
cmGeneratorTarget const* t) = 0;
virtual void WriteProjectConfigurations(
std::ostream& fout, const std::string& name,
@@ -141,10 +142,10 @@ protected:
OrderedTargetDependSet const& projectTargets);
virtual void WriteExternalProject(
- std::ostream& fout, const std::string& name, const char* path,
+ std::ostream& fout, const std::string& name, const std::string& path,
const char* typeGuid, const std::set<BT<std::string>>& dependencies) = 0;
- std::string ConvertToSolutionPath(const char* path);
+ std::string ConvertToSolutionPath(const std::string& path);
std::set<std::string> IsPartOfDefaultBuild(
std::vector<std::string> const& configs,
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index ba54f98..c0551f7 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -307,7 +307,7 @@ bool cmGlobalVisualStudio8Generator::ComputeTargetDepends()
}
void cmGlobalVisualStudio8Generator::WriteProjectDepends(
- std::ostream& fout, const std::string&, const char*,
+ std::ostream& fout, const std::string&, const std::string&,
cmGeneratorTarget const* gt)
{
TargetDependSet const& unordered = this->GetTargetDirectDepends(gt);
diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h
index 352bc3c..8f8e33b 100644
--- a/Source/cmGlobalVisualStudio8Generator.h
+++ b/Source/cmGlobalVisualStudio8Generator.h
@@ -74,7 +74,7 @@ protected:
const std::string& platformMapping = "") override;
bool ComputeTargetDepends() override;
void WriteProjectDepends(std::ostream& fout, const std::string& name,
- const char* path,
+ const std::string& path,
const cmGeneratorTarget* t) override;
bool UseFolderProperty() const override;
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index be5cfd4..012a77c 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -308,7 +308,7 @@ void cmGlobalVisualStudioGenerator::CallVisualStudioMacro(
if (!dir.empty()) {
std::string macrosFile = dir + "/CMakeMacros/" CMAKE_VSMACROS_FILENAME;
std::string nextSubkeyName;
- if (cmSystemTools::FileExists(macrosFile.c_str()) &&
+ if (cmSystemTools::FileExists(macrosFile) &&
IsVisualStudioMacrosFileRegistered(
macrosFile, this->GetUserMacrosRegKeyBase(), nextSubkeyName)) {
if (m == MacroReload) {
@@ -593,7 +593,7 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
std::string filepath;
std::string filepathname;
std::string filepathpath;
- if (cmSystemTools::FileExists(fullname.c_str())) {
+ if (cmSystemTools::FileExists(fullname)) {
filename = cmSystemTools::GetFilenameName(fullname);
filepath = cmSystemTools::GetFilenamePath(fullname);
filepathname = cmSystemTools::GetFilenameName(filepath);
@@ -917,7 +917,7 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
std::string objFile = it;
// replace $(ConfigurationName) in the object names
cmSystemTools::ReplaceString(objFile, this->GetCMakeCFGIntDir(),
- configName.c_str());
+ configName);
if (cmHasLiteralSuffix(objFile, ".obj")) {
fout << objFile << "\n";
}
diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx
index e59c428..86a0921 100644
--- a/Source/cmIncludeExternalMSProjectCommand.cxx
+++ b/Source/cmIncludeExternalMSProjectCommand.cxx
@@ -77,8 +77,8 @@ bool cmIncludeExternalMSProjectCommand(std::vector<std::string> const& args,
if (!customGuid.empty()) {
std::string guidVariable = utility_name + "_GUID_CMAKE";
- mf.GetCMakeInstance()->AddCacheEntry(guidVariable.c_str(),
- customGuid.c_str(), "Stored GUID",
+ mf.GetCMakeInstance()->AddCacheEntry(guidVariable, customGuid.c_str(),
+ "Stored GUID",
cmStateEnums::INTERNAL);
}
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 261413a..cf6802d 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2749,11 +2749,11 @@ void cmLocalGenerator::AppendPositionIndependentLinkerFlags(
}
void cmLocalGenerator::AppendCompileOptions(std::string& options,
- const char* options_list,
+ std::string const& options_list,
const char* regex) const
{
// Short-circuit if there are no options.
- if (!options_list) {
+ if (options_list.empty()) {
return;
}
@@ -2807,11 +2807,11 @@ void cmLocalGenerator::AppendCompileOptions(
}
void cmLocalGenerator::AppendIncludeDirectories(
- std::vector<std::string>& includes, const char* includes_list,
+ std::vector<std::string>& includes, const std::string& includes_list,
const cmSourceFile& sourceFile) const
{
// Short-circuit if there are no includes.
- if (!includes_list) {
+ if (includes_list.empty()) {
return;
}
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index b91d5f7..88194b7 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -167,15 +167,8 @@ public:
* Process a list of include directories
*/
void AppendIncludeDirectories(std::vector<std::string>& includes,
- const char* includes_list,
- const cmSourceFile& sourceFile) const;
- void AppendIncludeDirectories(std::vector<std::string>& includes,
std::string const& includes_list,
- const cmSourceFile& sourceFile) const
- {
- this->AppendIncludeDirectories(includes, includes_list.c_str(),
- sourceFile);
- }
+ const cmSourceFile& sourceFile) const;
void AppendIncludeDirectories(std::vector<std::string>& includes,
const std::vector<std::string>& includes_vec,
const cmSourceFile& sourceFile) const;
@@ -195,14 +188,9 @@ public:
* Encode a list of compile options for the compiler
* command line.
*/
- void AppendCompileOptions(std::string& options, const char* options_list,
- const char* regex = nullptr) const;
void AppendCompileOptions(std::string& options,
std::string const& options_list,
- const char* regex = nullptr) const
- {
- this->AppendCompileOptions(options, options_list.c_str(), regex);
- }
+ const char* regex = nullptr) const;
void AppendCompileOptions(std::string& options,
const std::vector<std::string>& options_vec,
const char* regex = nullptr) const;
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 1420f7c..d037b93 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1972,18 +1972,18 @@ void cmLocalUnixMakefileGenerator3::WriteDivider(std::ostream& os)
}
void cmLocalUnixMakefileGenerator3::WriteCMakeArgument(std::ostream& os,
- const char* s)
+ const std::string& s)
{
// Write the given string to the stream with escaping to get it back
// into CMake through the lexical scanner.
os << "\"";
- for (const char* c = s; *c; ++c) {
- if (*c == '\\') {
+ for (char c : s) {
+ if (c == '\\') {
os << "\\\\";
- } else if (*c == '"') {
+ } else if (c == '"') {
os << "\\\"";
} else {
- os << *c;
+ os << c;
}
}
os << "\"";
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index 1629e63..68eeb29 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -77,7 +77,7 @@ public:
void SetBorlandMakeCurlyHack(bool b) { this->BorlandMakeCurlyHack = b; }
// used in writing out Cmake files such as WriteDirectoryInformation
- static void WriteCMakeArgument(std::ostream& os, const char* s);
+ static void WriteCMakeArgument(std::ostream& os, const std::string& s);
/** creates the common disclaimer text at the top of each makefile */
void WriteDisclaimer(std::ostream& os);
diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx
index 6f456c6..02e2c6d 100644
--- a/Source/cmLocalVisualStudio10Generator.cxx
+++ b/Source/cmLocalVisualStudio10Generator.cxx
@@ -128,8 +128,7 @@ void cmLocalVisualStudio10Generator::ReadAndStoreExternalGUID(
std::string guidStoreName = cmStrCat(name, "_GUID_CMAKE");
// save the GUID in the cache
this->GlobalGenerator->GetCMakeInstance()->AddCacheEntry(
- guidStoreName.c_str(), parser.GUID.c_str(), "Stored GUID",
- cmStateEnums::INTERNAL);
+ guidStoreName, parser.GUID.c_str(), "Stored GUID", cmStateEnums::INTERNAL);
}
const char* cmLocalVisualStudio10Generator::ReportErrorLabel() const
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 68f2c2f..f1a68c2 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -419,9 +419,9 @@ public:
{
this->ComplainFileRegularExpression = regex;
}
- const char* GetComplainRegularExpression() const
+ const std::string& GetComplainRegularExpression() const
{
- return this->ComplainFileRegularExpression.c_str();
+ return this->ComplainFileRegularExpression;
}
// -- List of targets
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index b69d4e8..a0c217b 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -39,13 +39,13 @@
#include "cmake.h"
template <>
-const char* cmTargetPropertyComputer::ComputeLocationForBuild<cmTarget>(
+const std::string& cmTargetPropertyComputer::ComputeLocationForBuild<cmTarget>(
cmTarget const* tgt)
{
static std::string loc;
if (tgt->IsImported()) {
loc = tgt->ImportedGetFullPath("", cmStateEnums::RuntimeBinaryArtifact);
- return loc.c_str();
+ return loc;
}
cmGlobalGenerator* gg = tgt->GetGlobalGenerator();
@@ -54,18 +54,18 @@ const char* cmTargetPropertyComputer::ComputeLocationForBuild<cmTarget>(
}
cmGeneratorTarget* gt = gg->FindGeneratorTarget(tgt->GetName());
loc = gt->GetLocationForBuild();
- return loc.c_str();
+ return loc;
}
template <>
-const char* cmTargetPropertyComputer::ComputeLocation<cmTarget>(
+const std::string& cmTargetPropertyComputer::ComputeLocation<cmTarget>(
cmTarget const* tgt, const std::string& config)
{
static std::string loc;
if (tgt->IsImported()) {
loc =
tgt->ImportedGetFullPath(config, cmStateEnums::RuntimeBinaryArtifact);
- return loc.c_str();
+ return loc;
}
cmGlobalGenerator* gg = tgt->GetGlobalGenerator();
@@ -74,7 +74,7 @@ const char* cmTargetPropertyComputer::ComputeLocation<cmTarget>(
}
cmGeneratorTarget* gt = gg->FindGeneratorTarget(tgt->GetName());
loc = gt->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact);
- return loc.c_str();
+ return loc;
}
template <>
diff --git a/Source/cmTargetPropertyComputer.h b/Source/cmTargetPropertyComputer.h
index 3b11acd..df34f18 100644
--- a/Source/cmTargetPropertyComputer.h
+++ b/Source/cmTargetPropertyComputer.h
@@ -46,10 +46,10 @@ private:
cmListFileBacktrace const& context);
template <typename Target>
- static const char* ComputeLocationForBuild(Target const* tgt);
+ static const std::string& ComputeLocationForBuild(Target const* tgt);
template <typename Target>
- static const char* ComputeLocation(Target const* tgt,
- std::string const& config);
+ static const std::string& ComputeLocation(Target const* tgt,
+ std::string const& config);
template <typename Target>
static const char* GetLocation(Target const* tgt, std::string const& prop,
@@ -71,7 +71,7 @@ private:
context)) {
return nullptr;
}
- return ComputeLocationForBuild(tgt);
+ return ComputeLocationForBuild(tgt).c_str();
}
// Support "LOCATION_<CONFIG>".
@@ -82,7 +82,7 @@ private:
return nullptr;
}
std::string configName = prop.substr(9);
- return ComputeLocation(tgt, configName);
+ return ComputeLocation(tgt, configName).c_str();
}
// Support "<CONFIG>_LOCATION".
@@ -95,7 +95,7 @@ private:
context)) {
return nullptr;
}
- return ComputeLocation(tgt, configName);
+ return ComputeLocation(tgt, configName).c_str();
}
}
}
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 8214c52..5fa40d5 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -389,7 +389,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
}
}
cmsys::RegularExpression regex(
- cmsys::Glob::PatternToRegex(entryPattern, true, true).c_str());
+ cmsys::Glob::PatternToRegex(entryPattern, true, true));
// go through all cache entries and collect the vars which will be
// removed
std::vector<std::string> entriesToDelete;