summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeLists.txt13
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CPack/IFW/cmCPackIFWRepository.cxx2
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx50
-rw-r--r--Source/CPack/cmCPackFreeBSDGenerator.cxx9
-rw-r--r--Source/CTest/cmCTestBuildHandler.cxx3
-rw-r--r--Source/CTest/cmCTestCVS.cxx4
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx3
-rw-r--r--Source/CTest/cmCTestLaunch.cxx2
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx2
-rw-r--r--Source/CTest/cmCTestRunScriptCommand.cxx3
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx12
-rw-r--r--Source/CTest/cmCTestScriptHandler.h5
-rw-r--r--Source/CursesDialog/ccmake.cxx7
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx5
-rw-r--r--Source/CursesDialog/cmCursesMainForm.h2
-rw-r--r--Source/QtDialog/CMakeSetup.cxx58
-rw-r--r--Source/QtDialog/CMakeSetup128.pngbin10944 -> 7981 bytes
-rw-r--r--Source/QtDialog/CMakeSetup32.pngbin2097 -> 1632 bytes
-rw-r--r--Source/QtDialog/CMakeSetup64.pngbin4676 -> 3566 bytes
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx1
-rw-r--r--Source/QtDialog/Delete16.pngbin731 -> 538 bytes
-rw-r--r--Source/QtDialog/FirstConfigure.cxx80
-rw-r--r--Source/QtDialog/FirstConfigure.h9
-rw-r--r--Source/QtDialog/Plus16.pngbin358 -> 207 bytes
-rw-r--r--Source/QtDialog/QCMake.cxx21
-rw-r--r--Source/QtDialog/QCMake.h5
-rw-r--r--Source/QtDialog/QCMakeWidgets.cxx5
-rw-r--r--Source/QtDialog/QCMakeWidgets.h2
-rw-r--r--Source/cmAlgorithms.h4
-rw-r--r--Source/cmCPluginAPI.cxx2
-rw-r--r--Source/cmCTest.cxx6
-rw-r--r--Source/cmCacheManager.cxx11
-rw-r--r--Source/cmCallVisualStudioMacro.cxx4
-rw-r--r--Source/cmComputeLinkInformation.cxx4
-rw-r--r--Source/cmComputeLinkInformation.h6
-rw-r--r--Source/cmComputeTargetDepends.cxx2
-rw-r--r--Source/cmConditionEvaluator.cxx9
-rw-r--r--Source/cmConditionEvaluator.h4
-rw-r--r--Source/cmConfigure.cmake.h.in1
-rw-r--r--Source/cmCoreTryCompile.cxx6
-rw-r--r--Source/cmCustomCommand.cxx18
-rw-r--r--Source/cmCustomCommand.h11
-rw-r--r--Source/cmCustomCommandGenerator.cxx4
-rw-r--r--Source/cmCustomCommandGenerator.h4
-rw-r--r--Source/cmDepends.cxx25
-rw-r--r--Source/cmDepends.h13
-rw-r--r--Source/cmDependsC.cxx21
-rw-r--r--Source/cmDependsC.h4
-rw-r--r--Source/cmDependsFortran.cxx58
-rw-r--r--Source/cmDependsFortran.h15
-rw-r--r--Source/cmDependsJava.cxx3
-rw-r--r--Source/cmDependsJava.h2
-rw-r--r--Source/cmDocumentation.cxx15
-rw-r--r--Source/cmDocumentationEntry.h1
-rw-r--r--Source/cmDocumentationFormatter.cxx3
-rw-r--r--Source/cmExecProgramCommand.cxx8
-rw-r--r--Source/cmExecuteProcessCommand.cxx10
-rw-r--r--Source/cmExpandedCommandArgument.cxx6
-rw-r--r--Source/cmExpandedCommandArgument.h2
-rw-r--r--Source/cmExportFileGenerator.cxx2
-rw-r--r--Source/cmExportInstallFileGenerator.cxx8
-rw-r--r--Source/cmExportSet.h5
-rw-r--r--Source/cmExternalMakefileProjectGenerator.cxx9
-rw-r--r--Source/cmExternalMakefileProjectGenerator.h3
-rw-r--r--Source/cmFLTKWrapUICommand.cxx2
-rw-r--r--Source/cmFileAPI.cxx2
-rw-r--r--Source/cmFileAPICodemodel.cxx8
-rw-r--r--Source/cmFileCommand.cxx12
-rw-r--r--Source/cmFileTimeComparison.cxx27
-rw-r--r--Source/cmFileTimeComparison.h7
-rw-r--r--Source/cmFindPackageCommand.cxx14
-rw-r--r--Source/cmFortranParser.h10
-rw-r--r--Source/cmFortranParserImpl.cxx9
-rw-r--r--Source/cmGeneratedFileStream.cxx2
-rw-r--r--Source/cmGeneratorExpression.cxx11
-rw-r--r--Source/cmGeneratorExpression.h16
-rw-r--r--Source/cmGeneratorExpressionContext.cxx14
-rw-r--r--Source/cmGeneratorExpressionContext.h6
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.cxx12
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.h6
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.cxx4
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.h2
-rw-r--r--Source/cmGeneratorExpressionParser.cxx4
-rw-r--r--Source/cmGeneratorExpressionParser.h3
-rw-r--r--Source/cmGeneratorTarget.cxx15
-rw-r--r--Source/cmGetFilenameComponentCommand.cxx4
-rw-r--r--Source/cmGhsMultiTargetGenerator.cxx6
-rw-r--r--Source/cmGlobVerificationManager.cxx5
-rw-r--r--Source/cmGlobVerificationManager.h8
-rw-r--r--Source/cmGlobalGenerator.cxx66
-rw-r--r--Source/cmGlobalGenerator.h4
-rw-r--r--Source/cmGlobalGeneratorFactory.h26
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx8
-rw-r--r--Source/cmGlobalNinjaGenerator.h4
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx37
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx50
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h2
-rw-r--r--Source/cmGlobalVisualStudio11Generator.cxx29
-rw-r--r--Source/cmGlobalVisualStudio12Generator.cxx25
-rw-r--r--Source/cmGlobalVisualStudio14Generator.cxx21
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx2
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx4
-rw-r--r--Source/cmGlobalVisualStudio9Generator.cxx28
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx6
-rw-r--r--Source/cmGlobalVisualStudioVersionedGenerator.cxx98
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx43
-rw-r--r--Source/cmGraphAdjacencyList.h5
-rw-r--r--Source/cmIncludeCommand.cxx2
-rw-r--r--Source/cmInstallCommand.cxx2
-rw-r--r--Source/cmInstallCommandArguments.cxx4
-rw-r--r--Source/cmInstallCommandArguments.h2
-rw-r--r--Source/cmInstallExportGenerator.cxx5
-rw-r--r--Source/cmInstallTargetGenerator.cxx13
-rw-r--r--Source/cmInstallTargetGenerator.h4
-rw-r--r--Source/cmJsonObjects.cxx2
-rw-r--r--Source/cmLinkItem.cxx11
-rw-r--r--Source/cmLinkItem.h4
-rw-r--r--Source/cmListCommand.cxx14
-rw-r--r--Source/cmListFileCache.cxx12
-rw-r--r--Source/cmListFileCache.h4
-rw-r--r--Source/cmLocalCommonGenerator.cxx5
-rw-r--r--Source/cmLocalCommonGenerator.h2
-rw-r--r--Source/cmLocalGenerator.cxx169
-rw-r--r--Source/cmLocalGenerator.h40
-rw-r--r--Source/cmLocalNinjaGenerator.cxx8
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx101
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.h32
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx6
-rw-r--r--Source/cmMakefile.cxx66
-rw-r--r--Source/cmMakefile.h8
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx3
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx3
-rw-r--r--Source/cmMakefileTargetGenerator.cxx15
-rw-r--r--Source/cmMessageCommand.cxx2
-rw-r--r--Source/cmMessenger.cxx4
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx7
-rw-r--r--Source/cmNinjaTargetGenerator.cxx7
-rw-r--r--Source/cmNinjaUtilityTargetGenerator.cxx3
-rw-r--r--Source/cmOSXBundleGenerator.cxx5
-rw-r--r--Source/cmOSXBundleGenerator.h3
-rw-r--r--Source/cmOutputRequiredFilesCommand.cxx2
-rw-r--r--Source/cmPathLabel.cxx6
-rw-r--r--Source/cmPathLabel.h2
-rw-r--r--Source/cmPipeConnection.cxx4
-rw-r--r--Source/cmPipeConnection.h2
-rw-r--r--Source/cmProcessTools.cxx2
-rw-r--r--Source/cmQtAutoGenInitializer.cxx28
-rw-r--r--Source/cmQtAutoGenerator.cxx8
-rw-r--r--Source/cmQtAutoGeneratorMocUic.h12
-rw-r--r--Source/cmRST.cxx4
-rw-r--r--Source/cmRST.h2
-rw-r--r--Source/cmRulePlaceholderExpander.cxx14
-rw-r--r--Source/cmRulePlaceholderExpander.h6
-rw-r--r--Source/cmScriptGenerator.cxx11
-rw-r--r--Source/cmScriptGenerator.h4
-rw-r--r--Source/cmServerProtocol.cxx28
-rw-r--r--Source/cmServerProtocol.h15
-rw-r--r--Source/cmSourceGroup.cxx6
-rw-r--r--Source/cmSourceGroup.h2
-rw-r--r--Source/cmState.cxx4
-rw-r--r--Source/cmStateSnapshot.cxx4
-rw-r--r--Source/cmStringReplaceHelper.cxx5
-rw-r--r--Source/cmStringReplaceHelper.h8
-rw-r--r--Source/cmSystemTools.cxx62
-rw-r--r--Source/cmSystemTools.h14
-rw-r--r--Source/cmTestGenerator.cxx2
-rw-r--r--Source/cmTryRunCommand.cxx6
-rw-r--r--Source/cmUnexpectedCommand.h5
-rw-r--r--Source/cmUtilitySourceCommand.cxx2
-rw-r--r--Source/cmVSSetupHelper.cxx10
-rw-r--r--Source/cmVariableRequiresCommand.cxx2
-rw-r--r--Source/cmVariableWatchCommand.cxx2
-rw-r--r--Source/cmVisualStudio10ToolsetOptions.cxx22
-rw-r--r--Source/cmXCodeScheme.cxx5
-rw-r--r--Source/cmXCodeScheme.h2
-rw-r--r--Source/cmake.cxx145
-rw-r--r--Source/cmake.h17
-rw-r--r--Source/cmakemain.cxx61
-rw-r--r--Source/cmcmd.cxx36
-rw-r--r--Source/kwsys/CMakeLists.txt8
-rw-r--r--Source/kwsys/SystemInformation.cxx3
-rw-r--r--Source/kwsys/SystemTools.cxx58
-rw-r--r--Source/kwsys/SystemTools.hxx.in7
-rw-r--r--Source/kwsys/testSystemTools.cxx46
185 files changed, 1603 insertions, 940 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 9e753e6..1c06052 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -31,6 +31,16 @@ else()
set(CMAKE_USE_ELF_PARSER)
endif()
+if(NOT CMake_DEFAULT_RECURSION_LIMIT)
+ if(DEFINED ENV{DASHBOARD_TEST_FROM_CTEST})
+ set(CMake_DEFAULT_RECURSION_LIMIT 100)
+ elseif(MINGW)
+ set(CMake_DEFAULT_RECURSION_LIMIT 400)
+ else()
+ set(CMake_DEFAULT_RECURSION_LIMIT 1000)
+ endif()
+endif()
+
if(APPLE)
set(CMAKE_USE_MACH_PARSER 1)
endif()
@@ -809,9 +819,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "sparc"
endif()
endif()
-# On Apple we need CoreFoundation
+# On Apple we need CoreFoundation and CoreServices
if(APPLE)
target_link_libraries(CMakeLib "-framework CoreFoundation")
+ target_link_libraries(CMakeLib "-framework CoreServices")
endif()
if(WIN32 AND NOT UNIX)
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 497feed..0362d52 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 13)
-set(CMake_VERSION_PATCH 20190122)
+set(CMake_VERSION_PATCH 20190129)
#set(CMake_VERSION_RC 1)
diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx
index 987cad8..8042167 100644
--- a/Source/CPack/IFW/cmCPackIFWRepository.cxx
+++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx
@@ -200,7 +200,7 @@ bool cmCPackIFWRepository::PatchUpdatesXml()
fout.Close();
- return cmSystemTools::RenameFile(updatesPatchXml.data(), updatesXml.data());
+ return cmSystemTools::RenameFile(updatesPatchXml, updatesXml);
}
void cmCPackIFWRepository::WriteRepositoryConfig(cmXMLWriter& xout)
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index 29968af..46a428f 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -23,17 +23,15 @@ namespace {
class DebGenerator
{
public:
- DebGenerator(cmCPackLog* logger, std::string const& outputName,
- std::string const& workDir, std::string const& topLevelDir,
- std::string const& temporaryDir,
+ DebGenerator(cmCPackLog* logger, std::string outputName, std::string workDir,
+ std::string topLevelDir, std::string temporaryDir,
const char* debianCompressionType,
const char* debianArchiveType,
- std::map<std::string, std::string> const& controlValues,
- bool genShLibs, std::string const& shLibsFilename,
- bool genPostInst, std::string const& postInst, bool genPostRm,
- std::string const& postRm, const char* controlExtra,
- bool permissionStrctPolicy,
- std::vector<std::string> const& packageFiles);
+ std::map<std::string, std::string> controlValues,
+ bool genShLibs, std::string shLibsFilename, bool genPostInst,
+ std::string postInst, bool genPostRm, std::string postRm,
+ const char* controlExtra, bool permissionStrctPolicy,
+ std::vector<std::string> packageFiles);
bool generate() const;
@@ -66,31 +64,29 @@ private:
};
DebGenerator::DebGenerator(
- cmCPackLog* logger, std::string const& outputName,
- std::string const& workDir, std::string const& topLevelDir,
- std::string const& temporaryDir, const char* debianCompressionType,
- const char* debianArchiveType,
- std::map<std::string, std::string> const& controlValues, bool genShLibs,
- std::string const& shLibsFilename, bool genPostInst,
- std::string const& postInst, bool genPostRm, std::string const& postRm,
- const char* controlExtra, bool permissionStrictPolicy,
- std::vector<std::string> const& packageFiles)
+ cmCPackLog* logger, std::string outputName, std::string workDir,
+ std::string topLevelDir, std::string temporaryDir,
+ const char* debianCompressionType, const char* debianArchiveType,
+ std::map<std::string, std::string> controlValues, bool genShLibs,
+ std::string shLibsFilename, bool genPostInst, std::string postInst,
+ bool genPostRm, std::string postRm, const char* controlExtra,
+ bool permissionStrictPolicy, std::vector<std::string> packageFiles)
: Logger(logger)
- , OutputName(outputName)
- , WorkDir(workDir)
- , TopLevelDir(topLevelDir)
- , TemporaryDir(temporaryDir)
+ , OutputName(std::move(outputName))
+ , WorkDir(std::move(workDir))
+ , TopLevelDir(std::move(topLevelDir))
+ , TemporaryDir(std::move(temporaryDir))
, DebianArchiveType(debianArchiveType ? debianArchiveType : "gnutar")
- , ControlValues(controlValues)
+ , ControlValues(std::move(controlValues))
, GenShLibs(genShLibs)
- , ShLibsFilename(shLibsFilename)
+ , ShLibsFilename(std::move(shLibsFilename))
, GenPostInst(genPostInst)
- , PostInst(postInst)
+ , PostInst(std::move(postInst))
, GenPostRm(genPostRm)
- , PostRm(postRm)
+ , PostRm(std::move(postRm))
, ControlExtra(controlExtra)
, PermissionStrictPolicy(permissionStrictPolicy)
- , PackageFiles(packageFiles)
+ , PackageFiles(std::move(packageFiles))
{
if (!debianCompressionType) {
debianCompressionType = "gzip";
diff --git a/Source/CPack/cmCPackFreeBSDGenerator.cxx b/Source/CPack/cmCPackFreeBSDGenerator.cxx
index 1e6b118..0ff0054 100644
--- a/Source/CPack/cmCPackFreeBSDGenerator.cxx
+++ b/Source/CPack/cmCPackFreeBSDGenerator.cxx
@@ -17,6 +17,7 @@
#include <pkg.h>
#include <algorithm>
+#include <utility>
cmCPackFreeBSDGenerator::cmCPackFreeBSDGenerator()
: cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr")
@@ -97,8 +98,8 @@ class ManifestKey
public:
std::string key;
- ManifestKey(const std::string& k)
- : key(k)
+ ManifestKey(std::string k)
+ : key(std::move(k))
{
}
@@ -115,9 +116,9 @@ class ManifestKeyValue : public ManifestKey
public:
std::string value;
- ManifestKeyValue(const std::string& k, const std::string& v)
+ ManifestKeyValue(const std::string& k, std::string v)
: ManifestKey(k)
- , value(v)
+ , value(std::move(v))
{
}
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index d07bd21..948547f 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -513,8 +513,7 @@ public:
// Order files by modification time. Use lexicographic order
// among files with the same time.
int result;
- if (this->FTC->FileTimeCompare(l.c_str(), r.c_str(), &result) &&
- result != 0) {
+ if (this->FTC->FileTimeCompare(l, r, &result) && result != 0) {
return result < 0;
}
return l < r;
diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx
index 4fb3273..6e1ada1 100644
--- a/Source/CTest/cmCTestCVS.cxx
+++ b/Source/CTest/cmCTestCVS.cxx
@@ -111,8 +111,8 @@ public:
, Revisions(revs)
, Section(SectionHeader)
{
- this->SetLog(&cvs->Log, prefix),
- this->RegexRevision.compile("^revision +([^ ]*) *$");
+ this->SetLog(&cvs->Log, prefix);
+ this->RegexRevision.compile("^revision +([^ ]*) *$");
this->RegexBranches.compile("^branches: .*$");
this->RegexPerson.compile("^date: +([^;]+); +author: +([^;]+);");
}
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 6c68f46..e39e25a 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -15,7 +15,6 @@
#include "cmSystemTools.h"
#include "cmWorkingDirectory.h"
#include "cmXMLWriter.h"
-#include "cmake.h"
#include "cmsys/FStream.hxx"
#include "cmsys/Glob.hxx"
@@ -2226,7 +2225,7 @@ int cmCTestCoverageHandler::GetLabelId(std::string const& label)
void cmCTestCoverageHandler::LoadLabels()
{
std::string fileList = this->CTest->GetBinaryDir();
- fileList += cmake::GetCMakeFilesDirectory();
+ fileList += "/CMakeFiles";
fileList += "/TargetDirectories.txt";
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" target directory list [" << fileList << "]\n",
diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx
index ec3307f..5e66e05 100644
--- a/Source/CTest/cmCTestLaunch.cxx
+++ b/Source/CTest/cmCTestLaunch.cxx
@@ -283,7 +283,7 @@ void cmCTestLaunch::LoadLabels()
// Labels are listed in per-target files.
std::string fname = this->OptionBuildDir;
- fname += cmake::GetCMakeFilesDirectory();
+ fname += "/CMakeFiles";
fname += "/";
fname += this->OptionTargetName;
fname += ".dir/Labels.txt";
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index 320647a..d3aa2b4 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -538,7 +538,7 @@ void cmCTestMultiProcessHandler::UpdateCostData()
fout << f << "\n";
}
fout.close();
- cmSystemTools::RenameFile(tmpout.c_str(), fname.c_str());
+ cmSystemTools::RenameFile(tmpout, fname);
}
void cmCTestMultiProcessHandler::ReadCostData()
diff --git a/Source/CTest/cmCTestRunScriptCommand.cxx b/Source/CTest/cmCTestRunScriptCommand.cxx
index 238284a..a7e47d3 100644
--- a/Source/CTest/cmCTestRunScriptCommand.cxx
+++ b/Source/CTest/cmCTestRunScriptCommand.cxx
@@ -39,7 +39,8 @@ bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
++i;
} else {
int ret;
- cmCTestScriptHandler::RunScript(this->CTest, args[i].c_str(), !np, &ret);
+ cmCTestScriptHandler::RunScript(this->CTest, this->Makefile,
+ args[i].c_str(), !np, &ret);
std::ostringstream str;
str << ret;
this->Makefile->AddDefinition(returnVariable, str.str().c_str());
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index f417f53..b949023 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -78,6 +78,7 @@ cmCTestScriptHandler::cmCTestScriptHandler()
this->EmptyBinDir = false;
this->EmptyBinDirOnce = false;
this->Makefile = nullptr;
+ this->ParentMakefile = nullptr;
this->CMake = nullptr;
this->GlobalGenerator = nullptr;
@@ -117,6 +118,7 @@ void cmCTestScriptHandler::Initialize()
delete this->Makefile;
this->Makefile = nullptr;
+ this->ParentMakefile = nullptr;
delete this->GlobalGenerator;
this->GlobalGenerator = nullptr;
@@ -292,6 +294,10 @@ void cmCTestScriptHandler::CreateCMake()
snapshot.GetDirectory().SetCurrentSource(cwd);
snapshot.GetDirectory().SetCurrentBinary(cwd);
this->Makefile = new cmMakefile(this->GlobalGenerator, snapshot);
+ if (this->ParentMakefile) {
+ this->Makefile->SetRecursionDepth(
+ this->ParentMakefile->GetRecursionDepth());
+ }
this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest);
@@ -891,11 +897,13 @@ void cmCTestScriptHandler::RestoreBackupDirectories()
}
}
-bool cmCTestScriptHandler::RunScript(cmCTest* ctest, const char* sname,
- bool InProcess, int* returnValue)
+bool cmCTestScriptHandler::RunScript(cmCTest* ctest, cmMakefile* mf,
+ const char* sname, bool InProcess,
+ int* returnValue)
{
cmCTestScriptHandler* sh = new cmCTestScriptHandler();
sh->SetCTestInstance(ctest);
+ sh->ParentMakefile = mf;
sh->AddConfigurationScript(sname, InProcess);
int res = sh->ProcessHandler();
if (returnValue) {
diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h
index cf0762e..d93b5f8 100644
--- a/Source/CTest/cmCTestScriptHandler.h
+++ b/Source/CTest/cmCTestScriptHandler.h
@@ -72,8 +72,8 @@ public:
/*
* Run a script
*/
- static bool RunScript(cmCTest* ctest, const char* script, bool InProcess,
- int* returnValue);
+ static bool RunScript(cmCTest* ctest, cmMakefile* mf, const char* script,
+ bool InProcess, int* returnValue);
int RunCurrentScript();
/*
@@ -166,6 +166,7 @@ private:
std::chrono::steady_clock::time_point ScriptStartTime;
cmMakefile* Makefile;
+ cmMakefile* ParentMakefile;
cmGlobalGenerator* GlobalGenerator;
cmake* CMake;
};
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index 856723a..dbf4a28 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -5,7 +5,7 @@
#include "cmCursesMainForm.h"
#include "cmCursesStandardIncludes.h"
#include "cmDocumentation.h"
-#include "cmDocumentationEntry.h"
+#include "cmDocumentationEntry.h" // IWYU pragma: keep
#include "cmState.h"
#include "cmSystemTools.h"
#include "cmake.h"
@@ -88,15 +88,14 @@ int main(int argc, char const* const* argv)
hcm.SetHomeDirectory("");
hcm.SetHomeOutputDirectory("");
hcm.AddCMakePaths();
- std::vector<cmDocumentationEntry> generators;
- hcm.GetGeneratorDocumentation(generators);
+ auto generators = hcm.GetGeneratorsDocumentation();
doc.SetName("ccmake");
doc.SetSection("Name", cmDocumentationName);
doc.SetSection("Usage", cmDocumentationUsage);
if (argc == 1) {
doc.AppendSection("Usage", cmDocumentationUsageNote);
}
- doc.SetSection("Generators", generators);
+ doc.AppendSection("Generators", generators);
doc.PrependSection("Options", cmDocumentationOptions);
return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1;
}
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index 55ef375..188ad69 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -20,15 +20,16 @@
#include <algorithm>
#include <stdio.h>
#include <string.h>
+#include <utility>
inline int ctrl(int z)
{
return (z & 037);
}
-cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args,
+cmCursesMainForm::cmCursesMainForm(std::vector<std::string> args,
int initWidth)
- : Args(args)
+ : Args(std::move(args))
, InitialWidth(initWidth)
{
this->NumberOfPages = 0;
diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h
index 2c006cf..824025b 100644
--- a/Source/CursesDialog/cmCursesMainForm.h
+++ b/Source/CursesDialog/cmCursesMainForm.h
@@ -26,7 +26,7 @@ class cmCursesMainForm : public cmCursesForm
CM_DISABLE_COPY(cmCursesMainForm)
public:
- cmCursesMainForm(std::vector<std::string> const& args, int initwidth);
+ cmCursesMainForm(std::vector<std::string> args, int initwidth);
~cmCursesMainForm() override;
/**
diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx
index b4307bb..cd30ad5 100644
--- a/Source/QtDialog/CMakeSetup.cxx
+++ b/Source/QtDialog/CMakeSetup.cxx
@@ -30,7 +30,8 @@ static const char* cmDocumentationUsage[][2] = {
{ nullptr,
" cmake-gui [options]\n"
" cmake-gui [options] <path-to-source>\n"
- " cmake-gui [options] <path-to-existing-build>" },
+ " cmake-gui [options] <path-to-existing-build>\n"
+ " cmake-gui [options] -S <path-to-source> -B <path-to-build>\n" },
{ nullptr, nullptr }
};
@@ -69,8 +70,7 @@ int main(int argc, char** argv)
hcm.SetHomeOutputDirectory("");
hcm.AddCMakePaths();
- std::vector<cmDocumentationEntry> generators;
- hcm.GetGeneratorDocumentation(generators);
+ auto generators = hcm.GetGeneratorsDocumentation();
doc.SetName("cmake");
doc.SetSection("Name", cmDocumentationName);
doc.SetSection("Usage", cmDocumentationUsage);
@@ -143,23 +143,53 @@ int main(int argc, char** argv)
CMakeSetupDialog dialog;
dialog.show();
- cmsys::CommandLineArguments arg;
- arg.Initialize(argc2, argv2);
+ QStringList args = QApplication::arguments();
std::string binaryDirectory;
std::string sourceDirectory;
- typedef cmsys::CommandLineArguments argT;
- arg.AddArgument("-B", argT::CONCAT_ARGUMENT, &binaryDirectory,
- "Binary Directory");
- arg.AddArgument("-S", argT::CONCAT_ARGUMENT, &sourceDirectory,
- "Source Directory");
- // do not complain about unknown options
- arg.StoreUnusedArguments(true);
- arg.Parse();
+ for (int i = 1; i < args.size(); ++i) {
+ const QString& arg = args[i];
+ if (arg.startsWith("-S")) {
+ QString path = arg.mid(2);
+ if (path.isEmpty()) {
+ ++i;
+ if (i >= args.size()) {
+ std::cerr << "No source directory specified for -S" << std::endl;
+ return 1;
+ }
+ path = args[i];
+ if (path[0] == '-') {
+ std::cerr << "No source directory specified for -S" << std::endl;
+ return 1;
+ }
+ }
+
+ sourceDirectory =
+ cmSystemTools::CollapseFullPath(path.toLocal8Bit().data());
+ cmSystemTools::ConvertToUnixSlashes(sourceDirectory);
+ } else if (arg.startsWith("-B")) {
+ QString path = arg.mid(2);
+ if (path.isEmpty()) {
+ ++i;
+ if (i >= args.size()) {
+ std::cerr << "No build directory specified for -B" << std::endl;
+ return 1;
+ }
+ path = args[i];
+ if (path[0] == '-') {
+ std::cerr << "No build directory specified for -B" << std::endl;
+ return 1;
+ }
+ }
+
+ binaryDirectory =
+ cmSystemTools::CollapseFullPath(path.toLocal8Bit().data());
+ cmSystemTools::ConvertToUnixSlashes(binaryDirectory);
+ }
+ }
if (!sourceDirectory.empty() && !binaryDirectory.empty()) {
dialog.setSourceDirectory(QString::fromLocal8Bit(sourceDirectory.c_str()));
dialog.setBinaryDirectory(QString::fromLocal8Bit(binaryDirectory.c_str()));
} else {
- QStringList args = QApplication::arguments();
if (args.count() == 2) {
std::string filePath =
cmSystemTools::CollapseFullPath(args[1].toLocal8Bit().data());
diff --git a/Source/QtDialog/CMakeSetup128.png b/Source/QtDialog/CMakeSetup128.png
index 728ef02..32984e1 100644
--- a/Source/QtDialog/CMakeSetup128.png
+++ b/Source/QtDialog/CMakeSetup128.png
Binary files differ
diff --git a/Source/QtDialog/CMakeSetup32.png b/Source/QtDialog/CMakeSetup32.png
index 1c36b31..78df82f 100644
--- a/Source/QtDialog/CMakeSetup32.png
+++ b/Source/QtDialog/CMakeSetup32.png
Binary files differ
diff --git a/Source/QtDialog/CMakeSetup64.png b/Source/QtDialog/CMakeSetup64.png
index 44eb171..5c2dbf5 100644
--- a/Source/QtDialog/CMakeSetup64.png
+++ b/Source/QtDialog/CMakeSetup64.png
Binary files differ
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 444a980..72cce9f 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -751,6 +751,7 @@ bool CMakeSetupDialog::setupFirstConfigure()
if (dialog.exec() == QDialog::Accepted) {
dialog.saveToSettings();
this->CMakeThread->cmakeInstance()->setGenerator(dialog.getGenerator());
+ this->CMakeThread->cmakeInstance()->setPlatform(dialog.getPlatform());
this->CMakeThread->cmakeInstance()->setToolset(dialog.getToolset());
QCMakeCacheModel* m = this->CacheValues->cacheModel();
diff --git a/Source/QtDialog/Delete16.png b/Source/QtDialog/Delete16.png
index 16989fee..9d2f2b7 100644
--- a/Source/QtDialog/Delete16.png
+++ b/Source/QtDialog/Delete16.png
Binary files differ
diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx
index 88ce7cb..ae5179c 100644
--- a/Source/QtDialog/FirstConfigure.cxx
+++ b/Source/QtDialog/FirstConfigure.cxx
@@ -16,8 +16,12 @@ StartCompilerSetup::StartCompilerSetup(QWidget* p)
this->GeneratorOptions = new QComboBox(this);
l->addWidget(this->GeneratorOptions);
+ // Add the generator platform
+ this->PlatformFrame = CreatePlatformWidgets();
+ l->addWidget(PlatformFrame);
+
// Add the ability to specify toolset (-T parameter)
- ToolsetFrame = CreateToolsetWidgets();
+ this->ToolsetFrame = CreateToolsetWidgets();
l->addWidget(ToolsetFrame);
l->addSpacing(6);
@@ -45,7 +49,7 @@ StartCompilerSetup::StartCompilerSetup(QWidget* p)
SLOT(onSelectionChanged(bool)));
QObject::connect(this->CompilerSetupOptions[3], SIGNAL(toggled(bool)), this,
SLOT(onSelectionChanged(bool)));
- QObject::connect(GeneratorOptions,
+ QObject::connect(this->GeneratorOptions,
SIGNAL(currentIndexChanged(QString const&)), this,
SLOT(onGeneratorChanged(QString const&)));
}
@@ -65,6 +69,23 @@ QFrame* StartCompilerSetup::CreateToolsetWidgets()
return frame;
}
+QFrame* StartCompilerSetup::CreatePlatformWidgets()
+{
+ QFrame* frame = new QFrame(this);
+ QVBoxLayout* l = new QVBoxLayout(frame);
+ l->setContentsMargins(0, 0, 0, 0);
+
+ this->PlatformLabel = new QLabel(tr("Optional platform for generator"));
+ l->addWidget(this->PlatformLabel);
+
+ this->PlatformOptions = new QComboBox(frame);
+ this->PlatformOptions->setEditable(true);
+
+ l->addWidget(this->PlatformOptions);
+
+ return frame;
+}
+
StartCompilerSetup::~StartCompilerSetup()
{
}
@@ -80,6 +101,26 @@ void StartCompilerSetup::setGenerators(
for (it = gens.begin(); it != gens.end(); ++it) {
generator_list.append(QString::fromLocal8Bit(it->name.c_str()));
+ if (it->supportsPlatform) {
+ this->GeneratorsSupportingPlatform.append(
+ QString::fromLocal8Bit(it->name.c_str()));
+
+ this
+ ->GeneratorDefaultPlatform[QString::fromLocal8Bit(it->name.c_str())] =
+ QString::fromLocal8Bit(it->defaultPlatform.c_str());
+
+ std::vector<std::string>::const_iterator platformIt =
+ it->supportedPlatforms.cbegin();
+ while (platformIt != it->supportedPlatforms.cend()) {
+
+ this->GeneratorSupportedPlatforms.insert(
+ QString::fromLocal8Bit(it->name.c_str()),
+ QString::fromLocal8Bit((*platformIt).c_str()));
+
+ platformIt++;
+ }
+ }
+
if (it->supportsToolset) {
this->GeneratorsSupportingToolset.append(
QString::fromLocal8Bit(it->name.c_str()));
@@ -102,6 +143,11 @@ QString StartCompilerSetup::getGenerator() const
return this->GeneratorOptions->currentText();
};
+QString StartCompilerSetup::getPlatform() const
+{
+ return this->PlatformOptions->currentText();
+};
+
QString StartCompilerSetup::getToolset() const
{
return this->Toolset->text();
@@ -136,6 +182,31 @@ void StartCompilerSetup::onSelectionChanged(bool on)
void StartCompilerSetup::onGeneratorChanged(QString const& name)
{
+ // Display the generator platform for the generators supporting it
+ if (GeneratorsSupportingPlatform.contains(name)) {
+
+ // Change the label title to include the default platform
+ std::string label = "Optional platform for generator";
+ label += "(if empty, generator uses: ";
+ label += this->GeneratorDefaultPlatform[name].toStdString();
+ label += ")";
+ this->PlatformLabel->setText(tr(label.c_str()));
+
+ // Regenerate the list of supported platform
+ this->PlatformOptions->clear();
+ QStringList platform_list;
+ platform_list.append("");
+
+ QList<QString> platforms = this->GeneratorSupportedPlatforms.values(name);
+ platform_list.append(platforms);
+
+ this->PlatformOptions->addItems(platform_list);
+ PlatformFrame->show();
+ } else {
+ PlatformFrame->hide();
+ }
+
+ // Display the toolset box for the generators supporting it
if (GeneratorsSupportingToolset.contains(name)) {
ToolsetFrame->show();
} else {
@@ -390,6 +461,11 @@ QString FirstConfigure::getGenerator() const
return this->mStartCompilerSetupPage->getGenerator();
}
+QString FirstConfigure::getPlatform() const
+{
+ return this->mStartCompilerSetupPage->getPlatform();
+}
+
QString FirstConfigure::getToolset() const
{
return this->mStartCompilerSetupPage->getToolset();
diff --git a/Source/QtDialog/FirstConfigure.h b/Source/QtDialog/FirstConfigure.h
index abfa03f..d1db5bf 100644
--- a/Source/QtDialog/FirstConfigure.h
+++ b/Source/QtDialog/FirstConfigure.h
@@ -35,6 +35,7 @@ public:
void setCurrentGenerator(const QString& gen);
QString getGenerator() const;
QString getToolset() const;
+ QString getPlatform() const;
bool defaultSetup() const;
bool compilerSetup() const;
@@ -56,10 +57,17 @@ protected:
QFrame* ToolsetFrame;
QLineEdit* Toolset;
QLabel* ToolsetLabel;
+ QFrame* PlatformFrame;
+ QComboBox* PlatformOptions;
+ QLabel* PlatformLabel;
QStringList GeneratorsSupportingToolset;
+ QStringList GeneratorsSupportingPlatform;
+ QMultiMap<QString, QString> GeneratorSupportedPlatforms;
+ QMap<QString, QString> GeneratorDefaultPlatform;
private:
QFrame* CreateToolsetWidgets();
+ QFrame* CreatePlatformWidgets();
};
//! the page that gives basic options for native compilers
@@ -159,6 +167,7 @@ public:
void setGenerators(std::vector<cmake::GeneratorInfo> const& gens);
QString getGenerator() const;
+ QString getPlatform() const;
QString getToolset() const;
bool defaultSetup() const;
diff --git a/Source/QtDialog/Plus16.png b/Source/QtDialog/Plus16.png
index 552f6f0..1c33bc7 100644
--- a/Source/QtDialog/Plus16.png
+++ b/Source/QtDialog/Plus16.png
Binary files differ
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index 9a6784e..2eecce6 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -35,7 +35,8 @@ QCMake::QCMake(QObject* p)
cmSystemTools::SetInterruptCallback(QCMake::interruptCallback, this);
std::vector<cmake::GeneratorInfo> generators;
- this->CMakeInstance->GetRegisteredGenerators(generators);
+ this->CMakeInstance->GetRegisteredGenerators(
+ generators, /*includeNamesWithPlatform=*/false);
std::vector<cmake::GeneratorInfo>::const_iterator it;
for (it = generators.begin(); it != generators.end(); ++it) {
@@ -74,6 +75,7 @@ void QCMake::setBinaryDirectory(const QString& _dir)
cmState* state = this->CMakeInstance->GetState();
this->setGenerator(QString());
this->setToolset(QString());
+ this->setPlatform(QString());
if (!this->CMakeInstance->LoadCache(
this->BinaryDirectory.toLocal8Bit().data())) {
QDir testDir(this->BinaryDirectory);
@@ -102,6 +104,12 @@ void QCMake::setBinaryDirectory(const QString& _dir)
this->setGenerator(QString::fromLocal8Bit(curGen.c_str()));
}
+ const char* platform =
+ state->GetCacheEntryValue("CMAKE_GENERATOR_PLATFORM");
+ if (platform) {
+ this->setPlatform(QString::fromLocal8Bit(platform));
+ }
+
const char* toolset = state->GetCacheEntryValue("CMAKE_GENERATOR_TOOLSET");
if (toolset) {
this->setToolset(QString::fromLocal8Bit(toolset));
@@ -119,6 +127,14 @@ void QCMake::setGenerator(const QString& gen)
}
}
+void QCMake::setPlatform(const QString& platform)
+{
+ if (this->Platform != platform) {
+ this->Platform = platform;
+ emit this->platformChanged(this->Platform);
+ }
+}
+
void QCMake::setToolset(const QString& toolset)
{
if (this->Toolset != toolset) {
@@ -140,7 +156,8 @@ void QCMake::configure()
this->CMakeInstance->SetGlobalGenerator(
this->CMakeInstance->CreateGlobalGenerator(
this->Generator.toLocal8Bit().data()));
- this->CMakeInstance->SetGeneratorPlatform("");
+ this->CMakeInstance->SetGeneratorPlatform(
+ this->Platform.toLocal8Bit().data());
this->CMakeInstance->SetGeneratorToolset(this->Toolset.toLocal8Bit().data());
this->CMakeInstance->LoadCache();
this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode);
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index 4b3920a..c84da58 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -75,6 +75,8 @@ public slots:
/// set the desired generator to use
void setGenerator(const QString& generator);
/// set the desired generator to use
+ void setPlatform(const QString& platform);
+ /// set the desired generator to use
void setToolset(const QString& toolset);
/// do the configure step
void configure();
@@ -155,6 +157,8 @@ signals:
void debugOutputChanged(bool);
/// signal when the toolset changes
void toolsetChanged(const QString& toolset);
+ /// signal when the platform changes
+ void platformChanged(const QString& platform);
/// signal when open is done
void openDone(bool successful);
/// signal when open is done
@@ -175,6 +179,7 @@ protected:
QString SourceDirectory;
QString BinaryDirectory;
QString Generator;
+ QString Platform;
QString Toolset;
std::vector<cmake::GeneratorInfo> AvailableGenerators;
QString CMakeExecutable;
diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx
index b544b86..eab418f 100644
--- a/Source/QtDialog/QCMakeWidgets.cxx
+++ b/Source/QtDialog/QCMakeWidgets.cxx
@@ -7,10 +7,11 @@
#include <QFileInfo>
#include <QResizeEvent>
#include <QToolButton>
+#include <utility>
-QCMakeFileEditor::QCMakeFileEditor(QWidget* p, const QString& var)
+QCMakeFileEditor::QCMakeFileEditor(QWidget* p, QString var)
: QLineEdit(p)
- , Variable(var)
+ , Variable(std::move(var))
{
this->ToolButton = new QToolButton(this);
this->ToolButton->setText("...");
diff --git a/Source/QtDialog/QCMakeWidgets.h b/Source/QtDialog/QCMakeWidgets.h
index e63c197..5d2368e 100644
--- a/Source/QtDialog/QCMakeWidgets.h
+++ b/Source/QtDialog/QCMakeWidgets.h
@@ -18,7 +18,7 @@ class QCMakeFileEditor : public QLineEdit
{
Q_OBJECT
public:
- QCMakeFileEditor(QWidget* p, const QString& var);
+ QCMakeFileEditor(QWidget* p, QString var);
protected slots:
virtual void chooseFile() = 0;
signals:
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index 2f8e675..9e3efd3 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -61,8 +61,8 @@ struct cmStrCmp
: m_test(test)
{
}
- cmStrCmp(const std::string& test)
- : m_test(test)
+ cmStrCmp(std::string test)
+ : m_test(std::move(test))
{
}
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index 8ed43f9..811af56 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -720,7 +720,7 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir,
ext != headerExts.end(); ++ext) {
e << " ." << *ext;
}
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
}
void CCONV cmSourceFileSetName2(void* arg, const char* name, const char* dir,
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 5f71520..989c7ee 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -2173,7 +2173,7 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
// handle the simple commandline arguments
std::string errormsg;
if (!this->HandleCommandLineArguments(i, args, errormsg)) {
- cmSystemTools::Error(errormsg.c_str());
+ cmSystemTools::Error(errormsg);
return 1;
}
@@ -2807,13 +2807,13 @@ bool cmCTest::RunCommand(std::vector<std::string> const& args,
if ((res == cmsysProcess_Pipe_STDOUT || res == cmsysProcess_Pipe_STDERR) &&
this->ExtraVerbose) {
processOutput.DecodeText(data, length, strdata);
- cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ cmSystemTools::Stdout(strdata);
}
}
if (this->ExtraVerbose) {
processOutput.DecodeText(std::string(), strdata);
if (!strdata.empty()) {
- cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ cmSystemTools::Stdout(strdata);
}
}
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index e1d312b..2728f0f 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -16,7 +16,6 @@
#include "cmState.h"
#include "cmSystemTools.h"
#include "cmVersion.h"
-#include "cmake.h"
cmCacheManager::cmCacheManager()
{
@@ -27,7 +26,7 @@ cmCacheManager::cmCacheManager()
void cmCacheManager::CleanCMakeFiles(const std::string& path)
{
std::string glob = path;
- glob += cmake::GetCMakeFilesDirectory();
+ glob += "/CMakeFiles";
glob += "/*.cmake";
cmsys::Glob globIt;
globIt.FindFiles(glob);
@@ -123,7 +122,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
std::ostringstream error;
error << "Parse error in cache file " << cacheFile;
error << " on line " << lineno << ". Offending entry: " << realbuffer;
- cmSystemTools::Error(error.str().c_str());
+ cmSystemTools::Error(error.str());
}
}
this->CacheMajorVersion = 0;
@@ -171,7 +170,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
<< " where CMakeCache.txt was created. This may result "
"in binaries being created in the wrong place. If you "
"are not sure, reedit the CMakeCache.txt";
- cmSystemTools::Error(message.str().c_str());
+ cmSystemTools::Error(message.str());
}
}
return true;
@@ -360,7 +359,7 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
fout << "\n";
fout.Close();
std::string checkCacheFile = path;
- checkCacheFile += cmake::GetCMakeFilesDirectory();
+ checkCacheFile += "/CMakeFiles";
cmSystemTools::MakeDirectory(checkCacheFile);
checkCacheFile += "/cmake.check_cache";
cmsys::ofstream checkCache(checkCacheFile.c_str());
@@ -384,7 +383,7 @@ bool cmCacheManager::DeleteCache(const std::string& path)
cmSystemTools::RemoveFile(cacheFile);
// now remove the files in the CMakeFiles directory
// this cleans up language cache files
- cmakeFiles += cmake::GetCMakeFilesDirectory();
+ cmakeFiles += "/CMakeFiles";
if (cmSystemTools::FileIsDirectory(cmakeFiles)) {
cmSystemTools::RemoveADirectory(cmakeFiles);
}
diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx
index ecfcfb9..ee5feee 100644
--- a/Source/cmCallVisualStudioMacro.cxx
+++ b/Source/cmCallVisualStudioMacro.cxx
@@ -46,7 +46,7 @@ static bool LogErrorsAsMessages;
<< std::endl; \
_hresult_oss.flags(std::ios::dec); \
_hresult_oss << __FILE__ << "(" << __LINE__ << ")"; \
- cmSystemTools::Message(_hresult_oss.str().c_str()); \
+ cmSystemTools::Message(_hresult_oss.str()); \
} \
}
@@ -446,7 +446,7 @@ int cmCallVisualStudioMacro::CallMacro(const std::string& slnFile,
if (err && LogErrorsAsMessages) {
std::ostringstream oss;
oss << "cmCallVisualStudioMacro::CallMacro failed, err = " << err;
- cmSystemTools::Message(oss.str().c_str());
+ cmSystemTools::Message(oss.str());
}
return 0;
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 87bc150..3d61665 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -1237,7 +1237,7 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
std::ostringstream e;
e << "Could not parse framework path \"" << item << "\" "
<< "linked by target " << this->Target->GetName() << ".";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return;
}
@@ -1282,7 +1282,7 @@ void cmComputeLinkInformation::DropDirectoryItem(std::string const& item)
<< "\" requests linking to directory \"" << item << "\". "
<< "Targets may link only to libraries. "
<< "CMake is dropping the item.";
- cmSystemTools::Message(e.str().c_str());
+ cmSystemTools::Message(e.str());
}
void cmComputeLinkInformation::ComputeFrameworkInfo()
diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h
index db7eb96..61fcf03 100644
--- a/Source/cmComputeLinkInformation.h
+++ b/Source/cmComputeLinkInformation.h
@@ -9,6 +9,7 @@
#include <iosfwd>
#include <set>
#include <string>
+#include <utility>
#include <vector>
class cmGeneratorTarget;
@@ -31,9 +32,8 @@ public:
struct Item
{
Item() {}
- Item(std::string const& v, bool p,
- cmGeneratorTarget const* target = nullptr)
- : Value(v)
+ Item(std::string v, bool p, cmGeneratorTarget const* target = nullptr)
+ : Value(std::move(v))
, IsPath(p)
, Target(target)
{
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index fde9750..1d20cff 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -495,7 +495,7 @@ void cmComputeTargetDepends::ComplainAboutBadComponent(
e << "At least one of these targets is not a STATIC_LIBRARY. "
<< "Cyclic dependencies are allowed only among static libraries.";
}
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
}
bool cmComputeTargetDepends::IntraComponent(std::vector<int> const& cmap,
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 33b9cf1..94ea529 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <utility>
#include "cmAlgorithms.h"
#include "cmMakefile.h"
@@ -53,11 +54,11 @@ static std::string const keyVERSION_LESS = "VERSION_LESS";
static std::string const keyVERSION_LESS_EQUAL = "VERSION_LESS_EQUAL";
cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile,
- const cmListFileContext& context,
- const cmListFileBacktrace& bt)
+ cmListFileContext context,
+ cmListFileBacktrace bt)
: Makefile(makefile)
- , ExecutionContext(context)
- , Backtrace(bt)
+ , ExecutionContext(std::move(context))
+ , Backtrace(std::move(bt))
, Policy12Status(makefile.GetPolicyStatus(cmPolicies::CMP0012))
, Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054))
, Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057))
diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h
index fc87a2d..59e1396 100644
--- a/Source/cmConditionEvaluator.h
+++ b/Source/cmConditionEvaluator.h
@@ -21,8 +21,8 @@ class cmConditionEvaluator
public:
typedef std::list<cmExpandedCommandArgument> cmArgumentList;
- cmConditionEvaluator(cmMakefile& makefile, cmListFileContext const& context,
- cmListFileBacktrace const& bt);
+ cmConditionEvaluator(cmMakefile& makefile, cmListFileContext context,
+ cmListFileBacktrace bt);
// this is a shared function for both If and Else to determine if the
// arguments were valid, and if so, was the response true. If there is
diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in
index c80439b..9d00c21 100644
--- a/Source/cmConfigure.cmake.h.in
+++ b/Source/cmConfigure.cmake.h.in
@@ -20,6 +20,7 @@
#cmakedefine CMAKE_USE_ELF_PARSER
#cmakedefine CMAKE_USE_MACH_PARSER
#cmakedefine CMake_HAVE_CXX_MAKE_UNIQUE
+#define CMake_DEFAULT_RECURSION_LIMIT @CMake_DEFAULT_RECURSION_LIMIT@
#define CMAKE_BIN_DIR "/@CMAKE_BIN_DIR@"
#define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@"
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index fcb27b4..bd110ec 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -400,7 +400,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
// compute the binary dir when TRY_COMPILE is called with a src file
// signature
if (this->SrcFileSignature) {
- this->BinaryDirectory += cmake::GetCMakeFilesDirectory();
+ this->BinaryDirectory += "/CMakeFiles";
this->BinaryDirectory += "/CMakeTmp";
} else {
// only valid for srcfile signatures
@@ -599,7 +599,9 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
fprintf(fout, "link_directories(${LINK_DIRECTORIES})\n");
// handle any compile flags we need to pass on
if (!compileDefs.empty()) {
- fprintf(fout, "add_definitions(%s)\n", cmJoin(compileDefs, " ").c_str());
+ // Pass using bracket arguments to preserve content.
+ fprintf(fout, "add_definitions([==[%s]==])\n",
+ cmJoin(compileDefs, "]==] [==[").c_str());
}
/* Use a random file name to avoid rapid creation and deletion
diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx
index 9dcec2f..242ceaa 100644
--- a/Source/cmCustomCommand.cxx
+++ b/Source/cmCustomCommand.cxx
@@ -4,17 +4,19 @@
#include "cmMakefile.h"
+#include <utility>
+
cmCustomCommand::cmCustomCommand(cmMakefile const* mf,
- const std::vector<std::string>& outputs,
- const std::vector<std::string>& byproducts,
- const std::vector<std::string>& depends,
- const cmCustomCommandLines& commandLines,
+ std::vector<std::string> outputs,
+ std::vector<std::string> byproducts,
+ std::vector<std::string> depends,
+ cmCustomCommandLines commandLines,
const char* comment,
const char* workingDirectory)
- : Outputs(outputs)
- , Byproducts(byproducts)
- , Depends(depends)
- , CommandLines(commandLines)
+ : Outputs(std::move(outputs))
+ , Byproducts(std::move(byproducts))
+ , Depends(std::move(depends))
+ , CommandLines(std::move(commandLines))
, Comment(comment ? comment : "")
, WorkingDirectory(workingDirectory ? workingDirectory : "")
, HaveComment(comment != nullptr)
diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h
index d82160b..50f15a4 100644
--- a/Source/cmCustomCommand.h
+++ b/Source/cmCustomCommand.h
@@ -23,12 +23,11 @@ class cmCustomCommand
{
public:
/** Main constructor specifies all information for the command. */
- cmCustomCommand(cmMakefile const* mf,
- const std::vector<std::string>& outputs,
- const std::vector<std::string>& byproducts,
- const std::vector<std::string>& depends,
- const cmCustomCommandLines& commandLines,
- const char* comment, const char* workingDirectory);
+ cmCustomCommand(cmMakefile const* mf, std::vector<std::string> outputs,
+ std::vector<std::string> byproducts,
+ std::vector<std::string> depends,
+ cmCustomCommandLines commandLines, const char* comment,
+ const char* workingDirectory);
/** Get the output file produced by the command. */
const std::vector<std::string>& GetOutputs() const;
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index d1c1736..6bf9946 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -16,10 +16,10 @@
#include <utility>
cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
- const std::string& config,
+ std::string config,
cmLocalGenerator* lg)
: CC(cc)
- , Config(config)
+ , Config(std::move(config))
, LG(lg)
, OldStyle(cc.GetEscapeOldStyle())
, MakeVars(cc.GetEscapeAllowMakeVars())
diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h
index b7e2a39..9684cff 100644
--- a/Source/cmCustomCommandGenerator.h
+++ b/Source/cmCustomCommandGenerator.h
@@ -29,8 +29,8 @@ class cmCustomCommandGenerator
const char* GetArgv0Location(unsigned int c) const;
public:
- cmCustomCommandGenerator(cmCustomCommand const& cc,
- const std::string& config, cmLocalGenerator* lg);
+ cmCustomCommandGenerator(cmCustomCommand const& cc, std::string config,
+ cmLocalGenerator* lg);
~cmCustomCommandGenerator();
cmCustomCommand const& GetCC() const { return this->CC; }
unsigned int GetNumberOfCommands() const;
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index 2acb015..7d1d316 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -13,9 +13,9 @@
#include <string.h>
#include <utility>
-cmDepends::cmDepends(cmLocalGenerator* lg, const char* targetDir)
+cmDepends::cmDepends(cmLocalGenerator* lg, std::string targetDir)
: LocalGenerator(lg)
- , TargetDirectory(targetDir)
+ , TargetDirectory(std::move(targetDir))
, Dependee(new char[MaxPath])
, Depender(new char[MaxPath])
{
@@ -65,12 +65,13 @@ bool cmDepends::Finalize(std::ostream& /*unused*/, std::ostream& /*unused*/)
return true;
}
-bool cmDepends::Check(const char* makeFile, const char* internalFile,
+bool cmDepends::Check(const std::string& makeFile,
+ const std::string& internalFile,
std::map<std::string, DependencyVector>& validDeps)
{
// Check whether dependencies must be regenerated.
bool okay = true;
- cmsys::ifstream fin(internalFile);
+ cmsys::ifstream fin(internalFile.c_str());
if (!(fin && this->CheckDependencies(fin, internalFile, validDeps))) {
// Clear all dependencies so they will be regenerated.
this->Clear(makeFile);
@@ -81,13 +82,13 @@ bool cmDepends::Check(const char* makeFile, const char* internalFile,
return okay;
}
-void cmDepends::Clear(const char* file)
+void cmDepends::Clear(const std::string& file)
{
// Print verbose output.
if (this->Verbose) {
std::ostringstream msg;
msg << "Clearing dependencies in \"" << file << "\"." << std::endl;
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
// Write an empty dependency file.
@@ -107,7 +108,7 @@ bool cmDepends::WriteDependencies(const std::set<std::string>& /*unused*/,
}
bool cmDepends::CheckDependencies(
- std::istream& internalDepends, const char* internalDependsFileName,
+ std::istream& internalDepends, const std::string& internalDependsFileName,
std::map<std::string, DependencyVector>& validDeps)
{
// Parse dependencies from the stream. If any dependee is missing
@@ -155,8 +156,8 @@ bool cmDepends::CheckDependencies(
// * if the depender does not exist, but the dependee is newer than the
// depends file
bool regenerate = false;
- const char* dependee = this->Dependee + 1;
- const char* depender = this->Depender;
+ const std::string dependee(this->Dependee + 1);
+ const std::string depender(this->Depender);
if (currentDependencies != nullptr) {
currentDependencies->push_back(dependee);
}
@@ -170,7 +171,7 @@ bool cmDepends::CheckDependencies(
std::ostringstream msg;
msg << "Dependee \"" << dependee << "\" does not exist for depender \""
<< depender << "\"." << std::endl;
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
} else {
if (dependerExists) {
@@ -187,7 +188,7 @@ bool cmDepends::CheckDependencies(
std::ostringstream msg;
msg << "Dependee \"" << dependee << "\" is newer than depender \""
<< depender << "\"." << std::endl;
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
}
} else {
@@ -206,7 +207,7 @@ bool cmDepends::CheckDependencies(
msg << "Dependee \"" << dependee
<< "\" is newer than depends file \""
<< internalDependsFileName << "\"." << std::endl;
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
}
}
diff --git a/Source/cmDepends.h b/Source/cmDepends.h
index 705d215..c5e1d5b 100644
--- a/Source/cmDepends.h
+++ b/Source/cmDepends.h
@@ -29,7 +29,7 @@ class cmDepends
public:
/** Instances need to know the build directory name and the relative
path from the build directory to the target file. */
- cmDepends(cmLocalGenerator* lg = nullptr, const char* targetDir = "");
+ cmDepends(cmLocalGenerator* lg = nullptr, std::string targetDir = "");
/** Set the local generator for the directory in which we are
scanning dependencies. This is not a full local generator; it
@@ -41,7 +41,10 @@ public:
void SetLanguage(const std::string& lang) { this->Language = lang; }
/** Set the target build directory. */
- void SetTargetDirectory(const char* dir) { this->TargetDirectory = dir; }
+ void SetTargetDirectory(const std::string& dir)
+ {
+ this->TargetDirectory = dir;
+ }
/** should this be verbose in its output */
void SetVerbose(bool verb) { this->Verbose = verb; }
@@ -61,11 +64,11 @@ public:
they must be generated Clear has already been called to wipe out
the old dependencies.
Dependencies which are still valid will be stored in validDeps. */
- bool Check(const char* makeFile, const char* internalFile,
+ bool Check(const std::string& makeFile, const std::string& internalFile,
std::map<std::string, DependencyVector>& validDeps);
/** Clear dependencies for the target file so they will be regenerated. */
- void Clear(const char* file);
+ void Clear(const std::string& file);
/** Set the file comparison object */
void SetFileComparison(cmFileTimeComparison* fc)
@@ -85,7 +88,7 @@ protected:
// Return false if dependencies must be regenerated and true
// otherwise.
virtual bool CheckDependencies(
- std::istream& internalDepends, const char* internalDependsFileName,
+ std::istream& internalDepends, const std::string& internalDependsFileName,
std::map<std::string, DependencyVector>& validDeps);
// Finalize the dependency information for the target.
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index dcf9cdf..2043d7c 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -24,7 +24,7 @@ cmDependsC::cmDependsC()
}
cmDependsC::cmDependsC(
- cmLocalGenerator* lg, const char* targetDir, const std::string& lang,
+ cmLocalGenerator* lg, const std::string& targetDir, const std::string& lang,
const std::map<std::string, DependencyVector>* validDeps)
: cmDepends(lg, targetDir)
, ValidDeps(validDeps)
@@ -53,8 +53,8 @@ cmDependsC::cmDependsC(
}
this->IncludeRegexLine.compile(INCLUDE_REGEX_LINE);
- this->IncludeRegexScan.compile(scanRegex.c_str());
- this->IncludeRegexComplain.compile(complainRegex.c_str());
+ this->IncludeRegexScan.compile(scanRegex);
+ this->IncludeRegexComplain.compile(complainRegex);
this->IncludeRegexLineString = INCLUDE_REGEX_LINE_MARKER INCLUDE_REGEX_LINE;
this->IncludeRegexScanString = INCLUDE_REGEX_SCAN_MARKER;
this->IncludeRegexScanString += scanRegex;
@@ -213,7 +213,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// Scan this file for new dependencies. Pass the directory
// containing the file to handle double-quote includes.
std::string dir = cmSystemTools::GetFilenamePath(fullName);
- this->Scan(fin, dir.c_str(), fullName);
+ this->Scan(fin, dir, fullName);
} else {
// Skip file with encoding we do not implement.
}
@@ -270,8 +270,7 @@ void cmDependsC::ReadCacheFile()
haveFileName = true;
int newer = 0;
cmFileTimeComparison comp;
- bool res = comp.FileTimeCompare(this->CacheFileName.c_str(),
- line.c_str(), &newer);
+ bool res = comp.FileTimeCompare(this->CacheFileName, line, &newer);
if (res && newer == 1) // cache is newer than the parsed file
{
@@ -344,7 +343,7 @@ void cmDependsC::WriteCacheFile() const
}
}
-void cmDependsC::Scan(std::istream& is, const char* directory,
+void cmDependsC::Scan(std::istream& is, const std::string& directory,
const std::string& fullName)
{
cmIncludeLines* newCacheEntry = new cmIncludeLines;
@@ -420,7 +419,7 @@ void cmDependsC::SetupTransforms()
sep = "|";
}
xform += ")[ \t]*\\(([^),]*)\\)";
- this->IncludeRegexTransform.compile(xform.c_str());
+ this->IncludeRegexTransform.compile(xform);
// Build a string that encodes all transformation rules and will
// change when rules are changed.
@@ -462,11 +461,11 @@ void cmDependsC::TransformLine(std::string& line)
// Construct the transformed line.
std::string newline = this->IncludeRegexTransform.match(1);
std::string arg = this->IncludeRegexTransform.match(4);
- for (const char* c = tri->second.c_str(); *c; ++c) {
- if (*c == '%') {
+ for (char c : tri->second) {
+ if (c == '%') {
newline += arg;
} else {
- newline += *c;
+ newline += c;
}
}
diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h
index f833888..af2b06e 100644
--- a/Source/cmDependsC.h
+++ b/Source/cmDependsC.h
@@ -28,7 +28,7 @@ public:
/** Checking instances need to know the build directory name and the
relative path from the build directory to the target file. */
cmDependsC();
- cmDependsC(cmLocalGenerator* lg, const char* targetDir,
+ cmDependsC(cmLocalGenerator* lg, const std::string& targetDir,
const std::string& lang,
const std::map<std::string, DependencyVector>* validDeps);
@@ -42,7 +42,7 @@ protected:
std::ostream& internalDepends) override;
// Method to scan a single file.
- void Scan(std::istream& is, const char* directory,
+ void Scan(std::istream& is, const std::string& directory,
const std::string& fullName);
// Regular expression to identify C preprocessor include directives.
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index e51f81e..6c5f647 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -7,7 +7,6 @@
#include <iostream>
#include <map>
#include <stdlib.h>
-#include <string.h>
#include <utility>
#include "cmAlgorithms.h"
@@ -54,7 +53,8 @@ public:
typedef std::map<std::string, cmFortranSourceInfo> ObjectInfoMap;
ObjectInfoMap ObjectInfo;
- cmFortranSourceInfo& CreateObjectInfo(const char* obj, const char* src)
+ cmFortranSourceInfo& CreateObjectInfo(const std::string& obj,
+ const std::string& src)
{
std::map<std::string, cmFortranSourceInfo>::iterator i =
this->ObjectInfo.find(obj);
@@ -121,8 +121,7 @@ bool cmDependsFortran::WriteDependencies(const std::set<std::string>& sources,
bool okay = true;
for (std::string const& src : sources) {
// Get the information object for this source.
- cmFortranSourceInfo& info =
- this->Internal->CreateObjectInfo(obj.c_str(), src.c_str());
+ cmFortranSourceInfo& info = this->Internal->CreateObjectInfo(obj, src);
// Create the parser object. The constructor takes info by reference,
// so we may look into the resulting objects later.
@@ -153,7 +152,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
this->LocateModules();
// Get the directory in which stamp files will be stored.
- const char* stamp_dir = this->TargetDirectory.c_str();
+ const std::string& stamp_dir = this->TargetDirectory;
// Get the directory in which module files will be created.
cmMakefile* mf = this->LocalGenerator->GetMakefile();
@@ -167,9 +166,8 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap;
ObjectInfoMap const& objInfo = this->Internal->ObjectInfo;
for (auto const& i : objInfo) {
- if (!this->WriteDependenciesReal(i.first.c_str(), i.second, mod_dir,
- stamp_dir, makeDepends,
- internalDepends)) {
+ if (!this->WriteDependenciesReal(i.first, i.second, mod_dir, stamp_dir,
+ makeDepends, internalDepends)) {
return false;
}
}
@@ -256,22 +254,22 @@ void cmDependsFortran::LocateModules()
std::string fname = targetDir + "/fortran.internal";
cmsys::ifstream fin(fname.c_str());
if (fin) {
- this->MatchRemoteModules(fin, targetDir.c_str());
+ this->MatchRemoteModules(fin, targetDir);
}
}
}
void cmDependsFortran::MatchLocalModules()
{
- const char* stampDir = this->TargetDirectory.c_str();
+ std::string const& stampDir = this->TargetDirectory;
std::set<std::string> const& provides = this->Internal->TargetProvides;
for (std::string const& i : provides) {
- this->ConsiderModule(i.c_str(), stampDir);
+ this->ConsiderModule(i, stampDir);
}
}
void cmDependsFortran::MatchRemoteModules(std::istream& fin,
- const char* stampDir)
+ const std::string& stampDir)
{
std::string line;
bool doing_provides = false;
@@ -300,7 +298,8 @@ void cmDependsFortran::MatchRemoteModules(std::istream& fin,
}
}
-void cmDependsFortran::ConsiderModule(const char* name, const char* stampDir)
+void cmDependsFortran::ConsiderModule(const std::string& name,
+ const std::string& stampDir)
{
// Locate each required module.
typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
@@ -317,17 +316,17 @@ void cmDependsFortran::ConsiderModule(const char* name, const char* stampDir)
}
}
-bool cmDependsFortran::WriteDependenciesReal(const char* obj,
+bool cmDependsFortran::WriteDependenciesReal(std::string const& obj,
cmFortranSourceInfo const& info,
std::string const& mod_dir,
- const char* stamp_dir,
+ std::string const& stamp_dir,
std::ostream& makeDepends,
std::ostream& internalDepends)
{
typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
// Get the source file for this object.
- const char* src = info.Source.c_str();
+ std::string const& src = info.Source;
// Write the include dependencies to the output stream.
std::string binDir = this->LocalGenerator->GetBinaryDirectory();
@@ -502,8 +501,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
cmFortranModuleAppendUpperLower(cmSystemTools::GetFilenameName(mod),
mod_upper, mod_lower);
if (cmSystemTools::FileExists(mod_upper, true)) {
- if (cmDependsFortran::ModulesDiffer(mod_upper.c_str(), stamp.c_str(),
- compilerId.c_str())) {
+ if (cmDependsFortran::ModulesDiffer(mod_upper, stamp, compilerId)) {
if (!cmSystemTools::CopyFileAlways(mod_upper, stamp)) {
std::cerr << "Error copying Fortran module from \"" << mod_upper
<< "\" to \"" << stamp << "\".\n";
@@ -513,8 +511,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
return true;
}
if (cmSystemTools::FileExists(mod_lower, true)) {
- if (cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str(),
- compilerId.c_str())) {
+ if (cmDependsFortran::ModulesDiffer(mod_lower, stamp, compilerId)) {
if (!cmSystemTools::CopyFileAlways(mod_lower, stamp)) {
std::cerr << "Error copying Fortran module from \"" << mod_lower
<< "\" to \"" << stamp << "\".\n";
@@ -581,9 +578,9 @@ static bool cmFortranStreamsDiffer(std::istream& ifs1, std::istream& ifs2)
return true;
}
-bool cmDependsFortran::ModulesDiffer(const char* modFile,
- const char* stampFile,
- const char* compilerId)
+bool cmDependsFortran::ModulesDiffer(const std::string& modFile,
+ const std::string& stampFile,
+ const std::string& compilerId)
{
/*
gnu >= 4.9:
@@ -617,16 +614,17 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
* source is compiled twice
* -SunPro
*/
- if (strcmp(compilerId, "SunPro") == 0) {
+ if (compilerId == "SunPro") {
return cmSystemTools::FilesDiffer(modFile, stampFile);
}
#if defined(_WIN32) || defined(__CYGWIN__)
- cmsys::ifstream finModFile(modFile, std::ios::in | std::ios::binary);
- cmsys::ifstream finStampFile(stampFile, std::ios::in | std::ios::binary);
+ cmsys::ifstream finModFile(modFile.c_str(), std::ios::in | std::ios::binary);
+ cmsys::ifstream finStampFile(stampFile.c_str(),
+ std::ios::in | std::ios::binary);
#else
- cmsys::ifstream finModFile(modFile);
- cmsys::ifstream finStampFile(stampFile);
+ cmsys::ifstream finModFile(modFile.c_str());
+ cmsys::ifstream finStampFile(stampFile.c_str());
#endif
if (!finModFile || !finStampFile) {
// At least one of the files does not exist. The modules differ.
@@ -641,7 +639,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
* Eat the stream content until all recompile only related changes
* are left behind.
*/
- if (strcmp(compilerId, "GNU") == 0) {
+ if (compilerId == "GNU") {
// GNU Fortran 4.9 and later compress .mod files with gzip
// but also do not include a date so we can fall through to
// compare them without skipping any prefix.
@@ -664,7 +662,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
return true;
}
}
- } else if (strcmp(compilerId, "Intel") == 0) {
+ } else if (compilerId == "Intel") {
const char seq[2] = { '\n', '\0' };
const int seqlen = 2;
diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h
index 5d96dd4..f5f5be2 100644
--- a/Source/cmDependsFortran.h
+++ b/Source/cmDependsFortran.h
@@ -44,8 +44,9 @@ public:
/** Determine if a mod file and the corresponding mod.stamp file
are representing different module information. */
- static bool ModulesDiffer(const char* modFile, const char* stampFile,
- const char* compilerId);
+ static bool ModulesDiffer(const std::string& modFile,
+ const std::string& stampFile,
+ const std::string& compilerId);
protected:
// Finalize the dependency information for the target.
@@ -55,8 +56,8 @@ protected:
// Find all the modules required by the target.
void LocateModules();
void MatchLocalModules();
- void MatchRemoteModules(std::istream& fin, const char* stampDir);
- void ConsiderModule(const char* name, const char* stampDir);
+ void MatchRemoteModules(std::istream& fin, const std::string& stampDir);
+ void ConsiderModule(const std::string& name, const std::string& stampDir);
bool FindModule(std::string const& name, std::string& module);
// Implement writing/checking methods required by superclass.
@@ -65,8 +66,10 @@ protected:
std::ostream& internalDepends) override;
// Actually write the dependencies to the streams.
- bool WriteDependenciesReal(const char* obj, cmFortranSourceInfo const& info,
- std::string const& mod_dir, const char* stamp_dir,
+ bool WriteDependenciesReal(std::string const& obj,
+ cmFortranSourceInfo const& info,
+ std::string const& mod_dir,
+ std::string const& stamp_dir,
std::ostream& makeDepends,
std::ostream& internalDepends);
diff --git a/Source/cmDependsJava.cxx b/Source/cmDependsJava.cxx
index 29938ba..b44b3a2 100644
--- a/Source/cmDependsJava.cxx
+++ b/Source/cmDependsJava.cxx
@@ -27,7 +27,8 @@ bool cmDependsJava::WriteDependencies(const std::set<std::string>& sources,
}
bool cmDependsJava::CheckDependencies(
- std::istream& /*internalDepends*/, const char* /*internalDependsFileName*/,
+ std::istream& /*internalDepends*/,
+ const std::string& /*internalDependsFileName*/,
std::map<std::string, DependencyVector>& /*validDeps*/)
{
return true;
diff --git a/Source/cmDependsJava.h b/Source/cmDependsJava.h
index d070840..1928c51 100644
--- a/Source/cmDependsJava.h
+++ b/Source/cmDependsJava.h
@@ -33,7 +33,7 @@ protected:
const std::string& file, std::ostream& makeDepends,
std::ostream& internalDepends) override;
bool CheckDependencies(
- std::istream& internalDepends, const char* internalDependsFileName,
+ std::istream& internalDepends, const std::string& internalDependsFileName,
std::map<std::string, DependencyVector>& validDeps) override;
};
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx
index 6a817b4..d4628fa 100644
--- a/Source/cmDocumentation.cxx
+++ b/Source/cmDocumentation.cxx
@@ -43,11 +43,18 @@ static const char* cmDocumentationStandardOptions[][2] = {
{ nullptr, nullptr }
};
-static const char* cmDocumentationGeneratorsHeader[][2] = {
+static const char* cmDocumentationCPackGeneratorsHeader[][2] = {
{ nullptr, "The following generators are available on this platform:" },
{ nullptr, nullptr }
};
+static const char* cmDocumentationCMakeGeneratorsHeader[][2] = {
+ { nullptr,
+ "The following generators are available on this platform (* marks "
+ "default):" },
+ { nullptr, nullptr }
+};
+
cmDocumentation::cmDocumentation()
{
this->addCommonStandardDocSections();
@@ -178,7 +185,7 @@ void cmDocumentation::addCommonStandardDocSections()
void cmDocumentation::addCMakeStandardDocSections()
{
cmDocumentationSection sec{ "Generators" };
- sec.Append(cmDocumentationGeneratorsHeader);
+ sec.Append(cmDocumentationCMakeGeneratorsHeader);
this->AllSections.emplace("Generators", std::move(sec));
}
@@ -191,7 +198,9 @@ void cmDocumentation::addCTestStandardDocSections()
void cmDocumentation::addCPackStandardDocSections()
{
- addCMakeStandardDocSections();
+ cmDocumentationSection sec{ "Generators" };
+ sec.Append(cmDocumentationCPackGeneratorsHeader);
+ this->AllSections.emplace("Generators", std::move(sec));
}
bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
diff --git a/Source/cmDocumentationEntry.h b/Source/cmDocumentationEntry.h
index ea43b88..ca323cc 100644
--- a/Source/cmDocumentationEntry.h
+++ b/Source/cmDocumentationEntry.h
@@ -12,6 +12,7 @@ struct cmDocumentationEntry
{
std::string Name;
std::string Brief;
+ char CustomNamePrefix = ' ';
cmDocumentationEntry() {}
cmDocumentationEntry(const char* doc[2])
{
diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx
index 678e408..e573c04 100644
--- a/Source/cmDocumentationFormatter.cxx
+++ b/Source/cmDocumentationFormatter.cxx
@@ -5,6 +5,7 @@
#include "cmDocumentationEntry.h"
#include "cmDocumentationSection.h"
+#include <iomanip>
#include <ostream>
#include <string.h>
#include <string>
@@ -168,7 +169,7 @@ void cmDocumentationFormatter::PrintSection(
const std::vector<cmDocumentationEntry>& entries = section.GetEntries();
for (cmDocumentationEntry const& entry : entries) {
if (!entry.Name.empty()) {
- os << " " << entry.Name;
+ os << std::setw(2) << std::left << entry.CustomNamePrefix << entry.Name;
this->TextIndent = " ";
int align = static_cast<int>(strlen(this->TextIndent)) - 4;
for (int i = static_cast<int>(entry.Name.size()); i < align; ++i) {
diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx
index ea4cd40..75a7786 100644
--- a/Source/cmExecProgramCommand.cxx
+++ b/Source/cmExecProgramCommand.cxx
@@ -217,11 +217,11 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
int p;
cmProcessOutput processOutput(encoding);
std::string strdata;
- while ((p = cmsysProcess_WaitForData(cp, &data, &length, nullptr), p)) {
+ while ((p = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) {
if (p == cmsysProcess_Pipe_STDOUT || p == cmsysProcess_Pipe_STDERR) {
if (verbose) {
processOutput.DecodeText(data, length, strdata);
- cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ cmSystemTools::Stdout(strdata);
}
output.append(data, length);
}
@@ -230,7 +230,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
if (verbose) {
processOutput.DecodeText(std::string(), strdata);
if (!strdata.empty()) {
- cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ cmSystemTools::Stdout(strdata);
}
}
@@ -270,7 +270,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
}
msg += "\n";
if (verbose) {
- cmSystemTools::Stdout(msg.c_str());
+ cmSystemTools::Stdout(msg);
}
output += msg;
#else
diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx
index 8de012a..8c67cdb 100644
--- a/Source/cmExecuteProcessCommand.cxx
+++ b/Source/cmExecuteProcessCommand.cxx
@@ -244,19 +244,19 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
int p;
cmProcessOutput processOutput(encoding);
std::string strdata;
- while ((p = cmsysProcess_WaitForData(cp, &data, &length, nullptr), p)) {
+ while ((p = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) {
// Put the output in the right place.
if (p == cmsysProcess_Pipe_STDOUT && !output_quiet) {
if (output_variable.empty()) {
processOutput.DecodeText(data, length, strdata, 1);
- cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ cmSystemTools::Stdout(strdata);
} else {
cmExecuteProcessCommandAppend(tempOutput, data, length);
}
} else if (p == cmsysProcess_Pipe_STDERR && !error_quiet) {
if (error_variable.empty()) {
processOutput.DecodeText(data, length, strdata, 2);
- cmSystemTools::Stderr(strdata.c_str(), strdata.size());
+ cmSystemTools::Stderr(strdata);
} else {
cmExecuteProcessCommandAppend(tempError, data, length);
}
@@ -265,13 +265,13 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
if (!output_quiet && output_variable.empty()) {
processOutput.DecodeText(std::string(), strdata, 1);
if (!strdata.empty()) {
- cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ cmSystemTools::Stdout(strdata);
}
}
if (!error_quiet && error_variable.empty()) {
processOutput.DecodeText(std::string(), strdata, 2);
if (!strdata.empty()) {
- cmSystemTools::Stderr(strdata.c_str(), strdata.size());
+ cmSystemTools::Stderr(strdata);
}
}
diff --git a/Source/cmExpandedCommandArgument.cxx b/Source/cmExpandedCommandArgument.cxx
index 650a5ad..00848a6 100644
--- a/Source/cmExpandedCommandArgument.cxx
+++ b/Source/cmExpandedCommandArgument.cxx
@@ -2,13 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExpandedCommandArgument.h"
+#include <utility>
+
cmExpandedCommandArgument::cmExpandedCommandArgument()
{
}
-cmExpandedCommandArgument::cmExpandedCommandArgument(std::string const& value,
+cmExpandedCommandArgument::cmExpandedCommandArgument(std::string value,
bool quoted)
- : Value(value)
+ : Value(std::move(value))
, Quoted(quoted)
{
}
diff --git a/Source/cmExpandedCommandArgument.h b/Source/cmExpandedCommandArgument.h
index d71fc92..69d35de 100644
--- a/Source/cmExpandedCommandArgument.h
+++ b/Source/cmExpandedCommandArgument.h
@@ -18,7 +18,7 @@ class cmExpandedCommandArgument
{
public:
cmExpandedCommandArgument();
- cmExpandedCommandArgument(std::string const& value, bool quoted);
+ cmExpandedCommandArgument(std::string value, bool quoted);
std::string const& GetValue() const;
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index c6b66a3..c8f743a 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -83,7 +83,7 @@ bool cmExportFileGenerator::GenerateImportFile()
std::string se = cmSystemTools::GetLastSystemError();
std::ostringstream e;
e << "cannot write to file \"" << this->MainImportFile << "\": " << se;
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return false;
}
std::ostream& os = *foutPtr;
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 3821144..f8bc0ab 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -54,7 +54,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
<< "\" ...) "
<< "includes target \"" << te->Target->GetName()
<< "\" more than once in the export set.";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return false;
}
}
@@ -112,7 +112,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
std::string errorMessage;
if (!this->PopulateExportProperties(gt, properties, errorMessage)) {
- cmSystemTools::Error(errorMessage.c_str());
+ cmSystemTools::Error(errorMessage);
return false;
}
@@ -294,7 +294,7 @@ bool cmExportInstallFileGenerator::GenerateImportFileConfig(
std::string se = cmSystemTools::GetLastSystemError();
std::ostringstream e;
e << "cannot write to file \"" << fileName << "\": " << se;
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return false;
}
std::ostream& os = exportFileStream;
@@ -518,7 +518,7 @@ void cmExportInstallFileGenerator::ComplainAboutMissingTarget(
e << "that is not in this export set, but " << occurrences
<< " times in others.";
}
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
}
std::string cmExportInstallFileGenerator::InstallNameDir(
diff --git a/Source/cmExportSet.h b/Source/cmExportSet.h
index 58ad617..0ef306f 100644
--- a/Source/cmExportSet.h
+++ b/Source/cmExportSet.h
@@ -6,6 +6,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include <utility>
#include <vector>
class cmInstallExportGenerator;
@@ -17,8 +18,8 @@ class cmExportSet
{
public:
/// Construct an empty export set named \a name
- cmExportSet(const std::string& name)
- : Name(name)
+ cmExportSet(std::string name)
+ : Name(std::move(name))
{
}
/// Destructor
diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx
index fecd821..150995f 100644
--- a/Source/cmExternalMakefileProjectGenerator.cxx
+++ b/Source/cmExternalMakefileProjectGenerator.cxx
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExternalMakefileProjectGenerator.h"
+#include <utility>
+
class cmMakefile;
void cmExternalMakefileProjectGenerator::EnableLanguage(
@@ -32,10 +34,9 @@ bool cmExternalMakefileProjectGenerator::Open(
}
cmExternalMakefileProjectGeneratorFactory::
- cmExternalMakefileProjectGeneratorFactory(const std::string& n,
- const std::string& doc)
- : Name(n)
- , Documentation(doc)
+ cmExternalMakefileProjectGeneratorFactory(std::string n, std::string doc)
+ : Name(std::move(n))
+ , Documentation(std::move(doc))
{
}
diff --git a/Source/cmExternalMakefileProjectGenerator.h b/Source/cmExternalMakefileProjectGenerator.h
index d48abca..492987d 100644
--- a/Source/cmExternalMakefileProjectGenerator.h
+++ b/Source/cmExternalMakefileProjectGenerator.h
@@ -70,8 +70,7 @@ protected:
class cmExternalMakefileProjectGeneratorFactory
{
public:
- cmExternalMakefileProjectGeneratorFactory(const std::string& n,
- const std::string& doc);
+ cmExternalMakefileProjectGeneratorFactory(std::string n, std::string doc);
virtual ~cmExternalMakefileProjectGeneratorFactory();
std::string GetName() const;
diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx
index effb446..4b14d26 100644
--- a/Source/cmFLTKWrapUICommand.cxx
+++ b/Source/cmFLTKWrapUICommand.cxx
@@ -117,7 +117,7 @@ void cmFLTKWrapUICommand::FinalPass()
msg += ". The problem was found while processing the source directory: ";
msg += this->Makefile->GetCurrentSourceDirectory();
msg += ". This FLTK_WRAP_UI call will be ignored.";
- cmSystemTools::Message(msg.c_str(), "Warning");
+ cmSystemTools::Message(msg, "Warning");
return;
}
}
diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx
index 89bd258..34b6b33 100644
--- a/Source/cmFileAPI.cxx
+++ b/Source/cmFileAPI.cxx
@@ -169,7 +169,7 @@ std::string cmFileAPI::WriteJsonFile(
// If the final name already exists then assume it has proper content.
// Otherwise, atomically place the reply file at its final name
if (cmSystemTools::FileExists(file, true) ||
- !cmSystemTools::RenameFile(tmpFile.c_str(), file.c_str())) {
+ !cmSystemTools::RenameFile(tmpFile, file)) {
cmSystemTools::RemoveFile(tmpFile);
}
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx
index 078d1d5..4597d4f 100644
--- a/Source/cmFileAPICodemodel.cxx
+++ b/Source/cmFileAPICodemodel.cxx
@@ -166,13 +166,13 @@ class BacktraceData
}
public:
- BacktraceData(std::string const& topSource);
+ BacktraceData(std::string topSource);
bool Add(cmListFileBacktrace const& bt, Json::ArrayIndex& index);
Json::Value Dump();
};
-BacktraceData::BacktraceData(std::string const& topSource)
- : TopSource(topSource)
+BacktraceData::BacktraceData(std::string topSource)
+ : TopSource(std::move(topSource))
{
}
@@ -727,7 +727,7 @@ void Target::ProcessLanguage(std::string const& lang)
lg->GetTargetDefines(this->GT, this->Config, lang);
cd.SetDefines(defines);
std::vector<BT<std::string>> includePathList =
- lg->GetIncludeDirectories(this->GT, lang, this->Config, true);
+ lg->GetIncludeDirectories(this->GT, lang, this->Config);
for (BT<std::string> const& i : includePathList) {
cd.Includes.emplace_back(
i, this->GT->IsSystemIncludeDirectory(i.Value, this->Config, lang));
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 999af54..afb0b2a 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -561,7 +561,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
if (hex_conversion_enabled) {
// TODO: should work without temp file, but just on a memory buffer
std::string binaryFileName = this->Makefile->GetCurrentBinaryDirectory();
- binaryFileName += cmake::GetCMakeFilesDirectory();
+ binaryFileName += "/CMakeFiles";
binaryFileName += "/FileCommandStringsBinaryFile";
if (cmHexFileConverter::TryConvert(fileName.c_str(),
binaryFileName.c_str())) {
@@ -2461,7 +2461,7 @@ bool cmFileCommand::HandleRename(std::vector<std::string> const& args)
newname += "/" + args[2];
}
- if (!cmSystemTools::RenameFile(oldname.c_str(), newname.c_str())) {
+ if (!cmSystemTools::RenameFile(oldname, newname)) {
std::string err = cmSystemTools::GetLastSystemError();
std::ostringstream e;
/* clang-format off */
@@ -2916,10 +2916,6 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
check_curl_result(res, "DOWNLOAD cannot set url: ");
- // enable auth
- res = ::curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
- check_curl_result(res, "DOWNLOAD cannot set httpauth: ");
-
// enable HTTP ERROR parsing
res = ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
check_curl_result(res, "DOWNLOAD cannot set http failure option: ");
@@ -3219,10 +3215,6 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
check_curl_result(res, "UPLOAD cannot set url: ");
- // enable auth
- res = ::curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
- check_curl_result(res, "UPLOAD cannot set httpauth: ");
-
res =
::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmWriteToMemoryCallback);
check_curl_result(res, "UPLOAD cannot set write function: ");
diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx
index 8f6993d..8b3911e 100644
--- a/Source/cmFileTimeComparison.cxx
+++ b/Source/cmFileTimeComparison.cxx
@@ -21,9 +21,10 @@ class cmFileTimeComparisonInternal
{
public:
// Internal comparison method.
- inline bool FileTimeCompare(const char* f1, const char* f2, int* result);
+ inline bool FileTimeCompare(const std::string& f1, const std::string& f2,
+ int* result);
- bool FileTimesDiffer(const char* f1, const char* f2);
+ bool FileTimesDiffer(const std::string& f1, const std::string& f2);
private:
typedef std::unordered_map<std::string, cmFileTimeComparison_Type>
@@ -31,14 +32,14 @@ private:
FileStatsMap Files;
// Internal methods to lookup and compare modification times.
- inline bool Stat(const char* fname, cmFileTimeComparison_Type* st);
+ inline bool Stat(const std::string& fname, cmFileTimeComparison_Type* st);
inline int Compare(cmFileTimeComparison_Type* st1,
cmFileTimeComparison_Type* st2);
inline bool TimesDiffer(cmFileTimeComparison_Type* st1,
cmFileTimeComparison_Type* st2);
};
-bool cmFileTimeComparisonInternal::Stat(const char* fname,
+bool cmFileTimeComparisonInternal::Stat(const std::string& fname,
cmFileTimeComparison_Type* st)
{
// Use the stored time if available.
@@ -51,7 +52,7 @@ bool cmFileTimeComparisonInternal::Stat(const char* fname,
#if !defined(_WIN32) || defined(__CYGWIN__)
// POSIX version. Use the stat function.
- int res = ::stat(fname, st);
+ int res = ::stat(fname.c_str(), st);
if (res != 0) {
return false;
}
@@ -83,13 +84,14 @@ cmFileTimeComparison::~cmFileTimeComparison()
delete this->Internals;
}
-bool cmFileTimeComparison::FileTimeCompare(const char* f1, const char* f2,
- int* result)
+bool cmFileTimeComparison::FileTimeCompare(const std::string& f1,
+ const std::string& f2, int* result)
{
return this->Internals->FileTimeCompare(f1, f2, result);
}
-bool cmFileTimeComparison::FileTimesDiffer(const char* f1, const char* f2)
+bool cmFileTimeComparison::FileTimesDiffer(const std::string& f1,
+ const std::string& f2)
{
return this->Internals->FileTimesDiffer(f1, f2);
}
@@ -199,8 +201,9 @@ bool cmFileTimeComparisonInternal::TimesDiffer(cmFileTimeComparison_Type* s1,
#endif
}
-bool cmFileTimeComparisonInternal::FileTimeCompare(const char* f1,
- const char* f2, int* result)
+bool cmFileTimeComparisonInternal::FileTimeCompare(const std::string& f1,
+ const std::string& f2,
+ int* result)
{
// Get the modification time for each file.
cmFileTimeComparison_Type s1;
@@ -215,8 +218,8 @@ bool cmFileTimeComparisonInternal::FileTimeCompare(const char* f1,
return false;
}
-bool cmFileTimeComparisonInternal::FileTimesDiffer(const char* f1,
- const char* f2)
+bool cmFileTimeComparisonInternal::FileTimesDiffer(const std::string& f1,
+ const std::string& f2)
{
// Get the modification time for each file.
cmFileTimeComparison_Type s1;
diff --git a/Source/cmFileTimeComparison.h b/Source/cmFileTimeComparison.h
index 114989b..5f74e34 100644
--- a/Source/cmFileTimeComparison.h
+++ b/Source/cmFileTimeComparison.h
@@ -5,6 +5,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <string>
+
class cmFileTimeComparisonInternal;
/** \class cmFileTimeComparison
@@ -24,13 +26,14 @@ public:
* When true is returned, result has -1, 0, +1 for
* f1 older, same, or newer than f2.
*/
- bool FileTimeCompare(const char* f1, const char* f2, int* result);
+ bool FileTimeCompare(const std::string& f1, const std::string& f2,
+ int* result);
/**
* Compare file modification times. Return true unless both files
* exist and have modification times less than 1 second apart.
*/
- bool FileTimesDiffer(const char* f1, const char* f2);
+ bool FileTimesDiffer(const std::string& f1, const std::string& f2);
protected:
cmFileTimeComparisonInternal* Internals;
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 9ae1cb9..bec2af9 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -663,7 +663,7 @@ bool cmFindPackageCommand::FindModule(bool& found)
module += this->Name;
module += ".cmake";
bool system = false;
- std::string mfile = this->Makefile->GetModulesFile(module.c_str(), system);
+ std::string mfile = this->Makefile->GetModulesFile(module, system);
if (!mfile.empty()) {
if (system) {
auto it = this->DeprecatedFindModules.find(this->Name);
@@ -1760,8 +1760,8 @@ bool cmFileListGeneratorBase::Consider(std::string const& fullPath,
class cmFileListGeneratorFixed : public cmFileListGeneratorBase
{
public:
- cmFileListGeneratorFixed(std::string const& str)
- : String(str)
+ cmFileListGeneratorFixed(std::string str)
+ : String(std::move(str))
{
}
cmFileListGeneratorFixed(cmFileListGeneratorFixed const& r)
@@ -1940,8 +1940,8 @@ private:
class cmFileListGeneratorCaseInsensitive : public cmFileListGeneratorBase
{
public:
- cmFileListGeneratorCaseInsensitive(std::string const& str)
- : String(str)
+ cmFileListGeneratorCaseInsensitive(std::string str)
+ : String(std::move(str))
{
}
cmFileListGeneratorCaseInsensitive(
@@ -1982,8 +1982,8 @@ private:
class cmFileListGeneratorGlob : public cmFileListGeneratorBase
{
public:
- cmFileListGeneratorGlob(std::string const& str)
- : Pattern(str)
+ cmFileListGeneratorGlob(std::string str)
+ : Pattern(std::move(str))
{
}
cmFileListGeneratorGlob(cmFileListGeneratorGlob const& r)
diff --git a/Source/cmFortranParser.h b/Source/cmFortranParser.h
index 132b3e6..8d4c90b 100644
--- a/Source/cmFortranParser.h
+++ b/Source/cmFortranParser.h
@@ -8,6 +8,7 @@
# include <set>
# include <string>
+# include <utility>
# include <vector>
#endif
@@ -114,10 +115,10 @@ int cmFortran_yyparse(yyscan_t);
// Define parser object internal structure.
struct cmFortranFile
{
- cmFortranFile(FILE* file, YY_BUFFER_STATE buffer, const std::string& dir)
+ cmFortranFile(FILE* file, YY_BUFFER_STATE buffer, std::string dir)
: File(file)
, Buffer(buffer)
- , Directory(dir)
+ , Directory(std::move(dir))
, LastCharWasNewline(false)
{
}
@@ -129,9 +130,8 @@ struct cmFortranFile
struct cmFortranParser_s
{
- cmFortranParser_s(std::vector<std::string> const& includes,
- std::set<std::string> const& defines,
- cmFortranSourceInfo& info);
+ cmFortranParser_s(std::vector<std::string> includes,
+ std::set<std::string> defines, cmFortranSourceInfo& info);
~cmFortranParser_s();
bool FindIncludeFile(const char* dir, const char* includeName,
diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx
index 01cbb78..45481a4 100644
--- a/Source/cmFortranParserImpl.cxx
+++ b/Source/cmFortranParserImpl.cxx
@@ -8,6 +8,7 @@
#include <stack>
#include <stdio.h>
#include <string>
+#include <utility>
#include <vector>
bool cmFortranParser_s::FindIncludeFile(const char* dir,
@@ -42,11 +43,11 @@ bool cmFortranParser_s::FindIncludeFile(const char* dir,
return false;
}
-cmFortranParser_s::cmFortranParser_s(std::vector<std::string> const& includes,
- std::set<std::string> const& defines,
+cmFortranParser_s::cmFortranParser_s(std::vector<std::string> includes,
+ std::set<std::string> defines,
cmFortranSourceInfo& info)
- : IncludePath(includes)
- , PPDefinitions(defines)
+ : IncludePath(std::move(includes))
+ , PPDefinitions(std::move(defines))
, Info(info)
{
this->InInterface = false;
diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx
index bf53dbf..eef5dc0 100644
--- a/Source/cmGeneratedFileStream.cxx
+++ b/Source/cmGeneratedFileStream.cxx
@@ -210,7 +210,7 @@ int cmGeneratedFileStreamBase::CompressFile(std::string const&,
int cmGeneratedFileStreamBase::RenameFile(std::string const& oldname,
std::string const& newname)
{
- return cmSystemTools::RenameFile(oldname.c_str(), newname.c_str());
+ return cmSystemTools::RenameFile(oldname, newname);
}
void cmGeneratedFileStream::SetName(const std::string& fname)
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 96d4ad6..f3f9771 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -15,9 +15,8 @@
#include "cmGeneratorExpressionParser.h"
#include "cmSystemTools.h"
-cmGeneratorExpression::cmGeneratorExpression(
- const cmListFileBacktrace& backtrace)
- : Backtrace(backtrace)
+cmGeneratorExpression::cmGeneratorExpression(cmListFileBacktrace backtrace)
+ : Backtrace(std::move(backtrace))
{
}
@@ -96,9 +95,9 @@ const std::string& cmCompiledGeneratorExpression::EvaluateWithContext(
}
cmCompiledGeneratorExpression::cmCompiledGeneratorExpression(
- cmListFileBacktrace const& backtrace, const std::string& input)
- : Backtrace(backtrace)
- , Input(input)
+ cmListFileBacktrace backtrace, std::string input)
+ : Backtrace(std::move(backtrace))
+ , Input(std::move(input))
, HadContextSensitiveCondition(false)
, HadHeadSensitiveCondition(false)
, EvaluateForBuildsystem(false)
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index 9c05f60..e5463a7 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -11,6 +11,7 @@
#include <memory> // IWYU pragma: keep
#include <set>
#include <string>
+#include <utility>
#include <vector>
class cmCompiledGeneratorExpression;
@@ -35,8 +36,7 @@ class cmGeneratorExpression
public:
/** Construct. */
- cmGeneratorExpression(
- cmListFileBacktrace const& backtrace = cmListFileBacktrace());
+ cmGeneratorExpression(cmListFileBacktrace backtrace = cmListFileBacktrace());
~cmGeneratorExpression();
std::unique_ptr<cmCompiledGeneratorExpression> Parse(
@@ -140,8 +140,8 @@ private:
cmGeneratorExpressionContext& context,
cmGeneratorExpressionDAGChecker* dagChecker) const;
- cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
- const std::string& input);
+ cmCompiledGeneratorExpression(cmListFileBacktrace backtrace,
+ std::string input);
friend class cmGeneratorExpression;
@@ -169,13 +169,13 @@ class cmGeneratorExpressionInterpreter
public:
cmGeneratorExpressionInterpreter(cmLocalGenerator* localGenerator,
- std::string const& config,
+ std::string config,
cmGeneratorTarget const* headTarget,
- std::string const& lang = std::string())
+ std::string lang = std::string())
: LocalGenerator(localGenerator)
- , Config(config)
+ , Config(std::move(config))
, HeadTarget(headTarget)
- , Language(lang)
+ , Language(std::move(lang))
{
}
diff --git a/Source/cmGeneratorExpressionContext.cxx b/Source/cmGeneratorExpressionContext.cxx
index a6dde5d..6d97331 100644
--- a/Source/cmGeneratorExpressionContext.cxx
+++ b/Source/cmGeneratorExpressionContext.cxx
@@ -2,15 +2,17 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGeneratorExpressionContext.h"
+#include <utility>
+
cmGeneratorExpressionContext::cmGeneratorExpressionContext(
- cmLocalGenerator* lg, std::string const& config, bool quiet,
+ cmLocalGenerator* lg, std::string config, bool quiet,
cmGeneratorTarget const* headTarget, const cmGeneratorTarget* currentTarget,
- bool evaluateForBuildsystem, cmListFileBacktrace const& backtrace,
- std::string const& language)
- : Backtrace(backtrace)
+ bool evaluateForBuildsystem, cmListFileBacktrace backtrace,
+ std::string language)
+ : Backtrace(std::move(backtrace))
, LG(lg)
- , Config(config)
- , Language(language)
+ , Config(std::move(config))
+ , Language(std::move(language))
, HeadTarget(headTarget)
, CurrentTarget(currentTarget)
, Quiet(quiet)
diff --git a/Source/cmGeneratorExpressionContext.h b/Source/cmGeneratorExpressionContext.h
index 5b0123e..6e076bf 100644
--- a/Source/cmGeneratorExpressionContext.h
+++ b/Source/cmGeneratorExpressionContext.h
@@ -14,12 +14,12 @@ class cmLocalGenerator;
struct cmGeneratorExpressionContext
{
- cmGeneratorExpressionContext(cmLocalGenerator* lg, std::string const& config,
+ cmGeneratorExpressionContext(cmLocalGenerator* lg, std::string config,
bool quiet, const cmGeneratorTarget* headTarget,
cmGeneratorTarget const* currentTarget,
bool evaluateForBuildsystem,
- cmListFileBacktrace const& backtrace,
- std::string const& language);
+ cmListFileBacktrace backtrace,
+ std::string language);
cmListFileBacktrace Backtrace;
std::set<cmGeneratorTarget*> DependTargets;
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx
index 61b798b..0f26e70 100644
--- a/Source/cmGeneratorExpressionDAGChecker.cxx
+++ b/Source/cmGeneratorExpressionDAGChecker.cxx
@@ -15,26 +15,26 @@
#include <utility>
cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
- const cmListFileBacktrace& backtrace, cmGeneratorTarget const* target,
- const std::string& property, const GeneratorExpressionContent* content,
+ cmListFileBacktrace backtrace, cmGeneratorTarget const* target,
+ std::string property, const GeneratorExpressionContent* content,
cmGeneratorExpressionDAGChecker* parent)
: Parent(parent)
, Target(target)
- , Property(property)
+ , Property(std::move(property))
, Content(content)
- , Backtrace(backtrace)
+ , Backtrace(std::move(backtrace))
, TransitivePropertiesOnly(false)
{
Initialize();
}
cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
- cmGeneratorTarget const* target, const std::string& property,
+ cmGeneratorTarget const* target, std::string property,
const GeneratorExpressionContent* content,
cmGeneratorExpressionDAGChecker* parent)
: Parent(parent)
, Target(target)
- , Property(property)
+ , Property(std::move(property))
, Content(content)
, Backtrace()
, TransitivePropertiesOnly(false)
diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h
index 1525c39..e1fba5e 100644
--- a/Source/cmGeneratorExpressionDAGChecker.h
+++ b/Source/cmGeneratorExpressionDAGChecker.h
@@ -42,13 +42,13 @@ class cmGeneratorTarget;
struct cmGeneratorExpressionDAGChecker
{
- cmGeneratorExpressionDAGChecker(const cmListFileBacktrace& backtrace,
+ cmGeneratorExpressionDAGChecker(cmListFileBacktrace backtrace,
cmGeneratorTarget const* target,
- const std::string& property,
+ std::string property,
const GeneratorExpressionContent* content,
cmGeneratorExpressionDAGChecker* parent);
cmGeneratorExpressionDAGChecker(cmGeneratorTarget const* target,
- const std::string& property,
+ std::string property,
const GeneratorExpressionContent* content,
cmGeneratorExpressionDAGChecker* parent);
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index 1c33a6e..326cb0e 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -18,11 +18,11 @@
#include "cmSystemTools.h"
cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile(
- const std::string& input,
+ std::string input,
std::unique_ptr<cmCompiledGeneratorExpression> outputFileExpr,
std::unique_ptr<cmCompiledGeneratorExpression> condition,
bool inputIsContent, cmPolicies::PolicyStatus policyStatusCMP0070)
- : Input(input)
+ : Input(std::move(input))
, OutputFileExpr(std::move(outputFileExpr))
, Condition(std::move(condition))
, InputIsContent(inputIsContent)
diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h
index 2a79069..89a2390 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.h
+++ b/Source/cmGeneratorExpressionEvaluationFile.h
@@ -20,7 +20,7 @@ class cmGeneratorExpressionEvaluationFile
{
public:
cmGeneratorExpressionEvaluationFile(
- const std::string& input,
+ std::string input,
std::unique_ptr<cmCompiledGeneratorExpression> outputFileExpr,
std::unique_ptr<cmCompiledGeneratorExpression> condition,
bool inputIsContent, cmPolicies::PolicyStatus policyStatusCMP0070);
diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx
index 489970c..949a86d 100644
--- a/Source/cmGeneratorExpressionParser.cxx
+++ b/Source/cmGeneratorExpressionParser.cxx
@@ -9,8 +9,8 @@
#include <utility>
cmGeneratorExpressionParser::cmGeneratorExpressionParser(
- const std::vector<cmGeneratorExpressionToken>& tokens)
- : Tokens(tokens)
+ std::vector<cmGeneratorExpressionToken> tokens)
+ : Tokens(std::move(tokens))
, NestingLevel(0)
{
}
diff --git a/Source/cmGeneratorExpressionParser.h b/Source/cmGeneratorExpressionParser.h
index 633381c..e663496 100644
--- a/Source/cmGeneratorExpressionParser.h
+++ b/Source/cmGeneratorExpressionParser.h
@@ -13,8 +13,7 @@ struct cmGeneratorExpressionEvaluator;
struct cmGeneratorExpressionParser
{
- cmGeneratorExpressionParser(
- const std::vector<cmGeneratorExpressionToken>& tokens);
+ cmGeneratorExpressionParser(std::vector<cmGeneratorExpressionToken> tokens);
void Parse(std::vector<cmGeneratorExpressionEvaluator*>& result);
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index eb3d4af..86f10dc 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -14,6 +14,7 @@
#include <stdlib.h>
#include <string.h>
#include <unordered_set>
+#include <utility>
#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
@@ -202,7 +203,7 @@ std::string cmGeneratorTarget::GetExportName() const
std::ostringstream e;
e << "EXPORT_NAME property \"" << exportName << "\" for \""
<< this->GetName() << "\": is not valid.";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return "";
}
return exportName;
@@ -1805,10 +1806,10 @@ class cmTargetCollectLinkLanguages
{
public:
cmTargetCollectLinkLanguages(cmGeneratorTarget const* target,
- const std::string& config,
+ std::string config,
std::unordered_set<std::string>& languages,
cmGeneratorTarget const* head)
- : Config(config)
+ : Config(std::move(config))
, Languages(languages)
, HeadTarget(head)
, Target(target)
@@ -4586,7 +4587,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
<< " property requirement\nof "
"dependency \""
<< theTarget->GetName() << "\".\n";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
break;
}
propContent = consistent.second;
@@ -4611,7 +4612,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
"already. The INTERFACE_"
<< p << " property on\ndependency \"" << theTarget->GetName()
<< "\" is in conflict.\n";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
break;
}
propContent = consistent.second;
@@ -4631,7 +4632,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
e << "The INTERFACE_" << p << " property of \""
<< theTarget->GetName() << "\" does\nnot agree with the value of "
<< p << " already determined\nfor \"" << tgt->GetName() << "\".\n";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
break;
}
propContent = consistent.second;
@@ -6140,7 +6141,7 @@ bool cmGeneratorTarget::HasImportLibrary(std::string const& config) const
std::string cmGeneratorTarget::GetSupportDirectory() const
{
std::string dir = this->LocalGenerator->GetCurrentBinaryDirectory();
- dir += cmake::GetCMakeFilesDirectory();
+ dir += "/CMakeFiles";
dir += "/";
dir += this->GetName();
#if defined(__VMS)
diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx
index ffb895e..163b4c8 100644
--- a/Source/cmGetFilenameComponentCommand.cxx
+++ b/Source/cmGetFilenameComponentCommand.cxx
@@ -88,6 +88,10 @@ bool cmGetFilenameComponentCommand::InitialPass(
result = cmSystemTools::GetFilenameExtension(filename);
} else if (args[2] == "NAME_WE") {
result = cmSystemTools::GetFilenameWithoutExtension(filename);
+ } else if (args[2] == "LAST_EXT") {
+ result = cmSystemTools::GetFilenameLastExtension(filename);
+ } else if (args[2] == "NAME_WLE") {
+ result = cmSystemTools::GetFilenameWithoutLastExtension(filename);
} else if (args[2] == "ABSOLUTE" || args[2] == "REALPATH") {
// If the path given is relative, evaluate it relative to the
// current source directory unless the user passes a different
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index 3a65ecc..04a8b3c 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -67,7 +67,7 @@ void cmGhsMultiTargetGenerator::Generate()
case cmStateEnums::SHARED_LIBRARY: {
std::string msg = "add_library(<name> SHARED ...) not supported: ";
msg += this->Name;
- cmSystemTools::Message(msg.c_str());
+ cmSystemTools::Message(msg);
return;
}
case cmStateEnums::OBJECT_LIBRARY: {
@@ -84,13 +84,13 @@ void cmGhsMultiTargetGenerator::Generate()
case cmStateEnums::MODULE_LIBRARY: {
std::string msg = "add_library(<name> MODULE ...) not supported: ";
msg += this->Name;
- cmSystemTools::Message(msg.c_str());
+ cmSystemTools::Message(msg);
return;
}
case cmStateEnums::UTILITY: {
std::string msg = "add_custom_target(<name> ...) not supported: ";
msg += this->Name;
- cmSystemTools::Message(msg.c_str());
+ cmSystemTools::Message(msg);
return;
}
default:
diff --git a/Source/cmGlobVerificationManager.cxx b/Source/cmGlobVerificationManager.cxx
index e8959f2..5fd890e 100644
--- a/Source/cmGlobVerificationManager.cxx
+++ b/Source/cmGlobVerificationManager.cxx
@@ -9,7 +9,6 @@
#include "cmListFileCache.h"
#include "cmSystemTools.h"
#include "cmVersion.h"
-#include "cmake.h"
bool cmGlobVerificationManager::SaveVerificationScript(const std::string& path)
{
@@ -18,7 +17,7 @@ bool cmGlobVerificationManager::SaveVerificationScript(const std::string& path)
}
std::string scriptFile = path;
- scriptFile += cmake::GetCMakeFilesDirectory();
+ scriptFile += "/CMakeFiles";
std::string stampFile = scriptFile;
cmSystemTools::MakeDirectory(scriptFile);
scriptFile += "/VerifyGlobs.cmake";
@@ -165,7 +164,7 @@ void cmGlobVerificationManager::AddCacheEntry(
message << "\n " << std::get<0>(bt);
std::get<1>(bt).PrintTitle(message);
}
- cmSystemTools::Error(message.str().c_str());
+ cmSystemTools::Error(message.str());
} else {
value.Backtraces.emplace_back(variable, backtrace);
}
diff --git a/Source/cmGlobVerificationManager.h b/Source/cmGlobVerificationManager.h
index cdbd275..c293a76 100644
--- a/Source/cmGlobVerificationManager.h
+++ b/Source/cmGlobVerificationManager.h
@@ -55,13 +55,13 @@ private:
const bool FollowSymlinks;
const std::string Relative;
const std::string Expression;
- CacheEntryKey(const bool rec, const bool l, const bool s,
- const std::string& rel, const std::string& e)
+ CacheEntryKey(const bool rec, const bool l, const bool s, std::string rel,
+ std::string e)
: Recurse(rec)
, ListDirectories(l)
, FollowSymlinks(s)
- , Relative(rel)
- , Expression(e)
+ , Relative(std::move(rel))
+ , Expression(std::move(e))
{
}
bool operator<(const CacheEntryKey& r) const;
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index fff99b8..b8626ab 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -97,6 +97,8 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm)
this->ConfigureDoneCMP0026AndCMP0024 = false;
this->FirstTimeProgress = 0.0f;
+ this->RecursionDepth = 0;
+
cm->GetState()->SetIsGeneratorMultiConfig(false);
cm->GetState()->SetMinGWMake(false);
cm->GetState()->SetMSYSShell(false);
@@ -352,8 +354,7 @@ bool cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
}
if (!mf->GetDefinition("CMAKE_MAKE_PROGRAM") ||
cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
- std::string setMakeProgram =
- mf->GetModulesFile(this->FindMakeProgramFile.c_str());
+ std::string setMakeProgram = mf->GetModulesFile(this->FindMakeProgramFile);
if (!setMakeProgram.empty()) {
mf->ReadListFile(setMakeProgram);
}
@@ -364,7 +365,7 @@ bool cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
err << "CMake was unable to find a build program corresponding to \""
<< this->GetName() << "\". CMAKE_MAKE_PROGRAM is not set. You "
<< "probably need to select a different build tool.";
- cmSystemTools::Error(err.str().c_str());
+ cmSystemTools::Error(err.str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -463,11 +464,10 @@ void cmGlobalGenerator::EnableLanguage(
if (this->TryCompileOuterMakefile) {
// In a try-compile we can only enable languages provided by caller.
- for (std::string const& li : languages) {
- if (li == "NONE") {
+ for (std::string const& lang : languages) {
+ if (lang == "NONE") {
this->SetLanguageEnabled("NONE", mf);
} else {
- const char* lang = li.c_str();
if (this->LanguagesReady.find(lang) == this->LanguagesReady.end()) {
std::ostringstream e;
e << "The test project needs language " << lang
@@ -485,7 +485,7 @@ void cmGlobalGenerator::EnableLanguage(
mf->AddDefinition("RUN_CONFIGURE", true);
std::string rootBin = this->CMakeInstance->GetHomeOutputDirectory();
- rootBin += cmake::GetCMakeFilesDirectory();
+ rootBin += "/CMakeFiles";
// If the configuration files path has been set,
// then we are in a try compile and need to copy the enable language
@@ -615,10 +615,9 @@ void cmGlobalGenerator::EnableLanguage(
// load the CMakeDetermine(LANG)Compiler.cmake file to find
// the compiler
- for (std::string const& l : languages) {
- const char* lang = l.c_str();
+ for (std::string const& lang : languages) {
needSetLanguageEnabledMaps[lang] = false;
- if (l == "NONE") {
+ if (lang == "NONE") {
this->SetLanguageEnabled("NONE", mf);
continue;
}
@@ -660,8 +659,7 @@ void cmGlobalGenerator::EnableLanguage(
std::string determineCompiler = "CMakeDetermine";
determineCompiler += lang;
determineCompiler += "Compiler.cmake";
- std::string determineFile =
- mf->GetModulesFile(determineCompiler.c_str());
+ std::string determineFile = mf->GetModulesFile(determineCompiler);
if (!mf->ReadListFile(determineFile)) {
cmSystemTools::Error("Could not find cmake module file: ",
determineCompiler.c_str());
@@ -720,9 +718,8 @@ void cmGlobalGenerator::EnableLanguage(
}
// loop over languages again loading CMake(LANG)Information.cmake
//
- for (std::string const& l : languages) {
- const char* lang = l.c_str();
- if (l == "NONE") {
+ for (std::string const& lang : languages) {
+ if (lang == "NONE") {
this->SetLanguageEnabled("NONE", mf);
continue;
}
@@ -743,7 +740,7 @@ void cmGlobalGenerator::EnableLanguage(
"No " << compilerName << " could be found.\n"
;
/* clang-format on */
- } else if (strcmp(lang, "RC") != 0 && strcmp(lang, "ASM_MASM") != 0) {
+ } else if ((lang != "RC") && (lang != "ASM_MASM")) {
if (!cmSystemTools::FileIsFullPath(compilerFile)) {
/* clang-format off */
noCompiler <<
@@ -789,7 +786,7 @@ void cmGlobalGenerator::EnableLanguage(
fpath = "CMake";
fpath += lang;
fpath += "Information.cmake";
- std::string informationFile = mf->GetModulesFile(fpath.c_str());
+ std::string informationFile = mf->GetModulesFile(fpath);
if (informationFile.empty()) {
cmSystemTools::Error("Could not find cmake module file: ",
fpath.c_str());
@@ -813,7 +810,7 @@ void cmGlobalGenerator::EnableLanguage(
std::string testLang = "CMakeTest";
testLang += lang;
testLang += "Compiler.cmake";
- std::string ifpath = mf->GetModulesFile(testLang.c_str());
+ std::string ifpath = mf->GetModulesFile(testLang);
if (!mf->ReadListFile(ifpath)) {
cmSystemTools::Error("Could not find cmake module file: ",
testLang.c_str());
@@ -1062,7 +1059,7 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l,
if (preference < 0) {
std::string msg = linkerPrefVar;
msg += " is negative, adjusting it to 0";
- cmSystemTools::Message(msg.c_str(), "Warning");
+ cmSystemTools::Message(msg, "Warning");
preference = 0;
}
@@ -1170,6 +1167,7 @@ void cmGlobalGenerator::Configure()
this->CMakeInstance->GetHomeOutputDirectory());
cmMakefile* dirMf = new cmMakefile(this, snapshot);
+ dirMf->SetRecursionDepth(this->RecursionDepth);
this->Makefiles.push_back(dirMf);
this->IndexMakefile(dirMf);
@@ -1214,7 +1212,7 @@ void cmGlobalGenerator::Configure()
const char* logs[] = { "CMakeOutput.log", "CMakeError.log", nullptr };
for (const char** log = logs; *log; ++log) {
std::string f = this->CMakeInstance->GetHomeOutputDirectory();
- f += cmake::GetCMakeFilesDirectory();
+ f += "/CMakeFiles";
f += "/";
f += *log;
if (cmSystemTools::FileExists(f)) {
@@ -1286,7 +1284,7 @@ bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const
<< "duplicate custom targets. "
<< "Consider using a Makefiles generator or fix the project to not "
<< "use duplicate target names.";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return false;
}
@@ -2000,7 +1998,7 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen)
this->ConfiguredFilesPath = gen->ConfiguredFilesPath;
} else {
this->ConfiguredFilesPath = gen->CMakeInstance->GetHomeOutputDirectory();
- this->ConfiguredFilesPath += cmake::GetCMakeFilesDirectory();
+ this->ConfiguredFilesPath += "/CMakeFiles";
}
}
@@ -2034,17 +2032,10 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
return this->IsExcluded(rootSnp, snp);
}
-bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
- cmGeneratorTarget* target) const
+bool cmGlobalGenerator::IsExcluded(cmGeneratorTarget* target) const
{
- if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
- target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
- // This target is excluded from its directory.
- return true;
- }
- // This target is included in its directory. Check whether the
- // directory is excluded.
- return this->IsExcluded(root, target->GetLocalGenerator());
+ return target->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
+ target->GetPropertyAsBool("EXCLUDE_FROM_ALL");
}
void cmGlobalGenerator::GetEnabledLanguages(
@@ -2618,8 +2609,7 @@ std::string cmGlobalGenerator::GenerateRuleFile(
ruleFile += ".rule";
const char* dir = this->GetCMakeCFGIntDir();
if (dir && dir[0] == '$') {
- cmSystemTools::ReplaceString(ruleFile, dir,
- cmake::GetCMakeFilesDirectory());
+ cmSystemTools::ReplaceString(ruleFile, dir, "/CMakeFiles");
}
return ruleFile;
}
@@ -2821,7 +2811,7 @@ void cmGlobalGenerator::CheckRuleHashes()
#if defined(CMAKE_BUILD_WITH_CMAKE)
std::string home = this->GetCMakeInstance()->GetHomeOutputDirectory();
std::string pfile = home;
- pfile += cmake::GetCMakeFilesDirectory();
+ pfile += "/CMakeFiles";
pfile += "/CMakeRuleHashes.txt";
this->CheckRuleHashes(pfile, home);
this->WriteRuleHashes(pfile);
@@ -2861,7 +2851,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile,
if (strncmp(line.c_str(), rhi->second.Data, 32) != 0) {
// The rule has changed. Delete the output so it will be
// built again.
- fname = cmSystemTools::CollapseFullPath(fname, home.c_str());
+ fname = cmSystemTools::CollapseFullPath(fname, home);
cmSystemTools::RemoveFile(fname);
}
} else {
@@ -2871,7 +2861,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile,
// Instead, we keep the rule hash as long as the file exists so
// that if the feature is turned back on and the rule has
// changed the file is still rebuilt.
- std::string fpath = cmSystemTools::CollapseFullPath(fname, home.c_str());
+ std::string fpath = cmSystemTools::CollapseFullPath(fname, home);
if (cmSystemTools::FileExists(fpath)) {
RuleHash hash;
memcpy(hash.Data, line.c_str(), 32);
@@ -2900,7 +2890,7 @@ void cmGlobalGenerator::WriteSummary()
{
// Record all target directories in a central location.
std::string fname = this->CMakeInstance->GetHomeOutputDirectory();
- fname += cmake::GetCMakeFilesDirectory();
+ fname += "/CMakeFiles";
fname += "/TargetDirectories.txt";
cmGeneratedFileStream fout(fname);
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 36d3d10..84ec7a9 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -432,6 +432,8 @@ public:
std::string MakeSilentFlag;
+ int RecursionDepth;
+
protected:
typedef std::vector<cmLocalGenerator*> GeneratorVector;
// for a project collect all its targets by following depend
@@ -468,7 +470,7 @@ protected:
bool IsExcluded(cmStateSnapshot const& root,
cmStateSnapshot const& snp) const;
bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const;
- bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const;
+ bool IsExcluded(cmGeneratorTarget* target) const;
virtual void InitializeProgressMarks() {}
struct GlobalTargetInfo
diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h
index 4e3e770..d4f772b 100644
--- a/Source/cmGlobalGeneratorFactory.h
+++ b/Source/cmGlobalGeneratorFactory.h
@@ -30,13 +30,20 @@ public:
virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
/** Get the names of the current registered generators */
- virtual void GetGenerators(std::vector<std::string>& names) const = 0;
+ virtual std::vector<std::string> GetGeneratorNames() const = 0;
+ virtual std::vector<std::string> GetGeneratorNamesWithPlatform() const = 0;
/** Determine whether or not this generator supports toolsets */
virtual bool SupportsToolset() const = 0;
/** Determine whether or not this generator supports platforms */
virtual bool SupportsPlatform() const = 0;
+
+ /** Get the list of supported platforms name for this generator */
+ virtual std::vector<std::string> GetKnownPlatforms() const = 0;
+
+ /** If the generator suports platforms, get its default. */
+ virtual std::string GetDefaultPlatformName() const = 0;
};
template <class T>
@@ -60,9 +67,15 @@ public:
}
/** Get the names of the current registered generators */
- void GetGenerators(std::vector<std::string>& names) const override
+ std::vector<std::string> GetGeneratorNames() const override
{
+ std::vector<std::string> names;
names.push_back(T::GetActualName());
+ return names;
+ }
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ return std::vector<std::string>();
}
/** Determine whether or not this generator supports toolsets */
@@ -70,6 +83,15 @@ public:
/** Determine whether or not this generator supports platforms */
bool SupportsPlatform() const override { return T::SupportsPlatform(); }
+
+ /** Get the list of supported platforms name for this generator */
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ // default is no platform supported
+ return std::vector<std::string>();
+ }
+
+ std::string GetDefaultPlatformName() const override { return std::string(); }
};
#endif
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index ff4c3a3..5720502 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -70,7 +70,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
"Green Hills MULTI: -T <toolset> not specified; defaulting to \"";
message += tsp;
message += "\"";
- cmSystemTools::Message(message.c_str());
+ cmSystemTools::Message(message);
/* store the full toolset for later use
* -- already done if -T<toolset> was specified
@@ -93,7 +93,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
message += prevTool;
message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
"directory or choose a different binary directory.";
- cmSystemTools::Error(message.c_str());
+ cmSystemTools::Error(message);
return false;
} else {
/* store the toolset that is being used for this build */
@@ -178,7 +178,7 @@ void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsd,
if (output.empty()) {
std::string msg =
"No GHS toolsets found in GHS_TOOLSET_ROOT \"" + tsd + "\".";
- cmSystemTools::Error(msg.c_str());
+ cmSystemTools::Error(msg);
tsd = "";
} else {
tsd += output.back();
@@ -189,7 +189,7 @@ void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsd,
tryPath = cmSystemTools::CollapseCombinedPath(tsd, ts);
if (!cmSystemTools::FileExists(tryPath)) {
std::string msg = "GHS toolset \"" + tryPath + "\" not found.";
- cmSystemTools::Error(msg.c_str());
+ cmSystemTools::Error(msg);
tsd = "";
} else {
tsd = tryPath;
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 00fa348..f1ab852 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -331,9 +331,9 @@ public:
return LocalGenerators;
}
- bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target)
+ bool IsExcluded(cmGeneratorTarget* target)
{
- return cmGlobalGenerator::IsExcluded(root, target);
+ return cmGlobalGenerator::IsExcluded(target);
}
int GetRuleCmdLength(const std::string& name) { return RuleCmdLength[name]; }
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 9d176c3..3ca2b17 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -146,7 +146,7 @@ void cmGlobalUnixMakefileGenerator3::Generate()
for (cmLocalGenerator* lg : this->LocalGenerators) {
std::string markFileName = lg->GetCurrentBinaryDirectory();
markFileName += "/";
- markFileName += cmake::GetCMakeFilesDirectory();
+ markFileName += "/CMakeFiles";
markFileName += "/progress.marks";
cmGeneratedFileStream markFile(markFileName);
markFile << this->CountProgressMarksInAll(lg) << "\n";
@@ -196,7 +196,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
// see if the build system must be regenerated.
std::string makefileName =
this->GetCMakeInstance()->GetHomeOutputDirectory();
- makefileName += cmake::GetCMakeFilesDirectory();
+ makefileName += "/CMakeFiles";
makefileName += "/Makefile2";
cmGeneratedFileStream makefileStream(makefileName, false,
this->GetMakefileEncoding());
@@ -268,7 +268,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
// see if the build system must be regenerated.
std::string cmakefileName =
this->GetCMakeInstance()->GetHomeOutputDirectory();
- cmakefileName += cmake::GetCMakeFilesDirectory();
+ cmakefileName += "/CMakeFiles";
cmakefileName += "/Makefile.cmake";
cmGeneratedFileStream cmakefileStream(cmakefileName);
if (!cmakefileStream) {
@@ -333,7 +333,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
// Build the path to the cache check file.
std::string check = this->GetCMakeInstance()->GetHomeOutputDirectory();
- check += cmake::GetCMakeFilesDirectory();
+ check += "/CMakeFiles";
check += "/cmake.check_cache";
// Set the corresponding makefile in the cmake file.
@@ -367,7 +367,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
for (cmLocalGenerator* localGen : this->LocalGenerators) {
lg = static_cast<cmLocalUnixMakefileGenerator3*>(localGen);
tmpStr = lg->GetCurrentBinaryDirectory();
- tmpStr += cmake::GetCMakeFilesDirectory();
+ tmpStr += "/CMakeFiles";
tmpStr += "/CMakeDirectoryInformation.cmake";
cmakefileStream << " \""
<< lg->MaybeConvertToRelativePath(binDir, tmpStr)
@@ -577,9 +577,9 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules(
// Write the rule.
commands.clear();
- std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
+ std::string tmp = "CMakeFiles/";
tmp += "Makefile2";
- commands.push_back(lg->GetRecursiveMakeCall(tmp.c_str(), name));
+ commands.push_back(lg->GetRecursiveMakeCall(tmp, name));
depends.clear();
if (regenerate) {
depends.emplace_back("cmake_check_build_system");
@@ -599,7 +599,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules(
localName = name;
localName += "/fast";
commands.push_back(
- lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
+ lg->GetRecursiveMakeCall(makefileName, makeTargetName));
lg->WriteMakeRule(ruleFileStream, "fast build rule for target.",
localName, depends, commands, true);
@@ -613,7 +613,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules(
depends.clear();
commands.clear();
commands.push_back(
- lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
+ lg->GetRecursiveMakeCall(makefileName, makeTargetName));
lg->WriteMakeRule(ruleFileStream,
"Manual pre-install relink rule for target.",
localName, depends, commands, true);
@@ -664,12 +664,12 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
makeTargetName = localName;
makeTargetName += "/depend";
commands.push_back(
- lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
+ lg->GetRecursiveMakeCall(makefileName, makeTargetName));
makeTargetName = localName;
makeTargetName += "/build";
commands.push_back(
- lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
+ lg->GetRecursiveMakeCall(makefileName, makeTargetName));
// Write the rule.
localName += "/all";
@@ -677,7 +677,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
cmLocalUnixMakefileGenerator3::EchoProgress progress;
progress.Dir = lg->GetBinaryDirectory();
- progress.Dir += cmake::GetCMakeFilesDirectory();
+ progress.Dir += "/CMakeFiles";
{
std::ostringstream progressArg;
const char* sep = "";
@@ -707,7 +707,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
localName, depends, commands, true);
// add the all/all dependency
- if (!this->IsExcluded(this->LocalGenerators[0], gtarget)) {
+ if (!this->IsExcluded(gtarget)) {
depends.clear();
depends.push_back(localName);
commands.clear();
@@ -731,9 +731,9 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
progCmd << " " << this->CountProgressMarksInTarget(gtarget, emitted);
commands.push_back(progCmd.str());
}
- std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
+ std::string tmp = "CMakeFiles/";
tmp += "Makefile2";
- commands.push_back(lg->GetRecursiveMakeCall(tmp.c_str(), localName));
+ commands.push_back(lg->GetRecursiveMakeCall(tmp, localName));
{
std::ostringstream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
@@ -766,13 +766,12 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
localName += "/preinstall";
depends.clear();
commands.clear();
- commands.push_back(
- lg->GetRecursiveMakeCall(makefileName.c_str(), localName));
+ commands.push_back(lg->GetRecursiveMakeCall(makefileName, localName));
lg->WriteMakeRule(ruleFileStream,
"Pre-install relink rule for target.", localName,
depends, commands, true);
- if (!this->IsExcluded(this->LocalGenerators[0], gtarget)) {
+ if (!this->IsExcluded(gtarget)) {
depends.clear();
depends.push_back(localName);
commands.clear();
@@ -788,7 +787,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
depends.clear();
commands.clear();
commands.push_back(
- lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
+ lg->GetRecursiveMakeCall(makefileName, makeTargetName));
lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
makeTargetName, depends, commands, true);
commands.clear();
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 79757a8..99e9173 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -74,15 +74,34 @@ public:
"Optional [arch] can be \"Win64\" or \"IA64\".";
}
- void GetGenerators(std::vector<std::string>& names) const override
+ std::vector<std::string> GetGeneratorNames() const override
{
+ std::vector<std::string> names;
names.push_back(vs10generatorName);
+ return names;
+ }
+
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ std::vector<std::string> names;
names.push_back(vs10generatorName + std::string(" IA64"));
names.push_back(vs10generatorName + std::string(" Win64"));
+ return names;
}
bool SupportsToolset() const override { return true; }
bool SupportsPlatform() const override { return true; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ std::vector<std::string> platforms;
+ platforms.emplace_back("x64");
+ platforms.emplace_back("Win32");
+ platforms.emplace_back("Itanium");
+ return platforms;
+ }
+
+ std::string GetDefaultPlatformName() const override { return "Win32"; }
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory()
@@ -588,10 +607,26 @@ cmGlobalVisualStudio10Generator::GetPlatformToolsetVersionString() const
const char*
cmGlobalVisualStudio10Generator::GetPlatformToolsetHostArchitecture() const
{
+ std::string const& hostArch =
+ this->GetPlatformToolsetHostArchitectureString();
+ if (hostArch.empty()) {
+ return nullptr;
+ }
+ return hostArch.c_str();
+}
+
+std::string const&
+cmGlobalVisualStudio10Generator::GetPlatformToolsetHostArchitectureString()
+ const
+{
if (!this->GeneratorToolsetHostArchitecture.empty()) {
- return this->GeneratorToolsetHostArchitecture.c_str();
+ return this->GeneratorToolsetHostArchitecture;
}
- return nullptr;
+ if (!this->DefaultPlatformToolsetHostArchitecture.empty()) {
+ return this->DefaultPlatformToolsetHostArchitecture;
+ }
+ static std::string const empty;
+ return empty;
}
const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetCuda() const
@@ -687,7 +722,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
wd = this->ConfiguredFilesPath;
} else {
wd = this->GetCMakeInstance()->GetHomeOutputDirectory();
- wd += cmake::GetCMakeFilesDirectory();
+ wd += "/CMakeFiles";
}
wd += "/";
wd += cmVersion::GetCMakeVersion();
@@ -767,10 +802,9 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
}
cmXMLElement(eprj, "Import")
.Attribute("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props");
- if (!this->GeneratorToolsetHostArchitecture.empty()) {
+ if (const char* hostArch = this->GetPlatformToolsetHostArchitecture()) {
cmXMLElement epg(eprj, "PropertyGroup");
- cmXMLElement(epg, "PreferredToolArchitecture")
- .Content(this->GeneratorToolsetHostArchitecture);
+ cmXMLElement(epg, "PreferredToolArchitecture").Content(hostArch);
}
{
cmXMLElement epg(eprj, "PropertyGroup");
@@ -986,7 +1020,7 @@ std::string cmGlobalVisualStudio10Generator::GenerateRuleFile(
// The VS 10 generator needs to create the .rule files on disk.
// Hide them away under the CMakeFiles directory.
std::string ruleDir = this->GetCMakeInstance()->GetHomeOutputDirectory();
- ruleDir += cmake::GetCMakeFilesDirectory();
+ ruleDir += "/CMakeFiles";
ruleDir += "/";
ruleDir += cmSystemTools::ComputeStringMD5(
cmSystemTools::GetFilenamePath(output).c_str());
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 7c8918a..f496357 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -58,6 +58,7 @@ public:
/** The toolset host architecture name (e.g. x64 for 64-bit host tools). */
const char* GetPlatformToolsetHostArchitecture() const;
+ std::string const& GetPlatformToolsetHostArchitectureString() const;
/** The cuda toolset version. */
const char* GetPlatformToolsetCuda() const;
@@ -152,6 +153,7 @@ protected:
std::string GeneratorToolsetHostArchitecture;
std::string GeneratorToolsetCuda;
std::string DefaultPlatformToolset;
+ std::string DefaultPlatformToolsetHostArchitecture;
std::string WindowsTargetPlatformVersion;
std::string SystemName;
std::string SystemVersion;
diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx
index 36eb492..4eb78ba 100644
--- a/Source/cmGlobalVisualStudio11Generator.cxx
+++ b/Source/cmGlobalVisualStudio11Generator.cxx
@@ -69,9 +69,16 @@ public:
"Optional [arch] can be \"Win64\" or \"ARM\".";
}
- void GetGenerators(std::vector<std::string>& names) const override
+ std::vector<std::string> GetGeneratorNames() const override
{
+ std::vector<std::string> names;
names.push_back(vs11generatorName);
+ return names;
+ }
+
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ std::vector<std::string> names;
names.push_back(vs11generatorName + std::string(" ARM"));
names.push_back(vs11generatorName + std::string(" Win64"));
@@ -80,10 +87,30 @@ public:
for (std::string const& i : installedSDKs) {
names.push_back(std::string(vs11generatorName) + " " + i);
}
+
+ return names;
}
bool SupportsToolset() const override { return true; }
bool SupportsPlatform() const override { return true; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ std::vector<std::string> platforms;
+ platforms.emplace_back("x64");
+ platforms.emplace_back("Win32");
+ platforms.emplace_back("ARM");
+
+ std::set<std::string> installedSDKs =
+ cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs();
+ for (std::string const& i : installedSDKs) {
+ platforms.emplace_back(i);
+ }
+
+ return platforms;
+ }
+
+ std::string GetDefaultPlatformName() const override { return "Win32"; }
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory()
diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx
index 61034a7..d9702c9 100644
--- a/Source/cmGlobalVisualStudio12Generator.cxx
+++ b/Source/cmGlobalVisualStudio12Generator.cxx
@@ -58,15 +58,34 @@ public:
"Optional [arch] can be \"Win64\" or \"ARM\".";
}
- void GetGenerators(std::vector<std::string>& names) const override
+ std::vector<std::string> GetGeneratorNames() const override
{
+ std::vector<std::string> names;
names.push_back(vs12generatorName);
+ return names;
+ }
+
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ std::vector<std::string> names;
names.push_back(vs12generatorName + std::string(" ARM"));
names.push_back(vs12generatorName + std::string(" Win64"));
+ return names;
}
bool SupportsToolset() const override { return true; }
bool SupportsPlatform() const override { return true; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ std::vector<std::string> platforms;
+ platforms.emplace_back("x64");
+ platforms.emplace_back("Win32");
+ platforms.emplace_back("ARM");
+ return platforms;
+ }
+
+ std::string GetDefaultPlatformName() const override { return "Win32"; }
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory()
@@ -107,8 +126,8 @@ bool cmGlobalVisualStudio12Generator::MatchesGeneratorName(
bool cmGlobalVisualStudio12Generator::ProcessGeneratorToolsetField(
std::string const& key, std::string const& value)
{
- if (key == "host" && value == "x64") {
- this->GeneratorToolsetHostArchitecture = "x64";
+ if (key == "host" && (value == "x64" || value == "x86")) {
+ this->GeneratorToolsetHostArchitecture = value;
return true;
}
return this->cmGlobalVisualStudio11Generator::ProcessGeneratorToolsetField(
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index 5ea5e67..a0a9558 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -58,15 +58,34 @@ public:
"Optional [arch] can be \"Win64\" or \"ARM\".";
}
- void GetGenerators(std::vector<std::string>& names) const override
+ std::vector<std::string> GetGeneratorNames() const override
{
+ std::vector<std::string> names;
names.push_back(vs14generatorName);
+ return names;
+ }
+
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ std::vector<std::string> names;
names.push_back(vs14generatorName + std::string(" ARM"));
names.push_back(vs14generatorName + std::string(" Win64"));
+ return names;
}
bool SupportsToolset() const override { return true; }
bool SupportsPlatform() const override { return true; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ std::vector<std::string> platforms;
+ platforms.emplace_back("x64");
+ platforms.emplace_back("Win32");
+ platforms.emplace_back("ARM");
+ return platforms;
+ }
+
+ std::string GetDefaultPlatformName() const override { return "Win32"; }
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory()
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 16796cf..8e67fad 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -149,7 +149,7 @@ void cmGlobalVisualStudio71Generator::WriteProjectDepends(
m += target->GetName();
m += " depends on unknown target: ";
m += name;
- cmSystemTools::Error(m.c_str());
+ cmSystemTools::Error(m);
}
fout << "\t\t{" << guid << "} = {" << guid << "}\n";
}
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index 4d165c2..f6db018 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -117,7 +117,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
// Create a list of all stamp files for this project.
std::vector<std::string> stamps;
- std::string stampList = cmake::GetCMakeFilesDirectoryPostSlash();
+ std::string stampList = "CMakeFiles/";
stampList += cmGlobalVisualStudio8Generator::GetGenerateStampList();
{
std::string stampListFile =
@@ -129,7 +129,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
for (cmLocalGenerator const* gi : generators) {
stampFile = gi->GetMakefile()->GetCurrentBinaryDirectory();
stampFile += "/";
- stampFile += cmake::GetCMakeFilesDirectoryPostSlash();
+ stampFile += "CMakeFiles/";
stampFile += "generate.stamp";
fout << stampFile << "\n";
stamps.push_back(stampFile);
diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx
index 445b40c..6e61d26 100644
--- a/Source/cmGlobalVisualStudio9Generator.cxx
+++ b/Source/cmGlobalVisualStudio9Generator.cxx
@@ -59,9 +59,16 @@ public:
"Optional [arch] can be \"Win64\" or \"IA64\".";
}
- void GetGenerators(std::vector<std::string>& names) const override
+ std::vector<std::string> GetGeneratorNames() const override
{
+ std::vector<std::string> names;
names.push_back(vs9generatorName);
+ return names;
+ }
+
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ std::vector<std::string> names;
names.push_back(vs9generatorName + std::string(" Win64"));
names.push_back(vs9generatorName + std::string(" IA64"));
cmVisualStudioWCEPlatformParser parser;
@@ -71,10 +78,29 @@ public:
for (std::string const& i : availablePlatforms) {
names.push_back("Visual Studio 9 2008 " + i);
}
+ return names;
}
bool SupportsToolset() const override { return false; }
bool SupportsPlatform() const override { return true; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ std::vector<std::string> platforms;
+ platforms.emplace_back("x64");
+ platforms.emplace_back("Win32");
+ platforms.emplace_back("Itanium");
+ cmVisualStudioWCEPlatformParser parser;
+ parser.ParseVersion("9.0");
+ const std::vector<std::string>& availablePlatforms =
+ parser.GetAvailablePlatforms();
+ for (std::string const& i : availablePlatforms) {
+ platforms.emplace_back(i);
+ }
+ return platforms;
+ }
+
+ std::string GetDefaultPlatformName() const override { return "Win32"; }
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 41d961c..e3dd2f9 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -201,7 +201,7 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
tgt->IsImported()) {
continue;
}
- if (!this->IsExcluded(gen[0], tgt)) {
+ if (!this->IsExcluded(tgt)) {
allBuild->AddUtility(tgt->GetName());
}
}
@@ -268,7 +268,7 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros()
std::ostringstream oss;
oss << "Could not copy from: " << src << std::endl;
oss << " to: " << dst << std::endl;
- cmSystemTools::Message(oss.str().c_str(), "Warning");
+ cmSystemTools::Message(oss.str(), "Warning");
}
}
@@ -783,7 +783,7 @@ void RegisterVisualStudioMacros(const std::string& macrosFile,
<< "CMake needs to register Visual Studio macros when its macros"
<< " file is updated or when it detects that its current macros file"
<< " is no longer registered with Visual Studio." << std::endl;
- cmSystemTools::Message(oss.str().c_str(), "Warning");
+ cmSystemTools::Message(oss.str(), "Warning");
// Count them again now that the warning is over. In the case of a GUI
// warning, the user may have gone to close Visual Studio and then come
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
index 99f9503..bc6b453 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
@@ -10,15 +10,46 @@
#include "cmake.h"
#if defined(_M_ARM64)
-# define HOST_PLATFORM_NAME "ARM64";
+# define HOST_PLATFORM_NAME "ARM64"
+# define HOST_TOOLS_ARCH ""
#elif defined(_M_ARM)
-# define HOST_PLATFORM_NAME "ARM";
+# define HOST_PLATFORM_NAME "ARM"
+# define HOST_TOOLS_ARCH ""
#elif defined(_M_IA64)
-# define HOST_PLATFORM_NAME "Itanium";
+# define HOST_PLATFORM_NAME "Itanium"
+# define HOST_TOOLS_ARCH ""
#else
# include "cmsys/SystemInformation.hxx"
#endif
+static std::string VSHostPlatformName()
+{
+#ifdef HOST_PLATFORM_NAME
+ return HOST_PLATFORM_NAME;
+#else
+ cmsys::SystemInformation info;
+ if (info.Is64Bits()) {
+ return "x64";
+ } else {
+ return "Win32";
+ }
+#endif
+}
+
+static std::string VSHostArchitecture()
+{
+#ifdef HOST_TOOLS_ARCH
+ return HOST_TOOLS_ARCH;
+#else
+ cmsys::SystemInformation info;
+ if (info.Is64Bits()) {
+ return "x64";
+ } else {
+ return "x86";
+ }
+#endif
+}
+
static unsigned int VSVersionToMajor(
cmGlobalVisualStudioGenerator::VSVersion v)
{
@@ -58,8 +89,7 @@ static const char* VSVersionToToolset(
case cmGlobalVisualStudioGenerator::VS15:
return "v141";
case cmGlobalVisualStudioGenerator::VS16:
- // FIXME: VS 2019 Preview 1.1 uses v141 but preview 2 will use v142.
- return "v141";
+ return "v142";
}
return "";
}
@@ -118,15 +148,35 @@ public:
"Optional [arch] can be \"Win64\" or \"ARM\".";
}
- void GetGenerators(std::vector<std::string>& names) const override
+ std::vector<std::string> GetGeneratorNames() const override
{
+ std::vector<std::string> names;
names.push_back(vs15generatorName);
+ return names;
+ }
+
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ std::vector<std::string> names;
names.push_back(vs15generatorName + std::string(" ARM"));
names.push_back(vs15generatorName + std::string(" Win64"));
+ return names;
}
bool SupportsToolset() const override { return true; }
bool SupportsPlatform() const override { return true; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ std::vector<std::string> platforms;
+ platforms.emplace_back("x64");
+ platforms.emplace_back("Win32");
+ platforms.emplace_back("ARM");
+ platforms.emplace_back("ARM64");
+ return platforms;
+ }
+
+ std::string GetDefaultPlatformName() const override { return "Win32"; }
};
cmGlobalGeneratorFactory*
@@ -178,13 +228,35 @@ public:
"Use -A option to specify architecture.";
}
- virtual void GetGenerators(std::vector<std::string>& names) const
+ std::vector<std::string> GetGeneratorNames() const override
{
+ std::vector<std::string> names;
names.push_back(vs16generatorName);
+ return names;
+ }
+
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ return std::vector<std::string>();
}
bool SupportsToolset() const override { return true; }
bool SupportsPlatform() const override { return true; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ std::vector<std::string> platforms;
+ platforms.emplace_back("x64");
+ platforms.emplace_back("Win32");
+ platforms.emplace_back("ARM");
+ platforms.emplace_back("ARM64");
+ return platforms;
+ }
+
+ std::string GetDefaultPlatformName() const override
+ {
+ return VSHostPlatformName();
+ }
};
cmGlobalGeneratorFactory*
@@ -206,16 +278,8 @@ cmGlobalVisualStudioVersionedGenerator::cmGlobalVisualStudioVersionedGenerator(
this->DefaultCSharpFlagTableName = VSVersionToToolset(this->Version);
this->DefaultLinkFlagTableName = VSVersionToToolset(this->Version);
if (this->Version >= cmGlobalVisualStudioGenerator::VS16) {
-#ifdef HOST_PLATFORM_NAME
- this->DefaultPlatformName = HOST_PLATFORM_NAME;
-#else
- cmsys::SystemInformation info;
- if (info.Is64Bits()) {
- this->DefaultPlatformName = "x64";
- } else {
- this->DefaultPlatformName = "Win32";
- }
-#endif
+ this->DefaultPlatformName = VSHostPlatformName();
+ this->DefaultPlatformToolsetHostArchitecture = VSHostArchitecture();
}
}
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 3d6f36e..35a09a7 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -133,13 +133,27 @@ public:
cmGlobalXCodeGenerator::GetDocumentation(entry);
}
- void GetGenerators(std::vector<std::string>& names) const override
+ std::vector<std::string> GetGeneratorNames() const override
{
+ std::vector<std::string> names;
names.push_back(cmGlobalXCodeGenerator::GetActualName());
+ return names;
+ }
+
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ return std::vector<std::string>();
}
bool SupportsToolset() const override { return true; }
bool SupportsPlatform() const override { return false; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ return std::vector<std::string>();
+ }
+
+ std::string GetDefaultPlatformName() const override { return std::string(); }
};
cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(
@@ -177,12 +191,14 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator(
std::string versionFile;
{
std::string out;
- std::string::size_type pos = 0;
- if (cmSystemTools::RunSingleCommand("xcode-select --print-path", &out,
- nullptr, nullptr, nullptr,
- cmSystemTools::OUTPUT_NONE) &&
- (pos = out.find(".app/"), pos != std::string::npos)) {
- versionFile = out.substr(0, pos + 5) + "Contents/version.plist";
+ bool commandResult = cmSystemTools::RunSingleCommand(
+ "xcode-select --print-path", &out, nullptr, nullptr, nullptr,
+ cmSystemTools::OUTPUT_NONE);
+ if (commandResult) {
+ std::string::size_type pos = out.find(".app/");
+ if (pos != std::string::npos) {
+ versionFile = out.substr(0, pos + 5) + "Contents/version.plist";
+ }
}
}
if (!versionFile.empty() && cmSystemTools::FileExists(versionFile.c_str())) {
@@ -522,10 +538,6 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
// now make the allbuild depend on all the non-utility targets
// in the project
for (auto& gen : gens) {
- if (this->IsExcluded(root, gen)) {
- continue;
- }
-
for (auto target : gen->GetGeneratorTargets()) {
if (target->GetType() == cmStateEnums::GLOBAL_TARGET) {
continue;
@@ -558,8 +570,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
false, "", false, cmMakefile::AcceptObjectLibraryCommands);
}
- if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
- !target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
+ if (!this->IsExcluded(target)) {
allbuild->AddUtility(target->GetName());
}
}
@@ -607,7 +618,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
std::string checkCache = root->GetBinaryDirectory();
checkCache += "/";
- checkCache += cmake::GetCMakeFilesDirectoryPostSlash();
+ checkCache += "CMakeFiles/";
checkCache += "cmake.check_cache";
if (cm->DoWriteGlobVerifyTarget()) {
@@ -1397,7 +1408,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
// language.
cmMakefile* mf = gtgt->Target->GetMakefile();
std::string fname = gtgt->GetLocalGenerator()->GetCurrentBinaryDirectory();
- fname += cmake::GetCMakeFilesDirectory();
+ fname += "/CMakeFiles";
fname += "/";
fname += gtgt->GetName();
fname += "-CMakeForceLinker";
@@ -3705,7 +3716,7 @@ std::string cmGlobalXCodeGenerator::ComputeInfoPListLocation(
cmGeneratorTarget* target)
{
std::string plist = target->GetLocalGenerator()->GetCurrentBinaryDirectory();
- plist += cmake::GetCMakeFilesDirectory();
+ plist += "/CMakeFiles";
plist += "/";
plist += target->GetName();
plist += ".dir/Info.plist";
diff --git a/Source/cmGraphAdjacencyList.h b/Source/cmGraphAdjacencyList.h
index fb2eee2..5ca9269 100644
--- a/Source/cmGraphAdjacencyList.h
+++ b/Source/cmGraphAdjacencyList.h
@@ -7,6 +7,7 @@
#include "cmListFileCache.h"
+#include <utility>
#include <vector>
/**
@@ -17,10 +18,10 @@
class cmGraphEdge
{
public:
- cmGraphEdge(int n, bool s, cmListFileBacktrace const& bt)
+ cmGraphEdge(int n, bool s, cmListFileBacktrace bt)
: Dest(n)
, Strong(s)
- , Backtrace(bt)
+ , Backtrace(std::move(bt))
{
}
operator int() const { return this->Dest; }
diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx
index a67d09e..0d608bb 100644
--- a/Source/cmIncludeCommand.cxx
+++ b/Source/cmIncludeCommand.cxx
@@ -67,7 +67,7 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args,
// Not a path. Maybe module.
std::string module = fname;
module += ".cmake";
- std::string mfile = this->Makefile->GetModulesFile(module.c_str());
+ std::string mfile = this->Makefile->GetModulesFile(module);
if (!mfile.empty()) {
fname = mfile;
}
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index c6f4064..8ef6441 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -712,7 +712,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
std::ostringstream e;
e << "INSTALL TARGETS - target " << target.GetName() << " has "
<< "RESOURCE files but no RESOURCE DESTINATION.";
- cmSystemTools::Message(e.str().c_str(), "Warning");
+ cmSystemTools::Message(e.str(), "Warning");
}
}
}
diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx
index 538aa9f..4f872f4 100644
--- a/Source/cmInstallCommandArguments.cxx
+++ b/Source/cmInstallCommandArguments.cxx
@@ -16,7 +16,7 @@ const char* cmInstallCommandArguments::PermissionsTable[] = {
const std::string cmInstallCommandArguments::EmptyString;
cmInstallCommandArguments::cmInstallCommandArguments(
- const std::string& defaultComponent)
+ std::string defaultComponent)
: Destination(&Parser, "DESTINATION", &ArgumentGroup)
, Component(&Parser, "COMPONENT", &ArgumentGroup)
, NamelinkComponent(&Parser, "NAMELINK_COMPONENT", &ArgumentGroup)
@@ -29,7 +29,7 @@ cmInstallCommandArguments::cmInstallCommandArguments(
, NamelinkSkip(&Parser, "NAMELINK_SKIP", &ArgumentGroup)
, Type(&Parser, "TYPE", &ArgumentGroup)
, GenericArguments(nullptr)
- , DefaultComponentName(defaultComponent)
+ , DefaultComponentName(std::move(defaultComponent))
{
}
diff --git a/Source/cmInstallCommandArguments.h b/Source/cmInstallCommandArguments.h
index 425e58a..8e974af 100644
--- a/Source/cmInstallCommandArguments.h
+++ b/Source/cmInstallCommandArguments.h
@@ -13,7 +13,7 @@
class cmInstallCommandArguments
{
public:
- cmInstallCommandArguments(const std::string& defaultComponent);
+ cmInstallCommandArguments(std::string defaultComponent);
void SetGenericArguments(cmInstallCommandArguments* args)
{
this->GenericArguments = args;
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index 4cc081c..47b9785 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -15,7 +15,6 @@
#include "cmInstallType.h"
#include "cmLocalGenerator.h"
#include "cmSystemTools.h"
-#include "cmake.h"
cmInstallExportGenerator::cmInstallExportGenerator(
cmExportSet* exportSet, const char* destination,
@@ -57,7 +56,7 @@ void cmInstallExportGenerator::ComputeTempDir()
// Choose a temporary directory in which to generate the import
// files to be installed.
this->TempDir = this->LocalGenerator->GetCurrentBinaryDirectory();
- this->TempDir += cmake::GetCMakeFilesDirectory();
+ this->TempDir += "/CMakeFiles";
this->TempDir += "/Export";
if (this->Destination.empty()) {
return;
@@ -127,7 +126,7 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os)
std::ostringstream e;
e << "INSTALL(EXPORT) given unknown export \"" << ExportSet->GetName()
<< "\"";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return;
}
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 86c6a58..3497814 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -19,21 +19,20 @@
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include "cmake.h"
cmInstallTargetGenerator::cmInstallTargetGenerator(
- const std::string& targetName, const char* dest, bool implib,
+ 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 const& backtrace)
+ bool optional, cmListFileBacktrace backtrace)
: cmInstallGenerator(dest, configurations, component, message,
exclude_from_all)
- , TargetName(targetName)
+ , TargetName(std::move(targetName))
, Target(nullptr)
, FilePermissions(file_permissions)
, ImportLibrary(implib)
, Optional(optional)
- , Backtrace(backtrace)
+ , Backtrace(std::move(backtrace))
{
this->ActionsPerConfig = true;
this->NamelinkMode = NamelinkModeNone;
@@ -52,7 +51,7 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os)
<< "\" has EXCLUDE_FROM_ALL set and will not be built by default "
<< "but an install rule has been provided for it. CMake does "
<< "not define behavior for this case.";
- cmSystemTools::Message(msg.str().c_str(), "Warning");
+ cmSystemTools::Message(msg.str(), "Warning");
}
// Perform the main install script generation.
@@ -102,7 +101,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(
if (this->Target->NeedRelinkBeforeInstall(config)) {
fromDirConfig =
this->Target->GetLocalGenerator()->GetCurrentBinaryDirectory();
- fromDirConfig += cmake::GetCMakeFilesDirectory();
+ fromDirConfig += "/CMakeFiles";
fromDirConfig += "/CMakeRelink.dir/";
} else {
cmStateEnums::ArtifactType artifact = this->ImportLibrary
diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h
index bf625d1..715b4ae 100644
--- a/Source/cmInstallTargetGenerator.h
+++ b/Source/cmInstallTargetGenerator.h
@@ -23,11 +23,11 @@ class cmInstallTargetGenerator : public cmInstallGenerator
{
public:
cmInstallTargetGenerator(
- std::string const& targetName, const char* dest, bool implib,
+ 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 const& backtrace = cmListFileBacktrace());
+ cmListFileBacktrace backtrace = cmListFileBacktrace());
~cmInstallTargetGenerator() override;
/** Select the policy for installing shared library linkable name
diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx
index 135fd25..4b6b4d5 100644
--- a/Source/cmJsonObjects.cxx
+++ b/Source/cmJsonObjects.cxx
@@ -578,7 +578,7 @@ static Json::Value DumpTarget(cmGeneratorTarget* target,
lg->GetTargetDefines(target, config, lang, defines);
ld.SetDefines(defines);
std::vector<std::string> includePathList;
- lg->GetIncludeDirectories(includePathList, target, lang, config, true);
+ lg->GetIncludeDirectories(includePathList, target, lang, config);
for (std::string const& i : includePathList) {
ld.IncludePathList.emplace_back(
i, target->IsSystemIncludeDirectory(i, config, lang));
diff --git a/Source/cmLinkItem.cxx b/Source/cmLinkItem.cxx
index 12a07f6..b035c8c 100644
--- a/Source/cmLinkItem.cxx
+++ b/Source/cmLinkItem.cxx
@@ -10,16 +10,15 @@ cmLinkItem::cmLinkItem()
{
}
-cmLinkItem::cmLinkItem(std::string const& n, cmListFileBacktrace const& bt)
- : String(n)
- , Backtrace(bt)
+cmLinkItem::cmLinkItem(std::string n, cmListFileBacktrace bt)
+ : String(std::move(n))
+ , Backtrace(std::move(bt))
{
}
-cmLinkItem::cmLinkItem(cmGeneratorTarget const* t,
- cmListFileBacktrace const& bt)
+cmLinkItem::cmLinkItem(cmGeneratorTarget const* t, cmListFileBacktrace bt)
: Target(t)
- , Backtrace(bt)
+ , Backtrace(std::move(bt))
{
}
diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h
index b841509..d2459db 100644
--- a/Source/cmLinkItem.h
+++ b/Source/cmLinkItem.h
@@ -24,8 +24,8 @@ class cmLinkItem
public:
cmLinkItem();
- cmLinkItem(std::string const& s, cmListFileBacktrace const& bt);
- cmLinkItem(cmGeneratorTarget const* t, cmListFileBacktrace const& bt);
+ cmLinkItem(std::string s, cmListFileBacktrace bt);
+ cmLinkItem(cmGeneratorTarget const* t, cmListFileBacktrace bt);
std::string const& AsStr() const;
cmGeneratorTarget const* Target = nullptr;
cmListFileBacktrace Backtrace;
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index b826795..b24c5ba 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -659,15 +659,19 @@ bool cmListCommand::HandleTransformCommand(
// Transform: lambda function implementing the action
struct ActionDescriptor
{
- ActionDescriptor(const std::string& name)
- : Name(name)
+ ActionDescriptor(std::string name)
+ : Name(std::move(name))
{
}
- ActionDescriptor(const std::string& name, int arity,
- const transform_type& transform)
- : Name(name)
+ ActionDescriptor(std::string name, int arity, transform_type transform)
+ : Name(std::move(name))
, Arity(arity)
+#if defined(__GNUC__) && __GNUC__ == 6 && defined(__aarch64__)
+ // std::function move constructor miscompiles on this architecture
, Transform(transform)
+#else
+ , Transform(std::move(transform))
+#endif
{
}
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index aa53552..f855119 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -24,7 +24,7 @@ cmCommandContext::cmCommandName& cmCommandContext::cmCommandName::operator=(
struct cmListFileParser
{
- cmListFileParser(cmListFile* lf, cmListFileBacktrace const& lfbt,
+ cmListFileParser(cmListFile* lf, cmListFileBacktrace lfbt,
cmMessenger* messenger, const char* filename);
~cmListFileParser();
void IssueFileOpenError(std::string const& text) const;
@@ -47,12 +47,11 @@ struct cmListFileParser
} Separation;
};
-cmListFileParser::cmListFileParser(cmListFile* lf,
- cmListFileBacktrace const& lfbt,
+cmListFileParser::cmListFileParser(cmListFile* lf, cmListFileBacktrace lfbt,
cmMessenger* messenger,
const char* filename)
: ListFile(lf)
- , Backtrace(lfbt)
+ , Backtrace(std::move(lfbt))
, Messenger(messenger)
, FileName(filename)
, Lexer(cmListFileLexer_New())
@@ -194,8 +193,9 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
unsigned long lastLine;
unsigned long parenDepth = 0;
this->Separation = SeparationOkay;
- while ((lastLine = cmListFileLexer_GetCurrentLine(this->Lexer),
- token = cmListFileLexer_Scan(this->Lexer))) {
+ while (
+ (static_cast<void>(lastLine = cmListFileLexer_GetCurrentLine(this->Lexer)),
+ token = cmListFileLexer_Scan(this->Lexer))) {
if (token->type == cmListFileLexer_Token_Space ||
token->type == cmListFileLexer_Token_Newline) {
this->Separation = SeparationOkay;
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h
index 4a247ba..529c389 100644
--- a/Source/cmListFileCache.h
+++ b/Source/cmListFileCache.h
@@ -51,8 +51,8 @@ struct cmListFileArgument
Bracket
};
cmListFileArgument() {}
- cmListFileArgument(const std::string& v, Delimiter d, long line)
- : Value(v)
+ cmListFileArgument(std::string v, Delimiter d, long line)
+ : Value(std::move(v))
, Delim(d)
, Line(line)
{
diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx
index ad89335..eef1c7c 100644
--- a/Source/cmLocalCommonGenerator.cxx
+++ b/Source/cmLocalCommonGenerator.cxx
@@ -12,10 +12,9 @@
class cmGlobalGenerator;
cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
- cmMakefile* mf,
- std::string const& wd)
+ cmMakefile* mf, std::string wd)
: cmLocalGenerator(gg, mf)
- , WorkingDirectory(wd)
+ , WorkingDirectory(std::move(wd))
{
// Store the configuration name that will be generated.
if (const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) {
diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h
index 7b8e6fe..abebbc2 100644
--- a/Source/cmLocalCommonGenerator.h
+++ b/Source/cmLocalCommonGenerator.h
@@ -22,7 +22,7 @@ class cmLocalCommonGenerator : public cmLocalGenerator
{
public:
cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf,
- std::string const& wd);
+ std::string wd);
~cmLocalCommonGenerator() override;
std::string const& GetConfigName() { return this->ConfigName; }
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 89ad96d..252aa4c 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -881,31 +881,27 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags,
this->AddCompilerRequirementFlag(flags, target, lang);
}
-void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
- cmGeneratorTarget const* target,
- const std::string& lang,
- const std::string& config,
- bool stripImplicitDirs,
- bool appendAllImplicitDirs) const
-{
- std::vector<BT<std::string>> tmp = this->GetIncludeDirectories(
- target, lang, config, stripImplicitDirs, appendAllImplicitDirs);
- dirs.reserve(tmp.size());
- for (BT<std::string>& v : tmp) {
- dirs.emplace_back(std::move(v.Value));
- }
-}
-
-std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories(
+std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
cmGeneratorTarget const* target, std::string const& lang,
std::string const& config, bool stripImplicitDirs,
bool appendAllImplicitDirs) const
{
std::vector<BT<std::string>> result;
-
// Do not repeat an include path.
std::set<std::string> emitted;
+ auto emitDir = [&result, &emitted](std::string const& dir) {
+ if (emitted.insert(dir).second) {
+ result.emplace_back(dir);
+ }
+ };
+
+ auto emitBT = [&result, &emitted](BT<std::string> const& dir) {
+ if (emitted.insert(dir.Value).second) {
+ result.emplace_back(dir);
+ }
+ };
+
// When automatic include directories are requested for a build then
// include the source and binary directories at the beginning of the
// include path to approximate include file behavior for an
@@ -915,21 +911,9 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories(
// per-source-file include paths.
if (this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR")) {
// Current binary directory
- {
- std::string binDir =
- this->StateSnapshot.GetDirectory().GetCurrentBinary();
- if (emitted.insert(binDir).second) {
- result.emplace_back(std::move(binDir));
- }
- }
+ emitDir(this->StateSnapshot.GetDirectory().GetCurrentBinary());
// Current source directory
- {
- std::string srcDir =
- this->StateSnapshot.GetDirectory().GetCurrentSource();
- if (emitted.insert(srcDir).second) {
- result.emplace_back(std::move(srcDir));
- }
- }
+ emitDir(this->StateSnapshot.GetDirectory().GetCurrentSource());
}
if (!target) {
@@ -938,6 +922,11 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories(
// Implicit include directories
std::vector<std::string> implicitDirs;
+ std::set<std::string> implicitSet;
+ // Checks if this is not an implicit include directory
+ auto notImplicit = [&implicitSet](std::string const& dir) {
+ return (implicitSet.find(dir) == implicitSet.end());
+ };
{
std::string rootPath;
if (const char* sysrootCompile =
@@ -947,20 +936,28 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories(
rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
}
+ // Raw list of implicit include directories
+ std::vector<std::string> impDirVec;
+
+ // Get platform-wide implicit directories.
+ if (const char* implicitIncludes = (this->Makefile->GetDefinition(
+ "CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES"))) {
+ cmSystemTools::ExpandListArgument(implicitIncludes, impDirVec);
+ }
+
// Load implicit include directories for this language.
std::string key = "CMAKE_";
key += lang;
key += "_IMPLICIT_INCLUDE_DIRECTORIES";
if (const char* value = this->Makefile->GetDefinition(key)) {
- std::vector<std::string> impDirVec;
cmSystemTools::ExpandListArgument(value, impDirVec);
- for (std::string const& i : impDirVec) {
- {
- std::string d = rootPath + i;
- cmSystemTools::ConvertToUnixSlashes(d);
- emitted.insert(std::move(d));
- }
- implicitDirs.push_back(i);
+ }
+
+ for (std::string const& i : impDirVec) {
+ std::string imd = rootPath + i;
+ cmSystemTools::ConvertToUnixSlashes(imd);
+ if (implicitSet.insert(imd).second) {
+ implicitDirs.emplace_back(std::move(imd));
}
}
}
@@ -974,30 +971,31 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories(
if (this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE")) {
std::string const &topSourceDir = this->GetState()->GetSourceDirectory(),
&topBinaryDir = this->GetState()->GetBinaryDirectory();
- for (BT<std::string> const& i : userDirs) {
+ for (BT<std::string> const& udr : userDirs) {
// Emit this directory only if it is a subdirectory of the
// top-level source or binary tree.
- if (cmSystemTools::ComparePath(i.Value, topSourceDir) ||
- cmSystemTools::ComparePath(i.Value, topBinaryDir) ||
- cmSystemTools::IsSubDirectory(i.Value, topSourceDir) ||
- cmSystemTools::IsSubDirectory(i.Value, topBinaryDir)) {
- if (emitted.insert(i.Value).second) {
- result.push_back(i);
+ if (cmSystemTools::ComparePath(udr.Value, topSourceDir) ||
+ cmSystemTools::ComparePath(udr.Value, topBinaryDir) ||
+ cmSystemTools::IsSubDirectory(udr.Value, topSourceDir) ||
+ cmSystemTools::IsSubDirectory(udr.Value, topBinaryDir)) {
+ if (notImplicit(udr.Value)) {
+ emitBT(udr);
}
}
}
}
- // Construct the final ordered include directory list.
- for (BT<std::string> const& i : userDirs) {
- if (emitted.insert(i.Value).second) {
- result.push_back(i);
+ // Emit remaining non implicit user direcories.
+ for (BT<std::string> const& udr : userDirs) {
+ if (notImplicit(udr.Value)) {
+ emitBT(udr);
}
}
+ // Sort result
MoveSystemIncludesToEnd(result, config, lang, target);
- // Add standard include directories for this language.
+ // Append standard include directories for this language.
{
std::vector<std::string> userStandardDirs;
{
@@ -1008,26 +1006,27 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories(
cmSystemTools::ExpandListArgument(value, userStandardDirs);
}
userDirs.reserve(userDirs.size() + userStandardDirs.size());
- for (std::string& d : userStandardDirs) {
- cmSystemTools::ConvertToUnixSlashes(d);
- result.emplace_back(d);
- userDirs.emplace_back(std::move(d));
+ for (std::string& usd : userStandardDirs) {
+ cmSystemTools::ConvertToUnixSlashes(usd);
+ if (notImplicit(usd)) {
+ emitDir(usd);
+ }
+ userDirs.emplace_back(std::move(usd));
}
}
+ // Append compiler implicit include directories
if (!stripImplicitDirs) {
- // Append only implicit directories that were requested by the user
- for (std::string const& i : implicitDirs) {
- if (std::find(userDirs.begin(), userDirs.end(), i) != userDirs.end()) {
- result.emplace_back(i);
+ // Append implicit directories that were requested by the user only
+ for (BT<std::string> const& udr : userDirs) {
+ if (!notImplicit(udr.Value)) {
+ emitBT(udr);
}
}
- // Append remaining implicit directories on demand
+ // Append remaining implicit directories (on demand)
if (appendAllImplicitDirs) {
- for (std::string const& i : implicitDirs) {
- if (std::find(result.begin(), result.end(), i) == result.end()) {
- result.emplace_back(i);
- }
+ for (std::string& imd : implicitDirs) {
+ emitDir(imd);
}
}
}
@@ -1035,6 +1034,34 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories(
return result;
}
+void cmLocalGenerator::GetIncludeDirectoriesImplicit(
+ std::vector<std::string>& dirs, cmGeneratorTarget const* target,
+ const std::string& lang, const std::string& config, bool stripImplicitDirs,
+ bool appendAllImplicitDirs) const
+{
+ std::vector<BT<std::string>> tmp = this->GetIncludeDirectoriesImplicit(
+ target, lang, config, stripImplicitDirs, appendAllImplicitDirs);
+ dirs.reserve(dirs.size() + tmp.size());
+ for (BT<std::string>& v : tmp) {
+ dirs.emplace_back(std::move(v.Value));
+ }
+}
+
+std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories(
+ cmGeneratorTarget const* target, std::string const& lang,
+ std::string const& config) const
+{
+ return this->GetIncludeDirectoriesImplicit(target, lang, config);
+}
+
+void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
+ cmGeneratorTarget const* target,
+ const std::string& lang,
+ const std::string& config) const
+{
+ this->GetIncludeDirectoriesImplicit(dirs, target, lang, config);
+}
+
void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags,
std::string const& config,
std::string const& linkLanguage,
@@ -1786,7 +1813,7 @@ static void AddVisibilityCompileOption(std::string& flags,
std::ostringstream e;
e << "Target " << target->GetName() << " uses unsupported value \"" << prop
<< "\" for " << flagDefine << ".";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return;
}
std::string option = std::string(opt) + prop;
@@ -2751,7 +2778,7 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const
<< "CMake is dropping a preprocessor definition: " << define << "\n"
<< "Consider defining the macro in a (configured) header file.\n";
/* clang-format on */
- cmSystemTools::Message(e.str().c_str());
+ cmSystemTools::Message(e.str());
return false;
}
}
@@ -2766,7 +2793,7 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const
<< "CMake is dropping a preprocessor definition: " << define << "\n"
<< "Consider defining the macro in a (configured) header file.\n";
/* clang-format on */
- cmSystemTools::Message(e.str().c_str());
+ cmSystemTools::Message(e.str());
return false;
}
@@ -2790,7 +2817,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target,
const char* in = target->GetProperty("MACOSX_BUNDLE_INFO_PLIST");
std::string inFile = (in && *in) ? in : "MacOSXBundleInfo.plist.in";
if (!cmSystemTools::FileIsFullPath(inFile)) {
- std::string inMod = this->Makefile->GetModulesFile(inFile.c_str());
+ std::string inMod = this->Makefile->GetModulesFile(inFile);
if (!inMod.empty()) {
inFile = inMod;
}
@@ -2799,7 +2826,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target,
std::ostringstream e;
e << "Target " << target->GetName() << " Info.plist template \"" << inFile
<< "\" could not be found.";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return;
}
@@ -2828,7 +2855,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(
const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST");
std::string inFile = (in && *in) ? in : "MacOSXFrameworkInfo.plist.in";
if (!cmSystemTools::FileIsFullPath(inFile)) {
- std::string inMod = this->Makefile->GetModulesFile(inFile.c_str());
+ std::string inMod = this->Makefile->GetModulesFile(inFile);
if (!inMod.empty()) {
inFile = inMod;
}
@@ -2837,7 +2864,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(
std::ostringstream e;
e << "Target " << target->GetName() << " Info.plist template \"" << inFile
<< "\" could not be found.";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return;
}
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 4be3905..f9839f6 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -233,28 +233,52 @@ public:
virtual void ClearDependencies(cmMakefile* /* mf */, bool /* verbose */) {}
/** Called from command-line hook to update dependencies. */
- virtual bool UpdateDependencies(const char* /* tgtInfo */, bool /*verbose*/,
- bool /*color*/)
+ virtual bool UpdateDependencies(const std::string& /* tgtInfo */,
+ bool /*verbose*/, bool /*color*/)
{
return true;
}
- /** @brief Get the include directories for the current makefile and language.
+ /** @brief Get the include directories for the current makefile and language
+ * and optional the compiler implicit include directories.
+ *
* @arg stripImplicitDirs Strip all directories found in
* CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES from the result.
* @arg appendAllImplicitDirs Append all directories found in
* CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES to the result.
*/
+ std::vector<BT<std::string>> GetIncludeDirectoriesImplicit(
+ cmGeneratorTarget const* target, std::string const& lang = "C",
+ std::string const& config = "", bool stripImplicitDirs = true,
+ bool appendAllImplicitDirs = false) const;
+
+ /** @brief Get the include directories for the current makefile and language
+ * and optional the compiler implicit include directories.
+ *
+ * @arg dirs Directories are appended to this list
+ */
+ void GetIncludeDirectoriesImplicit(std::vector<std::string>& dirs,
+ cmGeneratorTarget const* target,
+ const std::string& lang = "C",
+ const std::string& config = "",
+ bool stripImplicitDirs = true,
+ bool appendAllImplicitDirs = false) const;
+
+ /** @brief Get the include directories for the current makefile and language.
+ * @arg dirs Include directories are appended to this list
+ */
void GetIncludeDirectories(std::vector<std::string>& dirs,
cmGeneratorTarget const* target,
const std::string& lang = "C",
- const std::string& config = "",
- bool stripImplicitDirs = true,
- bool appendAllImplicitDirs = false) const;
+ const std::string& config = "") const;
+
+ /** @brief Get the include directories for the current makefile and language.
+ * @return The include directory list
+ */
std::vector<BT<std::string>> GetIncludeDirectories(
cmGeneratorTarget const* target, std::string const& lang = "C",
- std::string const& config = "", bool stripImplicitDirs = true,
- bool appendAllImplicitDirs = false) const;
+ std::string const& config = "") const;
+
void AddCompileOptions(std::string& flags, cmGeneratorTarget* target,
const std::string& lang, const std::string& config);
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index f252045..7417e80 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -90,9 +90,7 @@ void cmLocalNinjaGenerator::Generate()
if (tg) {
tg->Generate();
// Add the target to "all" if required.
- if (!this->GetGlobalNinjaGenerator()->IsExcluded(
- this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0],
- target)) {
+ if (!this->GetGlobalNinjaGenerator()->IsExcluded(target)) {
this->GetGlobalNinjaGenerator()->AddDependencyToAll(target);
}
delete tg;
@@ -106,7 +104,7 @@ void cmLocalNinjaGenerator::Generate()
std::string cmLocalNinjaGenerator::GetTargetDirectory(
cmGeneratorTarget const* target) const
{
- std::string dir = cmake::GetCMakeFilesDirectoryPostSlash();
+ std::string dir = "CMakeFiles/";
dir += target->GetName();
#if defined(__VMS)
dir += "_dir";
@@ -306,7 +304,7 @@ std::string cmLocalNinjaGenerator::WriteCommandScript(
scriptPath = target->GetSupportDirectory();
} else {
scriptPath = this->GetCurrentBinaryDirectory();
- scriptPath += cmake::GetCMakeFilesDirectory();
+ scriptPath += "/CMakeFiles";
}
cmSystemTools::MakeDirectory(scriptPath);
scriptPath += '/';
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 1d4793a..55ce50b 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -248,8 +248,8 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
for (auto& localObjectFile : localObjectFiles) {
// Add a convenience rule for building the object file.
this->WriteObjectConvenienceRule(
- ruleFileStream, "target to build an object file",
- localObjectFile.first.c_str(), localObjectFile.second);
+ ruleFileStream, "target to build an object file", localObjectFile.first,
+ localObjectFile.second);
// Check whether preprocessing and assembly rules make sense.
// They make sense only for C and C++ sources.
@@ -271,9 +271,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
if (lang_has_preprocessor && do_preprocess_rules) {
std::string::size_type dot_pos = localObjectFile.first.rfind(".");
std::string base = localObjectFile.first.substr(0, dot_pos);
- this->WriteObjectConvenienceRule(
- ruleFileStream, "target to preprocess a source file",
- (base + ".i").c_str(), localObjectFile.second);
+ this->WriteObjectConvenienceRule(ruleFileStream,
+ "target to preprocess a source file",
+ (base + ".i"), localObjectFile.second);
localObjectFile.second.HasPreprocessRule = true;
}
@@ -282,7 +282,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
std::string base = localObjectFile.first.substr(0, dot_pos);
this->WriteObjectConvenienceRule(
ruleFileStream, "target to generate assembly for a file",
- (base + ".s").c_str(), localObjectFile.second);
+ (base + ".s"), localObjectFile.second);
localObjectFile.second.HasAssembleRule = true;
}
}
@@ -298,7 +298,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
}
void cmLocalUnixMakefileGenerator3::WriteObjectConvenienceRule(
- std::ostream& ruleFileStream, const char* comment, const char* output,
+ std::ostream& ruleFileStream, const char* comment, const std::string& output,
LocalObjectInfo const& info)
{
// If the rule includes the source file extension then create a
@@ -334,7 +334,7 @@ void cmLocalUnixMakefileGenerator3::WriteObjectConvenienceRule(
targetName += "/";
targetName += output;
commands.push_back(
- this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName));
+ this->GetRecursiveMakeCall(tgtMakefileName, targetName));
}
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
@@ -371,10 +371,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
depends.clear();
// Build the target for this pass.
- std::string makefile2 = cmake::GetCMakeFilesDirectoryPostSlash();
+ std::string makefile2 = "CMakeFiles/";
makefile2 += "Makefile2";
- commands.push_back(
- this->GetRecursiveMakeCall(makefile2.c_str(), localName));
+ commands.push_back(this->GetRecursiveMakeCall(makefile2, localName));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
@@ -399,7 +398,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
depends.clear();
commands.clear();
commands.push_back(
- this->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
+ this->GetRecursiveMakeCall(makefileName, makeTargetName));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "fast build rule for target.",
@@ -415,7 +414,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
depends.clear();
commands.clear();
commands.push_back(
- this->GetRecursiveMakeCall(makefile2.c_str(), makeTargetName));
+ this->GetRecursiveMakeCall(makefile2, makeTargetName));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream,
@@ -429,7 +428,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile()
{
std::string infoFileName = this->GetCurrentBinaryDirectory();
- infoFileName += cmake::GetCMakeFilesDirectory();
+ infoFileName += "/CMakeFiles";
infoFileName += "/CMakeDirectoryInformation.cmake";
// Open the output file.
@@ -771,7 +770,7 @@ void cmLocalUnixMakefileGenerator3::WriteSpecialTargetsBottom(
cmOutputConverter::SHELL);
commands.push_back(rescanRule);
}
- std::string cmakefileName = cmake::GetCMakeFilesDirectoryPostSlash();
+ std::string cmakefileName = "CMakeFiles/";
cmakefileName += "Makefile.cmake";
std::string runRule =
"$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)";
@@ -1254,9 +1253,8 @@ std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable(
return ret;
}
-bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
- bool verbose,
- bool color)
+bool cmLocalUnixMakefileGenerator3::UpdateDependencies(
+ const std::string& tgtInfo, bool verbose, bool color)
{
// read in the target info file
if (!this->Makefile->ReadListFile(tgtInfo) ||
@@ -1280,13 +1278,13 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
this->GlobalGenerator->GetCMakeInstance()->GetFileComparison();
{
int result;
- if (!ftc->FileTimeCompare(internalDependFile.c_str(), tgtInfo, &result) ||
+ if (!ftc->FileTimeCompare(internalDependFile, tgtInfo, &result) ||
result < 0) {
if (verbose) {
std::ostringstream msg;
msg << "Dependee \"" << tgtInfo << "\" is newer than depender \""
<< internalDependFile << "\"." << std::endl;
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
needRescanDependInfo = true;
}
@@ -1296,18 +1294,17 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
// may have changed. In this case discard all old dependencies.
bool needRescanDirInfo = false;
std::string dirInfoFile = this->GetCurrentBinaryDirectory();
- dirInfoFile += cmake::GetCMakeFilesDirectory();
+ dirInfoFile += "/CMakeFiles";
dirInfoFile += "/CMakeDirectoryInformation.cmake";
{
int result;
- if (!ftc->FileTimeCompare(internalDependFile.c_str(), dirInfoFile.c_str(),
- &result) ||
+ if (!ftc->FileTimeCompare(internalDependFile, dirInfoFile, &result) ||
result < 0) {
if (verbose) {
std::ostringstream msg;
msg << "Dependee \"" << dirInfoFile << "\" is newer than depender \""
<< internalDependFile << "\"." << std::endl;
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
needRescanDirInfo = true;
}
@@ -1333,8 +1330,8 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
// dependency vector. This means that in the normal case, when only
// few or one file have been edited, then also only this one file is
// actually scanned again, instead of all files for this target.
- needRescanDependencies = !checker.Check(
- dependFile.c_str(), internalDependFile.c_str(), validDependencies);
+ needRescanDependencies =
+ !checker.Check(dependFile, internalDependFile, validDependencies);
}
if (needRescanDependInfo || needRescanDirInfo || needRescanDependencies) {
@@ -1347,7 +1344,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
cmsysTerminal_Color_ForegroundBold,
message.c_str(), true, color);
- return this->ScanDependencies(dir.c_str(), validDependencies);
+ return this->ScanDependencies(dir, validDependencies);
}
// The dependencies are already up-to-date.
@@ -1355,14 +1352,14 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
}
bool cmLocalUnixMakefileGenerator3::ScanDependencies(
- const char* targetDir,
+ const std::string& targetDir,
std::map<std::string, cmDepends::DependencyVector>& validDeps)
{
// Read the directory information file.
cmMakefile* mf = this->Makefile;
bool haveDirectoryInfo = false;
std::string dirInfoFile = this->GetCurrentBinaryDirectory();
- dirInfoFile += cmake::GetCMakeFilesDirectory();
+ dirInfoFile += "/CMakeFiles";
dirInfoFile += "/CMakeDirectoryInformation.cmake";
if (mf->ReadListFile(dirInfoFile) && !cmSystemTools::GetErrorOccuredFlag()) {
haveDirectoryInfo = true;
@@ -1392,12 +1389,9 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
cmSystemTools::Error("Directory Information file not found");
}
- // create the file stream for the depends file
- std::string dir = targetDir;
-
// Open the make depends file. This should be copy-if-different
// because the make tool may try to reload it needlessly otherwise.
- std::string ruleFileNameFull = dir;
+ std::string ruleFileNameFull = targetDir;
ruleFileNameFull += "/depend.make";
cmGeneratedFileStream ruleFileStream(
ruleFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
@@ -1409,7 +1403,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
// Open the cmake dependency tracking file. This should not be
// copy-if-different because dependencies are re-scanned when it is
// older than the DependInfo.cmake.
- std::string internalRuleFileNameFull = dir;
+ std::string internalRuleFileNameFull = targetDir;
internalRuleFileNameFull += "/depend.internal";
cmGeneratedFileStream internalRuleFileStream(
internalRuleFileNameFull, false,
@@ -1450,7 +1444,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
scanner->SetFileComparison(
this->GlobalGenerator->GetCMakeInstance()->GetFileComparison());
scanner->SetLanguage(lang);
- scanner->SetTargetDirectory(dir.c_str());
+ scanner->SetTargetDirectory(targetDir);
scanner->Write(ruleFileStream, internalRuleFileStream);
// free the scanner for this language
@@ -1488,7 +1482,7 @@ void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose)
msg << "Deleting primary custom command output \"" << dependee
<< "\" because another output \"" << depender
<< "\" does not exist." << std::endl;
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
cmSystemTools::RemoveFile(dependee);
}
@@ -1596,14 +1590,14 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
}
std::string progressDir = this->GetBinaryDirectory();
- progressDir += cmake::GetCMakeFilesDirectory();
+ progressDir += "/CMakeFiles";
{
std::ostringstream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start ";
progCmd << this->ConvertToOutputFormat(
cmSystemTools::CollapseFullPath(progressDir), cmOutputConverter::SHELL);
- std::string progressFile = cmake::GetCMakeFilesDirectory();
+ std::string progressFile = "/CMakeFiles";
progressFile += "/progress.marks";
std::string progressFileNameFull = this->ConvertToFullPath(progressFile);
progCmd << " "
@@ -1612,10 +1606,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
cmOutputConverter::SHELL);
commands.push_back(progCmd.str());
}
- std::string mf2Dir = cmake::GetCMakeFilesDirectoryPostSlash();
+ std::string mf2Dir = "CMakeFiles/";
mf2Dir += "Makefile2";
- commands.push_back(
- this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
+ commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
{
@@ -1634,8 +1627,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
recursiveTarget += "/clean";
commands.clear();
depends.clear();
- commands.push_back(
- this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
+ commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "The main clean target", "clean",
@@ -1660,8 +1652,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
// At least make sure the build system is up to date.
depends.emplace_back("cmake_check_build_system");
}
- commands.push_back(
- this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
+ commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.",
@@ -1681,7 +1672,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
cmOutputConverter::SHELL);
commands.push_back(rescanRule);
}
- std::string cmakefileName = cmake::GetCMakeFilesDirectoryPostSlash();
+ std::string cmakefileName = "CMakeFiles/";
cmakefileName += "Makefile.cmake";
{
std::string runRule =
@@ -1719,7 +1710,7 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf,
// Clear the implicit dependency makefile.
std::string dependFile = dir + "/depend.make";
- clearer.Clear(dependFile.c_str());
+ clearer.Clear(dependFile);
// Remove the internal dependency check file to force
// regeneration.
@@ -1736,9 +1727,9 @@ class NotInProjectDir
{
public:
// Constructor with the source and binary directory's path
- NotInProjectDir(const std::string& sourceDir, const std::string& binaryDir)
- : SourceDir(sourceDir)
- , BinaryDir(binaryDir)
+ NotInProjectDir(std::string sourceDir, std::string binaryDir)
+ : SourceDir(std::move(sourceDir))
+ , BinaryDir(std::move(binaryDir))
{
}
@@ -1889,7 +1880,7 @@ void cmLocalUnixMakefileGenerator3::WriteDisclaimer(std::ostream& os)
}
std::string cmLocalUnixMakefileGenerator3::GetRecursiveMakeCall(
- const char* makefile, const std::string& tgt)
+ const std::string& makefile, const std::string& tgt)
{
// Call make on the given file.
std::string cmd;
@@ -1959,7 +1950,7 @@ void cmLocalUnixMakefileGenerator3::WriteCMakeArgument(std::ostream& os,
}
std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
- const char* p, bool useWatcomQuote)
+ const std::string& p, bool useWatcomQuote)
{
// Split the path into its components.
std::vector<std::string> components;
@@ -2026,7 +2017,7 @@ std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
std::string cmLocalUnixMakefileGenerator3::GetTargetDirectory(
cmGeneratorTarget const* target) const
{
- std::string dir = cmake::GetCMakeFilesDirectoryPostSlash();
+ std::string dir = "CMakeFiles/";
dir += target->GetName();
#if defined(__VMS)
dir += "_dir";
@@ -2043,8 +2034,8 @@ cmLocalUnixMakefileGenerator3::GetImplicitDepends(const cmGeneratorTarget* tgt)
}
void cmLocalUnixMakefileGenerator3::AddImplicitDepends(
- const cmGeneratorTarget* tgt, const std::string& lang, const char* obj,
- const char* src)
+ const cmGeneratorTarget* tgt, const std::string& lang,
+ const std::string& obj, const std::string& src)
{
this->ImplicitDepends[tgt->GetName()][lang][obj].push_back(src);
}
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index b256fdc..d83c9bb 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -12,6 +12,7 @@
#include <map>
#include <set>
#include <string>
+#include <utility>
#include <vector>
class cmCustomCommand;
@@ -83,7 +84,7 @@ public:
void WriteDivider(std::ostream& os);
/** used to create a recursive make call */
- std::string GetRecursiveMakeCall(const char* makefile,
+ std::string GetRecursiveMakeCall(const std::string& makefile,
const std::string& tgt);
// append flags to a string
@@ -120,7 +121,7 @@ public:
std::string const& targetDir,
std::string const& relDir);
- static std::string ConvertToQuotedOutputPath(const char* p,
+ static std::string ConvertToQuotedOutputPath(const std::string& p,
bool useWatcomQuote);
std::string CreateMakeVariable(const std::string& sin,
@@ -128,7 +129,7 @@ public:
/** Called from command-line hook to bring dependencies up to date
for a target. */
- bool UpdateDependencies(const char* tgtInfo, bool verbose,
+ bool UpdateDependencies(const std::string& tgtInfo, bool verbose,
bool color) override;
/** Called from command-line hook to clear dependencies. */
@@ -158,8 +159,8 @@ public:
cmGeneratorTarget const* tgt);
void AddImplicitDepends(cmGeneratorTarget const* tgt,
- const std::string& lang, const char* obj,
- const char* src);
+ const std::string& lang, const std::string& obj,
+ const std::string& src);
// write the target rules for the local Makefile into the stream
void WriteLocalAllRules(std::ostream& ruleFileStream);
@@ -197,9 +198,6 @@ protected:
void WriteDependLanguageInfo(std::ostream& cmakefileStream,
cmGeneratorTarget* tgt);
- // write the local help rule
- void WriteHelpRule(std::ostream& ruleFileStream);
-
// this converts a file name that is relative to the StartOuputDirectory
// into a full path
std::string ConvertToFullPath(const std::string& localPath);
@@ -208,15 +206,6 @@ protected:
const std::string& realTarget,
const std::string& helpTarget);
- void WriteTargetDependRule(std::ostream& ruleFileStream,
- cmGeneratorTarget* target);
- void WriteTargetCleanRule(std::ostream& ruleFileStream,
- cmGeneratorTarget* target,
- const std::vector<std::string>& files);
- void WriteTargetRequiresRule(std::ostream& ruleFileStream,
- cmGeneratorTarget* target,
- const std::vector<std::string>& objects);
-
void AppendRuleDepend(std::vector<std::string>& depends,
const char* ruleFileName);
void AppendRuleDepends(std::vector<std::string>& depends,
@@ -242,7 +231,7 @@ protected:
// Helper methods for dependency updates.
bool ScanDependencies(
- const char* targetDir,
+ const std::string& targetDir,
std::map<std::string, cmDepends::DependencyVector>& validDeps);
void CheckMultipleOutputs(bool verbose);
@@ -264,9 +253,9 @@ private:
cmGeneratorTarget* Target = nullptr;
std::string Language;
LocalObjectEntry() {}
- LocalObjectEntry(cmGeneratorTarget* t, const std::string& lang)
+ LocalObjectEntry(cmGeneratorTarget* t, std::string lang)
: Target(t)
- , Language(lang)
+ , Language(std::move(lang))
{
}
};
@@ -281,7 +270,8 @@ private:
std::map<std::string, LocalObjectInfo>& localObjectFiles);
void WriteObjectConvenienceRule(std::ostream& ruleFileStream,
- const char* comment, const char* output,
+ const char* comment,
+ const std::string& output,
LocalObjectInfo const& info);
std::vector<std::string> LocalHelp;
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index cd97dc4..7019552 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -97,7 +97,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets()
force_commands.push_back(force_command);
std::string no_main_dependency;
std::string force = this->GetCurrentBinaryDirectory();
- force += cmake::GetCMakeFilesDirectory();
+ force += "/CMakeFiles";
force += "/";
force += l->GetName();
force += "_force";
@@ -144,7 +144,7 @@ void cmLocalVisualStudio7Generator::WriteStampFiles()
// Touch a timestamp file used to determine when the project file is
// out of date.
std::string stampName = this->GetCurrentBinaryDirectory();
- stampName += cmake::GetCMakeFilesDirectory();
+ stampName += "/CMakeFiles";
cmSystemTools::MakeDirectory(stampName.c_str());
stampName += "/";
stampName += "generate.stamp";
@@ -254,7 +254,7 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
std::string stampName = this->GetCurrentBinaryDirectory();
stampName += "/";
- stampName += cmake::GetCMakeFilesDirectoryPostSlash();
+ stampName += "CMakeFiles/";
stampName += "generate.stamp";
cmCustomCommandLine commandLine;
commandLine.push_back(cmSystemTools::GetCMakeCommand());
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 9589b7f..9bd3b01 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -45,6 +45,8 @@
#include "cm_sys_stat.h"
#include "cmake.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+
#ifdef CMAKE_BUILD_WITH_CMAKE
# include "cmVariableWatch.h"
#endif
@@ -83,6 +85,7 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
this->StateSnapshot =
this->StateSnapshot.GetState()->CreatePolicyScopeSnapshot(
this->StateSnapshot);
+ this->RecursionDepth = 0;
// Enter a policy level for this directory.
this->PushPolicy();
@@ -319,7 +322,7 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
msg << " ";
}
msg << ")";
- cmSystemTools::Message(msg.str().c_str());
+ cmSystemTools::Message(msg.str());
}
// Helper class to make sure the call stack is valid.
@@ -333,12 +336,14 @@ public:
cmListFileContext const& lfc = cmListFileContext::FromCommandContext(
cc, this->Makefile->StateSnapshot.GetExecutionListFile());
this->Makefile->Backtrace = this->Makefile->Backtrace.Push(lfc);
+ ++this->Makefile->RecursionDepth;
this->Makefile->ExecutionStatusStack.push_back(&status);
}
~cmMakefileCall()
{
this->Makefile->ExecutionStatusStack.pop_back();
+ --this->Makefile->RecursionDepth;
this->Makefile->Backtrace = this->Makefile->Backtrace.Pop();
}
@@ -361,6 +366,24 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
cmMakefileCall stack_manager(this, lff, status);
static_cast<void>(stack_manager);
+ // Check for maximum recursion depth.
+ int depth = CMake_DEFAULT_RECURSION_LIMIT;
+ const char* depthStr = this->GetDefinition("CMAKE_MAXIMUM_RECURSION_DEPTH");
+ if (depthStr) {
+ std::istringstream s(depthStr);
+ int d;
+ if (s >> d) {
+ depth = d;
+ }
+ }
+ if (this->RecursionDepth > depth) {
+ std::ostringstream e;
+ e << "Maximum recursion depth of " << depth << " exceeded";
+ this->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+
// Lookup the command prototype.
if (cmCommand* proto =
this->GetState()->GetCommandByExactName(lff.Name.Lower)) {
@@ -1128,7 +1151,7 @@ cmTarget* cmMakefile::AddUtilityCommand(
// Create a target instance for this utility.
cmTarget* target = this->AddNewTarget(cmStateEnums::UTILITY, utilityName);
target->SetIsGeneratorProvided(origin == TargetOrigin::Generator);
- if (excludeFromAll) {
+ if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
}
if (!comment) {
@@ -1139,7 +1162,7 @@ cmTarget* cmMakefile::AddUtilityCommand(
// Store the custom command in the target.
if (!commandLines.empty() || !depends.empty()) {
std::string force = this->GetCurrentBinaryDirectory();
- force += cmake::GetCMakeFilesDirectory();
+ force += "/CMakeFiles";
force += "/";
force += utilityName;
std::vector<std::string> forced;
@@ -1369,6 +1392,9 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
// Imported targets.
this->ImportedTargets = parent->ImportedTargets;
+
+ // Recursion depth.
+ this->RecursionDepth = parent->RecursionDepth;
}
void cmMakefile::PushFunctionScope(std::string const& fileName,
@@ -1493,7 +1519,7 @@ void cmMakefile::Configure()
// make sure the CMakeFiles dir is there
std::string filesDir = this->StateSnapshot.GetDirectory().GetCurrentBinary();
- filesDir += cmake::GetCMakeFilesDirectory();
+ filesDir += "/CMakeFiles";
cmSystemTools::MakeDirectory(filesDir);
assert(cmSystemTools::FileExists(currentStart, true));
@@ -1596,7 +1622,7 @@ void cmMakefile::ConfigureSubDirectory(cmMakefile* mf)
if (this->GetCMakeInstance()->GetDebugOutput()) {
std::string msg = " Entering ";
msg += currentStart;
- cmSystemTools::Message(msg.c_str());
+ cmSystemTools::Message(msg);
}
std::string const currentStartFile = currentStart + "/CMakeLists.txt";
@@ -1639,7 +1665,7 @@ void cmMakefile::ConfigureSubDirectory(cmMakefile* mf)
if (this->GetCMakeInstance()->GetDebugOutput()) {
std::string msg = " Returning to ";
msg += this->GetCurrentSourceDirectory();
- cmSystemTools::Message(msg.c_str());
+ cmSystemTools::Message(msg);
}
}
@@ -1663,7 +1689,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot);
this->GetGlobalGenerator()->AddMakefile(subMf);
- if (excludeFromAll) {
+ if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
subMf->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
}
@@ -1959,7 +1985,7 @@ cmTarget* cmMakefile::AddLibrary(const std::string& lname,
// over changes in CMakeLists.txt, making the information stale and
// hence useless.
target->ClearDependencyInformation(*this);
- if (excludeFromAll) {
+ if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
}
target->AddSources(srcs);
@@ -1972,7 +1998,7 @@ cmTarget* cmMakefile::AddExecutable(const std::string& exeName,
bool excludeFromAll)
{
cmTarget* target = this->AddNewTarget(cmStateEnums::EXECUTABLE, exeName);
- if (excludeFromAll) {
+ if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
}
target->AddSources(srcs);
@@ -2721,8 +2747,17 @@ bool cmMakefile::IsProjectFile(const char* filename) const
{
return cmSystemTools::IsSubDirectory(filename, this->GetHomeDirectory()) ||
(cmSystemTools::IsSubDirectory(filename, this->GetHomeOutputDirectory()) &&
- !cmSystemTools::IsSubDirectory(filename,
- cmake::GetCMakeFilesDirectory()));
+ !cmSystemTools::IsSubDirectory(filename, "/CMakeFiles"));
+}
+
+int cmMakefile::GetRecursionDepth() const
+{
+ return this->RecursionDepth;
+}
+
+void cmMakefile::SetRecursionDepth(int recursionDepth)
+{
+ this->RecursionDepth = recursionDepth;
}
MessageType cmMakefile::ExpandVariablesInStringNew(
@@ -3388,6 +3423,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
this->IsSourceFileTryCompile = false;
return 1;
}
+ gg->RecursionDepth = this->RecursionDepth;
cm.SetGlobalGenerator(gg);
// do a configure
@@ -3407,6 +3443,12 @@ int cmMakefile::TryCompile(const std::string& srcdir,
cmStateEnums::STRING);
}
}
+ const char* recursionDepth =
+ this->GetDefinition("CMAKE_MAXIMUM_RECURSION_DEPTH");
+ if (recursionDepth) {
+ cm.AddCacheEntry("CMAKE_MAXIMUM_RECURSION_DEPTH", recursionDepth,
+ "Maximum recursion depth", cmStateEnums::STRING);
+ }
// if cmake args were provided then pass them in
if (cmakeArgs) {
// FIXME: Workaround to ignore unused CLI variables in try-compile.
@@ -3516,7 +3558,7 @@ void cmMakefile::DisplayStatus(const char* message, float s) const
cm->UpdateProgress(message, s);
}
-std::string cmMakefile::GetModulesFile(const char* filename,
+std::string cmMakefile::GetModulesFile(const std::string& filename,
bool& system) const
{
std::string result;
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index abe2cd1..2bd44e2 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -689,13 +689,13 @@ public:
/**
* Return a location of a file in cmake or custom modules directory
*/
- std::string GetModulesFile(const char* name) const
+ std::string GetModulesFile(const std::string& name) const
{
bool system;
return this->GetModulesFile(name, system);
}
- std::string GetModulesFile(const char* name, bool& system) const;
+ std::string GetModulesFile(const std::string& name, bool& system) const;
///! Set/Get a property of this directory
void SetProperty(const std::string& prop, const char* value);
@@ -870,6 +870,9 @@ public:
const char* sourceFilename) const;
bool IsProjectFile(const char* filename) const;
+ int GetRecursionDepth() const;
+ void SetRecursionDepth(int recursionDepth);
+
protected:
// add link libraries and directories to the target
void AddGlobalLinkInformation(cmTarget& target);
@@ -930,6 +933,7 @@ protected:
private:
cmStateSnapshot StateSnapshot;
cmListFileBacktrace Backtrace;
+ int RecursionDepth;
void ReadListFile(cmListFile const& listFile,
const std::string& filenametoread);
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 92eeb2e..e576b5f 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -25,7 +25,6 @@
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
-#include "cmake.h"
cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator(
cmGeneratorTarget* target)
@@ -317,7 +316,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
std::string outpathImp;
if (relink) {
outpath = this->Makefile->GetCurrentBinaryDirectory();
- outpath += cmake::GetCMakeFilesDirectory();
+ outpath += "/CMakeFiles";
outpath += "/CMakeRelink.dir";
cmSystemTools::MakeDirectory(outpath);
outpath += "/";
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 0c2d7b3..72181ab 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -25,7 +25,6 @@
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
-#include "cmake.h"
cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator(
cmGeneratorTarget* target)
@@ -499,7 +498,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
outpath += "/";
} else if (relink) {
outpath = this->Makefile->GetCurrentBinaryDirectory();
- outpath += cmake::GetCMakeFilesDirectory();
+ outpath += "/CMakeFiles";
outpath += "/CMakeRelink.dir";
cmSystemTools::MakeDirectory(outpath);
outpath += "/";
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 1207646..af34169 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -403,7 +403,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
err << "Warning: Source file \"" << source.GetFullPath()
<< "\" is listed multiple times for target \""
<< this->GeneratorTarget->GetName() << "\".";
- cmSystemTools::Message(err.str().c_str(), "Warning");
+ cmSystemTools::Message(err.str(), "Warning");
return;
}
@@ -435,8 +435,8 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
objFullPath = cmSystemTools::CollapseFullPath(objFullPath);
std::string srcFullPath =
cmSystemTools::CollapseFullPath(source.GetFullPath());
- this->LocalGenerator->AddImplicitDepends(
- this->GeneratorTarget, lang, objFullPath.c_str(), srcFullPath.c_str());
+ this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, lang,
+ objFullPath, srcFullPath);
}
void cmMakefileTargetGenerator::WriteObjectBuildFile(
@@ -1213,8 +1213,7 @@ void cmMakefileTargetGenerator::GenerateCustomRuleFile(
std::string objFullPath = cmSystemTools::CollapseFullPath(outputs[0]);
std::string srcFullPath = cmSystemTools::CollapseFullPath(idi.second);
this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, idi.first,
- objFullPath.c_str(),
- srcFullPath.c_str());
+ objFullPath, srcFullPath);
}
}
@@ -1222,7 +1221,7 @@ void cmMakefileTargetGenerator::MakeEchoProgress(
cmLocalUnixMakefileGenerator3::EchoProgress& progress) const
{
progress.Dir = this->LocalGenerator->GetBinaryDirectory();
- progress.Dir += cmake::GetCMakeFilesDirectory();
+ progress.Dir += "/CMakeFiles";
std::ostringstream progressArg;
progressArg << "$(CMAKE_PROGRESS_" << this->NumberOfProgressActions << ")";
progress.Arg = progressArg.str();
@@ -1249,7 +1248,7 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
*this->BuildFileStream << " " << lineContinue << "\n";
*this->BuildFileStream
<< cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
- obj.c_str(), useWatcomQuote);
+ obj, useWatcomQuote);
}
*this->BuildFileStream << "\n";
@@ -1272,7 +1271,7 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
*this->BuildFileStream << " " << lineContinue << "\n";
*this->BuildFileStream
<< cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
- obj.c_str(), useWatcomQuote);
+ obj, useWatcomQuote);
}
*this->BuildFileStream << "\n"
<< "\n";
diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx
index 4c26c66..95f5fcb 100644
--- a/Source/cmMessageCommand.cxx
+++ b/Source/cmMessageCommand.cxx
@@ -70,7 +70,7 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args,
if (status) {
this->Makefile->DisplayStatus(message.c_str(), -1);
} else {
- cmSystemTools::Message(message.c_str());
+ cmSystemTools::Message(message);
}
}
if (fatal) {
diff --git a/Source/cmMessenger.cxx b/Source/cmMessenger.cxx
index 3d788f6..1d790e2 100644
--- a/Source/cmMessenger.cxx
+++ b/Source/cmMessenger.cxx
@@ -124,9 +124,9 @@ void displayMessage(MessageType t, std::ostringstream& msg)
if (t == MessageType::FATAL_ERROR || t == MessageType::INTERNAL_ERROR ||
t == MessageType::DEPRECATION_ERROR || t == MessageType::AUTHOR_ERROR) {
cmSystemTools::SetErrorOccured();
- cmSystemTools::Message(msg.str().c_str(), "Error");
+ cmSystemTools::Message(msg.str(), "Error");
} else {
- cmSystemTools::Message(msg.str().c_str(), "Warning");
+ cmSystemTools::Message(msg.str(), "Warning");
}
}
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 8f6a23a..0d05782 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -31,7 +31,6 @@
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
-#include "cmake.h"
class cmCustomCommand;
@@ -718,8 +717,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement()
globalGen.GetRuleCmdLength(this->LanguageLinkerDeviceRule());
const std::string rspfile = this->ConvertToNinjaPath(
- std::string(cmake::GetCMakeFilesDirectoryPostSlash()) +
- genTarget.GetName() + ".rsp");
+ std::string("CMakeFiles/") + genTarget.GetName() + ".rsp");
// Gather order-only dependencies.
cmNinjaDeps orderOnlyDeps;
@@ -1004,8 +1002,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
}
const std::string rspfile = this->ConvertToNinjaPath(
- std::string(cmake::GetCMakeFilesDirectoryPostSlash()) + gt.GetName() +
- ".rsp");
+ std::string("CMakeFiles/") + gt.GetName() + ".rsp");
// Gather order-only dependencies.
cmNinjaDeps orderOnlyDeps;
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index c959a04..edb0ef3 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -919,7 +919,12 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
}
vars["SWIFT_AUXILIARY_SOURCES"] = aux_sources;
- vars["SWIFT_MODULE_NAME"] = this->GeneratorTarget->GetName();
+ if (const char* name =
+ this->GeneratorTarget->GetProperty("SWIFT_MODULE_NAME")) {
+ vars["SWIFT_MODULE_NAME"] = name;
+ } else {
+ vars["SWIFT_MODULE_NAME"] = this->GeneratorTarget->GetName();
+ }
}
if (!this->NeedDepTypeMSVC(language)) {
diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx
index cc6d4b9..5057dc4 100644
--- a/Source/cmNinjaUtilityTargetGenerator.cxx
+++ b/Source/cmNinjaUtilityTargetGenerator.cxx
@@ -14,7 +14,6 @@
#include "cmSourceFile.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
-#include "cmake.h"
#include <algorithm>
#include <iterator>
@@ -35,7 +34,7 @@ void cmNinjaUtilityTargetGenerator::Generate()
{
std::string utilCommandName =
this->GetLocalGenerator()->GetCurrentBinaryDirectory();
- utilCommandName += cmake::GetCMakeFilesDirectory();
+ utilCommandName += "/CMakeFiles";
utilCommandName += "/";
utilCommandName += this->GetTargetName() + ".util";
utilCommandName = this->ConvertToNinjaPath(utilCommandName);
diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
index 2b96785..6857d5a 100644
--- a/Source/cmOSXBundleGenerator.cxx
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -10,15 +10,16 @@
#include "cmTarget.h"
#include <cassert>
+#include <utility>
class cmSourceFile;
cmOSXBundleGenerator::cmOSXBundleGenerator(cmGeneratorTarget* target,
- const std::string& configName)
+ std::string configName)
: GT(target)
, Makefile(target->Target->GetMakefile())
, LocalGenerator(target->GetLocalGenerator())
- , ConfigName(configName)
+ , ConfigName(std::move(configName))
, MacContentFolders(nullptr)
{
if (this->MustSkip()) {
diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h
index be7e932..ba5bee0 100644
--- a/Source/cmOSXBundleGenerator.h
+++ b/Source/cmOSXBundleGenerator.h
@@ -17,8 +17,7 @@ class cmSourceFile;
class cmOSXBundleGenerator
{
public:
- cmOSXBundleGenerator(cmGeneratorTarget* target,
- const std::string& configName);
+ cmOSXBundleGenerator(cmGeneratorTarget* target, std::string configName);
// create an app bundle at a given root, and return
// the directory within the bundle that contains the executable
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx
index ab1e699..ff1e027 100644
--- a/Source/cmOutputRequiredFilesCommand.cxx
+++ b/Source/cmOutputRequiredFilesCommand.cxx
@@ -194,7 +194,7 @@ protected:
message += includeFile;
message += " for file ";
message += info->FullPath;
- cmSystemTools::Error(message.c_str(), nullptr);
+ cmSystemTools::Error(message);
}
continue;
}
diff --git a/Source/cmPathLabel.cxx b/Source/cmPathLabel.cxx
index 4793206..fb81351 100644
--- a/Source/cmPathLabel.cxx
+++ b/Source/cmPathLabel.cxx
@@ -2,8 +2,10 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmPathLabel.h"
-cmPathLabel::cmPathLabel(const std::string& label)
- : Label(label)
+#include <utility>
+
+cmPathLabel::cmPathLabel(std::string label)
+ : Label(std::move(label))
, Hash(0)
{
// Use a Jenkins one-at-a-time hash with under/over-flow protection
diff --git a/Source/cmPathLabel.h b/Source/cmPathLabel.h
index 97551fb..55dffab 100644
--- a/Source/cmPathLabel.h
+++ b/Source/cmPathLabel.h
@@ -17,7 +17,7 @@
class cmPathLabel
{
public:
- cmPathLabel(const std::string& label);
+ cmPathLabel(std::string label);
// The comparison operators are only for quick sorting and searching and
// in no way imply any lexicographical order of the label
diff --git a/Source/cmPipeConnection.cxx b/Source/cmPipeConnection.cxx
index 999d6f3..1eede13 100644
--- a/Source/cmPipeConnection.cxx
+++ b/Source/cmPipeConnection.cxx
@@ -6,10 +6,10 @@
#include "cmServer.h"
-cmPipeConnection::cmPipeConnection(const std::string& name,
+cmPipeConnection::cmPipeConnection(std::string name,
cmConnectionBufferStrategy* bufferStrategy)
: cmEventBasedConnection(bufferStrategy)
- , PipeName(name)
+ , PipeName(std::move(name))
{
}
diff --git a/Source/cmPipeConnection.h b/Source/cmPipeConnection.h
index 49f9fdf..e67f15c 100644
--- a/Source/cmPipeConnection.h
+++ b/Source/cmPipeConnection.h
@@ -13,7 +13,7 @@
class cmPipeConnection : public cmEventBasedConnection
{
public:
- cmPipeConnection(const std::string& name,
+ cmPipeConnection(std::string name,
cmConnectionBufferStrategy* bufferStrategy = nullptr);
bool OnServeStart(std::string* pString) override;
diff --git a/Source/cmProcessTools.cxx b/Source/cmProcessTools.cxx
index facde5d..a2bc16f 100644
--- a/Source/cmProcessTools.cxx
+++ b/Source/cmProcessTools.cxx
@@ -16,7 +16,7 @@ void cmProcessTools::RunProcess(struct cmsysProcess_s* cp, OutputParser* out,
cmProcessOutput processOutput(encoding);
std::string strdata;
while ((out || err) &&
- (p = cmsysProcess_WaitForData(cp, &data, &length, nullptr), p)) {
+ (p = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) {
if (out && p == cmsysProcess_Pipe_STDOUT) {
processOutput.DecodeText(data, length, strdata, 1);
if (!out->Process(strdata.c_str(), int(strdata.size()))) {
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 47f7d73..1d7f6d1 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -26,7 +26,6 @@
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include "cmake.h"
#include "cmsys/FStream.hxx"
#include "cmsys/SystemInformation.hxx"
@@ -111,7 +110,7 @@ static bool AddToSourceGroup(cmMakefile* makefile, std::string const& fileName,
ost << ": " << property;
ost << ": Could not find or create the source group ";
ost << cmQtAutoGen::Quoted(groupName);
- cmSystemTools::Error(ost.str().c_str());
+ cmSystemTools::Error(ost.str());
return false;
}
}
@@ -352,7 +351,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
// Info directory
this->Dir.Info = cbd;
- this->Dir.Info += cmake::GetCMakeFilesDirectory();
+ this->Dir.Info += "/CMakeFiles";
this->Dir.Info += '/';
this->Dir.Info += this->Target->GetName();
this->Dir.Info += "_autogen";
@@ -521,19 +520,16 @@ bool cmQtAutoGenInitializer::InitMoc()
// Moc includes
{
- // We need to disable this until we have all implicit includes available.
- // See issue #18669.
- // bool const appendImplicit = (this->QtVersion.Major >= 5);
-
+ bool const appendImplicit = (this->QtVersion.Major >= 5);
auto GetIncludeDirs =
- [this, localGen](std::string const& cfg) -> std::vector<std::string> {
- bool const appendImplicit = false;
+ [this, localGen,
+ appendImplicit](std::string const& cfg) -> std::vector<std::string> {
// Get the include dirs for this target, without stripping the implicit
// include dirs off, see
// https://gitlab.kitware.com/cmake/cmake/issues/13667
std::vector<std::string> dirs;
- localGen->GetIncludeDirectories(dirs, this->Target, "CXX", cfg, false,
- appendImplicit);
+ localGen->GetIncludeDirectoriesImplicit(dirs, this->Target, "CXX", cfg,
+ false, appendImplicit);
return dirs;
};
@@ -941,7 +937,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
if (!qrc.Generated) {
std::string error;
if (!RccListInputs(qrc.QrcFile, qrc.Resources, error)) {
- cmSystemTools::Error(error.c_str());
+ cmSystemTools::Error(error);
return false;
}
}
@@ -1219,7 +1215,7 @@ bool cmQtAutoGenInitializer::SetupCustomTargets()
if (!cmSystemTools::MakeDirectory(this->Dir.Info)) {
std::string emsg = ("AutoGen: Could not create directory: ");
emsg += Quoted(this->Dir.Info);
- cmSystemTools::Error(emsg.c_str());
+ cmSystemTools::Error(emsg);
return false;
}
@@ -1307,7 +1303,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
} else {
std::string err = "AutoGen: Could not write file ";
err += this->AutogenTarget.InfoFile;
- cmSystemTools::Error(err.c_str());
+ cmSystemTools::Error(err);
return false;
}
@@ -1347,7 +1343,7 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo()
} else {
std::string err = "AutoRcc: Could not write file ";
err += qrc.InfoFile;
- cmSystemTools::Error(err.c_str());
+ cmSystemTools::Error(err);
return false;
}
}
@@ -1512,7 +1508,7 @@ std::pair<bool, std::string> GetQtExecutable(
msg += target->GetName();
msg += "): ";
msg += err;
- cmSystemTools::Error(msg.c_str());
+ cmSystemTools::Error(msg);
return std::make_pair(false, "");
}
diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx
index c5d5d7c..e2d7deb 100644
--- a/Source/cmQtAutoGenerator.cxx
+++ b/Source/cmQtAutoGenerator.cxx
@@ -54,7 +54,7 @@ void cmQtAutoGenerator::Logger::Info(GeneratorT genType,
}
{
std::lock_guard<std::mutex> lock(Mutex_);
- cmSystemTools::Stdout(msg.c_str(), msg.size());
+ cmSystemTools::Stdout(msg);
}
}
@@ -78,7 +78,7 @@ void cmQtAutoGenerator::Logger::Warning(GeneratorT genType,
msg.push_back('\n');
{
std::lock_guard<std::mutex> lock(Mutex_);
- cmSystemTools::Stdout(msg.c_str(), msg.size());
+ cmSystemTools::Stdout(msg);
}
}
@@ -107,7 +107,7 @@ void cmQtAutoGenerator::Logger::Error(GeneratorT genType,
msg.push_back('\n');
{
std::lock_guard<std::mutex> lock(Mutex_);
- cmSystemTools::Stderr(msg.c_str(), msg.size());
+ cmSystemTools::Stderr(msg);
}
}
@@ -149,7 +149,7 @@ void cmQtAutoGenerator::Logger::ErrorCommand(
msg.push_back('\n');
{
std::lock_guard<std::mutex> lock(Mutex_);
- cmSystemTools::Stderr(msg.c_str(), msg.size());
+ cmSystemTools::Stderr(msg);
}
}
diff --git a/Source/cmQtAutoGeneratorMocUic.h b/Source/cmQtAutoGeneratorMocUic.h
index 9ec1def..0df2cff 100644
--- a/Source/cmQtAutoGeneratorMocUic.h
+++ b/Source/cmQtAutoGeneratorMocUic.h
@@ -49,8 +49,8 @@ public:
{
}
- KeyExpT(std::string const& key, std::string const& exp)
- : Key(key)
+ KeyExpT(std::string key, std::string const& exp)
+ : Key(std::move(key))
, Exp(exp)
{
}
@@ -240,10 +240,10 @@ public:
class JobMocT : public JobT
{
public:
- JobMocT(std::string&& sourceFile, std::string const& includerFile,
+ JobMocT(std::string&& sourceFile, std::string includerFile,
std::string&& includeString)
: SourceFile(std::move(sourceFile))
- , IncluderFile(includerFile)
+ , IncluderFile(std::move(includerFile))
, IncludeString(std::move(includeString))
{
}
@@ -269,10 +269,10 @@ public:
class JobUicT : public JobT
{
public:
- JobUicT(std::string&& sourceFile, std::string const& includerFile,
+ JobUicT(std::string&& sourceFile, std::string includerFile,
std::string&& includeString)
: SourceFile(std::move(sourceFile))
- , IncluderFile(includerFile)
+ , IncluderFile(std::move(includerFile))
, IncludeString(std::move(includeString))
{
}
diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx
index 2866a39..55204d7 100644
--- a/Source/cmRST.cxx
+++ b/Source/cmRST.cxx
@@ -13,9 +13,9 @@
#include <stddef.h>
#include <utility>
-cmRST::cmRST(std::ostream& os, std::string const& docroot)
+cmRST::cmRST(std::ostream& os, std::string docroot)
: OS(os)
- , DocRoot(docroot)
+ , DocRoot(std::move(docroot))
, IncludeDepth(0)
, OutputLinePending(false)
, LastLineEndedInColonColon(false)
diff --git a/Source/cmRST.h b/Source/cmRST.h
index ee47867..d8d2a0b 100644
--- a/Source/cmRST.h
+++ b/Source/cmRST.h
@@ -25,7 +25,7 @@
class cmRST
{
public:
- cmRST(std::ostream& os, std::string const& docroot);
+ cmRST(std::ostream& os, std::string docroot);
bool ProcessFile(std::string const& fname, bool isModule = false);
private:
diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx
index c3e8ff5..e347a2c 100644
--- a/Source/cmRulePlaceholderExpander.cxx
+++ b/Source/cmRulePlaceholderExpander.cxx
@@ -10,13 +10,13 @@
#include "cmSystemTools.h"
cmRulePlaceholderExpander::cmRulePlaceholderExpander(
- std::map<std::string, std::string> const& compilers,
- std::map<std::string, std::string> const& variableMappings,
- std::string const& compilerSysroot, std::string const& linkerSysroot)
- : Compilers(compilers)
- , VariableMappings(variableMappings)
- , CompilerSysroot(compilerSysroot)
- , LinkerSysroot(linkerSysroot)
+ std::map<std::string, std::string> compilers,
+ std::map<std::string, std::string> variableMappings,
+ std::string compilerSysroot, std::string linkerSysroot)
+ : Compilers(std::move(compilers))
+ , VariableMappings(std::move(variableMappings))
+ , CompilerSysroot(std::move(compilerSysroot))
+ , LinkerSysroot(std::move(linkerSysroot))
{
}
diff --git a/Source/cmRulePlaceholderExpander.h b/Source/cmRulePlaceholderExpander.h
index 7aa63db..5c03637 100644
--- a/Source/cmRulePlaceholderExpander.h
+++ b/Source/cmRulePlaceholderExpander.h
@@ -15,9 +15,9 @@ class cmRulePlaceholderExpander
{
public:
cmRulePlaceholderExpander(
- std::map<std::string, std::string> const& compilers,
- std::map<std::string, std::string> const& variableMappings,
- std::string const& compilerSysroot, std::string const& linkerSysroot);
+ std::map<std::string, std::string> compilers,
+ std::map<std::string, std::string> variableMappings,
+ std::string compilerSysroot, std::string linkerSysroot);
void SetTargetImpLib(std::string const& targetImpLib)
{
diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx
index 2cae714..ae0a158 100644
--- a/Source/cmScriptGenerator.cxx
+++ b/Source/cmScriptGenerator.cxx
@@ -4,11 +4,12 @@
#include "cmSystemTools.h"
-cmScriptGenerator::cmScriptGenerator(
- const std::string& config_var,
- std::vector<std::string> const& configurations)
- : RuntimeConfigVariable(config_var)
- , Configurations(configurations)
+#include <utility>
+
+cmScriptGenerator::cmScriptGenerator(std::string config_var,
+ std::vector<std::string> configurations)
+ : RuntimeConfigVariable(std::move(config_var))
+ , Configurations(std::move(configurations))
, ConfigurationName("")
, ConfigurationTypes(nullptr)
, ActionsPerConfig(false)
diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h
index 0bb388e..725cbc6 100644
--- a/Source/cmScriptGenerator.h
+++ b/Source/cmScriptGenerator.h
@@ -47,8 +47,8 @@ class cmScriptGenerator
CM_DISABLE_COPY(cmScriptGenerator)
public:
- cmScriptGenerator(const std::string& config_var,
- std::vector<std::string> const& configurations);
+ cmScriptGenerator(std::string config_var,
+ std::vector<std::string> configurations);
virtual ~cmScriptGenerator();
void Generate(std::ostream& os, const std::string& config,
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index 11a3f46..c3c8156 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -20,6 +20,7 @@
#include <functional>
#include <memory>
#include <string>
+#include <utility>
#include <vector>
// Get rid of some windows macros:
@@ -39,11 +40,10 @@ std::vector<std::string> toStringList(const Json::Value& in)
} // namespace
cmServerRequest::cmServerRequest(cmServer* server, cmConnection* connection,
- const std::string& t, const std::string& c,
- const Json::Value& d)
- : Type(t)
- , Cookie(c)
- , Data(d)
+ std::string t, std::string c, Json::Value d)
+ : Type(std::move(t))
+ , Cookie(std::move(c))
+ , Data(std::move(d))
, Connection(connection)
, m_Server(server)
{
@@ -707,15 +707,15 @@ cmServerResponse cmServerProtocol1::ProcessCTests(
}
cmServerProtocol1::GeneratorInformation::GeneratorInformation(
- const std::string& generatorName, const std::string& extraGeneratorName,
- const std::string& toolset, const std::string& platform,
- const std::string& sourceDirectory, const std::string& buildDirectory)
- : GeneratorName(generatorName)
- , ExtraGeneratorName(extraGeneratorName)
- , Toolset(toolset)
- , Platform(platform)
- , SourceDirectory(sourceDirectory)
- , BuildDirectory(buildDirectory)
+ std::string generatorName, std::string extraGeneratorName,
+ std::string toolset, std::string platform, std::string sourceDirectory,
+ std::string buildDirectory)
+ : GeneratorName(std::move(generatorName))
+ , ExtraGeneratorName(std::move(extraGeneratorName))
+ , Toolset(std::move(toolset))
+ , Platform(std::move(platform))
+ , SourceDirectory(std::move(sourceDirectory))
+ , BuildDirectory(std::move(buildDirectory))
{
}
diff --git a/Source/cmServerProtocol.h b/Source/cmServerProtocol.h
index df71cff..2d1507b 100644
--- a/Source/cmServerProtocol.h
+++ b/Source/cmServerProtocol.h
@@ -56,9 +56,8 @@ public:
cmConnection* Connection;
private:
- cmServerRequest(cmServer* server, cmConnection* connection,
- const std::string& t, const std::string& c,
- const Json::Value& d);
+ cmServerRequest(cmServer* server, cmConnection* connection, std::string t,
+ std::string c, Json::Value d);
void ReportProgress(int min, int current, int max,
const std::string& message) const;
@@ -140,12 +139,10 @@ private:
{
public:
GeneratorInformation() = default;
- GeneratorInformation(const std::string& generatorName,
- const std::string& extraGeneratorName,
- const std::string& toolset,
- const std::string& platform,
- const std::string& sourceDirectory,
- const std::string& buildDirectory);
+ GeneratorInformation(std::string generatorName,
+ std::string extraGeneratorName, std::string toolset,
+ std::string platform, std::string sourceDirectory,
+ std::string buildDirectory);
void SetupGenerator(cmake* cm, std::string* errorMessage);
diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx
index 12ef62b..7e1e836 100644
--- a/Source/cmSourceGroup.cxx
+++ b/Source/cmSourceGroup.cxx
@@ -2,15 +2,17 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSourceGroup.h"
+#include <utility>
+
class cmSourceGroupInternals
{
public:
std::vector<cmSourceGroup> GroupChildren;
};
-cmSourceGroup::cmSourceGroup(const std::string& name, const char* regex,
+cmSourceGroup::cmSourceGroup(std::string name, const char* regex,
const char* parentName)
- : Name(name)
+ : Name(std::move(name))
{
this->Internal = new cmSourceGroupInternals;
this->SetGroupRegex(regex);
diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h
index b39f8dd..7c65494 100644
--- a/Source/cmSourceGroup.h
+++ b/Source/cmSourceGroup.h
@@ -26,7 +26,7 @@ class cmSourceGroupInternals;
class cmSourceGroup
{
public:
- cmSourceGroup(const std::string& name, const char* regex,
+ cmSourceGroup(std::string name, const char* regex,
const char* parentName = nullptr);
cmSourceGroup(cmSourceGroup const& r);
~cmSourceGroup();
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index d4d3df5..fdd7b3d 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -545,10 +545,10 @@ const char* cmState::GetGlobalProperty(const std::string& prop)
}
#define STRING_LIST_ELEMENT(F) ";" #F
if (prop == "CMAKE_C_KNOWN_FEATURES") {
- return FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT) + 1;
+ return &FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT)[1];
}
if (prop == "CMAKE_CXX_KNOWN_FEATURES") {
- return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1;
+ return &FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT)[1];
}
#undef STRING_LIST_ELEMENT
return this->GlobalProperties.GetPropertyValue(prop);
diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx
index a4305e6..63bec71 100644
--- a/Source/cmStateSnapshot.cxx
+++ b/Source/cmStateSnapshot.cxx
@@ -16,7 +16,6 @@
#include "cmStateDirectory.h"
#include "cmStatePrivate.h"
#include "cmVersion.h"
-#include "cmake.h"
#if !defined(_WIN32)
# include <sys/utsname.h>
@@ -348,8 +347,7 @@ void cmStateSnapshot::SetDefaultDefinitions()
std::to_string(cmVersion::GetTweakVersion()));
this->SetDefinition("CMAKE_VERSION", cmVersion::GetCMakeVersion());
- this->SetDefinition("CMAKE_FILES_DIRECTORY",
- cmake::GetCMakeFilesDirectory());
+ this->SetDefinition("CMAKE_FILES_DIRECTORY", "/CMakeFiles");
// Setup the default include file regular expression (match everything).
this->Position->BuildSystemDirectory->Properties.SetProperty(
diff --git a/Source/cmStringReplaceHelper.cxx b/Source/cmStringReplaceHelper.cxx
index f50cf58..4a62987 100644
--- a/Source/cmStringReplaceHelper.cxx
+++ b/Source/cmStringReplaceHelper.cxx
@@ -5,13 +5,14 @@
#include "cmMakefile.h"
#include <sstream>
+#include <utility>
cmStringReplaceHelper::cmStringReplaceHelper(const std::string& regex,
- const std::string& replace_expr,
+ std::string replace_expr,
cmMakefile* makefile)
: RegExString(regex)
, RegularExpression(regex)
- , ReplaceExpression(replace_expr)
+ , ReplaceExpression(std::move(replace_expr))
, Makefile(makefile)
{
this->ParseReplaceExpression();
diff --git a/Source/cmStringReplaceHelper.h b/Source/cmStringReplaceHelper.h
index 3e76d86..5cebde7 100644
--- a/Source/cmStringReplaceHelper.h
+++ b/Source/cmStringReplaceHelper.h
@@ -6,6 +6,7 @@
#include "cmsys/RegularExpression.hxx"
#include <string>
+#include <utility>
#include <vector>
class cmMakefile;
@@ -13,8 +14,7 @@ class cmMakefile;
class cmStringReplaceHelper
{
public:
- cmStringReplaceHelper(const std::string& regex,
- const std::string& replace_expr,
+ cmStringReplaceHelper(const std::string& regex, std::string replace_expr,
cmMakefile* makefile = nullptr);
bool IsRegularExpressionValid() const
@@ -39,9 +39,9 @@ private:
, Value(s)
{
}
- RegexReplacement(const std::string& s)
+ RegexReplacement(std::string s)
: Number(-1)
- , Value(s)
+ , Value(std::move(s))
{
}
RegexReplacement(int n)
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 71a9cb4..f7de3aa 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -267,7 +267,14 @@ void cmSystemTools::Error(const char* m1, const char* m2, const char* m3,
message += m4;
}
cmSystemTools::s_ErrorOccured = true;
- cmSystemTools::Message(message.c_str(), "Error");
+ cmSystemTools::Message(message, "Error");
+}
+
+void cmSystemTools::Error(const std::string& m)
+{
+ std::string message = "CMake Error: " + m;
+ cmSystemTools::s_ErrorOccured = true;
+ cmSystemTools::Message(message, "Error");
}
void cmSystemTools::SetInterruptCallback(InterruptCallback f, void* clientData)
@@ -302,33 +309,21 @@ void cmSystemTools::SetStderrCallback(OutputCallback f, void* clientData)
s_StderrCallbackClientData = clientData;
}
-void cmSystemTools::Stdout(const char* s)
-{
- cmSystemTools::Stdout(s, strlen(s));
-}
-
-void cmSystemTools::Stderr(const char* s)
-{
- cmSystemTools::Stderr(s, strlen(s));
-}
-
-void cmSystemTools::Stderr(const char* s, size_t length)
+void cmSystemTools::Stderr(const std::string& s)
{
if (s_StderrCallback) {
- (*s_StderrCallback)(s, length, s_StderrCallbackClientData);
+ (*s_StderrCallback)(s.c_str(), s.length(), s_StderrCallbackClientData);
} else {
- std::cerr.write(s, length);
- std::cerr.flush();
+ std::cerr << s << std::flush;
}
}
-void cmSystemTools::Stdout(const char* s, size_t length)
+void cmSystemTools::Stdout(const std::string& s)
{
if (s_StdoutCallback) {
- (*s_StdoutCallback)(s, length, s_StdoutCallbackClientData);
+ (*s_StdoutCallback)(s.c_str(), s.length(), s_StdoutCallbackClientData);
} else {
- std::cout.write(s, length);
- std::cout.flush();
+ std::cout << s << std::flush;
}
}
@@ -350,7 +345,7 @@ void cmSystemTools::ReportLastSystemError(const char* msg)
std::string m = msg;
m += ": System Error: ";
m += Superclass::GetLastSystemError();
- cmSystemTools::Error(m.c_str());
+ cmSystemTools::Error(m);
}
bool cmSystemTools::IsInternallyOn(const char* val)
@@ -561,7 +556,7 @@ std::vector<std::string> cmSystemTools::HandleResponseFile(
error += cmSystemTools::GetLastSystemError();
error += "):\n ";
error += arg.substr(1);
- cmSystemTools::Error(error.c_str());
+ cmSystemTools::Error(error);
} else {
std::string line;
cmSystemTools::GetLineFromStream(responseFile, line);
@@ -792,7 +787,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
if (pipe == cmsysProcess_Pipe_STDOUT) {
if (outputflag != OUTPUT_NONE) {
processOutput.DecodeText(data, length, strdata, 1);
- cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ cmSystemTools::Stdout(strdata);
}
if (captureStdOut) {
tempStdOut.insert(tempStdOut.end(), data, data + length);
@@ -800,7 +795,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
} else if (pipe == cmsysProcess_Pipe_STDERR) {
if (outputflag != OUTPUT_NONE) {
processOutput.DecodeText(data, length, strdata, 2);
- cmSystemTools::Stderr(strdata.c_str(), strdata.size());
+ cmSystemTools::Stderr(strdata);
}
if (captureStdErr) {
tempStdErr.insert(tempStdErr.end(), data, data + length);
@@ -811,11 +806,11 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
if (outputflag != OUTPUT_NONE) {
processOutput.DecodeText(std::string(), strdata, 1);
if (!strdata.empty()) {
- cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ cmSystemTools::Stdout(strdata);
}
processOutput.DecodeText(std::string(), strdata, 2);
if (!strdata.empty()) {
- cmSystemTools::Stderr(strdata.c_str(), strdata.size());
+ cmSystemTools::Stderr(strdata);
}
}
}
@@ -1040,7 +1035,8 @@ void cmSystemTools::InitializeLibUV()
#endif
}
-bool cmSystemTools::RenameFile(const char* oldname, const char* newname)
+bool cmSystemTools::RenameFile(const std::string& oldname,
+ const std::string& newname)
{
#ifdef _WIN32
# ifndef INVALID_FILE_ATTRIBUTES
@@ -1078,7 +1074,7 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname)
return retry.Count > 0;
#else
/* On UNIX we have an OS-provided call to do this atomically. */
- return rename(oldname, newname) == 0;
+ return rename(oldname.c_str(), newname.c_str()) == 0;
#endif
}
@@ -1663,7 +1659,7 @@ bool cmSystemTools::CreateTar(const char* outFileName,
e += outFileName;
e += "\": ";
e += cmSystemTools::GetLastSystemError();
- cmSystemTools::Error(e.c_str());
+ cmSystemTools::Error(e);
return false;
}
cmArchiveWrite::Compress compress = cmArchiveWrite::CompressNone;
@@ -1696,7 +1692,7 @@ bool cmSystemTools::CreateTar(const char* outFileName,
}
}
if (!a) {
- cmSystemTools::Error(a.GetError().c_str());
+ cmSystemTools::Error(a.GetError());
return false;
}
return true;
@@ -1899,13 +1895,13 @@ bool extract_tar(const char* outFileName, bool verbose, bool extract)
if (verbose) {
if (extract) {
cmSystemTools::Stdout("x ");
- cmSystemTools::Stdout(cm_archive_entry_pathname(entry).c_str());
+ cmSystemTools::Stdout(cm_archive_entry_pathname(entry));
} else {
list_item_verbose(stdout, entry);
}
cmSystemTools::Stdout("\n");
} else if (!extract) {
- cmSystemTools::Stdout(cm_archive_entry_pathname(entry).c_str());
+ cmSystemTools::Stdout(cm_archive_entry_pathname(entry));
cmSystemTools::Stdout("\n");
}
if (extract) {
@@ -3132,7 +3128,7 @@ bool cmSystemTools::CreateSymlink(const std::string& origName,
if (errorMessage) {
*errorMessage = std::move(e);
} else {
- cmSystemTools::Error(e.c_str());
+ cmSystemTools::Error(e);
}
return false;
}
@@ -3153,7 +3149,7 @@ bool cmSystemTools::CreateLink(const std::string& origName,
if (errorMessage) {
*errorMessage = std::move(e);
} else {
- cmSystemTools::Error(e.c_str());
+ cmSystemTools::Error(e);
}
return false;
}
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 489811d..b1d5751 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -70,22 +70,25 @@ public:
*/
static void Error(const char* m, const char* m2 = nullptr,
const char* m3 = nullptr, const char* m4 = nullptr);
+ static void Error(const std::string& m);
/**
* Display a message.
*/
static void Message(const char* m, const char* title = nullptr);
+ static void Message(const std::string& m, const char* title = nullptr)
+ {
+ Message(m.c_str(), title);
+ }
typedef void (*OutputCallback)(const char*, size_t length, void*);
///! Send a string to stdout
- static void Stdout(const char* s);
- static void Stdout(const char* s, size_t length);
+ static void Stdout(const std::string& s);
static void SetStdoutCallback(OutputCallback, void* clientData = nullptr);
///! Send a string to stderr
- static void Stderr(const char* s);
- static void Stderr(const char* s, size_t length);
+ static void Stderr(const std::string& s);
static void SetStderrCallback(OutputCallback, void* clientData = nullptr);
typedef bool (*InterruptCallback)(void*);
@@ -181,7 +184,8 @@ public:
/** Rename a file or directory within a single disk volume (atomic
if possible). */
- static bool RenameFile(const char* oldname, const char* newname);
+ static bool RenameFile(const std::string& oldname,
+ const std::string& newname);
///! Compute the hash of a file
static std::string ComputeFileHash(const std::string& source,
diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx
index 1e2ddc7..6032701 100644
--- a/Source/cmTestGenerator.cxx
+++ b/Source/cmTestGenerator.cxx
@@ -90,7 +90,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
// Prepend with the emulator when cross compiling if required.
const char* emulator = target->GetProperty("CROSSCOMPILING_EMULATOR");
- if (emulator != nullptr) {
+ if (emulator != nullptr && *emulator) {
std::vector<std::string> emulatorWithArgs;
cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs);
std::string emulatorExe(emulatorWithArgs[0]);
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index 10a6d9a..c57aabd 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -121,7 +121,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv,
// now try running the command if it compiled
if (!res) {
if (this->OutputFile.empty()) {
- cmSystemTools::Error(this->FindErrorMessage.c_str());
+ cmSystemTools::Error(this->FindErrorMessage);
} else {
// "run" it and capture the output
std::string runOutputContents;
@@ -217,7 +217,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
// removed at the end of TRY_RUN and the user can run it manually
// on the target platform.
std::string copyDest = this->Makefile->GetHomeOutputDirectory();
- copyDest += cmake::GetCMakeFilesDirectory();
+ copyDest += "/CMakeFiles";
copyDest += "/";
copyDest += cmSystemTools::GetFilenameWithoutExtension(this->OutputFile);
copyDest += "-";
@@ -354,7 +354,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
errorMessage += " " + internalRunOutputName + " (advanced)\n";
}
errorMessage += detailsString;
- cmSystemTools::Error(errorMessage.c_str());
+ cmSystemTools::Error(errorMessage);
return;
}
diff --git a/Source/cmUnexpectedCommand.h b/Source/cmUnexpectedCommand.h
index 7154881..33d6bdc 100644
--- a/Source/cmUnexpectedCommand.h
+++ b/Source/cmUnexpectedCommand.h
@@ -6,6 +6,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include <utility>
#include <vector>
#include "cmCommand.h"
@@ -15,8 +16,8 @@ class cmExecutionStatus;
class cmUnexpectedCommand : public cmCommand
{
public:
- cmUnexpectedCommand(std::string const& name, const char* error)
- : Name(name)
+ cmUnexpectedCommand(std::string name, const char* error)
+ : Name(std::move(name))
, Error(error)
{
}
diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx
index f374626..231bca4 100644
--- a/Source/cmUtilitySourceCommand.cxx
+++ b/Source/cmUtilitySourceCommand.cxx
@@ -40,7 +40,7 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args,
msg += ". If your intention is to run this executable, you need to "
"preload the cache with the full path to a version of that "
"program, which runs on this build machine.";
- cmSystemTools::Message(msg.c_str(), "Warning");
+ cmSystemTools::Message(msg, "Warning");
}
} else {
cmState* state = this->Makefile->GetState();
diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx
index 9187c29..91a0e15 100644
--- a/Source/cmVSSetupHelper.cxx
+++ b/Source/cmVSSetupHelper.cxx
@@ -188,8 +188,16 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo(
// Check if a compiler is installed with this instance.
{
std::string const vcRoot = vsInstanceInfo.GetInstallLocation();
- std::string const vcToolsVersionFile =
+ std::string vcToolsVersionFile =
vcRoot + "/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt";
+ if (!cmSystemTools::PathExists(vcToolsVersionFile)) {
+ // FIXME: VS 2019 Preview 2 installs the v142 toolset and does not
+ // provide the plain `Microsoft.VCToolsVersion.default.txt` that v141
+ // does. This should be fixed in preview 3 and this workaround can
+ // be dropped. Otherwise, we may need to switch to globbing.
+ vcToolsVersionFile = vcRoot +
+ "/VC/Auxiliary/Build/Microsoft.VCToolsVersion.v142.default.txt";
+ }
std::string vcToolsVersion;
cmsys::ifstream fin(vcToolsVersionFile.c_str());
if (!fin || !cmSystemTools::GetLineFromStream(fin, vcToolsVersion)) {
diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx
index 06ca53c..c02157a 100644
--- a/Source/cmVariableRequiresCommand.cxx
+++ b/Source/cmVariableRequiresCommand.cxx
@@ -57,7 +57,7 @@ bool cmVariableRequiresCommand::InitialPass(
"One or more of the required variables is advanced."
" To set the variable, you must turn on advanced mode in cmake.";
}
- cmSystemTools::Error(message.c_str());
+ cmSystemTools::Error(message);
}
return true;
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index 03e0059..975d6e4 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -60,7 +60,7 @@ static void cmVariableWatchCommandVariableAccessed(const std::string& variable,
error << "Error in cmake code at\nUnknown:0:\n"
<< "A command failed during the invocation of callback \""
<< data->Command << "\".";
- cmSystemTools::Error(error.str().c_str());
+ cmSystemTools::Error(error.str());
data->InCallback = false;
return;
}
diff --git a/Source/cmVisualStudio10ToolsetOptions.cxx b/Source/cmVisualStudio10ToolsetOptions.cxx
index 39063ed..a490e03 100644
--- a/Source/cmVisualStudio10ToolsetOptions.cxx
+++ b/Source/cmVisualStudio10ToolsetOptions.cxx
@@ -11,7 +11,9 @@ std::string cmVisualStudio10ToolsetOptions::GetClFlagTableName(
{
std::string const useToolset = this->GetToolsetName(name, toolset);
- if (toolset == "v141") {
+ if (toolset == "v142") {
+ return "v142";
+ } else if (toolset == "v141") {
return "v141";
} else if (useToolset == "v140") {
return "v140";
@@ -31,7 +33,10 @@ std::string cmVisualStudio10ToolsetOptions::GetCSharpFlagTableName(
{
std::string const useToolset = this->GetToolsetName(name, toolset);
- if ((useToolset == "v141")) {
+ if (useToolset == "v142") {
+ // FIXME: Add CSharp flag table for v142.
+ return "v141";
+ } else if (useToolset == "v141") {
return "v141";
} else if (useToolset == "v140") {
return "v140";
@@ -51,7 +56,8 @@ std::string cmVisualStudio10ToolsetOptions::GetRcFlagTableName(
{
std::string const useToolset = this->GetToolsetName(name, toolset);
- if ((useToolset == "v140") || (useToolset == "v141")) {
+ if ((useToolset == "v140") || (useToolset == "v141") ||
+ (useToolset == "v142")) {
return "v14";
} else if (useToolset == "v120") {
return "v12";
@@ -69,7 +75,8 @@ std::string cmVisualStudio10ToolsetOptions::GetLibFlagTableName(
{
std::string const useToolset = this->GetToolsetName(name, toolset);
- if ((useToolset == "v140") || (useToolset == "v141")) {
+ if ((useToolset == "v140") || (useToolset == "v141") ||
+ (useToolset == "v142")) {
return "v14";
} else if (useToolset == "v120") {
return "v12";
@@ -87,7 +94,9 @@ std::string cmVisualStudio10ToolsetOptions::GetLinkFlagTableName(
{
std::string const useToolset = this->GetToolsetName(name, toolset);
- if (useToolset == "v141") {
+ if (useToolset == "v142") {
+ return "v142";
+ } else if (useToolset == "v141") {
return "v141";
} else if (useToolset == "v140") {
return "v140";
@@ -107,7 +116,8 @@ std::string cmVisualStudio10ToolsetOptions::GetMasmFlagTableName(
{
std::string const useToolset = this->GetToolsetName(name, toolset);
- if ((useToolset == "v140") || (useToolset == "v141")) {
+ if ((useToolset == "v140") || (useToolset == "v141") ||
+ (useToolset == "v142")) {
return "v14";
} else if (useToolset == "v120") {
return "v12";
diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx
index d301ad0..1b16198 100644
--- a/Source/cmXCodeScheme.cxx
+++ b/Source/cmXCodeScheme.cxx
@@ -5,16 +5,17 @@
#include <iomanip>
#include <iostream>
#include <sstream>
+#include <utility>
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmXMLSafe.h"
-cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj, const TestObjects& tests,
+cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj, TestObjects tests,
const std::vector<std::string>& configList,
unsigned int xcVersion)
: Target(xcObj)
- , Tests(tests)
+ , Tests(std::move(tests))
, TargetName(xcObj->GetTarget()->GetName())
, ConfigList(configList)
, XcodeVersion(xcVersion)
diff --git a/Source/cmXCodeScheme.h b/Source/cmXCodeScheme.h
index 96c76e6..8c47123 100644
--- a/Source/cmXCodeScheme.h
+++ b/Source/cmXCodeScheme.h
@@ -20,7 +20,7 @@ class cmXCodeScheme
public:
typedef std::vector<const cmXCodeObject*> TestObjects;
- cmXCodeScheme(cmXCodeObject* xcObj, const TestObjects& tests,
+ cmXCodeScheme(cmXCodeObject* xcObj, TestObjects tests,
const std::vector<std::string>& configList,
unsigned int xcVersion);
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index b97feab..6127094 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -115,8 +115,10 @@ typedef std::unordered_map<std::string, Json::Value> JsonValueMapType;
} // namespace
-static bool cmakeCheckStampFile(const char* stampName, bool verbose = true);
-static bool cmakeCheckStampList(const char* stampList, bool verbose = true);
+static bool cmakeCheckStampFile(const std::string& stampName,
+ bool verbose = true);
+static bool cmakeCheckStampList(const std::string& stampList,
+ bool verbose = true);
void cmWarnUnusedCliWarning(const std::string& variable, int /*unused*/,
void* ctx, const char* /*unused*/,
@@ -810,8 +812,11 @@ void cmake::SetArgs(const std::vector<std::string>& args)
if (this->CurrentWorkingMode == cmake::NORMAL_MODE && !haveSourceDir &&
!haveBinaryDir) {
- cmSystemTools::Error("No source or binary directory provided");
- return;
+ this->IssueMessage(
+ MessageType::WARNING,
+ "No source or binary directory provided. Both will be assumed to be "
+ "the same as the current working directory, but note that this "
+ "warning will become a fatal error in future CMake releases.");
}
if (!haveSourceDir) {
@@ -959,17 +964,25 @@ void cmake::AddDefaultExtraGenerators()
#endif
}
-void cmake::GetRegisteredGenerators(
- std::vector<GeneratorInfo>& generators) const
+void cmake::GetRegisteredGenerators(std::vector<GeneratorInfo>& generators,
+ bool includeNamesWithPlatform) const
{
for (cmGlobalGeneratorFactory* gen : this->Generators) {
- std::vector<std::string> names;
- gen->GetGenerators(names);
+ std::vector<std::string> names = gen->GetGeneratorNames();
+
+ if (includeNamesWithPlatform) {
+ std::vector<std::string> namesWithPlatform =
+ gen->GetGeneratorNamesWithPlatform();
+ names.insert(names.end(), namesWithPlatform.begin(),
+ namesWithPlatform.end());
+ }
for (std::string const& name : names) {
GeneratorInfo info;
info.supportsToolset = gen->SupportsToolset();
info.supportsPlatform = gen->SupportsPlatform();
+ info.supportedPlatforms = gen->GetKnownPlatforms();
+ info.defaultPlatform = gen->GetDefaultPlatformName();
info.name = name;
info.baseName = name;
info.isAlias = false;
@@ -1161,7 +1174,7 @@ int cmake::DoPreConfigureChecks()
}
err << "Specify --help for usage, or press the help button on the CMake "
"GUI.";
- cmSystemTools::Error(err.str().c_str());
+ cmSystemTools::Error(err.str());
return -2;
}
@@ -1179,7 +1192,7 @@ int cmake::DoPreConfigureChecks()
message += cacheStart;
message += "\" used to generate cache. ";
message += "Re-run cmake with a different source directory.";
- cmSystemTools::Error(message.c_str());
+ cmSystemTools::Error(message);
return -2;
}
} else {
@@ -1239,7 +1252,7 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)
for (SaveCacheEntry const& i : saved) {
this->AddCacheEntry(i.key, i.value.c_str(), i.help.c_str(), i.type);
}
- cmSystemTools::Message(warning.str().c_str());
+ cmSystemTools::Message(warning.str());
// avoid reconfigure if there were errors
if (!cmSystemTools::GetErrorOccuredFlag()) {
// re-run configure
@@ -1389,7 +1402,7 @@ int cmake::ActualConfigure()
message += *genName;
message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
"directory or choose a different binary directory.";
- cmSystemTools::Error(message.c_str());
+ cmSystemTools::Error(message);
return -2;
}
}
@@ -1413,7 +1426,7 @@ int cmake::ActualConfigure()
message += *instance;
message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
"directory or choose a different binary directory.";
- cmSystemTools::Error(message.c_str());
+ cmSystemTools::Error(message);
return -2;
}
} else {
@@ -1432,7 +1445,7 @@ int cmake::ActualConfigure()
message += *platformName;
message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
"directory or choose a different binary directory.";
- cmSystemTools::Error(message.c_str());
+ cmSystemTools::Error(message);
return -2;
}
} else {
@@ -1450,7 +1463,7 @@ int cmake::ActualConfigure()
message += *tsName;
message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
"directory or choose a different binary directory.";
- cmSystemTools::Error(message.c_str());
+ cmSystemTools::Error(message);
return -2;
}
} else {
@@ -1519,7 +1532,7 @@ int cmake::ActualConfigure()
return 0;
}
-void cmake::CreateDefaultGlobalGenerator()
+std::unique_ptr<cmGlobalGenerator> cmake::EvaluateDefaultGlobalGenerator()
{
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW)
std::string found;
@@ -1572,13 +1585,22 @@ void cmake::CreateDefaultGlobalGenerator()
if (!gen) {
gen = new cmGlobalNMakeMakefileGenerator(this);
}
- this->SetGlobalGenerator(gen);
- std::cout << "-- Building for: " << gen->GetName() << "\n";
+ return std::unique_ptr<cmGlobalGenerator>(gen);
#else
- this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator3(this));
+ return cm::make_unique<cmGlobalUnixMakefileGenerator3>(this);
#endif
}
+void cmake::CreateDefaultGlobalGenerator()
+{
+ auto gen = this->EvaluateDefaultGlobalGenerator();
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW)
+ // This print could be unified for all platforms
+ std::cout << "-- Building for: " << gen->GetName() << "\n";
+#endif
+ this->SetGlobalGenerator(gen.release());
+}
+
void cmake::PreLoadCMakeFiles()
{
std::vector<std::string> args;
@@ -1609,13 +1631,13 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
// If we are given a stamp list file check if it is really out of date.
if (!this->CheckStampList.empty() &&
- cmakeCheckStampList(this->CheckStampList.c_str())) {
+ cmakeCheckStampList(this->CheckStampList)) {
return 0;
}
// If we are given a stamp file check if it is really out of date.
if (!this->CheckStampFile.empty() &&
- cmakeCheckStampFile(this->CheckStampFile.c_str())) {
+ cmakeCheckStampFile(this->CheckStampFile)) {
return 0;
}
@@ -1924,13 +1946,28 @@ void cmake::SetIsInTryCompile(bool b)
this->State->SetIsInTryCompile(b);
}
-void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v)
+void cmake::AppendGlobalGeneratorsDocumentation(
+ std::vector<cmDocumentationEntry>& v)
{
+ const auto defaultGenerator = this->EvaluateDefaultGlobalGenerator();
+ const std::string defaultName = defaultGenerator->GetName();
+ bool foundDefaultOne = false;
+
for (cmGlobalGeneratorFactory* g : this->Generators) {
cmDocumentationEntry e;
g->GetDocumentation(e);
+ if (!foundDefaultOne &&
+ cmSystemTools::StringStartsWith(e.Name, defaultName.c_str())) {
+ e.CustomNamePrefix = '*';
+ foundDefaultOne = true;
+ }
v.push_back(std::move(e));
}
+}
+
+void cmake::AppendExtraGeneratorsDocumentation(
+ std::vector<cmDocumentationEntry>& v)
+{
for (cmExternalMakefileProjectGeneratorFactory* eg : this->ExtraGenerators) {
const std::string doc = eg->GetDocumentation();
const std::string name = eg->GetName();
@@ -1956,12 +1993,19 @@ void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v)
}
}
+std::vector<cmDocumentationEntry> cmake::GetGeneratorsDocumentation()
+{
+ std::vector<cmDocumentationEntry> v;
+ this->AppendGlobalGeneratorsDocumentation(v);
+ this->AppendExtraGeneratorsDocumentation(v);
+ return v;
+}
+
void cmake::PrintGeneratorList()
{
#ifdef CMAKE_BUILD_WITH_CMAKE
cmDocumentation doc;
- std::vector<cmDocumentationEntry> generators;
- this->GetGeneratorDocumentation(generators);
+ auto generators = this->GetGeneratorsDocumentation();
doc.AppendSection("Generators", generators);
std::cerr << "\n";
doc.PrintDocumentation(cmDocumentation::ListGenerators, std::cerr);
@@ -2006,7 +2050,7 @@ int cmake::CheckBuildSystem()
if (verbose) {
std::ostringstream msg;
msg << "Re-run cmake no build system arguments\n";
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
return 1;
}
@@ -2017,7 +2061,7 @@ int cmake::CheckBuildSystem()
std::ostringstream msg;
msg << "Re-run cmake missing file: " << this->CheckBuildSystemArgument
<< "\n";
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
return 1;
}
@@ -2037,7 +2081,7 @@ int cmake::CheckBuildSystem()
std::ostringstream msg;
msg << "Re-run cmake error reading : " << this->CheckBuildSystemArgument
<< "\n";
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
// There was an error reading the file. Just rerun.
return 1;
@@ -2071,7 +2115,7 @@ int cmake::CheckBuildSystem()
if (verbose) {
std::ostringstream msg;
msg << "Re-run cmake, missing byproduct: " << p << "\n";
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
return 1;
}
@@ -2092,7 +2136,7 @@ int cmake::CheckBuildSystem()
std::ostringstream msg;
msg << "Re-run cmake no CMAKE_MAKEFILE_DEPENDS "
"or CMAKE_MAKEFILE_OUTPUTS :\n";
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
return 1;
}
@@ -2102,8 +2146,7 @@ int cmake::CheckBuildSystem()
std::string dep_newest = *dep++;
for (; dep != depends.end(); ++dep) {
int result = 0;
- if (this->FileComparison->FileTimeCompare(dep_newest.c_str(), dep->c_str(),
- &result)) {
+ if (this->FileComparison->FileTimeCompare(dep_newest, *dep, &result)) {
if (result < 0) {
dep_newest = *dep;
}
@@ -2111,7 +2154,7 @@ int cmake::CheckBuildSystem()
if (verbose) {
std::ostringstream msg;
msg << "Re-run cmake: build system dependency is missing\n";
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
return 1;
}
@@ -2122,8 +2165,7 @@ int cmake::CheckBuildSystem()
std::string out_oldest = *out++;
for (; out != outputs.end(); ++out) {
int result = 0;
- if (this->FileComparison->FileTimeCompare(out_oldest.c_str(), out->c_str(),
- &result)) {
+ if (this->FileComparison->FileTimeCompare(out_oldest, *out, &result)) {
if (result > 0) {
out_oldest = *out;
}
@@ -2131,7 +2173,7 @@ int cmake::CheckBuildSystem()
if (verbose) {
std::ostringstream msg;
msg << "Re-run cmake: build system output is missing\n";
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
return 1;
}
@@ -2140,14 +2182,14 @@ int cmake::CheckBuildSystem()
// If any output is older than any dependency then rerun.
{
int result = 0;
- if (!this->FileComparison->FileTimeCompare(out_oldest.c_str(),
- dep_newest.c_str(), &result) ||
+ if (!this->FileComparison->FileTimeCompare(out_oldest, dep_newest,
+ &result) ||
result < 0) {
if (verbose) {
std::ostringstream msg;
msg << "Re-run cmake file: " << out_oldest
<< " older than: " << dep_newest << "\n";
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
return 1;
}
@@ -2374,7 +2416,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
return 0;
}
-static bool cmakeCheckStampFile(const char* stampName, bool verbose)
+static bool cmakeCheckStampFile(const std::string& stampName, bool verbose)
{
// The stamp file does not exist. Use the stamp dependencies to
// determine whether it is really out of date. This works in
@@ -2402,8 +2444,7 @@ static bool cmakeCheckStampFile(const char* stampName, bool verbose)
while (cmSystemTools::GetLineFromStream(fin, dep)) {
int result;
if (!dep.empty() && dep[0] != '#' &&
- (!ftc.FileTimeCompare(stampDepends.c_str(), dep.c_str(), &result) ||
- result < 0)) {
+ (!ftc.FileTimeCompare(stampDepends, dep, &result) || result < 0)) {
// The stamp depends file is older than this dependency. The
// build system is really out of date.
std::cout << "CMake is re-running because " << stampName
@@ -2419,12 +2460,11 @@ static bool cmakeCheckStampFile(const char* stampName, bool verbose)
// by the VS IDE due to a "rebuild" request. Restore it atomically.
std::ostringstream stampTempStream;
stampTempStream << stampName << ".tmp" << cmSystemTools::RandomSeed();
- std::string stampTempString = stampTempStream.str();
- const char* stampTemp = stampTempString.c_str();
+ std::string stampTemp = stampTempStream.str();
{
// TODO: Teach cmGeneratedFileStream to use a random temp file (with
// multiple tries in unlikely case of conflict) and use that here.
- cmsys::ofstream stamp(stampTemp);
+ cmsys::ofstream stamp(stampTemp.c_str());
stamp << "# CMake generation timestamp file for this directory.\n";
}
if (cmSystemTools::RenameFile(stampTemp, stampName)) {
@@ -2438,11 +2478,11 @@ static bool cmakeCheckStampFile(const char* stampName, bool verbose)
return true;
}
cmSystemTools::RemoveFile(stampTemp);
- cmSystemTools::Error("Cannot restore timestamp ", stampName);
+ cmSystemTools::Error("Cannot restore timestamp ", stampName.c_str());
return false;
}
-static bool cmakeCheckStampList(const char* stampList, bool verbose)
+static bool cmakeCheckStampList(const std::string& stampList, bool verbose)
{
// If the stamp list does not exist CMake must rerun to generate it.
if (!cmSystemTools::FileExists(stampList)) {
@@ -2450,7 +2490,7 @@ static bool cmakeCheckStampList(const char* stampList, bool verbose)
<< "is missing.\n";
return false;
}
- cmsys::ifstream fin(stampList);
+ cmsys::ifstream fin(stampList.c_str());
if (!fin) {
std::cout << "CMake is re-running because generate.stamp.list "
<< "could not be read.\n";
@@ -2460,7 +2500,7 @@ static bool cmakeCheckStampList(const char* stampList, bool verbose)
// Check each stamp.
std::string stampName;
while (cmSystemTools::GetLineFromStream(fin, stampName)) {
- if (!cmakeCheckStampFile(stampName.c_str(), verbose)) {
+ if (!cmakeCheckStampFile(stampName, verbose)) {
return false;
}
}
@@ -2562,8 +2602,7 @@ int cmake::Build(int jobs, const std::string& dir, const std::string& target,
// actually starting the build. If not done separately from the build
// itself, there is the risk of building an out-of-date solution file due
// to limitations of the underlying build system.
- std::string const stampList = cachePath + "/" +
- GetCMakeFilesDirectoryPostSlash() +
+ std::string const stampList = cachePath + "/" + "CMakeFiles/" +
cmGlobalVisualStudio9Generator::GetGenerateStampList();
// Note that the stampList file only exists for VS generators.
@@ -2573,15 +2612,15 @@ int cmake::Build(int jobs, const std::string& dir, const std::string& target,
// the glob verification script before starting the build
this->AddScriptingCommands();
if (this->GlobalGenerator->MatchesGeneratorName("Visual Studio 9 2008")) {
- std::string const globVerifyScript = cachePath + "/" +
- GetCMakeFilesDirectoryPostSlash() + "VerifyGlobs.cmake";
+ std::string const globVerifyScript =
+ cachePath + "/" + "CMakeFiles/" + "VerifyGlobs.cmake";
if (cmSystemTools::FileExists(globVerifyScript)) {
std::vector<std::string> args;
this->ReadListFile(args, globVerifyScript.c_str());
}
}
- if (!cmakeCheckStampList(stampList.c_str(), false)) {
+ if (!cmakeCheckStampList(stampList, false)) {
// Correctly initialize the home (=source) and home output (=binary)
// directories, which is required for running the generation step.
std::string homeOrig = this->GetHomeDirectory();
diff --git a/Source/cmake.h b/Source/cmake.h
index cd8c622..0f53d28 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -104,6 +104,8 @@ public:
std::string extraName;
bool supportsToolset;
bool supportsPlatform;
+ std::vector<std::string> supportedPlatforms;
+ std::string defaultPlatform;
bool isAlias;
};
@@ -123,12 +125,6 @@ public:
#endif
std::string ReportCapabilities(bool haveServerMode) const;
- static const char* GetCMakeFilesDirectory() { return "/CMakeFiles"; }
- static const char* GetCMakeFilesDirectoryPostSlash()
- {
- return "CMakeFiles/";
- }
-
//@{
/**
* Set/Get the home directory (or output directory) in the project. The
@@ -196,7 +192,8 @@ public:
void SetGlobalGenerator(cmGlobalGenerator*);
///! Get the names of the current registered generators
- void GetRegisteredGenerators(std::vector<GeneratorInfo>& generators) const;
+ void GetRegisteredGenerators(std::vector<GeneratorInfo>& generators,
+ bool includeNamesWithPlatform = true) const;
///! Set the name of the selected generator-specific instance.
void SetGeneratorInstance(std::string const& instance)
@@ -292,7 +289,7 @@ public:
cmVariableWatch* GetVariableWatch() { return this->VariableWatch; }
#endif
- void GetGeneratorDocumentation(std::vector<cmDocumentationEntry>&);
+ std::vector<cmDocumentationEntry> GetGeneratorsDocumentation();
///! Set/Get a property of this target file
void SetProperty(const std::string& prop, const char* value);
@@ -531,8 +528,12 @@ private:
// Print a list of valid generators to stderr.
void PrintGeneratorList();
+ std::unique_ptr<cmGlobalGenerator> EvaluateDefaultGlobalGenerator();
void CreateDefaultGlobalGenerator();
+ void AppendGlobalGeneratorsDocumentation(std::vector<cmDocumentationEntry>&);
+ void AppendExtraGeneratorsDocumentation(std::vector<cmDocumentationEntry>&);
+
/**
* Convert a message type between a warning and an error, based on the state
* of the error output CMake variables, in the cache.
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 5a04eab..0c25498 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -2,7 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAlgorithms.h"
-#include "cmDocumentationEntry.h"
+#include "cmDocumentationEntry.h" // IWYU pragma: keep
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmState.h"
@@ -227,9 +227,7 @@ int do_cmake(int ac, char const* const* av)
std::vector<std::string> args(av, av + ac);
hcm.SetCacheArgs(args);
- std::vector<cmDocumentationEntry> generators;
-
- hcm.GetGeneratorDocumentation(generators);
+ auto generators = hcm.GetGeneratorsDocumentation();
doc.SetName("cmake");
doc.SetSection("Name", cmDocumentationName);
@@ -360,6 +358,31 @@ int do_cmake(int ac, char const* const* av)
return 0;
}
+namespace {
+int extract_job_number(int& index, char const* current, char const* next,
+ int len_of_flag)
+{
+ std::string command(current);
+ std::string jobString = command.substr(len_of_flag);
+ if (jobString.empty() && next && isdigit(next[0])) {
+ ++index; // skip parsing the job number
+ jobString = std::string(next);
+ }
+
+ int jobs = -1;
+ unsigned long numJobs = 0;
+ if (jobString.empty()) {
+ jobs = cmake::DEFAULT_BUILD_PARALLEL_LEVEL;
+ } else if (cmSystemTools::StringToULong(jobString.c_str(), &numJobs)) {
+ jobs = int(numJobs);
+ } else {
+ std::cerr << "'" << command.substr(0, len_of_flag) << "' invalid number '"
+ << jobString << "' given.\n\n";
+ }
+ return jobs;
+}
+}
+
static int do_build(int ac, char const* const* av)
{
#ifndef CMAKE_BUILD_WITH_CMAKE
@@ -377,7 +400,6 @@ static int do_build(int ac, char const* const* av)
enum Doing
{
DoingNone,
- DoingJobs,
DoingDir,
DoingTarget,
DoingConfig,
@@ -387,12 +409,17 @@ static int do_build(int ac, char const* const* av)
for (int i = 2; i < ac; ++i) {
if (doing == DoingNative) {
nativeOptions.emplace_back(av[i]);
- } else if ((strcmp(av[i], "-j") == 0) ||
- (strcmp(av[i], "--parallel") == 0)) {
- jobs = cmake::DEFAULT_BUILD_PARALLEL_LEVEL;
- /* does the next argument start with a number? */
- if ((i + 1 < ac) && (isdigit(*av[i + 1]))) {
- doing = DoingJobs;
+ } else if (cmHasLiteralPrefix(av[i], "-j")) {
+ const char* nextArg = ((i + 1 < ac) ? av[i + 1] : nullptr);
+ jobs = extract_job_number(i, av[i], nextArg, sizeof("-j") - 1);
+ if (jobs < 0) {
+ dir.clear();
+ }
+ } else if (cmHasLiteralPrefix(av[i], "--parallel")) {
+ const char* nextArg = ((i + 1 < ac) ? av[i + 1] : nullptr);
+ jobs = extract_job_number(i, av[i], nextArg, sizeof("--parallel") - 1);
+ if (jobs < 0) {
+ dir.clear();
}
} else if (strcmp(av[i], "--target") == 0) {
if (!hasTarget) {
@@ -414,18 +441,6 @@ static int do_build(int ac, char const* const* av)
doing = DoingNative;
} else {
switch (doing) {
- case DoingJobs: {
- unsigned long numJobs = 0;
- if (cmSystemTools::StringToULong(av[i], &numJobs)) {
- jobs = int(numJobs);
- doing = DoingNone;
- } else {
- std::cerr << "'" << av[i - 1] << "' invalid number '" << av[i]
- << "' given.\n\n";
- dir.clear();
- break;
- }
- } break;
case DoingDir:
dir = cmSystemTools::CollapseFullPath(av[i]);
doing = DoingNone;
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 26f7509..0ad9b88 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -78,7 +78,8 @@ void CMakeCommandUsage(const char* program)
<< " capabilities - Report capabilities built into cmake "
"in JSON format\n"
<< " chdir dir cmd [args...] - run command in a given directory\n"
- << " compare_files file1 file2 - check if file1 is same as file2\n"
+ << " compare_files [--ignore-eol] file1 file2\n"
+ << " - check if file1 is same as file2\n"
<< " copy <file>... destination - copy files to destination "
"(either file or directory)\n"
<< " copy_directory <dir>... destination - copy content of <dir>... "
@@ -123,7 +124,7 @@ void CMakeCommandUsage(const char* program)
;
/* clang-format on */
- cmSystemTools::Error(errorStream.str().c_str());
+ cmSystemTools::Error(errorStream.str());
}
static bool cmTarFilesFrom(std::string const& file,
@@ -132,14 +133,14 @@ static bool cmTarFilesFrom(std::string const& file,
if (cmSystemTools::FileIsDirectory(file)) {
std::ostringstream e;
e << "-E tar --files-from= file '" << file << "' is a directory";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return false;
}
cmsys::ifstream fin(file.c_str());
if (!fin) {
std::ostringstream e;
e << "-E tar --files-from= file '" << file << "' not found";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return false;
}
std::string line;
@@ -153,7 +154,7 @@ static bool cmTarFilesFrom(std::string const& file,
std::ostringstream e;
e << "-E tar --files-from='" << file << "' file invalid line:\n"
<< line << "\n";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return false;
} else {
files.push_back(line);
@@ -530,7 +531,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// Rename a file or directory
if (args[1] == "rename" && args.size() == 4) {
- if (!cmSystemTools::RenameFile(args[2].c_str(), args[3].c_str())) {
+ if (!cmSystemTools::RenameFile(args[2], args[3])) {
std::string e = cmSystemTools::GetLastSystemError();
std::cerr << "Error renaming from \"" << args[2] << "\" to \""
<< args[3] << "\": " << e << "\n";
@@ -540,10 +541,20 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
}
// Compare files
- if (args[1] == "compare_files" && args.size() == 4) {
- if (cmSystemTools::FilesDiffer(args[2], args[3])) {
- std::cerr << "Files \"" << args[2] << "\" to \"" << args[3]
- << "\" are different.\n";
+ if (args[1] == "compare_files" && (args.size() == 4 || args.size() == 5)) {
+ bool filesDiffer;
+ if (args.size() == 4) {
+ filesDiffer = cmSystemTools::FilesDiffer(args[2], args[3]);
+ } else if (args[2] == "--ignore-eol") {
+ filesDiffer = cmsys::SystemTools::TextFilesDiffer(args[3], args[4]);
+ } else {
+ ::CMakeCommandUsage(args[0].c_str());
+ return 1;
+ }
+
+ if (filesDiffer) {
+ std::cerr << "Files \"" << args[args.size() - 2] << "\" to \""
+ << args[args.size() - 1] << "\" are different.\n";
return 1;
}
return 0;
@@ -964,8 +975,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
std::unique_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(&mf));
// Actually scan dependencies.
- return lgd->UpdateDependencies(depInfo.c_str(), verbose, color) ? 0
- : 2;
+ return lgd->UpdateDependencies(depInfo, verbose, color) ? 0 : 2;
}
return 1;
}
@@ -1173,7 +1183,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
if (server.Serve(&errorMessage)) {
return 0;
}
- cmSystemTools::Error(errorMessage.c_str());
+ cmSystemTools::Error(errorMessage);
#else
static_cast<void>(supportExperimental);
static_cast<void>(isDebug);
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index a2fcc16..b33aa80 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -454,6 +454,10 @@ ELSE()
SET(KWSYS_LIBRARY_TYPE STATIC)
ENDIF()
+if(NOT DEFINED KWSYS_BUILD_PIC)
+ set(KWSYS_BUILD_PIC 0)
+endif()
+
#-----------------------------------------------------------------------------
# Configure some implementation details.
@@ -870,7 +874,7 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
SET(KWSYS_LINK_DEPENDENCY INTERFACE)
ADD_LIBRARY(${KWSYS_TARGET_OBJECT} OBJECT
${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
- IF(KWSYS_BUILD_SHARED)
+ IF(KWSYS_BUILD_SHARED OR KWSYS_BUILD_PIC)
SET_PROPERTY(TARGET ${KWSYS_TARGET_OBJECT} PROPERTY
POSITION_INDEPENDENT_CODE TRUE)
ENDIF()
@@ -965,7 +969,7 @@ IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
${KWSYS_TARGET_C_INTERFACE} ${KWSYS_TARGET_C_LINK})
SET(KWSYS_LINK_DEPENDENCY INTERFACE)
ADD_LIBRARY(${KWSYS_TARGET_C_OBJECT} OBJECT ${KWSYS_C_SRCS})
- IF(KWSYS_BUILD_SHARED)
+ IF(KWSYS_BUILD_SHARED OR KWSYS_BUILD_PIC)
SET_PROPERTY(TARGET ${KWSYS_TARGET_C_OBJECT} PROPERTY
POSITION_INDEPENDENT_CODE TRUE)
ENDIF()
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index d368fa2..6c12355 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -3871,7 +3871,8 @@ SystemInformation::LongLong SystemInformationImplementation::GetProcessId()
{
#if defined(_WIN32)
return GetCurrentProcessId();
-#elif defined(__linux) || defined(__APPLE__)
+#elif defined(__linux) || defined(__APPLE__) || defined(__OpenBSD__) || \
+ defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
return getpid();
#else
return -1;
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index c5160a9..cbdfe11 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2161,6 +2161,32 @@ bool SystemTools::FilesDiffer(const std::string& source,
return false;
}
+bool SystemTools::TextFilesDiffer(const std::string& path1,
+ const std::string& path2)
+{
+ kwsys::ifstream if1(path1.c_str());
+ kwsys::ifstream if2(path2.c_str());
+ if (!if1 || !if2) {
+ return true;
+ }
+
+ for (;;) {
+ std::string line1, line2;
+ bool hasData1 = GetLineFromStream(if1, line1);
+ bool hasData2 = GetLineFromStream(if2, line2);
+ if (hasData1 != hasData2) {
+ return true;
+ }
+ if (!hasData1) {
+ break;
+ }
+ if (line1 != line2) {
+ return true;
+ }
+ }
+ return false;
+}
+
/**
* Blockwise copy source to destination file
*/
@@ -2979,10 +3005,36 @@ bool SystemTools::FileIsDirectory(const std::string& inName)
bool SystemTools::FileIsSymlink(const std::string& name)
{
#if defined(_WIN32)
- DWORD attr =
- GetFileAttributesW(Encoding::ToWindowsExtendedPath(name).c_str());
+ std::wstring path = Encoding::ToWindowsExtendedPath(name);
+ DWORD attr = GetFileAttributesW(path.c_str());
if (attr != INVALID_FILE_ATTRIBUTES) {
- return (attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
+ if ((attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
+ // FILE_ATTRIBUTE_REPARSE_POINT means:
+ // * a file or directory that has an associated reparse point, or
+ // * a file that is a symbolic link.
+ HANDLE hFile = CreateFileW(
+ path.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
+ FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ if (hFile == INVALID_HANDLE_VALUE) {
+ return false;
+ }
+ byte buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
+ DWORD bytesReturned = 0;
+ if (!DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer,
+ MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &bytesReturned,
+ NULL)) {
+ CloseHandle(hFile);
+ // Since FILE_ATTRIBUTE_REPARSE_POINT is set this file must be
+ // a symbolic link if it is not a reparse point.
+ return GetLastError() == ERROR_NOT_A_REPARSE_POINT;
+ }
+ CloseHandle(hFile);
+ ULONG reparseTag =
+ reinterpret_cast<PREPARSE_GUID_DATA_BUFFER>(&buffer[0])->ReparseTag;
+ return (reparseTag == IO_REPARSE_TAG_SYMLINK) ||
+ (reparseTag == IO_REPARSE_TAG_MOUNT_POINT);
+ }
+ return false;
} else {
return false;
}
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in
index 8d1f78c..1967860 100644
--- a/Source/kwsys/SystemTools.hxx.in
+++ b/Source/kwsys/SystemTools.hxx.in
@@ -579,6 +579,13 @@ public:
const std::string& destination);
/**
+ * Compare the contents of two files, ignoring line ending differences.
+ * Return true if different
+ */
+ static bool TextFilesDiffer(const std::string& path1,
+ const std::string& path2);
+
+ /**
* Return true if the two files are the same file
*/
static bool SameFile(const std::string& file1, const std::string& file2);
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx
index 0477d59..9a40b53 100644
--- a/Source/kwsys/testSystemTools.cxx
+++ b/Source/kwsys/testSystemTools.cxx
@@ -984,6 +984,50 @@ static bool CheckGetLineFromStreamLongLine()
return true;
}
+static bool writeFile(const char* fileName, const char* data)
+{
+ kwsys::ofstream out(fileName, std::ios::binary);
+ out << data;
+ if (!out) {
+ std::cerr << "Failed to write file: " << fileName << std::endl;
+ return false;
+ }
+ return true;
+}
+
+static bool CheckTextFilesDiffer()
+{
+ struct
+ {
+ const char* a;
+ const char* b;
+ bool differ;
+ } test_cases[] = { { "one", "one", false },
+ { "one", "two", true },
+ { "", "", false },
+ { "\n", "\r\n", false },
+ { "one\n", "one\n", false },
+ { "one\r\n", "one\n", false },
+ { "one\n", "one", false },
+ { "one\ntwo", "one\ntwo", false },
+ { "one\ntwo", "one\r\ntwo", false } };
+ const int num_test_cases = sizeof(test_cases) / sizeof(test_cases[0]);
+ for (int i = 0; i < num_test_cases; ++i) {
+ if (!writeFile("file_a", test_cases[i].a) ||
+ !writeFile("file_b", test_cases[i].b)) {
+ return false;
+ }
+ if (kwsys::SystemTools::TextFilesDiffer("file_a", "file_b") !=
+ test_cases[i].differ) {
+ std::cerr << "Incorrect TextFilesDiffer result for test case " << i + 1
+ << "." << std::endl;
+ return false;
+ }
+ }
+
+ return true;
+}
+
int testSystemTools(int, char* [])
{
bool res = true;
@@ -1027,5 +1071,7 @@ int testSystemTools(int, char* [])
res &= CheckGetFilenameName();
+ res &= CheckTextFilesDiffer();
+
return res ? 0 : 1;
}