summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmCustomCommandGenerator.cxx4
-rw-r--r--Source/cmGeneratorTarget.cxx22
-rw-r--r--Source/cmGlobalGenerator.cxx11
-rw-r--r--Source/cmGlobalGenerator.h6
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h2
-rw-r--r--Source/cmInstallCommand.cxx50
-rw-r--r--Source/cmInstallDirectoryGenerator.cxx16
-rw-r--r--Source/cmInstallDirectoryGenerator.h21
-rw-r--r--Source/cmInstallExportGenerator.cxx14
-rw-r--r--Source/cmInstallExportGenerator.h20
-rw-r--r--Source/cmInstallFilesCommand.cxx8
-rw-r--r--Source/cmInstallFilesGenerator.cxx15
-rw-r--r--Source/cmInstallFilesGenerator.h18
-rw-r--r--Source/cmInstallGenerator.cxx15
-rw-r--r--Source/cmInstallGenerator.h14
-rw-r--r--Source/cmInstallProgramsCommand.cxx8
-rw-r--r--Source/cmInstallScriptGenerator.cxx12
-rw-r--r--Source/cmInstallScriptGenerator.h9
-rw-r--r--Source/cmInstallSubdirectoryGenerator.cxx9
-rw-r--r--Source/cmInstallSubdirectoryGenerator.h6
-rw-r--r--Source/cmInstallTargetGenerator.cxx8
-rw-r--r--Source/cmInstallTargetGenerator.h20
-rw-r--r--Source/cmLocalGenerator.cxx297
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx91
-rw-r--r--Source/cmLocalVisualStudio7Generator.h4
-rw-r--r--Source/cmMakefile.cxx2
-rw-r--r--Source/cmMakefileTargetGenerator.cxx49
-rw-r--r--Source/cmMakefileTargetGenerator.h15
-rw-r--r--Source/cmMarkAsAdvancedCommand.cxx62
-rw-r--r--Source/cmPolicies.h5
-rw-r--r--Source/cmQtAutoGenInitializer.cxx24
-rw-r--r--Source/cmQtAutoGenInitializer.h9
-rw-r--r--Source/cmScriptGenerator.h2
34 files changed, 488 insertions, 382 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 58b8191..a2976ab 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 16)
-set(CMake_VERSION_PATCH 20200120)
+set(CMake_VERSION_PATCH 20200122)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index a595007..34f815f 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -8,7 +8,6 @@
#include <cmext/algorithm>
-#include "cmAlgorithms.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandLines.h"
#include "cmGeneratorExpression.h"
@@ -30,9 +29,6 @@ void AppendPaths(const std::vector<std::string>& inputs,
cmExpandedList(cge->Evaluate(lg, config));
for (std::string& it : result) {
cmSystemTools::ConvertToUnixSlashes(it);
- if (cmContains(it, '/') && !cmSystemTools::FileIsFullPath(it)) {
- it = cmStrCat(lg->GetMakefile()->GetCurrentBinaryDirectory(), '/', it);
- }
if (cmSystemTools::FileIsFullPath(it)) {
it = cmSystemTools::CollapseFullPath(
it, lg->GetMakefile()->GetHomeOutputDirectory());
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 4158c53..792cd4d 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -2713,6 +2713,17 @@ void cmTargetTraceDependencies::FollowName(std::string const& name)
if (i == this->NameMap.end() || i->first != name) {
// Check if we know how to generate this file.
cmSourcesWithOutput sources = this->Makefile->GetSourcesWithOutput(name);
+ // If we failed to find a target or source and we have a relative path, it
+ // might be a valid source if made relative to the current binary
+ // directory.
+ if (!sources.Target && !sources.Source &&
+ !cmSystemTools::FileIsFullPath(name)) {
+ auto fullname =
+ cmStrCat(this->Makefile->GetCurrentBinaryDirectory(), '/', name);
+ fullname = cmSystemTools::CollapseFullPath(
+ fullname, this->Makefile->GetHomeOutputDirectory());
+ sources = this->Makefile->GetSourcesWithOutput(fullname);
+ }
i = this->NameMap.emplace_hint(i, name, sources);
}
if (cmTarget* t = i->second.Target) {
@@ -3396,8 +3407,15 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config,
{ "OBJCXX", ".objcxx.hxx" }
};
- filename = cmStrCat(filename, "CMakeFiles/", generatorTarget->GetName(),
- ".dir/cmake_pch", languageToExtension.at(language));
+ filename =
+ cmStrCat(filename, "CMakeFiles/", generatorTarget->GetName(), ".dir");
+
+ if (this->GetGlobalGenerator()->IsMultiConfig()) {
+ filename = cmStrCat(filename, "/", config);
+ }
+
+ filename =
+ cmStrCat(filename, "/cmake_pch", languageToExtension.at(language));
const std::string filename_tmp = cmStrCat(filename, ".tmp");
if (!pchReuseFrom) {
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index b3eb8e4..38ff3ae 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -7,6 +7,7 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
+#include <functional>
#include <initializer_list>
#include <iterator>
#include <sstream>
@@ -3120,6 +3121,16 @@ cmGlobalGenerator::GetFilenameTargetDepends(cmSourceFile* sf) const
return this->FilenameTargetDepends[sf];
}
+const std::string& cmGlobalGenerator::GetRealPath(const std::string& dir)
+{
+ auto i = this->RealPaths.lower_bound(dir);
+ if (i == this->RealPaths.end() ||
+ this->RealPaths.key_comp()(dir, i->first)) {
+ i = this->RealPaths.emplace_hint(i, dir, cmSystemTools::GetRealPath(dir));
+ }
+ return i->second;
+}
+
void cmGlobalGenerator::ProcessEvaluationFiles()
{
std::vector<std::string> generatedFiles;
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index b427992..f6ed10f 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -415,6 +415,8 @@ public:
virtual bool IsXcode() const { return false; }
+ virtual bool IsVisualStudio() const { return false; }
+
/** Return true if we know the exact location of object files.
If false, store the reason in the given string.
This is meaningful only after EnableLanguage has been called. */
@@ -486,6 +488,8 @@ public:
configs.emplace_back("$<CONFIG>");
}
+ std::string const& GetRealPath(std::string const& dir);
+
protected:
// for a project collect all its targets by following depend
// information, and also collect all the targets
@@ -678,6 +682,8 @@ private:
mutable std::map<cmSourceFile*, std::set<cmGeneratorTarget const*>>
FilenameTargetDepends;
+ std::map<std::string, std::string> RealPaths;
+
#if !defined(CMAKE_BOOTSTRAP)
// Pool of file locks
cmFileLockPool FileLockPool;
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index 4f2007f..29a5c2c 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -150,6 +150,8 @@ public:
bool Open(const std::string& bindir, const std::string& projectName,
bool dryRun) override;
+ bool IsVisualStudio() const override { return true; }
+
protected:
cmGlobalVisualStudioGenerator(cmake* cm,
std::string const& platformInGeneratorName);
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 54b85cd..c67358f 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -93,13 +93,12 @@ std::unique_ptr<cmInstallTargetGenerator> CreateInstallTargetGenerator(
cmInstallGenerator::MessageLevel message =
cmInstallGenerator::SelectMessageLevel(target.GetMakefile());
target.SetHaveInstallRule(true);
- const char* component = namelink ? args.GetNamelinkComponent().c_str()
- : args.GetComponent().c_str();
+ const std::string& component =
+ namelink ? args.GetNamelinkComponent() : args.GetComponent();
auto g = cm::make_unique<cmInstallTargetGenerator>(
- target.GetName(), destination.c_str(), impLib,
- args.GetPermissions().c_str(), args.GetConfigurations(), component,
- message, args.GetExcludeFromAll(), args.GetOptional() || forceOpt,
- backtrace);
+ target.GetName(), destination, impLib, args.GetPermissions(),
+ args.GetConfigurations(), component, message, args.GetExcludeFromAll(),
+ args.GetOptional() || forceOpt, backtrace);
target.AddInstallGenerator(g.get());
return g;
}
@@ -122,9 +121,9 @@ std::unique_ptr<cmInstallFilesGenerator> CreateInstallFilesGenerator(
cmInstallGenerator::MessageLevel message =
cmInstallGenerator::SelectMessageLevel(mf);
return cm::make_unique<cmInstallFilesGenerator>(
- absFiles, destination.c_str(), programs, args.GetPermissions().c_str(),
- args.GetConfigurations(), args.GetComponent().c_str(), message,
- args.GetExcludeFromAll(), args.GetRename().c_str(), args.GetOptional());
+ absFiles, destination, programs, args.GetPermissions(),
+ args.GetConfigurations(), args.GetComponent(), message,
+ args.GetExcludeFromAll(), args.GetRename(), args.GetOptional());
}
std::unique_ptr<cmInstallFilesGenerator> CreateInstallFilesGenerator(
@@ -197,14 +196,14 @@ bool HandleScriptMode(std::vector<std::string> const& args,
return false;
}
helper.Makefile->AddInstallGenerator(
- cm::make_unique<cmInstallScriptGenerator>(
- script.c_str(), false, component.c_str(), exclude_from_all));
+ cm::make_unique<cmInstallScriptGenerator>(script, false, component,
+ exclude_from_all));
} else if (doing_code) {
doing_code = false;
std::string const& code = arg;
helper.Makefile->AddInstallGenerator(
- cm::make_unique<cmInstallScriptGenerator>(
- code.c_str(), true, component.c_str(), exclude_from_all));
+ cm::make_unique<cmInstallScriptGenerator>(code, true, component,
+ exclude_from_all));
}
}
@@ -943,7 +942,7 @@ bool HandleDirectoryMode(std::vector<std::string> const& args,
bool exclude_from_all = false;
bool message_never = false;
std::vector<std::string> dirs;
- const char* destination = nullptr;
+ const std::string* destination = nullptr;
std::string permissions_file;
std::string permissions_dir;
std::vector<std::string> configurations;
@@ -1102,7 +1101,7 @@ bool HandleDirectoryMode(std::vector<std::string> const& args,
} else if (doing == DoingConfigurations) {
configurations.push_back(args[i]);
} else if (doing == DoingDestination) {
- destination = args[i].c_str();
+ destination = &args[i];
doing = DoingNone;
} else if (doing == DoingType) {
if (allowedTypes.count(args[i]) == 0) {
@@ -1188,7 +1187,7 @@ bool HandleDirectoryMode(std::vector<std::string> const& args,
return false;
}
destinationStr = helper.GetDestinationForType(nullptr, type);
- destination = destinationStr.c_str();
+ destination = &destinationStr;
} else if (!type.empty()) {
status.SetError(cmStrCat(args[0],
" given both TYPE and DESTINATION "
@@ -1202,9 +1201,8 @@ bool HandleDirectoryMode(std::vector<std::string> const& args,
// Create the directory install generator.
helper.Makefile->AddInstallGenerator(
cm::make_unique<cmInstallDirectoryGenerator>(
- dirs, destination, permissions_file.c_str(), permissions_dir.c_str(),
- configurations, component.c_str(), message, exclude_from_all,
- literal_args.c_str(), optional));
+ dirs, *destination, permissions_file, permissions_dir, configurations,
+ component, message, exclude_from_all, literal_args, optional));
// Tell the global generator about any installation component names
// specified.
@@ -1294,10 +1292,9 @@ bool HandleExportAndroidMKMode(std::vector<std::string> const& args,
// Create the export install generator.
helper.Makefile->AddInstallGenerator(
cm::make_unique<cmInstallExportGenerator>(
- &exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
- ica.GetConfigurations(), ica.GetComponent().c_str(), message,
- ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld,
- true));
+ &exportSet, ica.GetDestination(), ica.GetPermissions(),
+ ica.GetConfigurations(), ica.GetComponent(), message,
+ ica.GetExcludeFromAll(), fname, name_space, exportOld, true));
return true;
#else
@@ -1408,10 +1405,9 @@ bool HandleExportMode(std::vector<std::string> const& args,
// Create the export install generator.
helper.Makefile->AddInstallGenerator(
cm::make_unique<cmInstallExportGenerator>(
- &exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
- ica.GetConfigurations(), ica.GetComponent().c_str(), message,
- ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld,
- false));
+ &exportSet, ica.GetDestination(), ica.GetPermissions(),
+ ica.GetConfigurations(), ica.GetComponent(), message,
+ ica.GetExcludeFromAll(), fname, name_space, exportOld, false));
return true;
}
diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx
index 259c7f7..175e7cf 100644
--- a/Source/cmInstallDirectoryGenerator.cxx
+++ b/Source/cmInstallDirectoryGenerator.cxx
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallDirectoryGenerator.h"
+#include <utility>
+
#include "cmGeneratorExpression.h"
#include "cmInstallType.h"
#include "cmLocalGenerator.h"
@@ -10,18 +12,18 @@
#include "cmSystemTools.h"
cmInstallDirectoryGenerator::cmInstallDirectoryGenerator(
- std::vector<std::string> const& dirs, const char* dest,
- const char* file_permissions, const char* dir_permissions,
- std::vector<std::string> const& configurations, const char* component,
- MessageLevel message, bool exclude_from_all, const char* literal_args,
+ std::vector<std::string> const& dirs, std::string const& dest,
+ std::string file_permissions, std::string dir_permissions,
+ std::vector<std::string> const& configurations, std::string const& component,
+ MessageLevel message, bool exclude_from_all, std::string literal_args,
bool optional)
: cmInstallGenerator(dest, configurations, component, message,
exclude_from_all)
, LocalGenerator(nullptr)
, Directories(dirs)
- , FilePermissions(file_permissions)
- , DirPermissions(dir_permissions)
- , LiteralArguments(literal_args)
+ , FilePermissions(std::move(file_permissions))
+ , DirPermissions(std::move(dir_permissions))
+ , LiteralArguments(std::move(literal_args))
, Optional(optional)
{
// We need per-config actions if destination have generator expressions.
diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h
index 84c0694..bec89df 100644
--- a/Source/cmInstallDirectoryGenerator.h
+++ b/Source/cmInstallDirectoryGenerator.h
@@ -21,12 +21,13 @@ class cmInstallDirectoryGenerator : public cmInstallGenerator
{
public:
cmInstallDirectoryGenerator(std::vector<std::string> const& dirs,
- const char* dest, const char* file_permissions,
- const char* dir_permissions,
+ std::string const& dest,
+ std::string file_permissions,
+ std::string dir_permissions,
std::vector<std::string> const& configurations,
- const char* component, MessageLevel message,
- bool exclude_from_all, const char* literal_args,
- bool optional = false);
+ std::string const& component,
+ MessageLevel message, bool exclude_from_all,
+ std::string literal_args, bool optional = false);
~cmInstallDirectoryGenerator() override;
bool Compute(cmLocalGenerator* lg) override;
@@ -41,11 +42,11 @@ protected:
Indent indent,
std::vector<std::string> const& dirs);
cmLocalGenerator* LocalGenerator;
- std::vector<std::string> Directories;
- std::string FilePermissions;
- std::string DirPermissions;
- std::string LiteralArguments;
- bool Optional;
+ std::vector<std::string> const Directories;
+ std::string const FilePermissions;
+ std::string const DirPermissions;
+ std::string const LiteralArguments;
+ bool const Optional;
};
#endif
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index cba68be..2c53a28 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -18,16 +18,16 @@
#include "cmSystemTools.h"
cmInstallExportGenerator::cmInstallExportGenerator(
- cmExportSet* exportSet, const char* destination,
- const char* file_permissions, std::vector<std::string> const& configurations,
- const char* component, MessageLevel message, bool exclude_from_all,
- const char* filename, const char* name_space, bool exportOld, bool android)
+ cmExportSet* exportSet, std::string const& destination,
+ std::string file_permissions, std::vector<std::string> const& configurations,
+ std::string const& component, MessageLevel message, bool exclude_from_all,
+ std::string filename, std::string name_space, bool exportOld, bool android)
: cmInstallGenerator(destination, configurations, component, message,
exclude_from_all)
, ExportSet(exportSet)
- , FilePermissions(file_permissions)
- , FileName(filename)
- , Namespace(name_space)
+ , FilePermissions(std::move(file_permissions))
+ , FileName(std::move(filename))
+ , Namespace(std::move(name_space))
, ExportOld(exportOld)
, LocalGenerator(nullptr)
{
diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h
index f44127e..cf28b35 100644
--- a/Source/cmInstallExportGenerator.h
+++ b/Source/cmInstallExportGenerator.h
@@ -23,12 +23,12 @@ class cmLocalGenerator;
class cmInstallExportGenerator : public cmInstallGenerator
{
public:
- cmInstallExportGenerator(cmExportSet* exportSet, const char* dest,
- const char* file_permissions,
+ cmInstallExportGenerator(cmExportSet* exportSet, std::string const& dest,
+ std::string file_permissions,
const std::vector<std::string>& configurations,
- const char* component, MessageLevel message,
- bool exclude_from_all, const char* filename,
- const char* name_space, bool exportOld,
+ std::string const& component, MessageLevel message,
+ bool exclude_from_all, std::string filename,
+ std::string name_space, bool exportOld,
bool android);
~cmInstallExportGenerator() override;
@@ -52,11 +52,11 @@ protected:
void ComputeTempDir();
size_t GetMaxConfigLength() const;
- cmExportSet* ExportSet;
- std::string FilePermissions;
- std::string FileName;
- std::string Namespace;
- bool ExportOld;
+ cmExportSet* const ExportSet;
+ std::string const FilePermissions;
+ std::string const FileName;
+ std::string const Namespace;
+ bool const ExportOld;
cmLocalGenerator* LocalGenerator;
std::string TempDir;
diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx
index bfc7359..3c59f01 100644
--- a/Source/cmInstallFilesCommand.cxx
+++ b/Source/cmInstallFilesCommand.cxx
@@ -115,8 +115,8 @@ static void CreateInstallGenerator(cmMakefile& makefile,
}
// Use a file install generator.
- const char* no_permissions = "";
- const char* no_rename = "";
+ const std::string no_permissions;
+ const std::string no_rename;
bool no_exclude_from_all = false;
std::string no_component =
makefile.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
@@ -124,8 +124,8 @@ static void CreateInstallGenerator(cmMakefile& makefile,
cmInstallGenerator::MessageLevel message =
cmInstallGenerator::SelectMessageLevel(&makefile);
makefile.AddInstallGenerator(cm::make_unique<cmInstallFilesGenerator>(
- files, destination.c_str(), false, no_permissions, no_configurations,
- no_component.c_str(), message, no_exclude_from_all, no_rename));
+ files, destination, false, no_permissions, no_configurations, no_component,
+ message, no_exclude_from_all, no_rename));
}
/**
diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx
index f5b69a5..ad2f84e 100644
--- a/Source/cmInstallFilesGenerator.cxx
+++ b/Source/cmInstallFilesGenerator.cxx
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallFilesGenerator.h"
+#include <utility>
+
#include "cmGeneratorExpression.h"
#include "cmInstallType.h"
#include "cmStringAlgorithms.h"
@@ -9,16 +11,17 @@
class cmLocalGenerator;
cmInstallFilesGenerator::cmInstallFilesGenerator(
- std::vector<std::string> const& files, const char* dest, bool programs,
- const char* file_permissions, std::vector<std::string> const& configurations,
- const char* component, MessageLevel message, bool exclude_from_all,
- const char* rename, bool optional)
+ std::vector<std::string> const& files, std::string const& dest,
+ bool programs, std::string file_permissions,
+ std::vector<std::string> const& configurations, std::string const& component,
+ MessageLevel message, bool exclude_from_all, std::string rename,
+ bool optional)
: cmInstallGenerator(dest, configurations, component, message,
exclude_from_all)
, LocalGenerator(nullptr)
, Files(files)
- , FilePermissions(file_permissions)
- , Rename(rename)
+ , FilePermissions(std::move(file_permissions))
+ , Rename(std::move(rename))
, Programs(programs)
, Optional(optional)
{
diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h
index a680037..8266603 100644
--- a/Source/cmInstallFilesGenerator.h
+++ b/Source/cmInstallFilesGenerator.h
@@ -21,11 +21,11 @@ class cmInstallFilesGenerator : public cmInstallGenerator
{
public:
cmInstallFilesGenerator(std::vector<std::string> const& files,
- const char* dest, bool programs,
- const char* file_permissions,
+ std::string const& dest, bool programs,
+ std::string file_permissions,
std::vector<std::string> const& configurations,
- const char* component, MessageLevel message,
- bool exclude_from_all, const char* rename,
+ std::string const& component, MessageLevel message,
+ bool exclude_from_all, std::string rename,
bool optional = false);
~cmInstallFilesGenerator() override;
@@ -42,11 +42,11 @@ protected:
std::vector<std::string> const& files);
cmLocalGenerator* LocalGenerator;
- std::vector<std::string> Files;
- std::string FilePermissions;
- std::string Rename;
- bool Programs;
- bool Optional;
+ std::vector<std::string> const Files;
+ std::string const FilePermissions;
+ std::string const Rename;
+ bool const Programs;
+ bool const Optional;
};
#endif
diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx
index ec17361..0665895 100644
--- a/Source/cmInstallGenerator.cxx
+++ b/Source/cmInstallGenerator.cxx
@@ -3,16 +3,17 @@
#include "cmInstallGenerator.h"
#include <ostream>
+#include <utility>
#include "cmMakefile.h"
#include "cmSystemTools.h"
cmInstallGenerator::cmInstallGenerator(
- const char* destination, std::vector<std::string> const& configurations,
- const char* component, MessageLevel message, bool exclude_from_all)
+ std::string destination, std::vector<std::string> const& configurations,
+ std::string component, MessageLevel message, bool exclude_from_all)
: cmScriptGenerator("CMAKE_INSTALL_CONFIG_NAME", configurations)
- , Destination(destination ? destination : "")
- , Component(component ? component : "")
+ , Destination(std::move(destination))
+ , Component(std::move(component))
, Message(message)
, ExcludeFromAll(exclude_from_all)
{
@@ -139,8 +140,8 @@ void cmInstallGenerator::AddInstallRule(
os << ")\n";
}
-std::string cmInstallGenerator::CreateComponentTest(const char* component,
- bool exclude_from_all)
+std::string cmInstallGenerator::CreateComponentTest(
+ const std::string& component, bool exclude_from_all)
{
std::string result = R"("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "x)";
result += component;
@@ -158,7 +159,7 @@ void cmInstallGenerator::GenerateScript(std::ostream& os)
// Begin this block of installation.
std::string component_test =
- this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll);
+ this->CreateComponentTest(this->Component, this->ExcludeFromAll);
os << indent << "if(" << component_test << ")\n";
// Generate the script possibly with per-configuration code.
diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h
index 024027d..d786d24 100644
--- a/Source/cmInstallGenerator.h
+++ b/Source/cmInstallGenerator.h
@@ -30,9 +30,9 @@ public:
MessageNever
};
- cmInstallGenerator(const char* destination,
+ cmInstallGenerator(std::string destination,
std::vector<std::string> const& configurations,
- const char* component, MessageLevel message,
+ std::string component, MessageLevel message,
bool exclude_from_all);
~cmInstallGenerator() override;
@@ -65,14 +65,14 @@ public:
protected:
void GenerateScript(std::ostream& os) override;
- std::string CreateComponentTest(const char* component,
+ std::string CreateComponentTest(const std::string& component,
bool exclude_from_all);
// Information shared by most generator types.
- std::string Destination;
- std::string Component;
- MessageLevel Message;
- bool ExcludeFromAll;
+ std::string const Destination;
+ std::string const Component;
+ MessageLevel const Message;
+ bool const ExcludeFromAll;
};
#endif
diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx
index 2fd9bad..be07fd4 100644
--- a/Source/cmInstallProgramsCommand.cxx
+++ b/Source/cmInstallProgramsCommand.cxx
@@ -89,8 +89,8 @@ static void FinalAction(cmMakefile& makefile, std::string const& dest,
}
// Use a file install generator.
- const char* no_permissions = "";
- const char* no_rename = "";
+ const std::string no_permissions;
+ const std::string no_rename;
bool no_exclude_from_all = false;
std::string no_component =
makefile.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
@@ -98,8 +98,8 @@ static void FinalAction(cmMakefile& makefile, std::string const& dest,
cmInstallGenerator::MessageLevel message =
cmInstallGenerator::SelectMessageLevel(&makefile);
makefile.AddInstallGenerator(cm::make_unique<cmInstallFilesGenerator>(
- files, destination.c_str(), true, no_permissions, no_configurations,
- no_component.c_str(), message, no_exclude_from_all, no_rename));
+ files, destination, true, no_permissions, no_configurations, no_component,
+ message, no_exclude_from_all, no_rename));
}
/**
diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx
index ea29455..7cdf3b4 100644
--- a/Source/cmInstallScriptGenerator.cxx
+++ b/Source/cmInstallScriptGenerator.cxx
@@ -3,6 +3,7 @@
#include "cmInstallScriptGenerator.h"
#include <ostream>
+#include <utility>
#include <vector>
#include "cmGeneratorExpression.h"
@@ -11,13 +12,12 @@
#include "cmPolicies.h"
#include "cmScriptGenerator.h"
-cmInstallScriptGenerator::cmInstallScriptGenerator(const char* script,
- bool code,
- const char* component,
- bool exclude_from_all)
- : cmInstallGenerator(nullptr, std::vector<std::string>(), component,
+cmInstallScriptGenerator::cmInstallScriptGenerator(
+ std::string script, bool code, std::string const& component,
+ bool exclude_from_all)
+ : cmInstallGenerator("", std::vector<std::string>(), component,
MessageDefault, exclude_from_all)
- , Script(script)
+ , Script(std::move(script))
, Code(code)
, AllowGenex(false)
{
diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h
index 7efa321..0a9c4ba 100644
--- a/Source/cmInstallScriptGenerator.h
+++ b/Source/cmInstallScriptGenerator.h
@@ -19,8 +19,9 @@ class cmLocalGenerator;
class cmInstallScriptGenerator : public cmInstallGenerator
{
public:
- cmInstallScriptGenerator(const char* script, bool code,
- const char* component, bool exclude_from_all);
+ cmInstallScriptGenerator(std::string script, bool code,
+ std::string const& component,
+ bool exclude_from_all);
~cmInstallScriptGenerator() override;
bool Compute(cmLocalGenerator* lg) override;
@@ -32,8 +33,8 @@ protected:
void AddScriptInstallRule(std::ostream& os, Indent indent,
std::string const& script);
- std::string Script;
- bool Code;
+ std::string const Script;
+ bool const Code;
cmLocalGenerator* LocalGenerator;
bool AllowGenex;
};
diff --git a/Source/cmInstallSubdirectoryGenerator.cxx b/Source/cmInstallSubdirectoryGenerator.cxx
index 5405b7c..12bc92b 100644
--- a/Source/cmInstallSubdirectoryGenerator.cxx
+++ b/Source/cmInstallSubdirectoryGenerator.cxx
@@ -4,6 +4,7 @@
#include <memory>
#include <sstream>
+#include <utility>
#include <vector>
#include "cmLocalGenerator.h"
@@ -13,11 +14,11 @@
#include "cmSystemTools.h"
cmInstallSubdirectoryGenerator::cmInstallSubdirectoryGenerator(
- cmMakefile* makefile, const char* binaryDirectory, bool excludeFromAll)
- : cmInstallGenerator(nullptr, std::vector<std::string>(), nullptr,
- MessageDefault, excludeFromAll)
+ cmMakefile* makefile, std::string binaryDirectory, bool excludeFromAll)
+ : cmInstallGenerator("", std::vector<std::string>(), "", MessageDefault,
+ excludeFromAll)
, Makefile(makefile)
- , BinaryDirectory(binaryDirectory)
+ , BinaryDirectory(std::move(binaryDirectory))
{
}
diff --git a/Source/cmInstallSubdirectoryGenerator.h b/Source/cmInstallSubdirectoryGenerator.h
index b99bdd5..f9cd0f1 100644
--- a/Source/cmInstallSubdirectoryGenerator.h
+++ b/Source/cmInstallSubdirectoryGenerator.h
@@ -20,7 +20,7 @@ class cmInstallSubdirectoryGenerator : public cmInstallGenerator
{
public:
cmInstallSubdirectoryGenerator(cmMakefile* makefile,
- const char* binaryDirectory,
+ std::string binaryDirectory,
bool excludeFromAll);
~cmInstallSubdirectoryGenerator() override;
@@ -33,8 +33,8 @@ public:
protected:
void GenerateScript(std::ostream& os) override;
- cmMakefile* Makefile;
- std::string BinaryDirectory;
+ cmMakefile* const Makefile;
+ std::string const BinaryDirectory;
cmLocalGenerator* LocalGenerator;
};
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 69c9b7e..e05daa8 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -25,15 +25,15 @@
#include "cmake.h"
cmInstallTargetGenerator::cmInstallTargetGenerator(
- std::string targetName, const char* dest, bool implib,
- const char* file_permissions, std::vector<std::string> const& configurations,
- const char* component, MessageLevel message, bool exclude_from_all,
+ std::string targetName, std::string const& dest, bool implib,
+ std::string file_permissions, std::vector<std::string> const& configurations,
+ std::string const& component, MessageLevel message, bool exclude_from_all,
bool optional, cmListFileBacktrace backtrace)
: cmInstallGenerator(dest, configurations, component, message,
exclude_from_all)
, TargetName(std::move(targetName))
, Target(nullptr)
- , FilePermissions(file_permissions)
+ , FilePermissions(std::move(file_permissions))
, ImportLibrary(implib)
, Optional(optional)
, Backtrace(std::move(backtrace))
diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h
index 8730454..e21001f 100644
--- a/Source/cmInstallTargetGenerator.h
+++ b/Source/cmInstallTargetGenerator.h
@@ -23,11 +23,11 @@ class cmInstallTargetGenerator : public cmInstallGenerator
{
public:
cmInstallTargetGenerator(
- std::string targetName, const char* dest, bool implib,
- const char* file_permissions,
- std::vector<std::string> const& configurations, const char* component,
- MessageLevel message, bool exclude_from_all, bool optional,
- cmListFileBacktrace backtrace = cmListFileBacktrace());
+ std::string targetName, std::string const& dest, bool implib,
+ std::string file_permissions,
+ std::vector<std::string> const& configurations,
+ std::string const& component, MessageLevel message, bool exclude_from_all,
+ bool optional, cmListFileBacktrace backtrace = cmListFileBacktrace());
~cmInstallTargetGenerator() override;
/** Select the policy for installing shared library linkable name
@@ -106,13 +106,13 @@ protected:
const std::string& toDestDirPath);
void IssueCMP0095Warning(const std::string& unescapedRpath);
- std::string TargetName;
+ std::string const TargetName;
cmGeneratorTarget* Target;
- std::string FilePermissions;
+ std::string const FilePermissions;
NamelinkModeType NamelinkMode;
- bool ImportLibrary;
- bool Optional;
- cmListFileBacktrace Backtrace;
+ bool const ImportLibrary;
+ bool const Optional;
+ cmListFileBacktrace const Backtrace;
};
#endif
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index cc07b11..d1a3454 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1171,7 +1171,7 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
}
for (std::string const& i : impDirVec) {
- if (implicitSet.insert(cmSystemTools::GetRealPath(i)).second) {
+ if (implicitSet.insert(this->GlobalGenerator->GetRealPath(i)).second) {
implicitDirs.emplace_back(i);
}
}
@@ -1182,7 +1182,7 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
&lang](std::string const& dir) {
return (
// Do not exclude directories that are not in an excluded set.
- ((!cmContains(implicitSet, cmSystemTools::GetRealPath(dir))) &&
+ ((!cmContains(implicitSet, this->GlobalGenerator->GetRealPath(dir))) &&
(!cmContains(implicitExclude, dir)))
// Do not exclude entries of the CPATH environment variable even though
// they are implicitly searched by the compiler. They are meant to be
@@ -2003,8 +2003,16 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
// Treat the name as relative to the source directory in which it
// was given.
- dep = cmStrCat(this->StateSnapshot.GetDirectory().GetCurrentSource(), '/',
- inName);
+ dep = cmStrCat(this->GetCurrentSourceDirectory(), '/', inName);
+
+ // If the in-source path does not exist, assume it instead lives in the
+ // binary directory.
+ if (!cmSystemTools::FileExists(dep)) {
+ dep = cmStrCat(this->GetCurrentBinaryDirectory(), '/', inName);
+ }
+
+ dep = cmSystemTools::CollapseFullPath(dep, this->GetBinaryDirectory());
+
return true;
}
@@ -2413,163 +2421,170 @@ void cmLocalGenerator::AppendFlagEscape(std::string& flags,
void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
{
- // FIXME: Handle all configurations in multi-config generators.
- std::string config;
- if (!this->GetGlobalGenerator()->IsMultiConfig()) {
- config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
+ std::vector<std::string> configsList;
+ std::string configDefault = this->Makefile->GetConfigurations(configsList);
+ if (configsList.empty()) {
+ configsList.push_back(configDefault);
}
- const std::string buildType = cmSystemTools::UpperCase(config);
-
- // FIXME: Refactor collection of sources to not evaluate object libraries.
- std::vector<cmSourceFile*> sources;
- target->GetSourceFiles(sources, buildType);
- for (const std::string& lang : { "C", "CXX", "OBJC", "OBJCXX" }) {
- auto langSources =
- std::count_if(sources.begin(), sources.end(), [lang](cmSourceFile* sf) {
- return lang == sf->GetLanguage() &&
- !sf->GetProperty("SKIP_PRECOMPILE_HEADERS");
- });
- if (langSources == 0) {
- continue;
- }
+ for (std::string const& config : configsList) {
+ const std::string buildType = cmSystemTools::UpperCase(config);
- const std::string pchSource = target->GetPchSource(config, lang);
- const std::string pchHeader = target->GetPchHeader(config, lang);
+ // FIXME: Refactor collection of sources to not evaluate object libraries.
+ std::vector<cmSourceFile*> sources;
+ target->GetSourceFiles(sources, buildType);
- if (pchSource.empty() || pchHeader.empty()) {
- continue;
- }
+ for (const std::string& lang : { "C", "CXX", "OBJC", "OBJCXX" }) {
+ auto langSources = std::count_if(
+ sources.begin(), sources.end(), [lang](cmSourceFile* sf) {
+ return lang == sf->GetLanguage() &&
+ !sf->GetProperty("SKIP_PRECOMPILE_HEADERS");
+ });
+ if (langSources == 0) {
+ continue;
+ }
- const std::string pchExtension =
- this->Makefile->GetSafeDefinition("CMAKE_PCH_EXTENSION");
+ const std::string pchSource = target->GetPchSource(config, lang);
+ const std::string pchHeader = target->GetPchHeader(config, lang);
- if (pchExtension.empty()) {
- continue;
- }
-
- const char* pchReuseFrom =
- target->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
+ if (pchSource.empty() || pchHeader.empty()) {
+ continue;
+ }
- auto pch_sf = this->Makefile->GetOrCreateSource(
- pchSource, false, cmSourceFileLocationKind::Known);
+ const std::string pchExtension =
+ this->Makefile->GetSafeDefinition("CMAKE_PCH_EXTENSION");
- if (!this->GetGlobalGenerator()->IsXcode()) {
- if (!pchReuseFrom) {
- target->AddSource(pchSource, true);
+ if (pchExtension.empty()) {
+ continue;
}
- const std::string pchFile = target->GetPchFile(config, lang);
+ const char* pchReuseFrom =
+ target->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
- // Exclude the pch files from linking
- if (this->Makefile->IsOn("CMAKE_LINK_PCH")) {
- if (!pchReuseFrom) {
- pch_sf->SetProperty("OBJECT_OUTPUTS", pchFile.c_str());
- } else {
- auto reuseTarget =
- this->GlobalGenerator->FindGeneratorTarget(pchReuseFrom);
+ auto pch_sf = this->Makefile->GetOrCreateSource(
+ pchSource, false, cmSourceFileLocationKind::Known);
- if (this->Makefile->IsOn("CMAKE_PCH_COPY_COMPILE_PDB")) {
+ if (!this->GetGlobalGenerator()->IsXcode()) {
+ if (!pchReuseFrom) {
+ target->AddSource(pchSource, true);
+ }
- const std::string pdb_prefix =
- this->GetGlobalGenerator()->IsMultiConfig()
- ? cmStrCat(this->GlobalGenerator->GetCMakeCFGIntDir(), "/")
- : "";
+ const std::string pchFile = target->GetPchFile(config, lang);
- const std::string target_compile_pdb_dir = cmStrCat(
- target->GetLocalGenerator()->GetCurrentBinaryDirectory(), "/",
- target->GetName(), ".dir/");
+ // Exclude the pch files from linking
+ if (this->Makefile->IsOn("CMAKE_LINK_PCH")) {
+ if (!pchReuseFrom) {
+ pch_sf->SetProperty("OBJECT_OUTPUTS", pchFile.c_str());
+ } else {
+ auto reuseTarget =
+ this->GlobalGenerator->FindGeneratorTarget(pchReuseFrom);
- const std::string copy_script =
- cmStrCat(target_compile_pdb_dir, "copy_idb_pdb.cmake");
- cmGeneratedFileStream file(copy_script);
+ if (this->Makefile->IsOn("CMAKE_PCH_COPY_COMPILE_PDB")) {
- file << "# CMake generated file\n";
- for (auto extension : { ".pdb", ".idb" }) {
- const std::string from_file = cmStrCat(
- reuseTarget->GetLocalGenerator()->GetCurrentBinaryDirectory(),
- "/", pchReuseFrom, ".dir/${PDB_PREFIX}", pchReuseFrom,
- extension);
+ const std::string pdb_prefix =
+ this->GetGlobalGenerator()->IsMultiConfig()
+ ? cmStrCat(this->GlobalGenerator->GetCMakeCFGIntDir(), "/")
+ : "";
- const std::string to_dir = cmStrCat(
+ const std::string target_compile_pdb_dir = cmStrCat(
target->GetLocalGenerator()->GetCurrentBinaryDirectory(), "/",
- target->GetName(), ".dir/${PDB_PREFIX}");
+ target->GetName(), ".dir/");
- const std::string to_file =
- cmStrCat(to_dir, pchReuseFrom, extension);
+ const std::string copy_script =
+ cmStrCat(target_compile_pdb_dir, "copy_idb_pdb.cmake");
+ cmGeneratedFileStream file(copy_script);
- std::string dest_file = to_file;
+ file << "# CMake generated file\n";
+ for (auto extension : { ".pdb", ".idb" }) {
+ const std::string from_file =
+ cmStrCat(reuseTarget->GetLocalGenerator()
+ ->GetCurrentBinaryDirectory(),
+ "/", pchReuseFrom, ".dir/${PDB_PREFIX}",
+ pchReuseFrom, extension);
- const std::string prefix = target->GetSafeProperty("PREFIX");
- if (!prefix.empty()) {
- dest_file = cmStrCat(to_dir, prefix, pchReuseFrom, extension);
- }
+ const std::string to_dir = cmStrCat(
+ target->GetLocalGenerator()->GetCurrentBinaryDirectory(),
+ "/", target->GetName(), ".dir/${PDB_PREFIX}");
+
+ const std::string to_file =
+ cmStrCat(to_dir, pchReuseFrom, extension);
+
+ std::string dest_file = to_file;
+
+ const std::string prefix = target->GetSafeProperty("PREFIX");
+ if (!prefix.empty()) {
+ dest_file =
+ cmStrCat(to_dir, prefix, pchReuseFrom, extension);
+ }
- file << "if (EXISTS \"" << from_file << "\" AND \"" << from_file
- << "\" IS_NEWER_THAN \"" << dest_file << "\")\n";
- file << " file(COPY \"" << from_file << "\""
- << " DESTINATION \"" << to_dir << "\")\n";
- if (!prefix.empty()) {
- file << " file(REMOVE \"" << dest_file << "\")\n";
- file << " file(RENAME \"" << to_file << "\" \"" << dest_file
+ file << "if (EXISTS \"" << from_file << "\" AND \""
+ << from_file << "\" IS_NEWER_THAN \"" << dest_file
<< "\")\n";
+ file << " file(COPY \"" << from_file << "\""
+ << " DESTINATION \"" << to_dir << "\")\n";
+ if (!prefix.empty()) {
+ file << " file(REMOVE \"" << dest_file << "\")\n";
+ file << " file(RENAME \"" << to_file << "\" \"" << dest_file
+ << "\")\n";
+ }
+ file << "endif()\n";
}
- file << "endif()\n";
- }
- cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
- { cmSystemTools::GetCMakeCommand(),
- cmStrCat("-DPDB_PREFIX=", pdb_prefix), "-P", copy_script });
-
- const std::string no_main_dependency;
- const std::vector<std::string> no_deps;
- const char* no_message = "";
- const char* no_current_dir = nullptr;
- std::vector<std::string> no_byproducts;
-
- std::vector<std::string> outputs;
- outputs.push_back(cmStrCat(target_compile_pdb_dir, pdb_prefix,
- pchReuseFrom, ".pdb"));
-
- if (this->GetGlobalGenerator()->IsMultiConfig()) {
- this->AddCustomCommandToTarget(
- target->GetName(), outputs, no_deps, commandLines,
- cmCustomCommandType::PRE_BUILD, no_message, no_current_dir);
- } else {
- cmImplicitDependsList no_implicit_depends;
- cmSourceFile* copy_rule = this->AddCustomCommandToOutput(
- outputs, no_byproducts, no_deps, no_main_dependency,
- no_implicit_depends, commandLines, no_message, no_current_dir);
-
- if (copy_rule) {
- target->AddSource(copy_rule->ResolveFullPath());
+ cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
+ { cmSystemTools::GetCMakeCommand(),
+ cmStrCat("-DPDB_PREFIX=", pdb_prefix), "-P", copy_script });
+
+ const std::string no_main_dependency;
+ const std::vector<std::string> no_deps;
+ const char* no_message = "";
+ const char* no_current_dir = nullptr;
+ std::vector<std::string> no_byproducts;
+
+ std::vector<std::string> outputs;
+ outputs.push_back(cmStrCat(target_compile_pdb_dir, pdb_prefix,
+ pchReuseFrom, ".pdb"));
+
+ if (this->GetGlobalGenerator()->IsVisualStudio()) {
+ this->AddCustomCommandToTarget(
+ target->GetName(), outputs, no_deps, commandLines,
+ cmCustomCommandType::PRE_BUILD, no_message, no_current_dir);
+ } else {
+ cmImplicitDependsList no_implicit_depends;
+ cmSourceFile* copy_rule = this->AddCustomCommandToOutput(
+ outputs, no_byproducts, no_deps, no_main_dependency,
+ no_implicit_depends, commandLines, no_message,
+ no_current_dir);
+
+ if (copy_rule) {
+ target->AddSource(copy_rule->ResolveFullPath());
+ }
}
- }
- target->Target->SetProperty("COMPILE_PDB_OUTPUT_DIRECTORY",
- target_compile_pdb_dir);
- }
+ target->Target->SetProperty("COMPILE_PDB_OUTPUT_DIRECTORY",
+ target_compile_pdb_dir);
+ }
- std::string pchSourceObj =
- reuseTarget->GetPchFileObject(config, lang);
+ std::string pchSourceObj =
+ reuseTarget->GetPchFileObject(config, lang);
- // Link to the pch object file
- target->Target->AppendProperty(
- "LINK_FLAGS",
- cmStrCat(" ", this->ConvertToOutputFormat(pchSourceObj, SHELL)),
- true);
+ // Link to the pch object file
+ target->Target->AppendProperty(
+ "LINK_FLAGS",
+ cmStrCat(" ", this->ConvertToOutputFormat(pchSourceObj, SHELL)),
+ true);
+ }
+ } else {
+ pch_sf->SetProperty("PCH_EXTENSION", pchExtension.c_str());
}
- } else {
- pch_sf->SetProperty("PCH_EXTENSION", pchExtension.c_str());
- }
- // Add pchHeader to source files, which will
- // be grouped as "Precompile Header File"
- auto pchHeader_sf = this->Makefile->GetOrCreateSource(
- pchHeader, false, cmSourceFileLocationKind::Known);
- std::string err;
- pchHeader_sf->ResolveFullPath(&err);
- target->AddSource(pchHeader);
+ // Add pchHeader to source files, which will
+ // be grouped as "Precompile Header File"
+ auto pchHeader_sf = this->Makefile->GetOrCreateSource(
+ pchHeader, false, cmSourceFileLocationKind::Known);
+ std::string err;
+ pchHeader_sf->ResolveFullPath(&err);
+ target->AddSource(pchHeader);
+ }
}
}
}
@@ -2989,7 +3004,7 @@ class cmInstallTargetGeneratorLocal : public cmInstallTargetGenerator
{
public:
cmInstallTargetGeneratorLocal(cmLocalGenerator* lg, std::string const& t,
- const char* dest, bool implib)
+ std::string const& dest, bool implib)
: cmInstallTargetGenerator(
t, dest, implib, "", std::vector<std::string>(), "Unspecified",
cmInstallGenerator::SelectMessageLevel(lg->GetMakefile()), false,
@@ -3013,7 +3028,7 @@ void cmLocalGenerator::GenerateTargetInstallRules(
// Include the user-specified pre-install script for this target.
if (const char* preinstall = l->GetProperty("PRE_INSTALL_SCRIPT")) {
- cmInstallScriptGenerator g(preinstall, false, nullptr, false);
+ cmInstallScriptGenerator g(preinstall, false, "", false);
g.Generate(os, config, configurationTypes);
}
@@ -3034,8 +3049,8 @@ void cmLocalGenerator::GenerateTargetInstallRules(
case cmStateEnums::STATIC_LIBRARY:
case cmStateEnums::MODULE_LIBRARY: {
// Use a target install generator.
- cmInstallTargetGeneratorLocal g(this, l->GetName(),
- destination.c_str(), false);
+ cmInstallTargetGeneratorLocal g(this, l->GetName(), destination,
+ false);
g.Generate(os, config, configurationTypes);
} break;
case cmStateEnums::SHARED_LIBRARY: {
@@ -3043,19 +3058,19 @@ void cmLocalGenerator::GenerateTargetInstallRules(
// Special code to handle DLL. Install the import library
// to the normal destination and the DLL to the runtime
// destination.
- cmInstallTargetGeneratorLocal g1(this, l->GetName(),
- destination.c_str(), true);
+ cmInstallTargetGeneratorLocal g1(this, l->GetName(), destination,
+ true);
g1.Generate(os, config, configurationTypes);
// We also skip over the leading slash given by the user.
destination = l->Target->GetRuntimeInstallPath().substr(1);
cmSystemTools::ConvertToUnixSlashes(destination);
- cmInstallTargetGeneratorLocal g2(this, l->GetName(),
- destination.c_str(), false);
+ cmInstallTargetGeneratorLocal g2(this, l->GetName(), destination,
+ false);
g2.Generate(os, config, configurationTypes);
#else
// Use a target install generator.
- cmInstallTargetGeneratorLocal g(this, l->GetName(),
- destination.c_str(), false);
+ cmInstallTargetGeneratorLocal g(this, l->GetName(), destination,
+ false);
g.Generate(os, config, configurationTypes);
#endif
} break;
@@ -3066,7 +3081,7 @@ void cmLocalGenerator::GenerateTargetInstallRules(
// Include the user-specified post-install script for this target.
if (const char* postinstall = l->GetProperty("POST_INSTALL_SCRIPT")) {
- cmInstallScriptGenerator g(postinstall, false, nullptr, false);
+ cmInstallScriptGenerator g(postinstall, false, "", false);
g.Generate(os, config, configurationTypes);
}
}
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 55a9a72..1a6b7b2 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -146,7 +146,7 @@ void cmLocalVisualStudio7Generator::WriteStampFiles()
// out of date.
std::string stampName =
cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles");
- cmSystemTools::MakeDirectory(stampName.c_str());
+ cmSystemTools::MakeDirectory(stampName);
stampName += "/generate.stamp";
cmsys::ofstream stamp(stampName.c_str());
stamp << "# CMake generation timestamp file for this directory.\n";
@@ -257,12 +257,11 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
"--check-stamp-file", stampName });
std::string comment = cmStrCat("Building Custom Rule ", makefileIn);
const char* no_working_directory = nullptr;
- std::string fullpathStampName =
- cmSystemTools::CollapseFullPath(stampName.c_str());
+ std::string fullpathStampName = cmSystemTools::CollapseFullPath(stampName);
this->AddCustomCommandToOutput(fullpathStampName, listFiles, makefileIn,
commandLines, comment.c_str(),
no_working_directory, true, false);
- if (cmSourceFile* file = this->Makefile->GetSource(makefileIn.c_str())) {
+ if (cmSourceFile* file = this->Makefile->GetSource(makefileIn)) {
// Finalize the source file path now since we're adding this after
// the generator validated all project-named sources.
file->ResolveFullPath();
@@ -279,7 +278,7 @@ void cmLocalVisualStudio7Generator::WriteConfigurations(
{
fout << "\t<Configurations>\n";
for (std::string const& config : configs) {
- this->WriteConfiguration(fout, config.c_str(), libName, target);
+ this->WriteConfiguration(fout, config, libName, target);
}
fout << "\t</Configurations>\n";
}
@@ -580,7 +579,7 @@ public:
this->Stream << this->LG->EscapeForXML("\n");
}
std::string script = this->LG->ConstructScript(ccg);
- this->Stream << this->LG->EscapeForXML(script.c_str());
+ this->Stream << this->LG->EscapeForXML(script);
}
private:
@@ -733,13 +732,13 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
: target->GetDirectory(configName);
/* clang-format off */
fout << "\t\t\tOutputDirectory=\""
- << this->ConvertToXMLOutputPathSingle(outDir.c_str()) << "\"\n";
+ << this->ConvertToXMLOutputPathSingle(outDir) << "\"\n";
/* clang-format on */
}
/* clang-format off */
fout << "\t\t\tIntermediateDirectory=\""
- << this->ConvertToXMLOutputPath(intermediateDir.c_str())
+ << this->ConvertToXMLOutputPath(intermediateDir)
<< "\"\n"
<< "\t\t\tConfigurationType=\"" << configType << "\"\n"
<< "\t\t\tUseOfMFC=\"" << mfcFlag << "\"\n"
@@ -788,8 +787,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
} else {
modDir = ".";
}
- fout << "\t\t\t\tModulePath=\""
- << this->ConvertToXMLOutputPath(modDir.c_str())
+ fout << "\t\t\t\tModulePath=\"" << this->ConvertToXMLOutputPath(modDir)
<< "\\$(ConfigurationName)\"\n";
}
targetOptions.OutputAdditionalIncludeDirectories(
@@ -802,7 +800,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
std::string pdb = target->GetCompilePDBPath(configName);
if (!pdb.empty()) {
fout << "\t\t\t\tProgramDataBaseFileName=\""
- << this->ConvertToXMLOutputPathSingle(pdb.c_str()) << "\"\n";
+ << this->ConvertToXMLOutputPathSingle(pdb) << "\"\n";
}
}
fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool
@@ -879,7 +877,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
fout << "\n\t\t\t\tAdditionalManifestFiles=\"";
for (cmSourceFile const* manifest : manifest_srcs) {
std::string m = manifest->GetFullPath();
- fout << this->ConvertToXMLOutputPath(m.c_str()) << ";";
+ fout << this->ConvertToXMLOutputPath(m) << ";";
}
fout << "\"";
}
@@ -946,7 +944,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
}
std::string configTypeUpper = cmSystemTools::UpperCase(configName);
std::string linkFlagsConfig = cmStrCat("LINK_FLAGS_", configTypeUpper);
- targetLinkFlags = target->GetProperty(linkFlagsConfig.c_str());
+ targetLinkFlags = target->GetProperty(linkFlagsConfig);
if (targetLinkFlags) {
extraLinkOptions += " ";
extraLinkOptions += targetLinkFlags;
@@ -985,7 +983,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
fout << "\t\t\t<Tool\n"
<< "\t\t\t\tName=\"" << tool << "\"\n";
fout << "\t\t\t\tOutputFile=\""
- << this->ConvertToXMLOutputPathSingle(libpath.c_str()) << "\"/>\n";
+ << this->ConvertToXMLOutputPathSingle(libpath) << "\"/>\n";
break;
}
case cmStateEnums::STATIC_LIBRARY: {
@@ -1015,7 +1013,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
}
fout << "\t\t\t\tOutputFile=\""
- << this->ConvertToXMLOutputPathSingle(libpath.c_str()) << "\"/>\n";
+ << this->ConvertToXMLOutputPathSingle(libpath) << "\"/>\n";
break;
}
case cmStateEnums::SHARED_LIBRARY:
@@ -1057,7 +1055,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
temp =
cmStrCat(target->GetDirectory(configName), '/', targetNames.Output);
fout << "\t\t\t\tOutputFile=\""
- << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
+ << this->ConvertToXMLOutputPathSingle(temp) << "\"\n";
this->WriteTargetVersionAttribute(fout, target);
linkOptions.OutputFlagMap(fout, 4);
fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
@@ -1066,7 +1064,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
temp =
cmStrCat(target->GetPDBDirectory(configName), '/', targetNames.PDB);
fout << "\t\t\t\tProgramDatabaseFile=\""
- << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
+ << this->ConvertToXMLOutputPathSingle(temp) << "\"\n";
if (targetOptions.IsDebug()) {
fout << "\t\t\t\tGenerateDebugInformation=\"true\"\n";
}
@@ -1078,7 +1076,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
}
}
std::string stackVar = cmStrCat("CMAKE_", linkLanguage, "_STACK_SIZE");
- const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
+ const char* stackVal = this->Makefile->GetDefinition(stackVar);
if (stackVal) {
fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n";
}
@@ -1086,7 +1084,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact),
'/', targetNames.ImportLibrary);
fout << "\t\t\t\tImportLibrary=\""
- << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"";
+ << this->ConvertToXMLOutputPathSingle(temp) << "\"";
if (this->FortranProject) {
fout << "\n\t\t\t\tLinkDLL=\"true\"";
}
@@ -1132,14 +1130,14 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
temp =
cmStrCat(target->GetDirectory(configName), '/', targetNames.Output);
fout << "\t\t\t\tOutputFile=\""
- << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
+ << this->ConvertToXMLOutputPathSingle(temp) << "\"\n";
this->WriteTargetVersionAttribute(fout, target);
linkOptions.OutputFlagMap(fout, 4);
fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
this->OutputLibraryDirectories(fout, cli.GetDirectories());
fout << "\"\n";
std::string path = this->ConvertToXMLOutputPathSingle(
- target->GetPDBDirectory(configName).c_str());
+ target->GetPDBDirectory(configName));
fout << "\t\t\t\tProgramDatabaseFile=\"" << path << "/"
<< targetNames.PDB << "\"\n";
if (targetOptions.IsDebug()) {
@@ -1167,7 +1165,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
<< "\"\n";
}
std::string stackVar = cmStrCat("CMAKE_", linkLanguage, "_STACK_SIZE");
- const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
+ const char* stackVal = this->Makefile->GetDefinition(stackVar);
if (stackVal) {
fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"";
}
@@ -1175,7 +1173,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact),
'/', targetNames.ImportLibrary);
fout << "\t\t\t\tImportLibrary=\""
- << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n";
+ << this->ConvertToXMLOutputPathSingle(temp) << "\"/>\n";
break;
}
case cmStateEnums::UTILITY:
@@ -1256,8 +1254,8 @@ void cmLocalVisualStudio7GeneratorInternals::OutputLibraries(
for (auto const& lib : libs) {
if (lib.IsPath) {
std::string rel =
- lg->MaybeConvertToRelativePath(currentBinDir, lib.Value.c_str());
- fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " ";
+ lg->MaybeConvertToRelativePath(currentBinDir, lib.Value);
+ fout << lg->ConvertToXMLOutputPath(rel) << " ";
} else if (!lib.Target ||
lib.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
fout << lib.Value << " ";
@@ -1282,7 +1280,7 @@ void cmLocalVisualStudio7GeneratorInternals::OutputObjects(
if (!obj->GetObjectLibrary().empty()) {
std::string const& objFile = obj->GetFullPath();
std::string rel = lg->MaybeConvertToRelativePath(currentBinDir, objFile);
- fout << sep << lg->ConvertToXMLOutputPath(rel.c_str());
+ fout << sep << lg->ConvertToXMLOutputPath(rel);
sep = " ";
}
}
@@ -1303,9 +1301,8 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories(
}
// Switch to a relative path specification if it is shorter.
- if (cmSystemTools::FileIsFullPath(dir.c_str())) {
- std::string rel =
- this->MaybeConvertToRelativePath(currentBinDir, dir.c_str());
+ if (cmSystemTools::FileIsFullPath(dir)) {
+ std::string rel = this->MaybeConvertToRelativePath(currentBinDir, dir);
if (rel.size() < dir.size()) {
dir = rel;
}
@@ -1314,9 +1311,8 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories(
// First search a configuration-specific subdirectory and then the
// original directory.
fout << comma
- << this->ConvertToXMLOutputPath(
- (dir + "/$(ConfigurationName)").c_str())
- << "," << this->ConvertToXMLOutputPath(dir.c_str());
+ << this->ConvertToXMLOutputPath(dir + "/$(ConfigurationName)") << ","
+ << this->ConvertToXMLOutputPath(dir);
comma = ",";
}
}
@@ -1518,13 +1514,13 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
for (std::vector<std::string>::iterator j = depends.begin();
j != depends.end(); ++j) {
fc.AdditionalDeps += sep;
- fc.AdditionalDeps += lg->ConvertToXMLOutputPath(j->c_str());
+ fc.AdditionalDeps += lg->ConvertToXMLOutputPath(*j);
sep = ";";
needfc = true;
}
}
- const std::string& linkLanguage = gt->GetLinkerLanguage(config.c_str());
+ const std::string& linkLanguage = gt->GetLinkerLanguage(config);
// If HEADER_FILE_ONLY is set, we must suppress this generation in
// the project file
fc.ExcludedFromBuild = sf.GetPropertyAsBool("HEADER_FILE_ONLY") ||
@@ -1629,7 +1625,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
FCInfo fcinfo(this, target, acs, configs);
fout << "\t\t\t<File\n";
- std::string d = this->ConvertToXMLOutputPathSingle(source.c_str());
+ std::string d = this->ConvertToXMLOutputPathSingle(source);
// Tell MS-Dev what the source is. If the compiler knows how to
// build it, then it will.
fout << "\t\t\t\tRelativePath=\"" << d << "\">\n";
@@ -1759,21 +1755,21 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(
fout << "\t\t\t\t\t<Tool\n"
<< "\t\t\t\t\tName=\"" << compileTool << "\"\n"
<< "\t\t\t\t\tAdditionalOptions=\""
- << this->EscapeForXML(fc.CompileFlags.c_str()) << "\"/>\n";
+ << this->EscapeForXML(fc.CompileFlags) << "\"/>\n";
}
std::string comment = this->ConstructComment(ccg);
std::string script = this->ConstructScript(ccg);
if (this->FortranProject) {
- cmSystemTools::ReplaceString(script, "$(Configuration)", config.c_str());
+ cmSystemTools::ReplaceString(script, "$(Configuration)", config);
}
/* clang-format off */
fout << "\t\t\t\t\t<Tool\n"
<< "\t\t\t\t\tName=\"" << customTool << "\"\n"
<< "\t\t\t\t\tDescription=\""
- << this->EscapeForXML(comment.c_str()) << "\"\n"
+ << this->EscapeForXML(comment) << "\"\n"
<< "\t\t\t\t\tCommandLine=\""
- << this->EscapeForXML(script.c_str()) << "\"\n"
+ << this->EscapeForXML(script) << "\"\n"
<< "\t\t\t\t\tAdditionalDependencies=\"";
/* clang-format on */
if (ccg.GetDepends().empty()) {
@@ -1789,8 +1785,8 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(
for (std::string const& d : ccg.GetDepends()) {
// Get the real name of the dependency in case it is a CMake target.
std::string dep;
- if (this->GetRealDependency(d.c_str(), config.c_str(), dep)) {
- fout << this->ConvertToXMLOutputPath(dep.c_str()) << ";";
+ if (this->GetRealDependency(d, config, dep)) {
+ fout << this->ConvertToXMLOutputPath(dep) << ";";
}
}
}
@@ -1802,7 +1798,7 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(
// Write a rule for the output generated by this command.
const char* sep = "";
for (std::string const& output : ccg.GetOutputs()) {
- fout << sep << this->ConvertToXMLOutputPathSingle(output.c_str());
+ fout << sep << this->ConvertToXMLOutputPathSingle(output);
sep = ";";
}
}
@@ -1948,7 +1944,7 @@ void cmLocalVisualStudio7Generator::WriteProjectStartFortran(
this->WriteProjectSCC(fout, target);
/* clang-format off */
fout<< "\tKeyword=\"" << keyword << "\">\n"
- << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\">\n"
+ << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\">\n"
<< "\t<Platforms>\n"
<< "\t\t<Platform\n\t\t\tName=\"" << gg->GetPlatformName() << "\"/>\n"
<< "\t</Platforms>\n";
@@ -1983,7 +1979,7 @@ void cmLocalVisualStudio7Generator::WriteProjectStart(
keyword = "Win32Proj";
}
fout << "\tName=\"" << projLabel << "\"\n";
- fout << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\"\n";
+ fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n";
this->WriteProjectSCC(fout, target);
if (const char* targetFrameworkVersion =
target->GetProperty("VS_DOTNET_TARGET_FRAMEWORK_VERSION")) {
@@ -2037,7 +2033,7 @@ std::string cmLocalVisualStudio7Generator::EscapeForXML(const std::string& s)
}
std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPath(
- const char* path)
+ const std::string& path)
{
std::string ret =
this->ConvertToOutputFormat(path, cmOutputConverter::SHELL);
@@ -2049,7 +2045,7 @@ std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPath(
}
std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPathSingle(
- const char* path)
+ const std::string& path)
{
std::string ret =
this->ConvertToOutputFormat(path, cmOutputConverter::SHELL);
@@ -2130,8 +2126,7 @@ void cmLocalVisualStudio7Generator::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);
}
std::string cmLocalVisualStudio7Generator::GetTargetDirectory(
diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h
index 22a5f9a..745766c 100644
--- a/Source/cmLocalVisualStudio7Generator.h
+++ b/Source/cmLocalVisualStudio7Generator.h
@@ -101,8 +101,8 @@ private:
void WriteConfiguration(std::ostream& fout, const std::string& configName,
const std::string& libName, cmGeneratorTarget* tgt);
std::string EscapeForXML(const std::string& s);
- std::string ConvertToXMLOutputPath(const char* path);
- std::string ConvertToXMLOutputPathSingle(const char* path);
+ std::string ConvertToXMLOutputPath(const std::string& path);
+ std::string ConvertToXMLOutputPathSingle(const std::string& path);
void OutputTargetRules(std::ostream& fout, const std::string& configName,
cmGeneratorTarget* target,
const std::string& libName);
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index dc741d3..668a27d 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1748,7 +1748,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
}
this->AddInstallGenerator(cm::make_unique<cmInstallSubdirectoryGenerator>(
- subMf, binPath.c_str(), excludeFromAll));
+ subMf, binPath, excludeFromAll));
}
const std::string& cmMakefile::GetCurrentSourceDirectory() const
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 77b6bc2..714d01e 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -4,10 +4,10 @@
#include <cassert>
#include <cstdio>
-#include <memory>
#include <sstream>
#include <utility>
+#include <cm/memory>
#include <cmext/algorithm>
#include "cmComputeLinkInformation.h"
@@ -38,12 +38,7 @@
cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target)
: cmCommonTargetGenerator(target)
- , OSXBundleGenerator(nullptr)
- , MacOSXContentGenerator(nullptr)
{
- this->BuildFileStream = nullptr;
- this->InfoFileStream = nullptr;
- this->FlagFileStream = nullptr;
this->CustomCommandDriver = OnBuild;
this->LocalGenerator =
static_cast<cmLocalUnixMakefileGenerator3*>(target->GetLocalGenerator());
@@ -55,31 +50,28 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target)
cm->GetState()->GetGlobalProperty("RULE_MESSAGES")) {
this->NoRuleMessages = cmIsOff(ruleStatus);
}
- MacOSXContentGenerator = new MacOSXContentGeneratorType(this);
+ MacOSXContentGenerator = cm::make_unique<MacOSXContentGeneratorType>(this);
}
-cmMakefileTargetGenerator::~cmMakefileTargetGenerator()
-{
- delete MacOSXContentGenerator;
-}
+cmMakefileTargetGenerator::~cmMakefileTargetGenerator() = default;
-cmMakefileTargetGenerator* cmMakefileTargetGenerator::New(
+std::unique_ptr<cmMakefileTargetGenerator> cmMakefileTargetGenerator::New(
cmGeneratorTarget* tgt)
{
- cmMakefileTargetGenerator* result = nullptr;
+ std::unique_ptr<cmMakefileTargetGenerator> result;
switch (tgt->GetType()) {
case cmStateEnums::EXECUTABLE:
- result = new cmMakefileExecutableTargetGenerator(tgt);
+ result = cm::make_unique<cmMakefileExecutableTargetGenerator>(tgt);
break;
case cmStateEnums::STATIC_LIBRARY:
case cmStateEnums::SHARED_LIBRARY:
case cmStateEnums::MODULE_LIBRARY:
case cmStateEnums::OBJECT_LIBRARY:
- result = new cmMakefileLibraryTargetGenerator(tgt);
+ result = cm::make_unique<cmMakefileLibraryTargetGenerator>(tgt);
break;
case cmStateEnums::UTILITY:
- result = new cmMakefileUtilityTargetGenerator(tgt);
+ result = cm::make_unique<cmMakefileUtilityTargetGenerator>(tgt);
break;
default:
return result;
@@ -139,9 +131,9 @@ void cmMakefileTargetGenerator::CreateRuleFile()
// Open the rule file. This should be copy-if-different because the
// rules may depend on this file itself.
- this->BuildFileStream =
- new cmGeneratedFileStream(this->BuildFileNameFull, false,
- this->GlobalGenerator->GetMakefileEncoding());
+ this->BuildFileStream = cm::make_unique<cmGeneratedFileStream>(
+ this->BuildFileNameFull, false,
+ this->GlobalGenerator->GetMakefileEncoding());
if (!this->BuildFileStream) {
return;
}
@@ -247,11 +239,11 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
this->GeneratorTarget->GetHeaderSources(headerSources,
this->GetConfigName());
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
- headerSources, this->MacOSXContentGenerator, this->GetConfigName());
+ headerSources, this->MacOSXContentGenerator.get(), this->GetConfigName());
std::vector<cmSourceFile const*> extraSources;
this->GeneratorTarget->GetExtraSources(extraSources, this->GetConfigName());
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
- extraSources, this->MacOSXContentGenerator, this->GetConfigName());
+ extraSources, this->MacOSXContentGenerator.get(), this->GetConfigName());
const char* pchExtension =
this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION");
std::vector<cmSourceFile const*> externalObjects;
@@ -316,9 +308,9 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
// rules may depend on this file itself.
this->FlagFileNameFull =
cmStrCat(this->TargetBuildDirectoryFull, "/flags.make");
- this->FlagFileStream =
- new cmGeneratedFileStream(this->FlagFileNameFull, false,
- this->GlobalGenerator->GetMakefileEncoding());
+ this->FlagFileStream = cm::make_unique<cmGeneratedFileStream>(
+ this->FlagFileNameFull, false,
+ this->GlobalGenerator->GetMakefileEncoding());
if (!this->FlagFileStream) {
return;
}
@@ -1057,7 +1049,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
this->InfoFileNameFull = cmStrCat(dir, "/DependInfo.cmake");
this->InfoFileNameFull =
this->LocalGenerator->ConvertToFullPath(this->InfoFileNameFull);
- this->InfoFileStream = new cmGeneratedFileStream(this->InfoFileNameFull);
+ this->InfoFileStream =
+ cm::make_unique<cmGeneratedFileStream>(this->InfoFileNameFull);
if (!this->InfoFileStream) {
return;
}
@@ -1524,9 +1517,9 @@ std::string cmMakefileTargetGenerator::GetLinkRule(
void cmMakefileTargetGenerator::CloseFileStreams()
{
- delete this->BuildFileStream;
- delete this->InfoFileStream;
- delete this->FlagFileStream;
+ this->BuildFileStream.reset();
+ this->InfoFileStream.reset();
+ this->FlagFileStream.reset();
}
void cmMakefileTargetGenerator::CreateLinkScript(
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index fd62933..ec6b314 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -34,10 +34,15 @@ class cmMakefileTargetGenerator : public cmCommonTargetGenerator
public:
// constructor to set the ivars
cmMakefileTargetGenerator(cmGeneratorTarget* target);
+ cmMakefileTargetGenerator(const cmMakefileTargetGenerator&) = delete;
~cmMakefileTargetGenerator() override;
+ cmMakefileTargetGenerator& operator=(const cmMakefileTargetGenerator&) =
+ delete;
+
// construct using this factory call
- static cmMakefileTargetGenerator* New(cmGeneratorTarget* tgt);
+ static std::unique_ptr<cmMakefileTargetGenerator> New(
+ cmGeneratorTarget* tgt);
/* the main entry point for this class. Writes the Makefiles associated
with this target */
@@ -195,11 +200,11 @@ protected:
std::string TargetBuildDirectoryFull;
// the stream for the build file
- cmGeneratedFileStream* BuildFileStream;
+ std::unique_ptr<cmGeneratedFileStream> BuildFileStream;
// the stream for the flag file
std::string FlagFileNameFull;
- cmGeneratedFileStream* FlagFileStream;
+ std::unique_ptr<cmGeneratedFileStream> FlagFileStream;
class StringList : public std::vector<std::string>
{
};
@@ -207,7 +212,7 @@ protected:
// the stream for the info file
std::string InfoFileNameFull;
- cmGeneratedFileStream* InfoFileStream;
+ std::unique_ptr<cmGeneratedFileStream> InfoFileStream;
// files to clean
std::set<std::string> CleanFiles;
@@ -236,7 +241,7 @@ protected:
// macOS content info.
std::set<std::string> MacContentFolders;
std::unique_ptr<cmOSXBundleGenerator> OSXBundleGenerator;
- MacOSXContentGeneratorType* MacOSXContentGenerator;
+ std::unique_ptr<MacOSXContentGeneratorType> MacOSXContentGenerator;
};
#endif
diff --git a/Source/cmMarkAsAdvancedCommand.cxx b/Source/cmMarkAsAdvancedCommand.cxx
index ca46e14..45043fa 100644
--- a/Source/cmMarkAsAdvancedCommand.cxx
+++ b/Source/cmMarkAsAdvancedCommand.cxx
@@ -4,8 +4,11 @@
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmPolicies.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
@@ -28,14 +31,63 @@ bool cmMarkAsAdvancedCommand(std::vector<std::string> const& args,
}
i = 1;
}
+
+ cmMakefile& mf = status.GetMakefile();
+ cmState* state = mf.GetState();
+
for (; i < args.size(); ++i) {
std::string const& variable = args[i];
- cmState* state = status.GetMakefile().GetState();
- if (!state->GetCacheEntryValue(variable)) {
- status.GetMakefile().GetCMakeInstance()->AddCacheEntry(
- variable, nullptr, nullptr, cmStateEnums::UNINITIALIZED);
- overwrite = true;
+
+ bool issueMessage = false;
+ bool oldBehavior = false;
+ bool ignoreVariable = false;
+ switch (mf.GetPolicyStatus(cmPolicies::CMP0102)) {
+ case cmPolicies::WARN:
+ if (mf.PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0102")) {
+ if (!state->GetCacheEntryValue(variable)) {
+ issueMessage = true;
+ }
+ }
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ oldBehavior = true;
+ break;
+ case cmPolicies::NEW:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ if (!state->GetCacheEntryValue(variable)) {
+ ignoreVariable = true;
+ }
+ break;
+ }
+
+ // First see if we should issue a message about CMP0102
+ if (issueMessage) {
+ std::string err = cmStrCat(
+ "Policy CMP0102 is not set: The variable named \"", variable,
+ "\" is not in the cache. This results in an empty cache entry which "
+ "is no longer created when policy CMP0102 is set to NEW. Run \"cmake "
+ "--help-policy CMP0102\" for policy details. Use the cmake_policy "
+ "command to set the policy and suppress this warning.");
+ mf.IssueMessage(MessageType::AUTHOR_WARNING, err);
}
+
+ // If it's not in the cache and we're using the new behavior, nothing to
+ // see here.
+ if (ignoreVariable) {
+ continue;
+ }
+
+ // Check if we want the old behavior of making a dummy cache entry.
+ if (oldBehavior) {
+ if (!state->GetCacheEntryValue(variable)) {
+ status.GetMakefile().GetCMakeInstance()->AddCacheEntry(
+ variable, nullptr, nullptr, cmStateEnums::UNINITIALIZED);
+ overwrite = true;
+ }
+ }
+
+ // We need a cache entry to do this.
if (!state->GetCacheEntryValue(variable)) {
cmSystemTools::Error("This should never happen...");
return false;
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index eef41c0..1366ff0 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -302,7 +302,10 @@ class cmMakefile;
17, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0101, \
"target_compile_options honors BEFORE keyword in all scopes.", 3, \
- 17, 0, cmPolicies::WARN)
+ 17, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0102, \
+ "mark_as_advanced() does nothing if a cache entry does not exist.", \
+ 3, 17, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 2edff25..ebb522b 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -1219,7 +1219,10 @@ bool cmQtAutoGenInitializer::InitRccTargets()
// Register info file as generated by CMake
this->Makefile->AddCMakeOutputFile(qrc.InfoFile);
// Register file at target
- this->AddGeneratedSource(qrc.OutputFile, this->Rcc);
+ {
+ cmSourceFile* sf = this->AddGeneratedSource(qrc.OutputFile, this->Rcc);
+ sf->SetProperty("SKIP_UNITY_BUILD_INCLUSION", "On");
+ }
std::vector<std::string> ccOutput;
ccOutput.push_back(qrc.OutputFile);
@@ -1514,27 +1517,30 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo()
return true;
}
-void cmQtAutoGenInitializer::RegisterGeneratedSource(
+cmSourceFile* cmQtAutoGenInitializer::RegisterGeneratedSource(
std::string const& filename)
{
cmSourceFile* gFile = this->Makefile->GetOrCreateSource(filename, true);
gFile->SetProperty("GENERATED", "1");
gFile->SetProperty("SKIP_AUTOGEN", "1");
+ return gFile;
}
-bool cmQtAutoGenInitializer::AddGeneratedSource(std::string const& filename,
- GenVarsT const& genVars,
- bool prepend)
+cmSourceFile* cmQtAutoGenInitializer::AddGeneratedSource(
+ std::string const& filename, GenVarsT const& genVars, bool prepend)
{
// Register source at makefile
- this->RegisterGeneratedSource(filename);
+ cmSourceFile* gFile = this->RegisterGeneratedSource(filename);
// Add source file to target
this->GenTarget->AddSource(filename, prepend);
+
// Add source file to source group
- return this->AddToSourceGroup(filename, genVars.GenNameUpper);
+ this->AddToSourceGroup(filename, genVars.GenNameUpper);
+
+ return gFile;
}
-bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
+void cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
cm::string_view genNameUpper)
{
cmSourceGroup* sourceGroup = nullptr;
@@ -1565,14 +1571,12 @@ bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
cmStrCat(genNameUpper, " error in ", property,
": Could not find or create the source group ",
cmQtAutoGen::Quoted(groupName)));
- return false;
}
}
}
if (sourceGroup != nullptr) {
sourceGroup->AddGroupFile(fileName);
}
- return true;
}
void cmQtAutoGenInitializer::AddCleanFile(std::string const& fileName)
diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h
index 847e4e5..8cedf14 100644
--- a/Source/cmQtAutoGenInitializer.h
+++ b/Source/cmQtAutoGenInitializer.h
@@ -129,10 +129,11 @@ private:
bool SetupWriteAutogenInfo();
bool SetupWriteRccInfo();
- void RegisterGeneratedSource(std::string const& filename);
- bool AddGeneratedSource(std::string const& filename, GenVarsT const& genVars,
- bool prepend = false);
- bool AddToSourceGroup(std::string const& fileName,
+ cmSourceFile* RegisterGeneratedSource(std::string const& filename);
+ cmSourceFile* AddGeneratedSource(std::string const& filename,
+ GenVarsT const& genVars,
+ bool prepend = false);
+ void AddToSourceGroup(std::string const& fileName,
cm::string_view genNameUpper);
void AddCleanFile(std::string const& fileName);
diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h
index c8bb1ab..7d676c9 100644
--- a/Source/cmScriptGenerator.h
+++ b/Source/cmScriptGenerator.h
@@ -71,7 +71,7 @@ protected:
std::string CreateConfigTest(const std::string& config);
std::string CreateConfigTest(std::vector<std::string> const& configs);
- std::string CreateComponentTest(const char* component);
+ std::string CreateComponentTest(const std::string& component);
// Information shared by most generator types.
std::string RuntimeConfigVariable;