summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/release/dev/xmllint-target.rst4
-rw-r--r--Modules/FindLibXml2.cmake13
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmCacheManager.cxx2
-rw-r--r--Source/cmExportBuildFileGenerator.cxx5
-rw-r--r--Source/cmExportCommand.cxx14
-rw-r--r--Source/cmExportLibraryDependenciesCommand.cxx4
-rw-r--r--Source/cmFileAPICodemodel.cxx2
-rw-r--r--Source/cmGhsMultiTargetGenerator.cxx4
-rw-r--r--Source/cmGlobalGenerator.cxx71
-rw-r--r--Source/cmGlobalGenerator.h20
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx15
-rw-r--r--Source/cmGlobalNinjaGenerator.h2
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx2
-rw-r--r--Source/cmJsonObjects.cxx7
-rw-r--r--Source/cmMakefile.cxx7
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx8
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx12
-rw-r--r--Source/cmMakefileTargetGenerator.cxx4
-rw-r--r--Source/cmMakefileTargetGenerator.h2
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx4
-rw-r--r--Source/cmSetCommand.cxx2
-rw-r--r--Source/cmState.cxx35
-rw-r--r--Source/cmState.h8
-rw-r--r--Source/cmake.cxx33
-rw-r--r--Templates/MSBuild/FlagTables/v10_Cuda.json20
-rw-r--r--Tests/CudaOnly/WithDefs/CMakeLists.txt2
-rw-r--r--Tests/FindLibXml2/Test/CMakeLists.txt4
-rwxr-xr-xTests/RunCMake/CommandLine/trace-json-v1-check.py6
29 files changed, 184 insertions, 130 deletions
diff --git a/Help/release/dev/xmllint-target.rst b/Help/release/dev/xmllint-target.rst
new file mode 100644
index 0000000..19c69bf
--- /dev/null
+++ b/Help/release/dev/xmllint-target.rst
@@ -0,0 +1,4 @@
+xmllint-target
+--------------
+
+* The :module:`FindLibXml2` module now provides an imported target for the xmllint executable
diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake
index da8bfe0..9480cea 100644
--- a/Modules/FindLibXml2.cmake
+++ b/Modules/FindLibXml2.cmake
@@ -10,8 +10,12 @@ Find the XML processing library (libxml2).
IMPORTED Targets
^^^^^^^^^^^^^^^^
-This module defines :prop_tgt:`IMPORTED` target ``LibXml2::LibXml2``, if
-libxml2 has been found.
+The following :prop_tgt:`IMPORTED` targets may be defined:
+
+``LibXml2::LibXml2``
+ If the libxml2 library has been found
+``LibXml2::xmllint``
+ If the xmllint command-line executable has been found
Result variables
^^^^^^^^^^^^^^^^
@@ -100,3 +104,8 @@ if(LibXml2_FOUND AND NOT TARGET LibXml2::LibXml2)
set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIRS}")
set_property(TARGET LibXml2::LibXml2 APPEND PROPERTY IMPORTED_LOCATION "${LIBXML2_LIBRARY}")
endif()
+
+if(LIBXML2_XMLLINT_EXECUTABLE AND NOT TARGET LibXml2::xmllint)
+ add_executable(LibXml2::xmllint IMPORTED)
+ set_target_properties(LibXml2::xmllint PROPERTIES IMPORTED_LOCATION "${LIBXML2_XMLLINT_EXECUTABLE}")
+endif()
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index df7abe5..361a424 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 20191230)
+set(CMake_VERSION_PATCH 20200103)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index d627465..e3536d5 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -617,7 +617,7 @@ const char* cmCacheManager::CacheEntry::GetProperty(
const std::string& prop) const
{
if (prop == "TYPE") {
- return cmState::CacheEntryTypeToString(this->Type);
+ return cmState::CacheEntryTypeToString(this->Type).c_str();
}
if (prop == "VALUE") {
return this->Value.c_str();
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index dbe5a5e..d22bd48 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -301,11 +301,10 @@ cmExportBuildFileGenerator::FindBuildExportInfo(cmGlobalGenerator* gg,
std::vector<std::string> exportFiles;
std::string ns;
- std::map<std::string, cmExportBuildFileGenerator*>& exportSets =
- gg->GetBuildExportSets();
+ auto& exportSets = gg->GetBuildExportSets();
for (auto const& exp : exportSets) {
- const cmExportBuildFileGenerator* exportSet = exp.second;
+ const auto& exportSet = exp.second;
std::vector<std::string> targets;
exportSet->GetTargets(targets);
if (cmContains(targets, name)) {
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index 2a6bf5d..b7cc193 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -6,6 +6,8 @@
#include <sstream>
#include <utility>
+#include <cm/memory>
+
#include "cmsys/RegularExpression.hxx"
#include "cm_static_string_view.hxx"
@@ -182,11 +184,11 @@ bool cmExportCommand(std::vector<std::string> const& args,
}
// Setup export file generation.
- cmExportBuildFileGenerator* ebfg = nullptr;
+ std::unique_ptr<cmExportBuildFileGenerator> ebfg = nullptr;
if (android) {
- ebfg = new cmExportBuildAndroidMKGenerator;
+ ebfg = cm::make_unique<cmExportBuildAndroidMKGenerator>();
} else {
- ebfg = new cmExportBuildFileGenerator;
+ ebfg = cm::make_unique<cmExportBuildFileGenerator>();
}
ebfg->SetExportFile(fname.c_str());
ebfg->SetNamespace(arguments.Namespace);
@@ -196,7 +198,7 @@ bool cmExportCommand(std::vector<std::string> const& args,
} else {
ebfg->SetTargets(targets);
}
- mf.AddExportBuildFileGenerator(ebfg);
+ mf.AddExportBuildFileGenerator(ebfg.get());
ebfg->SetExportOld(arguments.ExportOld);
// Compute the set of configurations exported.
@@ -209,9 +211,9 @@ bool cmExportCommand(std::vector<std::string> const& args,
ebfg->AddConfiguration(ct);
}
if (exportSet != nullptr) {
- gg->AddBuildExportExportSet(ebfg);
+ gg->AddBuildExportExportSet(std::move(ebfg));
} else {
- gg->AddBuildExportSet(ebfg);
+ gg->AddBuildExportSet(std::move(ebfg));
}
return true;
diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx
index dfc8de5..6011ba4 100644
--- a/Source/cmExportLibraryDependenciesCommand.cxx
+++ b/Source/cmExportLibraryDependenciesCommand.cxx
@@ -49,11 +49,11 @@ static void FinalAction(cmMakefile& makefile, std::string const& filename,
// the project.
cmake* cm = makefile.GetCMakeInstance();
cmGlobalGenerator* global = cm->GetGlobalGenerator();
- const std::vector<cmMakefile*>& locals = global->GetMakefiles();
+ const auto& locals = global->GetMakefiles();
std::map<std::string, std::string> libDepsOld;
std::map<std::string, std::string> libDepsNew;
std::map<std::string, std::string> libTypes;
- for (cmMakefile* local : locals) {
+ for (const auto& local : locals) {
for (auto const& tgt : local->GetTargets()) {
// Get the current target.
cmTarget const& target = tgt.second;
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx
index 7a2d9d5..d13e8ec 100644
--- a/Source/cmFileAPICodemodel.cxx
+++ b/Source/cmFileAPICodemodel.cxx
@@ -427,7 +427,7 @@ Json::Value Codemodel::DumpConfigurations()
Json::Value configurations = Json::arrayValue;
cmGlobalGenerator* gg =
this->FileAPI.GetCMakeInstance()->GetGlobalGenerator();
- auto makefiles = gg->GetMakefiles();
+ const auto& makefiles = gg->GetMakefiles();
if (!makefiles.empty()) {
std::vector<std::string> const& configs =
makefiles[0]->GetGeneratorConfigs();
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index f7c542f..5e2248e 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -279,10 +279,10 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLine(std::ostream& fout,
std::string frameworkPath;
std::string linkPath;
- std::unique_ptr<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer =
this->GetGlobalGenerator()->CreateLinkLineComputer(
this->LocalGenerator,
- this->LocalGenerator->GetStateSnapshot().GetDirectory()));
+ this->LocalGenerator->GetStateSnapshot().GetDirectory());
this->LocalGenerator->GetTargetFlags(
linkLineComputer.get(), config, linkLibraries, flags, linkFlags,
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index bcc9050..d6d8c7b 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -261,16 +261,17 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string& lang,
}
}
-void cmGlobalGenerator::AddBuildExportSet(cmExportBuildFileGenerator* gen)
+void cmGlobalGenerator::AddBuildExportSet(
+ std::unique_ptr<cmExportBuildFileGenerator> gen)
{
- this->BuildExportSets[gen->GetMainExportFileName()] = gen;
+ this->BuildExportSets[gen->GetMainExportFileName()] = std::move(gen);
}
void cmGlobalGenerator::AddBuildExportExportSet(
- cmExportBuildFileGenerator* gen)
+ std::unique_ptr<cmExportBuildFileGenerator> gen)
{
- this->BuildExportSets[gen->GetMainExportFileName()] = gen;
- this->BuildExportExportSets[gen->GetMainExportFileName()] = gen;
+ this->BuildExportExportSets[gen->GetMainExportFileName()] = gen.get();
+ this->AddBuildExportSet(std::move(gen));
}
bool cmGlobalGenerator::GenerateImportFile(const std::string& file)
@@ -280,13 +281,11 @@ bool cmGlobalGenerator::GenerateImportFile(const std::string& file)
bool result = it->second->GenerateImportFile();
if (!this->ConfigureDoneCMP0026AndCMP0024) {
- for (cmMakefile* m : this->Makefiles) {
- m->RemoveExportBuildFileGeneratorCMP0024(it->second);
+ for (const auto& m : this->Makefiles) {
+ m->RemoveExportBuildFileGeneratorCMP0024(it->second.get());
}
}
- delete it->second;
- it->second = nullptr;
this->BuildExportSets.erase(it);
return result;
}
@@ -1206,8 +1205,8 @@ void cmGlobalGenerator::CreateLocalGenerators()
this->LocalGeneratorSearchIndex.clear();
this->LocalGenerators.clear();
this->LocalGenerators.reserve(this->Makefiles.size());
- for (cmMakefile* m : this->Makefiles) {
- auto lg = this->CreateLocalGenerator(m);
+ for (const auto& m : this->Makefiles) {
+ auto lg = this->CreateLocalGenerator(m.get());
this->IndexLocalGenerator(lg.get());
this->LocalGenerators.push_back(std::move(lg));
}
@@ -1225,9 +1224,10 @@ void cmGlobalGenerator::Configure()
snapshot.GetDirectory().SetCurrentBinary(
this->CMakeInstance->GetHomeOutputDirectory());
- cmMakefile* dirMf = new cmMakefile(this, snapshot);
+ auto dirMfu = cm::make_unique<cmMakefile>(this, snapshot);
+ auto dirMf = dirMfu.get();
+ this->Makefiles.push_back(std::move(dirMfu));
dirMf->SetRecursionDepth(this->RecursionDepth);
- this->Makefiles.push_back(dirMf);
this->IndexMakefile(dirMf);
this->BinaryDirectories.insert(
@@ -1245,11 +1245,11 @@ void cmGlobalGenerator::Configure()
std::vector<GlobalTargetInfo> globalTargets;
this->CreateDefaultGlobalTargets(globalTargets);
- for (cmMakefile* mf : this->Makefiles) {
+ for (const auto& mf : this->Makefiles) {
auto& targets = mf->GetTargets();
for (GlobalTargetInfo const& globalTarget : globalTargets) {
targets.emplace(globalTarget.Name,
- this->CreateGlobalTarget(globalTarget, mf));
+ this->CreateGlobalTarget(globalTarget, mf.get()));
}
}
}
@@ -1298,7 +1298,10 @@ void cmGlobalGenerator::CreateImportedGenerationObjects(
{
this->CreateGenerationObjects(ImportedOnly);
auto const mfit =
- std::find(this->Makefiles.begin(), this->Makefiles.end(), mf);
+ std::find_if(this->Makefiles.begin(), this->Makefiles.end(),
+ [mf](const std::unique_ptr<cmMakefile>& item) {
+ return item.get() == mf;
+ });
auto& lg =
this->LocalGenerators[std::distance(this->Makefiles.begin(), mfit)];
for (std::string const& t : targets) {
@@ -1313,7 +1316,7 @@ cmExportBuildFileGenerator* cmGlobalGenerator::GetExportedTargetsFile(
const std::string& filename) const
{
auto const it = this->BuildExportSets.find(filename);
- return it == this->BuildExportSets.end() ? nullptr : it->second;
+ return it == this->BuildExportSets.end() ? nullptr : it->second.get();
}
void cmGlobalGenerator::AddCMP0042WarnTarget(const std::string& target)
@@ -1586,16 +1589,18 @@ bool cmGlobalGenerator::AddAutomaticSources()
return true;
}
-cmLinkLineComputer* cmGlobalGenerator::CreateLinkLineComputer(
+std::unique_ptr<cmLinkLineComputer> cmGlobalGenerator::CreateLinkLineComputer(
cmOutputConverter* outputConverter, cmStateDirectory const& stateDir) const
{
- return new cmLinkLineComputer(outputConverter, stateDir);
+ return cm::make_unique<cmLinkLineComputer>(outputConverter, stateDir);
}
-cmLinkLineComputer* cmGlobalGenerator::CreateMSVC60LinkLineComputer(
+std::unique_ptr<cmLinkLineComputer>
+cmGlobalGenerator::CreateMSVC60LinkLineComputer(
cmOutputConverter* outputConverter, cmStateDirectory const& stateDir) const
{
- return new cmMSVC60LinkLineComputer(outputConverter, stateDir);
+ return std::unique_ptr<cmLinkLineComputer>(
+ cm::make_unique<cmMSVC60LinkLineComputer>(outputConverter, stateDir));
}
void cmGlobalGenerator::FinalizeTargetCompileInfo()
@@ -1604,7 +1609,7 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
this->CMakeInstance->GetState()->GetEnabledLanguages();
// Construct per-target generator information.
- for (cmMakefile* mf : this->Makefiles) {
+ for (const auto& mf : this->Makefiles) {
const cmStringRange noconfig_compile_definitions =
mf->GetCompileDefinitionsEntries();
const cmBacktraceRange noconfig_compile_definitions_bts =
@@ -1681,7 +1686,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes)
{
std::map<cmTarget*, cmGeneratorTarget*> importedMap;
for (unsigned int i = 0; i < this->Makefiles.size(); ++i) {
- cmMakefile* mf = this->Makefiles[i];
+ auto& mf = this->Makefiles[i];
for (cmTarget* ownedImpTgt : mf->GetOwnedImportedTargets()) {
cmLocalGenerator* lg = this->LocalGenerators[i].get();
auto gt = cm::make_unique<cmGeneratorTarget>(ownedImpTgt, lg);
@@ -1692,17 +1697,15 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes)
// Construct per-target generator information.
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
- this->CreateGeneratorTargets(targetTypes, this->Makefiles[i],
+ this->CreateGeneratorTargets(targetTypes, this->Makefiles[i].get(),
this->LocalGenerators[i].get(), importedMap);
}
}
void cmGlobalGenerator::ClearGeneratorMembers()
{
- cmDeleteAll(this->BuildExportSets);
this->BuildExportSets.clear();
- cmDeleteAll(this->Makefiles);
this->Makefiles.clear();
this->LocalGenerators.clear();
@@ -1999,10 +2002,10 @@ std::string cmGlobalGenerator::GenerateCMakeBuildCommand(
return makeCommand;
}
-void cmGlobalGenerator::AddMakefile(cmMakefile* mf)
+void cmGlobalGenerator::AddMakefile(std::unique_ptr<cmMakefile> mf)
{
- this->Makefiles.push_back(mf);
- this->IndexMakefile(mf);
+ this->IndexMakefile(mf.get());
+ this->Makefiles.push_back(std::move(mf));
// update progress
// estimate how many lg there will be
@@ -2354,7 +2357,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(
void cmGlobalGenerator::AddGlobalTarget_Package(
std::vector<GlobalTargetInfo>& targets)
{
- cmMakefile* mf = this->Makefiles[0];
+ auto& mf = this->Makefiles[0];
std::string configFile =
cmStrCat(mf->GetCurrentBinaryDirectory(), "/CPackConfig.cmake");
if (!cmSystemTools::FileExists(configFile)) {
@@ -2403,7 +2406,7 @@ void cmGlobalGenerator::AddGlobalTarget_PackageSource(
return;
}
- cmMakefile* mf = this->Makefiles[0];
+ auto& mf = this->Makefiles[0];
std::string configFile =
cmStrCat(mf->GetCurrentBinaryDirectory(), "/CPackSourceConfig.cmake");
if (!cmSystemTools::FileExists(configFile)) {
@@ -2435,7 +2438,7 @@ void cmGlobalGenerator::AddGlobalTarget_PackageSource(
void cmGlobalGenerator::AddGlobalTarget_Test(
std::vector<GlobalTargetInfo>& targets)
{
- cmMakefile* mf = this->Makefiles[0];
+ auto& mf = this->Makefiles[0];
if (!mf->IsOn("CMAKE_TESTING_ENABLED")) {
return;
}
@@ -2523,7 +2526,7 @@ void cmGlobalGenerator::AddGlobalTarget_RebuildCache(
void cmGlobalGenerator::AddGlobalTarget_Install(
std::vector<GlobalTargetInfo>& targets)
{
- cmMakefile* mf = this->Makefiles[0];
+ auto& mf = this->Makefiles[0];
const char* cmakeCfgIntDir = this->GetCMakeCFGIntDir();
bool skipInstallRules = mf->IsOn("CMAKE_SKIP_INSTALL_RULES");
if (this->InstallTargetEnabled && skipInstallRules) {
@@ -2573,7 +2576,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install(
singleLine.push_back(cmd);
if (cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') {
std::string cfgArg = "-DBUILD_TYPE=";
- bool useEPN = this->UseEffectivePlatformName(mf);
+ bool useEPN = this->UseEffectivePlatformName(mf.get());
if (useEPN) {
cfgArg += "$(CONFIGURATION)";
singleLine.push_back(cfgArg);
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index f3078ac..3d11c61 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -162,11 +162,11 @@ public:
*/
virtual void Generate();
- virtual cmLinkLineComputer* CreateLinkLineComputer(
+ virtual std::unique_ptr<cmLinkLineComputer> CreateLinkLineComputer(
cmOutputConverter* outputConverter,
cmStateDirectory const& stateDir) const;
- cmLinkLineComputer* CreateMSVC60LinkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> CreateMSVC60LinkLineComputer(
cmOutputConverter* outputConverter,
cmStateDirectory const& stateDir) const;
@@ -249,7 +249,7 @@ public:
cmake* GetCMakeInstance() const { return this->CMakeInstance; }
void SetConfiguredFilesPath(cmGlobalGenerator* gen);
- const std::vector<cmMakefile*>& GetMakefiles() const
+ const std::vector<std::unique_ptr<cmMakefile>>& GetMakefiles() const
{
return this->Makefiles;
}
@@ -268,7 +268,7 @@ public:
this->CurrentConfigureMakefile = mf;
}
- void AddMakefile(cmMakefile* mf);
+ void AddMakefile(std::unique_ptr<cmMakefile> mf);
//! Set an generator for an "external makefile based project"
void SetExternalMakefileProjectGenerator(
@@ -445,12 +445,13 @@ public:
void ProcessEvaluationFiles();
- std::map<std::string, cmExportBuildFileGenerator*>& GetBuildExportSets()
+ std::map<std::string, std::unique_ptr<cmExportBuildFileGenerator>>&
+ GetBuildExportSets()
{
return this->BuildExportSets;
}
- void AddBuildExportSet(cmExportBuildFileGenerator*);
- void AddBuildExportExportSet(cmExportBuildFileGenerator*);
+ void AddBuildExportSet(std::unique_ptr<cmExportBuildFileGenerator>);
+ void AddBuildExportExportSet(std::unique_ptr<cmExportBuildFileGenerator>);
bool IsExportedTargetsFile(const std::string& filename) const;
bool GenerateImportFile(const std::string& file);
cmExportBuildFileGenerator* GetExportedTargetsFile(
@@ -549,7 +550,7 @@ protected:
std::string FindMakeProgramFile;
std::string ConfiguredFilesPath;
cmake* CMakeInstance;
- std::vector<cmMakefile*> Makefiles;
+ std::vector<std::unique_ptr<cmMakefile>> Makefiles;
LocalGeneratorVector LocalGenerators;
cmMakefile* CurrentConfigureMakefile;
// map from project name to vector of local generators in that project
@@ -559,7 +560,8 @@ protected:
std::set<std::string> InstallComponents;
// Sets of named target exports
cmExportSetMap ExportSets;
- std::map<std::string, cmExportBuildFileGenerator*> BuildExportSets;
+ std::map<std::string, std::unique_ptr<cmExportBuildFileGenerator>>
+ BuildExportSets;
std::map<std::string, cmExportBuildFileGenerator*> BuildExportExportSets;
std::map<std::string, std::string> AliasTargets;
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 2a59708..f5f5af8 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -25,6 +25,7 @@
#include "cmGeneratorExpressionEvaluationFile.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
+#include "cmLinkLineComputer.h"
#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmLocalNinjaGenerator.h"
@@ -44,8 +45,6 @@
#include "cmVersion.h"
#include "cmake.h"
-class cmLinkLineComputer;
-
const char* cmGlobalNinjaGenerator::NINJA_BUILD_FILE = "build.ninja";
const char* cmGlobalNinjaGenerator::NINJA_RULES_FILE = "rules.ninja";
const char* cmGlobalNinjaGenerator::INDENT = " ";
@@ -85,13 +84,15 @@ void cmGlobalNinjaGenerator::WriteComment(std::ostream& os,
os << "# " << comment.substr(lpos) << "\n\n";
}
-cmLinkLineComputer* cmGlobalNinjaGenerator::CreateLinkLineComputer(
+std::unique_ptr<cmLinkLineComputer>
+cmGlobalNinjaGenerator::CreateLinkLineComputer(
cmOutputConverter* outputConverter,
cmStateDirectory const& /* stateDir */) const
{
- return new cmNinjaLinkLineComputer(
- outputConverter,
- this->LocalGenerators[0]->GetStateSnapshot().GetDirectory(), this);
+ return std::unique_ptr<cmLinkLineComputer>(
+ cm::make_unique<cmNinjaLinkLineComputer>(
+ outputConverter,
+ this->LocalGenerators[0]->GetStateSnapshot().GetDirectory(), this));
}
std::string cmGlobalNinjaGenerator::EncodeRuleName(std::string const& name)
@@ -2044,7 +2045,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
snapshot.GetDirectory().SetRelativePathTopBinary(dir_top_bld.c_str());
auto mfd = cm::make_unique<cmMakefile>(this, snapshot);
auto lgd = this->CreateLocalGenerator(mfd.get());
- this->Makefiles.push_back(mfd.release());
+ this->Makefiles.push_back(std::move(mfd));
this->LocalGenerators.push_back(std::move(lgd));
}
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 6ebb31d..20e2c8e 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -77,7 +77,7 @@ public:
std::string EncodeLiteral(const std::string& lit);
std::string EncodePath(const std::string& path);
- cmLinkLineComputer* CreateLinkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> CreateLinkLineComputer(
cmOutputConverter* outputConverter,
cmStateDirectory const& stateDir) const override;
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index f2595ea..0591758 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -492,7 +492,7 @@ cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
std::unique_ptr<cmMakefile> mfu;
cmMakefile* mf;
if (!this->Makefiles.empty()) {
- mf = this->Makefiles[0];
+ mf = this->Makefiles[0].get();
} else {
cmStateSnapshot snapshot = this->CMakeInstance->GetCurrentSnapshot();
snapshot.GetDirectory().SetCurrentSource(
diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx
index 5f86d85..54edabc 100644
--- a/Source/cmJsonObjects.cxx
+++ b/Source/cmJsonObjects.cxx
@@ -8,6 +8,7 @@
#include <functional>
#include <limits>
#include <map>
+#include <memory>
#include <set>
#include <string>
#include <unordered_map>
@@ -44,7 +45,7 @@ namespace {
std::vector<std::string> getConfigurations(const cmake* cm)
{
std::vector<std::string> configurations;
- auto makefiles = cm->GetGlobalGenerator()->GetMakefiles();
+ const auto& makefiles = cm->GetGlobalGenerator()->GetMakefiles();
if (makefiles.empty()) {
return configurations;
}
@@ -83,8 +84,8 @@ void cmGetCMakeInputs(const cmGlobalGenerator* gg,
std::vector<std::string>* tmpFiles)
{
const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot() + '/';
- std::vector<cmMakefile*> const& makefiles = gg->GetMakefiles();
- for (cmMakefile const* mf : makefiles) {
+ auto const& makefiles = gg->GetMakefiles();
+ for (const auto& mf : makefiles) {
for (std::string const& lf : mf->GetListFiles()) {
const std::string startOfFile = lf.substr(0, cmakeRootDir.size());
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 13a6ed7..44328d3 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -15,6 +15,7 @@
#include <utility>
#include <cm/iterator>
+#include <cm/memory>
#include <cm/optional>
#include <cmext/algorithm>
@@ -1723,8 +1724,10 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
cmSystemTools::MakeDirectory(binPath);
- cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot);
- this->GetGlobalGenerator()->AddMakefile(subMf);
+ auto subMfu =
+ cm::make_unique<cmMakefile>(this->GlobalGenerator, newSnapshot);
+ auto subMf = subMfu.get();
+ this->GetGlobalGenerator()->AddMakefile(std::move(subMfu));
if (excludeFromAll) {
subMf->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 5c9608c..1df5410 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -420,10 +420,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
this->GetTargetLinkFlags(linkFlags, linkLanguage);
{
- std::unique_ptr<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer =
this->CreateLinkLineComputer(
this->LocalGenerator,
- this->LocalGenerator->GetStateSnapshot().GetDirectory()));
+ this->LocalGenerator->GetStateSnapshot().GetDirectory());
this->AddModuleDefinitionFlag(linkLineComputer.get(), linkFlags,
this->GetConfigName());
@@ -509,10 +509,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Set path conversion for link script shells.
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
- std::unique_ptr<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer =
this->CreateLinkLineComputer(
this->LocalGenerator,
- this->LocalGenerator->GetStateSnapshot().GetDirectory()));
+ this->LocalGenerator->GetStateSnapshot().GetDirectory());
linkLineComputer->SetForResponse(useResponseFileForLibs);
linkLineComputer->SetUseWatcomQuote(useWatcomQuote);
linkLineComputer->SetRelink(relink);
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index e728b67..357e273 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -172,10 +172,10 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
this->LocalGenerator->AddConfigVariableFlags(
extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->GetConfigName());
- std::unique_ptr<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer =
this->CreateLinkLineComputer(
this->LocalGenerator,
- this->LocalGenerator->GetStateSnapshot().GetDirectory()));
+ this->LocalGenerator->GetStateSnapshot().GetDirectory());
this->AddModuleDefinitionFlag(linkLineComputer.get(), extraFlags,
this->GetConfigName());
@@ -207,10 +207,10 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
this->LocalGenerator->AddConfigVariableFlags(
extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->GetConfigName());
- std::unique_ptr<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer =
this->CreateLinkLineComputer(
this->LocalGenerator,
- this->LocalGenerator->GetStateSnapshot().GetDirectory()));
+ this->LocalGenerator->GetStateSnapshot().GetDirectory());
this->AddModuleDefinitionFlag(linkLineComputer.get(), extraFlags,
this->GetConfigName());
@@ -700,10 +700,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
std::string linkLibs;
if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) {
- std::unique_ptr<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer =
this->CreateLinkLineComputer(
this->LocalGenerator,
- this->LocalGenerator->GetStateSnapshot().GetDirectory()));
+ this->LocalGenerator->GetStateSnapshot().GetDirectory());
linkLineComputer->SetForResponse(useResponseFileForLibs);
linkLineComputer->SetUseWatcomQuote(useWatcomQuote);
linkLineComputer->SetRelink(relink);
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 4979da5..a9f68a6 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -17,6 +17,7 @@
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalUnixMakefileGenerator3.h"
+#include "cmLinkLineComputer.h"
#include "cmLocalCommonGenerator.h"
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
@@ -1634,7 +1635,8 @@ std::string cmMakefileTargetGenerator::CreateResponseFile(
return responseFileName;
}
-cmLinkLineComputer* cmMakefileTargetGenerator::CreateLinkLineComputer(
+std::unique_ptr<cmLinkLineComputer>
+cmMakefileTargetGenerator::CreateLinkLineComputer(
cmOutputConverter* outputConverter, cmStateDirectory const& stateDir)
{
if (this->Makefile->IsOn("MSVC60")) {
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 710ef89..fd62933 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -140,7 +140,7 @@ protected:
std::vector<std::string>& makefile_commands,
std::vector<std::string>& makefile_depends);
- cmLinkLineComputer* CreateLinkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> CreateLinkLineComputer(
cmOutputConverter* outputConverter, cmStateDirectory const& stateDir);
/** Create a response file with the given set of options. Returns
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 5a12855..987f241 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -884,10 +884,10 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
vars["TARGET_FILE"] =
localGen.ConvertToOutputFormat(targetOutputReal, cmOutputConverter::SHELL);
- std::unique_ptr<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer =
globalGen->CreateLinkLineComputer(
this->GetLocalGenerator(),
- this->GetLocalGenerator()->GetStateSnapshot().GetDirectory()));
+ this->GetLocalGenerator()->GetStateSnapshot().GetDirectory());
linkLineComputer->SetUseWatcomQuote(useWatcomQuote);
linkLineComputer->SetUseNinjaMulti(globalGen->IsMultiConfig());
diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx
index 8c3a4cb..5e2a146 100644
--- a/Source/cmSetCommand.cxx
+++ b/Source/cmSetCommand.cxx
@@ -121,7 +121,7 @@ bool cmSetCommand(std::vector<std::string> const& args,
if (cache) {
std::string::size_type cacheStart = args.size() - 3 - (force ? 1 : 0);
- if (!cmState::StringToCacheEntryType(args[cacheStart + 1].c_str(), type)) {
+ if (!cmState::StringToCacheEntryType(args[cacheStart + 1], type)) {
std::string m = "implicitly converting '" + args[cacheStart + 1] +
"' to 'STRING' type.";
status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, m);
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 72f663d..9d83a72 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -3,9 +3,9 @@
#include "cmState.h"
#include <algorithm>
+#include <array>
#include <cassert>
#include <cstdlib>
-#include <cstring>
#include <utility>
#include <cm/memory>
@@ -60,43 +60,44 @@ const char* cmState::GetTargetTypeName(cmStateEnums::TargetType targetType)
return nullptr;
}
-const char* cmCacheEntryTypes[] = { "BOOL", "PATH", "FILEPATH",
- "STRING", "INTERNAL", "STATIC",
- "UNINITIALIZED", nullptr };
+static const std::array<std::string, 7> cmCacheEntryTypes = {
+ { "BOOL", "PATH", "FILEPATH", "STRING", "INTERNAL", "STATIC",
+ "UNINITIALIZED" }
+};
-const char* cmState::CacheEntryTypeToString(cmStateEnums::CacheEntryType type)
+const std::string& cmState::CacheEntryTypeToString(
+ cmStateEnums::CacheEntryType type)
{
- if (type > 6) {
- return cmCacheEntryTypes[6];
+ if (type < cmStateEnums::BOOL || type > cmStateEnums::UNINITIALIZED) {
+ type = cmStateEnums::UNINITIALIZED;
}
return cmCacheEntryTypes[type];
}
-cmStateEnums::CacheEntryType cmState::StringToCacheEntryType(const char* s)
+cmStateEnums::CacheEntryType cmState::StringToCacheEntryType(
+ const std::string& s)
{
cmStateEnums::CacheEntryType type = cmStateEnums::STRING;
StringToCacheEntryType(s, type);
return type;
}
-bool cmState::StringToCacheEntryType(const char* s,
+bool cmState::StringToCacheEntryType(const std::string& s,
cmStateEnums::CacheEntryType& type)
{
- int i = 0;
- while (cmCacheEntryTypes[i]) {
- if (strcmp(s, cmCacheEntryTypes[i]) == 0) {
+ for (size_t i = 0; i < cmCacheEntryTypes.size(); ++i) {
+ if (s == cmCacheEntryTypes[i]) {
type = static_cast<cmStateEnums::CacheEntryType>(i);
return true;
}
- ++i;
}
return false;
}
bool cmState::IsCacheEntryType(std::string const& key)
{
- for (int i = 0; cmCacheEntryTypes[i]; ++i) {
- if (key == cmCacheEntryTypes[i]) {
+ for (const std::string& i : cmCacheEntryTypes) {
+ if (key == i) {
return true;
}
}
@@ -1006,12 +1007,12 @@ bool cmState::ParseCacheEntry(const std::string& entry, std::string& var,
bool flag = false;
if (regQuoted.find(entry)) {
var = regQuoted.match(1);
- type = cmState::StringToCacheEntryType(regQuoted.match(2).c_str());
+ type = cmState::StringToCacheEntryType(regQuoted.match(2));
value = regQuoted.match(3);
flag = true;
} else if (reg.find(entry)) {
var = reg.match(1);
- type = cmState::StringToCacheEntryType(reg.match(2).c_str());
+ type = cmState::StringToCacheEntryType(reg.match(2));
value = reg.match(3);
flag = true;
}
diff --git a/Source/cmState.h b/Source/cmState.h
index cd871b9..a744266 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -70,10 +70,12 @@ public:
cmStateSnapshot const& originSnapshot);
cmStateSnapshot Pop(cmStateSnapshot const& originSnapshot);
- static cmStateEnums::CacheEntryType StringToCacheEntryType(const char*);
- static bool StringToCacheEntryType(const char*,
+ static cmStateEnums::CacheEntryType StringToCacheEntryType(
+ const std::string&);
+ static bool StringToCacheEntryType(const std::string&,
cmStateEnums::CacheEntryType& type);
- static const char* CacheEntryTypeToString(cmStateEnums::CacheEntryType);
+ static const std::string& CacheEntryTypeToString(
+ cmStateEnums::CacheEntryType);
static bool IsCacheEntryType(std::string const& key);
bool LoadCache(const std::string& path, bool internal,
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 8e4f629..5341971 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -2,6 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmake.h"
+#include <algorithm>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <initializer_list>
+#include <iostream>
+#include <sstream>
+#include <utility>
+
#include <cm/memory>
#include <cm/string_view>
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW)
@@ -10,6 +19,10 @@
#include <cmext/algorithm>
+#include "cmsys/FStream.hxx"
+#include "cmsys/Glob.hxx"
+#include "cmsys/RegularExpression.hxx"
+
#include "cm_sys_stat.h"
#include "cmAlgorithms.h"
@@ -108,19 +121,6 @@
# include <sys/time.h>
#endif
-#include <algorithm>
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <initializer_list>
-#include <iostream>
-#include <sstream>
-#include <utility>
-
-#include "cmsys/FStream.hxx"
-#include "cmsys/Glob.hxx"
-#include "cmsys/RegularExpression.hxx"
-
namespace {
#if !defined(CMAKE_BOOTSTRAP)
@@ -513,8 +513,9 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
cmSystemTools::GetCurrentWorkingDirectory());
// read in the list file to fill the cache
snapshot.SetDefaultDefinitions();
- cmMakefile* mf = new cmMakefile(gg, snapshot);
- gg->AddMakefile(mf);
+ auto mfu = cm::make_unique<cmMakefile>(gg, snapshot);
+ cmMakefile* mf = mfu.get();
+ gg->AddMakefile(std::move(mfu));
mf->SetArgcArgv(args);
@@ -1647,7 +1648,7 @@ int cmake::ActualConfigure()
}
}
- cmMakefile* mf = this->GlobalGenerator->GetMakefiles()[0];
+ auto& mf = this->GlobalGenerator->GetMakefiles()[0];
if (mf->IsOn("CTEST_USE_LAUNCHERS") &&
!this->State->GetGlobalProperty("RULE_LAUNCH_COMPILE")) {
cmSystemTools::Error(
diff --git a/Templates/MSBuild/FlagTables/v10_Cuda.json b/Templates/MSBuild/FlagTables/v10_Cuda.json
index 1831b8a..b3230ac 100644
--- a/Templates/MSBuild/FlagTables/v10_Cuda.json
+++ b/Templates/MSBuild/FlagTables/v10_Cuda.json
@@ -20,6 +20,26 @@
]
},
{
+ "name": "AdditionalCompilerOptions",
+ "switch": "-compiler-options=",
+ "comment": "Host compiler options",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SpaceAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalCompilerOptions",
+ "switch": "-compiler-options",
+ "comment": "Host compiler options",
+ "value": "",
+ "flags": [
+ "UserFollowing",
+ "SpaceAppendable"
+ ]
+ },
+ {
"name": "CudaRuntime",
"switch": "cudart=none",
"comment": "No CUDA runtime library",
diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt
index 00fd7d2..ba9bf04 100644
--- a/Tests/CudaOnly/WithDefs/CMakeLists.txt
+++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt
@@ -28,7 +28,7 @@ target_compile_options(CudaOnlyWithDefs
PRIVATE
-DFLAG_COMPILE_LANG_$<COMPILE_LANGUAGE>
-DFLAG_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA>
- -Xcompiler=-DHOST_DEFINE
+ --compiler-options=-DHOST_DEFINE
$<$<CONFIG:DEBUG>:$<BUILD_INTERFACE:${debug_compile_flags}>>
)
diff --git a/Tests/FindLibXml2/Test/CMakeLists.txt b/Tests/FindLibXml2/Test/CMakeLists.txt
index df5d8c3..041cc13 100644
--- a/Tests/FindLibXml2/Test/CMakeLists.txt
+++ b/Tests/FindLibXml2/Test/CMakeLists.txt
@@ -14,3 +14,7 @@ add_executable(test_var main.c)
target_include_directories(test_var PRIVATE ${LIBXML2_INCLUDE_DIRS})
target_link_libraries(test_var PRIVATE ${LIBXML2_LIBRARIES})
add_test(NAME test_var COMMAND test_var)
+
+add_test(NAME xmllint_tgt COMMAND LibXml2::xmllint --version)
+
+add_test(NAME xmllint_var COMMAND ${LIBXML2_XMLLINT_EXECUTABLE} --version)
diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-check.py b/Tests/RunCMake/CommandLine/trace-json-v1-check.py
index f5cefa5..14febaf 100755
--- a/Tests/RunCMake/CommandLine/trace-json-v1-check.py
+++ b/Tests/RunCMake/CommandLine/trace-json-v1-check.py
@@ -65,8 +65,8 @@ with open(trace_file, 'r') as fp:
assert isinstance(line['file'], unicode)
assert isinstance(line['line'], int)
- for i in required_traces:
- if i['cmd'] == line['cmd'] and i['args'] == line['args']:
- i['found'] = True
+ for j in required_traces:
+ if j['cmd'] == line['cmd'] and j['args'] == line['args']:
+ j['found'] = True
assert all([x.get('found', False) == True for x in required_traces])