summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeLists.txt5
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CPack/cpack.cxx4
-rw-r--r--Source/CTest/cmCTestRunTest.cxx2
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx2
-rw-r--r--Source/cmArchiveWrite.h2
-rw-r--r--Source/cmCTest.cxx2
-rw-r--r--Source/cmCommands.cxx8
-rw-r--r--Source/cmDefinitions.cxx61
-rw-r--r--Source/cmDefinitions.h16
-rw-r--r--Source/cmExecutionStatus.h9
-rw-r--r--Source/cmFileCommand.cxx841
-rw-r--r--Source/cmFileCommand.h67
-rw-r--r--Source/cmFileCopier.cxx46
-rw-r--r--Source/cmFileCopier.h6
-rw-r--r--Source/cmFileInstaller.cxx40
-rw-r--r--Source/cmFileInstaller.h4
-rw-r--r--Source/cmForEachCommand.cxx3
-rw-r--r--Source/cmGeneratedFileStream.cxx8
-rw-r--r--Source/cmGeneratorTarget.cxx2
-rw-r--r--Source/cmGlobalGenerator.cxx20
-rw-r--r--Source/cmGlobalGenerator.h8
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx2
-rw-r--r--Source/cmGlobalVisualStudio7Generator.h2
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx6
-rw-r--r--Source/cmIfCommand.cxx3
-rw-r--r--Source/cmIncludeGuardCommand.cxx2
-rw-r--r--Source/cmInstallCommand.cxx2
-rw-r--r--Source/cmInstallExportGenerator.cxx4
-rw-r--r--Source/cmLocalGenerator.cxx2
-rw-r--r--Source/cmLocalGenerator.h2
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx4
-rw-r--r--Source/cmMakefile.cxx32
-rw-r--r--Source/cmMakefile.h8
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx2
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx2
-rw-r--r--Source/cmMessenger.cxx4
-rw-r--r--Source/cmQtAutoGen.cxx5
-rw-r--r--Source/cmQtAutoGenGlobalInitializer.cxx37
-rw-r--r--Source/cmQtAutoGenInitializer.cxx132
-rw-r--r--Source/cmQtAutoGenInitializer.h17
-rw-r--r--Source/cmQtAutoGenerator.cxx39
-rw-r--r--Source/cmQtAutoMocUic.cxx186
-rw-r--r--Source/cmQtAutoRcc.cxx43
-rw-r--r--Source/cmRuntimeDependencyArchive.cxx14
-rw-r--r--Source/cmRuntimeDependencyArchive.h6
-rw-r--r--Source/cmStringAlgorithms.cxx14
-rw-r--r--Source/cmStringAlgorithms.h3
-rw-r--r--Source/cmStringCommand.cxx4
-rw-r--r--Source/cmSubcommandTable.cxx31
-rw-r--r--Source/cmSubcommandTable.h36
-rw-r--r--Source/cmSystemTools.cxx28
-rw-r--r--Source/cmSystemTools.h2
-rw-r--r--Source/cmTimestamp.cxx2
-rw-r--r--Source/cmUVHandlePtr.cxx6
-rw-r--r--Source/cmUnsetCommand.cxx2
-rw-r--r--Source/cm_codecvt.hxx2
-rw-r--r--Source/cmake.cxx46
-rw-r--r--Source/cmake.h8
-rw-r--r--Source/cmakemain.cxx18
-rw-r--r--Source/cmcmd.cxx24
-rw-r--r--Source/ctest.cxx4
62 files changed, 925 insertions, 1019 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index b1f4ca5..7cd07a8 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -95,9 +95,6 @@ include_directories(
${CMake_HAIKU_INCLUDE_DIRS}
)
-# let cmake know it is supposed to use it
-add_definitions(-DCMAKE_BUILD_WITH_CMAKE)
-
# Check if we can build the ELF parser.
if(CMAKE_USE_ELF_PARSER)
set(ELF_SRCS cmELF.h cmELF.cxx)
@@ -639,6 +636,8 @@ set(SRCS
cmStringReplaceHelper.cxx
cmStringCommand.cxx
cmStringCommand.h
+ cmSubcommandTable.cxx
+ cmSubcommandTable.h
cmSubdirCommand.cxx
cmSubdirCommand.h
cmSubdirDependsCommand.cxx
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 1a93578..40a4ee6 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 15)
-set(CMake_VERSION_PATCH 20190809)
+set(CMake_VERSION_PATCH 20190813)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index 89c3b1c..ae56adb 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -11,7 +11,7 @@
#include <utility>
#include <vector>
-#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
# include "cmsys/ConsoleBuf.hxx"
#endif
@@ -100,7 +100,7 @@ void cpackProgressCallback(const std::string& message, float /*unused*/)
int main(int argc, char const* const* argv)
{
cmSystemTools::EnsureStdPipes();
-#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
// Replace streambuf so we can output Unicode to console
cmsys::ConsoleBuf::Manager consoleOut(std::cout);
consoleOut.SetUTF8Pipes();
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index 65cf646..fb91322 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -689,7 +689,7 @@ bool cmCTestRunTest::ForkProcess(cmDuration testTimeOut, bool explicitTimeout,
this->TestProcess->SetTimeout(timeout);
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmSystemTools::SaveRestoreEnvironment sre;
#endif
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 4288b25..58f88be 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -495,7 +495,7 @@ void cmCTestScriptHandler::SleepInSeconds(unsigned int secondsToWait)
int cmCTestScriptHandler::RunConfigurationScript(
const std::string& total_script_arg, bool pscope)
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmSystemTools::SaveRestoreEnvironment sre;
#endif
diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h
index 9ea88d3..e90a603 100644
--- a/Source/cmArchiveWrite.h
+++ b/Source/cmArchiveWrite.h
@@ -9,7 +9,7 @@
#include <stddef.h>
#include <string>
-#if !defined(CMAKE_BUILD_WITH_CMAKE)
+#if defined(CMAKE_BOOTSTRAP)
# error "cmArchiveWrite not allowed during bootstrap build!"
#endif
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 026250d..c0ca73b 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -2423,7 +2423,7 @@ int cmCTest::RunCMakeAndTest(std::string* output)
cmCTestBuildAndTestHandler* handler = this->GetBuildAndTestHandler();
int retv = handler->ProcessHandler();
*output = handler->GetOutput();
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmDynamicLoader::FlushCache();
#endif
if (retv != 0) {
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index f351ff8..8c62c30 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -84,7 +84,7 @@
#include "cmUnsetCommand.h"
#include "cmWhileCommand.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# include "cmAddCompileOptionsCommand.h"
# include "cmAddLinkOptionsCommand.h"
# include "cmAuxSourceDirectoryCommand.h"
@@ -128,7 +128,7 @@ void GetScriptingCommands(cmState* state)
cm::make_unique<cmExecProgramCommand>());
state->AddBuiltinCommand("execute_process",
cm::make_unique<cmExecuteProcessCommand>());
- state->AddBuiltinCommand("file", cm::make_unique<cmFileCommand>());
+ state->AddBuiltinCommand("file", cmFileCommand);
state->AddBuiltinCommand("find_file", cm::make_unique<cmFindFileCommand>());
state->AddBuiltinCommand("find_library",
cm::make_unique<cmFindLibraryCommand>());
@@ -210,7 +210,7 @@ void GetScriptingCommands(cmState* state)
"WHILE ENDWHILE structure. Or its arguments did not "
"match the opening WHILE command.");
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
state->AddBuiltinCommand(
"cmake_host_system_information",
cm::make_unique<cmCMakeHostSystemInformationCommand>());
@@ -301,7 +301,7 @@ void GetProjectCommands(cmState* state)
cm::make_unique<cmTryCompileCommand>());
state->AddBuiltinCommand("try_run", cm::make_unique<cmTryRunCommand>());
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
state->AddBuiltinCommand("add_compile_definitions",
cm::make_unique<cmAddCompileDefinitionsCommand>());
state->AddBuiltinCommand("add_compile_options",
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 42e70d6..cc38d84 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -2,8 +2,11 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmDefinitions.h"
+#include "cm_string_view.hxx"
+
#include <assert.h>
-#include <set>
+#include <functional>
+#include <unordered_set>
#include <utility>
cmDefinitions::Def cmDefinitions::NoDef;
@@ -14,7 +17,7 @@ cmDefinitions::Def const& cmDefinitions::GetInternal(const std::string& key,
{
assert(begin != end);
{
- MapType::iterator it = begin->Map.find(key);
+ auto it = begin->Map.find(key);
if (it != begin->Map.end()) {
it->second.Used = true;
return it->second;
@@ -56,33 +59,10 @@ bool cmDefinitions::HasKey(const std::string& key, StackIter begin,
return false;
}
-void cmDefinitions::Set(const std::string& key, cm::string_view value)
-{
- this->Map[key] = Def(value);
-}
-
-void cmDefinitions::Unset(const std::string& key)
-{
- this->Map[key] = Def();
-}
-
-std::vector<std::string> cmDefinitions::UnusedKeys() const
-{
- std::vector<std::string> keys;
- keys.reserve(this->Map.size());
- // Consider local definitions.
- for (auto const& mi : this->Map) {
- if (!mi.second.Used) {
- keys.push_back(mi.first);
- }
- }
- return keys;
-}
-
cmDefinitions cmDefinitions::MakeClosure(StackIter begin, StackIter end)
{
cmDefinitions closure;
- std::set<std::string> undefined;
+ std::unordered_set<cm::string_view> undefined;
for (StackIter it = begin; it != end; ++it) {
// Consider local definitions.
for (auto const& mi : it->Map) {
@@ -92,7 +72,7 @@ cmDefinitions cmDefinitions::MakeClosure(StackIter begin, StackIter end)
if (mi.second.Exists) {
closure.Map.insert(mi);
} else {
- undefined.insert(mi.first);
+ undefined.emplace(mi.first);
}
}
}
@@ -104,13 +84,13 @@ std::vector<std::string> cmDefinitions::ClosureKeys(StackIter begin,
StackIter end)
{
std::vector<std::string> defined;
- std::set<std::string> bound;
+ std::unordered_set<cm::string_view> bound;
for (StackIter it = begin; it != end; ++it) {
defined.reserve(defined.size() + it->Map.size());
for (auto const& mi : it->Map) {
// Use this key if it is not already set or unset.
- if (bound.insert(mi.first).second && mi.second.Exists) {
+ if (bound.emplace(mi.first).second && mi.second.Exists) {
defined.push_back(mi.first);
}
}
@@ -118,3 +98,26 @@ std::vector<std::string> cmDefinitions::ClosureKeys(StackIter begin,
return defined;
}
+
+void cmDefinitions::Set(const std::string& key, cm::string_view value)
+{
+ this->Map[key] = Def(value);
+}
+
+void cmDefinitions::Unset(const std::string& key)
+{
+ this->Map[key] = Def();
+}
+
+std::vector<std::string> cmDefinitions::UnusedKeys() const
+{
+ std::vector<std::string> keys;
+ keys.reserve(this->Map.size());
+ // Consider local definitions.
+ for (auto const& mi : this->Map) {
+ if (!mi.second.Used) {
+ keys.push_back(mi.first);
+ }
+ }
+ return keys;
+}
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 4d8810a..787471a 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -25,6 +25,8 @@ class cmDefinitions
typedef cmLinkedTree<cmDefinitions>::iterator StackIter;
public:
+ // -- Static member functions
+
static const std::string* Get(const std::string& key, StackIter begin,
StackIter end);
@@ -32,18 +34,21 @@ public:
static bool HasKey(const std::string& key, StackIter begin, StackIter end);
+ static std::vector<std::string> ClosureKeys(StackIter begin, StackIter end);
+
+ static cmDefinitions MakeClosure(StackIter begin, StackIter end);
+
+ // -- Member functions
+
/** Set a value associated with a key. */
void Set(const std::string& key, cm::string_view value);
/** Unset a definition. */
void Unset(const std::string& key);
+ /** List of unused keys. */
std::vector<std::string> UnusedKeys() const;
- static std::vector<std::string> ClosureKeys(StackIter begin, StackIter end);
-
- static cmDefinitions MakeClosure(StackIter begin, StackIter end);
-
private:
/** String with existence boolean. */
struct Def
@@ -61,8 +66,7 @@ private:
};
static Def NoDef;
- typedef std::unordered_map<std::string, Def> MapType;
- MapType Map;
+ std::unordered_map<std::string, Def> Map;
static Def const& GetInternal(const std::string& key, StackIter begin,
StackIter end, bool raise);
diff --git a/Source/cmExecutionStatus.h b/Source/cmExecutionStatus.h
index bcacc2f..654922c 100644
--- a/Source/cmExecutionStatus.h
+++ b/Source/cmExecutionStatus.h
@@ -22,15 +22,6 @@ public:
{
}
- void Clear()
- {
- this->Error = "unknown error.";
- this->ReturnInvoked = false;
- this->BreakInvoked = false;
- this->ContinueInvoked = false;
- this->NestedError = false;
- }
-
cmMakefile& GetMakefile() { return this->Makefile; }
void SetError(std::string const& e) { this->Error = e; }
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 22f0d1f..fd319f6 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -25,6 +25,7 @@
#include "cmAlgorithms.h"
#include "cmArgumentParser.h"
#include "cmCryptoHash.h"
+#include "cmExecutionStatus.h"
#include "cmFileCopier.h"
#include "cmFileInstaller.h"
#include "cmFileLockPool.h"
@@ -40,12 +41,13 @@
#include "cmRuntimeDependencyArchive.h"
#include "cmState.h"
#include "cmStringAlgorithms.h"
+#include "cmSubcommandTable.h"
#include "cmSystemTools.h"
#include "cmTimestamp.h"
#include "cm_sys_stat.h"
#include "cmake.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# include "cmCurl.h"
# include "cmFileLockResult.h"
# include "cm_curl.h"
@@ -59,10 +61,12 @@
# include <windows.h>
#endif
+namespace {
+
#if defined(_WIN32)
// libcurl doesn't support file:// urls for unicode filenames on Windows.
// Convert string from UTF-8 to ACP if this is a file:// URL.
-static std::string fix_file_url_windows(const std::string& url)
+std::string fix_file_url_windows(const std::string& url)
{
std::string ret = url;
if (strncmp(url.c_str(), "file://", 7) == 0) {
@@ -84,123 +88,8 @@ static std::string fix_file_url_windows(const std::string& url)
}
#endif
-// cmLibraryCommand
-bool cmFileCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
-{
- if (args.size() < 2) {
- this->SetError("must be called with at least two arguments.");
- return false;
- }
- std::string const& subCommand = args[0];
- if (subCommand == "WRITE") {
- return this->HandleWriteCommand(args, false);
- }
- if (subCommand == "APPEND") {
- return this->HandleWriteCommand(args, true);
- }
- if (subCommand == "DOWNLOAD") {
- return this->HandleDownloadCommand(args);
- }
- if (subCommand == "UPLOAD") {
- return this->HandleUploadCommand(args);
- }
- if (subCommand == "READ") {
- return this->HandleReadCommand(args);
- }
- if (subCommand == "MD5" || subCommand == "SHA1" || subCommand == "SHA224" ||
- subCommand == "SHA256" || subCommand == "SHA384" ||
- subCommand == "SHA512" || subCommand == "SHA3_224" ||
- subCommand == "SHA3_256" || subCommand == "SHA3_384" ||
- subCommand == "SHA3_512") {
- return this->HandleHashCommand(args);
- }
- if (subCommand == "STRINGS") {
- return this->HandleStringsCommand(args);
- }
- if (subCommand == "GLOB") {
- return this->HandleGlobCommand(args, false);
- }
- if (subCommand == "GLOB_RECURSE") {
- return this->HandleGlobCommand(args, true);
- }
- if (subCommand == "MAKE_DIRECTORY") {
- return this->HandleMakeDirectoryCommand(args);
- }
- if (subCommand == "RENAME") {
- return this->HandleRename(args);
- }
- if (subCommand == "REMOVE") {
- return this->HandleRemove(args, false);
- }
- if (subCommand == "REMOVE_RECURSE") {
- return this->HandleRemove(args, true);
- }
- if (subCommand == "COPY") {
- return this->HandleCopyCommand(args);
- }
- if (subCommand == "INSTALL") {
- return this->HandleInstallCommand(args);
- }
- if (subCommand == "DIFFERENT") {
- return this->HandleDifferentCommand(args);
- }
- if (subCommand == "RPATH_CHANGE" || subCommand == "CHRPATH") {
- return this->HandleRPathChangeCommand(args);
- }
- if (subCommand == "RPATH_CHECK") {
- return this->HandleRPathCheckCommand(args);
- }
- if (subCommand == "RPATH_REMOVE") {
- return this->HandleRPathRemoveCommand(args);
- }
- if (subCommand == "READ_ELF") {
- return this->HandleReadElfCommand(args);
- }
- if (subCommand == "RELATIVE_PATH") {
- return this->HandleRelativePathCommand(args);
- }
- if (subCommand == "TO_CMAKE_PATH") {
- return this->HandleCMakePathCommand(args, false);
- }
- if (subCommand == "TO_NATIVE_PATH") {
- return this->HandleCMakePathCommand(args, true);
- }
- if (subCommand == "TOUCH") {
- return this->HandleTouchCommand(args, true);
- }
- if (subCommand == "TOUCH_NOCREATE") {
- return this->HandleTouchCommand(args, false);
- }
- if (subCommand == "TIMESTAMP") {
- return this->HandleTimestampCommand(args);
- }
- if (subCommand == "GENERATE") {
- return this->HandleGenerateCommand(args);
- }
- if (subCommand == "LOCK") {
- return this->HandleLockCommand(args);
- }
- if (subCommand == "SIZE") {
- return this->HandleSizeCommand(args);
- }
- if (subCommand == "READ_SYMLINK") {
- return this->HandleReadSymlinkCommand(args);
- }
- if (subCommand == "CREATE_LINK") {
- return this->HandleCreateLinkCommand(args);
- }
- if (subCommand == "GET_RUNTIME_DEPENDENCIES") {
- return this->HandleGetRuntimeDependenciesCommand(args);
- }
-
- std::string e = "does not recognize sub-command " + subCommand;
- this->SetError(e);
- return false;
-}
-
-bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
- bool append)
+bool HandleWriteImpl(std::vector<std::string> const& args, bool append,
+ cmExecutionStatus& status)
{
std::vector<std::string>::const_iterator i = args.begin();
@@ -208,16 +97,16 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
std::string fileName = *i;
if (!cmsys::SystemTools::FileIsFullPath(*i)) {
- fileName = this->Makefile->GetCurrentSourceDirectory();
+ fileName = status.GetMakefile().GetCurrentSourceDirectory();
fileName += "/" + *i;
}
i++;
- if (!this->Makefile->CanIWriteThisFile(fileName)) {
+ if (!status.GetMakefile().CanIWriteThisFile(fileName)) {
std::string e =
"attempted to write a file: " + fileName + " into a source directory.";
- this->SetError(e);
+ status.SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -249,7 +138,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
error += cmSystemTools::GetLastSystemError();
error += "):\n ";
error += fileName;
- this->SetError(error);
+ status.SetError(error);
return false;
}
std::string message = cmJoin(cmMakeRange(i, args.end()), std::string());
@@ -259,7 +148,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
error += cmSystemTools::GetLastSystemError();
error += "):\n ";
error += fileName;
- this->SetError(error);
+ status.SetError(error);
return false;
}
file.close();
@@ -269,11 +158,24 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
return true;
}
-bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
+bool HandleWriteCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleWriteImpl(args, false, status);
+}
+
+bool HandleAppendCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleWriteImpl(args, true, status);
+}
+
+bool HandleReadCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("READ must be called with at least two additional "
- "arguments");
+ status.SetError("READ must be called with at least two additional "
+ "arguments");
return false;
}
@@ -296,7 +198,7 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
std::string fileName = fileNameArg;
if (!cmsys::SystemTools::FileIsFullPath(fileName)) {
- fileName = this->Makefile->GetCurrentSourceDirectory();
+ fileName = status.GetMakefile().GetCurrentSourceDirectory();
fileName += "/" + fileNameArg;
}
@@ -314,7 +216,7 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
error += cmSystemTools::GetLastSystemError();
error += "):\n ";
error += fileName;
- this->SetError(error);
+ status.SetError(error);
return false;
}
@@ -366,17 +268,18 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
}
}
}
- this->Makefile->AddDefinition(variable, output);
+ status.GetMakefile().AddDefinition(variable, output);
return true;
}
-bool cmFileCommand::HandleHashCommand(std::vector<std::string> const& args)
+bool HandleHashCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
if (args.size() != 3) {
std::ostringstream e;
e << args[0] << " requires a file name and output variable";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
@@ -384,34 +287,35 @@ bool cmFileCommand::HandleHashCommand(std::vector<std::string> const& args)
if (hash) {
std::string out = hash->HashFile(args[1]);
if (!out.empty()) {
- this->Makefile->AddDefinition(args[2], out);
+ status.GetMakefile().AddDefinition(args[2], out);
return true;
}
std::ostringstream e;
e << args[0] << " failed to read file \"" << args[1]
<< "\": " << cmSystemTools::GetLastSystemError();
- this->SetError(e.str());
+ status.SetError(e.str());
}
return false;
#else
std::ostringstream e;
e << args[0] << " not available during bootstrap";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
#endif
}
-bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
+bool HandleStringsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("STRINGS requires a file name and output variable");
+ status.SetError("STRINGS requires a file name and output variable");
return false;
}
// Get the file to read.
std::string fileName = args[1];
if (!cmsys::SystemTools::FileIsFullPath(fileName)) {
- fileName = this->Makefile->GetCurrentSourceDirectory();
+ fileName = status.GetMakefile().GetCurrentSourceDirectory();
fileName += "/" + args[1];
}
@@ -478,7 +382,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
std::ostringstream e;
e << "STRINGS option LIMIT_INPUT value \"" << args[i]
<< "\" is not an unsigned integer.";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
arg_mode = arg_none;
@@ -488,7 +392,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
std::ostringstream e;
e << "STRINGS option LIMIT_OUTPUT value \"" << args[i]
<< "\" is not an unsigned integer.";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
arg_mode = arg_none;
@@ -498,7 +402,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
std::ostringstream e;
e << "STRINGS option LIMIT_COUNT value \"" << args[i]
<< "\" is not an unsigned integer.";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
limit_count = count;
@@ -509,7 +413,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
std::ostringstream e;
e << "STRINGS option LENGTH_MINIMUM value \"" << args[i]
<< "\" is not an unsigned integer.";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
minlen = len;
@@ -520,7 +424,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
std::ostringstream e;
e << "STRINGS option LENGTH_MAXIMUM value \"" << args[i]
<< "\" is not an unsigned integer.";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
maxlen = len;
@@ -530,7 +434,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
std::ostringstream e;
e << "STRINGS option REGEX value \"" << args[i]
<< "\" could not be compiled.";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
have_regex = true;
@@ -549,21 +453,22 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
} else {
std::ostringstream e;
e << "STRINGS option ENCODING \"" << args[i] << "\" not recognized.";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
arg_mode = arg_none;
} else {
std::ostringstream e;
e << "STRINGS given unknown argument \"" << args[i] << "\"";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
}
if (hex_conversion_enabled) {
// TODO: should work without temp file, but just on a memory buffer
- std::string binaryFileName = this->Makefile->GetCurrentBinaryDirectory();
+ std::string binaryFileName =
+ status.GetMakefile().GetCurrentBinaryDirectory();
binaryFileName += "/CMakeFiles";
binaryFileName += "/FileCommandStringsBinaryFile";
if (cmHexFileConverter::TryConvert(fileName, binaryFileName)) {
@@ -580,7 +485,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
if (!fin) {
std::ostringstream e;
e << "STRINGS file \"" << fileName << "\" cannot be read.";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
@@ -752,12 +657,12 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
}
// Save the output in a makefile variable.
- this->Makefile->AddDefinition(outVar, output);
+ status.GetMakefile().AddDefinition(outVar, output);
return true;
}
-bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
- bool recurse)
+bool HandleGlobImpl(std::vector<std::string> const& args, bool recurse,
+ cmExecutionStatus& status)
{
// File commands has at least one argument
assert(args.size() > 1);
@@ -772,10 +677,10 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
g.SetRecurse(recurse);
bool explicitFollowSymlinks = false;
- cmPolicies::PolicyStatus status =
- this->Makefile->GetPolicyStatus(cmPolicies::CMP0009);
+ cmPolicies::PolicyStatus policyStatus =
+ status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0009);
if (recurse) {
- switch (status) {
+ switch (policyStatus) {
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
@@ -793,7 +698,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
bool warnConfigureLate = false;
bool warnFollowedSymlinks = false;
const cmake::WorkingMode workingMode =
- this->Makefile->GetCMakeInstance()->GetWorkingMode();
+ status.GetMakefile().GetCMakeInstance()->GetWorkingMode();
while (i != args.end()) {
if (*i == "LIST_DIRECTORIES") {
++i; // skip LIST_DIRECTORIES
@@ -805,12 +710,12 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
g.SetListDirs(false);
g.SetRecurseListDirs(false);
} else {
- this->SetError("LIST_DIRECTORIES missing bool value.");
+ status.SetError("LIST_DIRECTORIES missing bool value.");
return false;
}
++i;
} else {
- this->SetError("LIST_DIRECTORIES missing bool value.");
+ status.SetError("LIST_DIRECTORIES missing bool value.");
return false;
}
} else if (*i == "FOLLOW_SYMLINKS") {
@@ -819,7 +724,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
explicitFollowSymlinks = true;
g.RecurseThroughSymlinksOn();
if (i == args.end()) {
- this->SetError(
+ status.SetError(
"GLOB_RECURSE requires a glob expression after FOLLOW_SYMLINKS.");
return false;
}
@@ -827,25 +732,26 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
} else if (*i == "RELATIVE") {
++i; // skip RELATIVE
if (i == args.end()) {
- this->SetError("GLOB requires a directory after the RELATIVE tag.");
+ status.SetError("GLOB requires a directory after the RELATIVE tag.");
return false;
}
g.SetRelative(i->c_str());
++i;
if (i == args.end()) {
- this->SetError("GLOB requires a glob expression after the directory.");
+ status.SetError(
+ "GLOB requires a glob expression after the directory.");
return false;
}
} else if (*i == "CONFIGURE_DEPENDS") {
// Generated build system depends on glob results
if (!configureDepends && warnConfigureLate) {
- this->Makefile->IssueMessage(
+ status.GetMakefile().IssueMessage(
MessageType::AUTHOR_WARNING,
"CONFIGURE_DEPENDS flag was given after a glob expression was "
"already evaluated.");
}
if (workingMode != cmake::NORMAL_MODE) {
- this->Makefile->IssueMessage(
+ status.GetMakefile().IssueMessage(
MessageType::FATAL_ERROR,
"CONFIGURE_DEPENDS is invalid for script and find package modes.");
return false;
@@ -853,14 +759,14 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
configureDepends = true;
++i;
if (i == args.end()) {
- this->SetError(
+ status.SetError(
"GLOB requires a glob expression after CONFIGURE_DEPENDS.");
return false;
}
} else {
std::string expr = *i;
if (!cmsys::SystemTools::FileIsFullPath(*i)) {
- expr = this->Makefile->GetCurrentSourceDirectory();
+ expr = status.GetMakefile().GetCurrentSourceDirectory();
// Handle script mode
if (!expr.empty()) {
expr += "/" + *i;
@@ -876,12 +782,12 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
bool shouldExit = false;
for (cmsys::Glob::Message const& globMessage : globMessages) {
if (globMessage.type == cmsys::Glob::cyclicRecursion) {
- this->Makefile->IssueMessage(
+ status.GetMakefile().IssueMessage(
MessageType::AUTHOR_WARNING,
"Cyclic recursion detected while globbing for '" + *i + "':\n" +
globMessage.content);
} else {
- this->Makefile->IssueMessage(
+ status.GetMakefile().IssueMessage(
MessageType::FATAL_ERROR,
"Error has occurred while globbing for '" + *i + "' - " +
globMessage.content);
@@ -905,11 +811,11 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
std::sort(foundFiles.begin(), foundFiles.end());
foundFiles.erase(std::unique(foundFiles.begin(), foundFiles.end()),
foundFiles.end());
- this->Makefile->GetCMakeInstance()->AddGlobCacheEntry(
+ status.GetMakefile().GetCMakeInstance()->AddGlobCacheEntry(
recurse, (recurse ? g.GetRecurseListDirs() : g.GetListDirs()),
(recurse ? g.GetRecurseThroughSymlinks() : false),
(g.GetRelative() ? g.GetRelative() : ""), expr, foundFiles, variable,
- this->Makefile->GetBacktrace());
+ status.GetMakefile().GetBacktrace());
} else {
warnConfigureLate = true;
}
@@ -917,7 +823,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
}
}
- switch (status) {
+ switch (policyStatus) {
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
@@ -930,7 +836,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
// Possibly unexpected old behavior *and* we actually traversed
// symlinks without being explicitly asked to: warn the author.
if (warnFollowedSymlinks) {
- this->Makefile->IssueMessage(
+ status.GetMakefile().IssueMessage(
MessageType::AUTHOR_WARNING,
cmPolicies::GetPolicyWarning(cmPolicies::CMP0009));
}
@@ -939,12 +845,24 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
std::sort(files.begin(), files.end());
files.erase(std::unique(files.begin(), files.end()), files.end());
- this->Makefile->AddDefinition(variable, cmJoin(files, ";"));
+ status.GetMakefile().AddDefinition(variable, cmJoin(files, ";"));
return true;
}
-bool cmFileCommand::HandleMakeDirectoryCommand(
- std::vector<std::string> const& args)
+bool HandleGlobCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleGlobImpl(args, false, status);
+}
+
+bool HandleGlobRecurseCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleGlobImpl(args, true, status);
+}
+
+bool HandleMakeDirectoryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
// File command has at least one argument
assert(args.size() > 1);
@@ -955,28 +873,28 @@ bool cmFileCommand::HandleMakeDirectoryCommand(
{
const std::string* cdir = &arg;
if (!cmsys::SystemTools::FileIsFullPath(arg)) {
- expr = this->Makefile->GetCurrentSourceDirectory();
+ expr = status.GetMakefile().GetCurrentSourceDirectory();
expr += "/" + arg;
cdir = &expr;
}
- if (!this->Makefile->CanIWriteThisFile(*cdir)) {
+ if (!status.GetMakefile().CanIWriteThisFile(*cdir)) {
std::string e = "attempted to create a directory: " + *cdir +
" into a source directory.";
- this->SetError(e);
+ status.SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
if (!cmSystemTools::MakeDirectory(*cdir)) {
std::string error = "problem creating directory: " + *cdir;
- this->SetError(error);
+ status.SetError(error);
return false;
}
}
return true;
}
-bool cmFileCommand::HandleTouchCommand(std::vector<std::string> const& args,
- bool create)
+bool HandleTouchImpl(std::vector<std::string> const& args, bool create,
+ cmExecutionStatus& status)
{
// File command has at least one argument
assert(args.size() > 1);
@@ -986,27 +904,39 @@ bool cmFileCommand::HandleTouchCommand(std::vector<std::string> const& args,
{
std::string tfile = arg;
if (!cmsys::SystemTools::FileIsFullPath(tfile)) {
- tfile = this->Makefile->GetCurrentSourceDirectory();
+ tfile = status.GetMakefile().GetCurrentSourceDirectory();
tfile += "/" + arg;
}
- if (!this->Makefile->CanIWriteThisFile(tfile)) {
+ if (!status.GetMakefile().CanIWriteThisFile(tfile)) {
std::string e =
"attempted to touch a file: " + tfile + " in a source directory.";
- this->SetError(e);
+ status.SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
if (!cmSystemTools::Touch(tfile, create)) {
std::string error = "problem touching file: " + tfile;
- this->SetError(error);
+ status.SetError(error);
return false;
}
}
return true;
}
-bool cmFileCommand::HandleDifferentCommand(
- std::vector<std::string> const& args)
+bool HandleTouchCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleTouchImpl(args, true, status);
+}
+
+bool HandleTouchNocreateCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleTouchImpl(args, false, status);
+}
+
+bool HandleDifferentCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
/*
FILE(DIFFERENT <variable> FILES <lhs> <rhs>)
@@ -1039,34 +969,35 @@ bool cmFileCommand::HandleDifferentCommand(
} else {
std::ostringstream e;
e << "DIFFERENT given unknown argument " << args[i];
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
}
if (!var) {
- this->SetError("DIFFERENT not given result variable name.");
+ status.SetError("DIFFERENT not given result variable name.");
return false;
}
if (!file_lhs || !file_rhs) {
- this->SetError("DIFFERENT not given FILES option with two file names.");
+ status.SetError("DIFFERENT not given FILES option with two file names.");
return false;
}
// Compare the files.
const char* result =
cmSystemTools::FilesDiffer(file_lhs, file_rhs) ? "1" : "0";
- this->Makefile->AddDefinition(var, result);
+ status.GetMakefile().AddDefinition(var, result);
return true;
}
-bool cmFileCommand::HandleCopyCommand(std::vector<std::string> const& args)
+bool HandleCopyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- cmFileCopier copier(this);
+ cmFileCopier copier(status);
return copier.Run(args);
}
-bool cmFileCommand::HandleRPathChangeCommand(
- std::vector<std::string> const& args)
+bool HandleRPathChangeCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
// Evaluate arguments.
std::string file;
@@ -1102,26 +1033,26 @@ bool cmFileCommand::HandleRPathChangeCommand(
} else {
std::ostringstream e;
e << "RPATH_CHANGE given unknown argument " << args[i];
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
}
if (file.empty()) {
- this->SetError("RPATH_CHANGE not given FILE option.");
+ status.SetError("RPATH_CHANGE not given FILE option.");
return false;
}
if (!oldRPath) {
- this->SetError("RPATH_CHANGE not given OLD_RPATH option.");
+ status.SetError("RPATH_CHANGE not given OLD_RPATH option.");
return false;
}
if (!newRPath) {
- this->SetError("RPATH_CHANGE not given NEW_RPATH option.");
+ status.SetError("RPATH_CHANGE not given NEW_RPATH option.");
return false;
}
if (!cmSystemTools::FileExists(file, true)) {
std::ostringstream e;
e << "RPATH_CHANGE given FILE \"" << file << "\" that does not exist.";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
bool success = true;
@@ -1139,7 +1070,7 @@ bool cmFileCommand::HandleRPathChangeCommand(
<< " " << file << "\n"
<< emsg;
/* clang-format on */
- this->SetError(e.str());
+ status.SetError(e.str());
success = false;
}
if (success) {
@@ -1149,15 +1080,15 @@ bool cmFileCommand::HandleRPathChangeCommand(
message += "\" to \"";
message += newRPath;
message += "\"";
- this->Makefile->DisplayStatus(message, -1);
+ status.GetMakefile().DisplayStatus(message, -1);
}
ft.Store(file);
}
return success;
}
-bool cmFileCommand::HandleRPathRemoveCommand(
- std::vector<std::string> const& args)
+bool HandleRPathRemoveCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
// Evaluate arguments.
std::string file;
@@ -1176,18 +1107,18 @@ bool cmFileCommand::HandleRPathRemoveCommand(
} else {
std::ostringstream e;
e << "RPATH_REMOVE given unknown argument " << args[i];
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
}
if (file.empty()) {
- this->SetError("RPATH_REMOVE not given FILE option.");
+ status.SetError("RPATH_REMOVE not given FILE option.");
return false;
}
if (!cmSystemTools::FileExists(file, true)) {
std::ostringstream e;
e << "RPATH_REMOVE given FILE \"" << file << "\" that does not exist.";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
bool success = true;
@@ -1201,7 +1132,7 @@ bool cmFileCommand::HandleRPathRemoveCommand(
<< " " << file << "\n"
<< emsg;
/* clang-format on */
- this->SetError(e.str());
+ status.SetError(e.str());
success = false;
}
if (success) {
@@ -1209,15 +1140,15 @@ bool cmFileCommand::HandleRPathRemoveCommand(
std::string message = "Removed runtime path from \"";
message += file;
message += "\"";
- this->Makefile->DisplayStatus(message, -1);
+ status.GetMakefile().DisplayStatus(message, -1);
}
ft.Store(file);
}
return success;
}
-bool cmFileCommand::HandleRPathCheckCommand(
- std::vector<std::string> const& args)
+bool HandleRPathCheckCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
// Evaluate arguments.
std::string file;
@@ -1243,16 +1174,16 @@ bool cmFileCommand::HandleRPathCheckCommand(
} else {
std::ostringstream e;
e << "RPATH_CHECK given unknown argument " << args[i];
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
}
if (file.empty()) {
- this->SetError("RPATH_CHECK not given FILE option.");
+ status.SetError("RPATH_CHECK not given FILE option.");
return false;
}
if (!rpath) {
- this->SetError("RPATH_CHECK not given RPATH option.");
+ status.SetError("RPATH_CHECK not given RPATH option.");
return false;
}
@@ -1267,11 +1198,12 @@ bool cmFileCommand::HandleRPathCheckCommand(
return true;
}
-bool cmFileCommand::HandleReadElfCommand(std::vector<std::string> const& args)
+bool HandleReadElfCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 4) {
- this->SetError("READ_ELF must be called with at least three additional "
- "arguments.");
+ status.SetError("READ_ELF must be called with at least three additional "
+ "arguments.");
return false;
}
@@ -1293,7 +1225,7 @@ bool cmFileCommand::HandleReadElfCommand(std::vector<std::string> const& args)
if (!cmSystemTools::FileExists(fileNameArg, true)) {
std::ostringstream e;
e << "READ_ELF given FILE \"" << fileNameArg << "\" that does not exist.";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
@@ -1304,14 +1236,14 @@ bool cmFileCommand::HandleReadElfCommand(std::vector<std::string> const& args)
if (cmELF::StringEntry const* se_rpath = elf.GetRPath()) {
std::string rpath(se_rpath->Value);
std::replace(rpath.begin(), rpath.end(), ':', ';');
- this->Makefile->AddDefinition(arguments.RPath, rpath);
+ status.GetMakefile().AddDefinition(arguments.RPath, rpath);
}
}
if (!arguments.RunPath.empty()) {
if (cmELF::StringEntry const* se_runpath = elf.GetRunPath()) {
std::string runpath(se_runpath->Value);
std::replace(runpath.begin(), runpath.end(), ':', ';');
- this->Makefile->AddDefinition(arguments.RunPath, runpath);
+ status.GetMakefile().AddDefinition(arguments.RunPath, runpath);
}
}
@@ -1319,25 +1251,26 @@ bool cmFileCommand::HandleReadElfCommand(std::vector<std::string> const& args)
#else
std::string error = "ELF parser not available on this platform.";
if (arguments.Error.empty()) {
- this->SetError(error);
+ status.SetError(error);
return false;
}
- this->Makefile->AddDefinition(arguments.Error, error);
+ status.GetMakefile().AddDefinition(arguments.Error, error);
return true;
#endif
}
-bool cmFileCommand::HandleInstallCommand(std::vector<std::string> const& args)
+bool HandleInstallCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- cmFileInstaller installer(this);
+ cmFileInstaller installer(status);
return installer.Run(args);
}
-bool cmFileCommand::HandleRelativePathCommand(
- std::vector<std::string> const& args)
+bool HandleRelativePathCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 4) {
- this->SetError("RELATIVE_PATH called with incorrect number of arguments");
+ status.SetError("RELATIVE_PATH called with incorrect number of arguments");
return false;
}
@@ -1349,37 +1282,38 @@ bool cmFileCommand::HandleRelativePathCommand(
std::string errstring =
"RELATIVE_PATH must be passed a full path to the directory: " +
directoryName;
- this->SetError(errstring);
+ status.SetError(errstring);
return false;
}
if (!cmSystemTools::FileIsFullPath(fileName)) {
std::string errstring =
"RELATIVE_PATH must be passed a full path to the file: " + fileName;
- this->SetError(errstring);
+ status.SetError(errstring);
return false;
}
std::string res = cmSystemTools::RelativePath(directoryName, fileName);
- this->Makefile->AddDefinition(outVar, res);
+ status.GetMakefile().AddDefinition(outVar, res);
return true;
}
-bool cmFileCommand::HandleRename(std::vector<std::string> const& args)
+bool HandleRename(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 3) {
- this->SetError("RENAME given incorrect number of arguments.");
+ status.SetError("RENAME given incorrect number of arguments.");
return false;
}
// Compute full path for old and new names.
std::string oldname = args[1];
if (!cmsys::SystemTools::FileIsFullPath(oldname)) {
- oldname = this->Makefile->GetCurrentSourceDirectory();
+ oldname = status.GetMakefile().GetCurrentSourceDirectory();
oldname += "/" + args[1];
}
std::string newname = args[2];
if (!cmsys::SystemTools::FileIsFullPath(newname)) {
- newname = this->Makefile->GetCurrentSourceDirectory();
+ newname = status.GetMakefile().GetCurrentSourceDirectory();
newname += "/" + args[2];
}
@@ -1393,14 +1327,14 @@ bool cmFileCommand::HandleRename(std::vector<std::string> const& args)
<< " " << newname << "\n"
<< "because: " << err << "\n";
/* clang-format on */
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
return true;
}
-bool cmFileCommand::HandleRemove(std::vector<std::string> const& args,
- bool recurse)
+bool HandleRemoveImpl(std::vector<std::string> const& args, bool recurse,
+ cmExecutionStatus& status)
{
std::string message;
@@ -1411,12 +1345,12 @@ bool cmFileCommand::HandleRemove(std::vector<std::string> const& args,
std::string fileName = arg;
if (fileName.empty()) {
std::string const r = recurse ? "REMOVE_RECURSE" : "REMOVE";
- this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING,
- "Ignoring empty file name in " + r + ".");
+ status.GetMakefile().IssueMessage(
+ MessageType::AUTHOR_WARNING, "Ignoring empty file name in " + r + ".");
continue;
}
if (!cmsys::SystemTools::FileIsFullPath(fileName)) {
- fileName = this->Makefile->GetCurrentSourceDirectory();
+ fileName = status.GetMakefile().GetCurrentSourceDirectory();
fileName += "/" + arg;
}
@@ -1430,7 +1364,18 @@ bool cmFileCommand::HandleRemove(std::vector<std::string> const& args,
return true;
}
-namespace {
+bool HandleRemove(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleRemoveImpl(args, false, status);
+}
+
+bool HandleRemoveRecurse(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleRemoveImpl(args, true, status);
+}
+
std::string ToNativePath(const std::string& path)
{
const auto& outPath = cmSystemTools::ConvertToOutputPath(path);
@@ -1447,14 +1392,14 @@ std::string ToCMakePath(const std::string& path)
cmSystemTools::ConvertToUnixSlashes(temp);
return temp;
}
-}
-bool cmFileCommand::HandleCMakePathCommand(
- std::vector<std::string> const& args, bool nativePath)
+bool HandlePathCommand(std::vector<std::string> const& args,
+ std::string (*convert)(std::string const&),
+ cmExecutionStatus& status)
{
if (args.size() != 3) {
- this->SetError("FILE([TO_CMAKE_PATH|TO_NATIVE_PATH] path result) must be "
- "called with exactly three arguments.");
+ status.SetError("FILE([TO_CMAKE_PATH|TO_NATIVE_PATH] path result) must be "
+ "called with exactly three arguments.");
return false;
}
#if defined(_WIN32) && !defined(__CYGWIN__)
@@ -1464,19 +1409,28 @@ bool cmFileCommand::HandleCMakePathCommand(
#endif
std::vector<std::string> path = cmSystemTools::SplitString(args[1], pathSep);
- std::string value = cmJoin(
- cmMakeRange(path).transform(nativePath ? ToNativePath : ToCMakePath), ";");
- this->Makefile->AddDefinition(args[2], value);
+ std::string value = cmJoin(cmMakeRange(path).transform(convert), ";");
+ status.GetMakefile().AddDefinition(args[2], value);
return true;
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+bool HandleCMakePathCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandlePathCommand(args, ToCMakePath, status);
+}
+
+bool HandleNativePathCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandlePathCommand(args, ToNativePath, status);
+}
+
+#if !defined(CMAKE_BOOTSTRAP)
// Stuff for curl download/upload
typedef std::vector<char> cmFileCommandVectorOfChar;
-namespace {
-
size_t cmWriteToFileCallback(void* ptr, size_t size, size_t nmemb, void* data)
{
int realsize = static_cast<int>(size * nmemb);
@@ -1527,11 +1481,10 @@ size_t cmFileCommandCurlDebugCallback(CURL*, curl_infotype type, char* chPtr,
class cURLProgressHelper
{
public:
- cURLProgressHelper(cmFileCommand* fc, const char* text)
+ cURLProgressHelper(cmMakefile* mf, const char* text)
+ : Makefile(mf)
+ , Text(text)
{
- this->CurrentPercentage = -1;
- this->FileCommand = fc;
- this->Text = text;
}
bool UpdatePercentage(double value, double total, std::string& status)
@@ -1558,11 +1511,11 @@ public:
return updated;
}
- cmFileCommand* GetFileCommand() { return this->FileCommand; }
+ cmMakefile* GetMakefile() { return this->Makefile; }
private:
- long CurrentPercentage;
- cmFileCommand* FileCommand;
+ long CurrentPercentage = -1;
+ cmMakefile* Makefile;
std::string Text;
};
@@ -1576,8 +1529,7 @@ int cmFileDownloadProgressCallback(void* clientp, double dltotal, double dlnow,
std::string status;
if (helper->UpdatePercentage(dlnow, dltotal, status)) {
- cmFileCommand* fc = helper->GetFileCommand();
- cmMakefile* mf = fc->GetMakefile();
+ cmMakefile* mf = helper->GetMakefile();
mf->DisplayStatus(status, -1);
}
@@ -1594,16 +1546,12 @@ int cmFileUploadProgressCallback(void* clientp, double dltotal, double dlnow,
std::string status;
if (helper->UpdatePercentage(ulnow, ultotal, status)) {
- cmFileCommand* fc = helper->GetFileCommand();
- cmMakefile* mf = fc->GetMakefile();
+ cmMakefile* mf = helper->GetMakefile();
mf->DisplayStatus(status, -1);
}
return 0;
}
-}
-
-namespace {
class cURLEasyGuard
{
@@ -1628,7 +1576,7 @@ public:
private:
::CURL* Easy;
};
-}
+
#endif
#define check_curl_result(result, errstr) \
@@ -1636,17 +1584,18 @@ private:
if (result != CURLE_OK) { \
std::string e(errstr); \
e += ::curl_easy_strerror(result); \
- this->SetError(e); \
+ status.SetError(e); \
return false; \
} \
} while (false)
-bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
+bool HandleDownloadCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
std::vector<std::string>::const_iterator i = args.begin();
if (args.size() < 3) {
- this->SetError("DOWNLOAD must be called with at least three arguments.");
+ status.SetError("DOWNLOAD must be called with at least three arguments.");
return false;
}
++i; // Get rid of subcommand
@@ -1659,11 +1608,12 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
long inactivity_timeout = 0;
std::string logVar;
std::string statusVar;
- bool tls_verify = this->Makefile->IsOn("CMAKE_TLS_VERIFY");
- const char* cainfo = this->Makefile->GetDefinition("CMAKE_TLS_CAINFO");
- std::string netrc_level = this->Makefile->GetSafeDefinition("CMAKE_NETRC");
+ bool tls_verify = status.GetMakefile().IsOn("CMAKE_TLS_VERIFY");
+ const char* cainfo = status.GetMakefile().GetDefinition("CMAKE_TLS_CAINFO");
+ std::string netrc_level =
+ status.GetMakefile().GetSafeDefinition("CMAKE_NETRC");
std::string netrc_file =
- this->Makefile->GetSafeDefinition("CMAKE_NETRC_FILE");
+ status.GetMakefile().GetSafeDefinition("CMAKE_NETRC_FILE");
std::string expectedHash;
std::string hashMatchMSG;
std::unique_ptr<cmCryptoHash> hash;
@@ -1678,7 +1628,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if (i != args.end()) {
timeout = atol(i->c_str());
} else {
- this->SetError("DOWNLOAD missing time for TIMEOUT.");
+ status.SetError("DOWNLOAD missing time for TIMEOUT.");
return false;
}
} else if (*i == "INACTIVITY_TIMEOUT") {
@@ -1686,20 +1636,20 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if (i != args.end()) {
inactivity_timeout = atol(i->c_str());
} else {
- this->SetError("DOWNLOAD missing time for INACTIVITY_TIMEOUT.");
+ status.SetError("DOWNLOAD missing time for INACTIVITY_TIMEOUT.");
return false;
}
} else if (*i == "LOG") {
++i;
if (i == args.end()) {
- this->SetError("DOWNLOAD missing VAR for LOG.");
+ status.SetError("DOWNLOAD missing VAR for LOG.");
return false;
}
logVar = *i;
} else if (*i == "STATUS") {
++i;
if (i == args.end()) {
- this->SetError("DOWNLOAD missing VAR for STATUS.");
+ status.SetError("DOWNLOAD missing VAR for STATUS.");
return false;
}
statusVar = *i;
@@ -1708,7 +1658,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if (i != args.end()) {
tls_verify = cmSystemTools::IsOn(*i);
} else {
- this->SetError("TLS_VERIFY missing bool value.");
+ status.SetError("TLS_VERIFY missing bool value.");
return false;
}
} else if (*i == "TLS_CAINFO") {
@@ -1716,7 +1666,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if (i != args.end()) {
cainfo = i->c_str();
} else {
- this->SetError("TLS_CAFILE missing file value.");
+ status.SetError("TLS_CAFILE missing file value.");
return false;
}
} else if (*i == "NETRC_FILE") {
@@ -1724,7 +1674,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if (i != args.end()) {
netrc_file = *i;
} else {
- this->SetError("DOWNLOAD missing file value for NETRC_FILE.");
+ status.SetError("DOWNLOAD missing file value for NETRC_FILE.");
return false;
}
} else if (*i == "NETRC") {
@@ -1732,13 +1682,13 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if (i != args.end()) {
netrc_level = *i;
} else {
- this->SetError("DOWNLOAD missing level value for NETRC.");
+ status.SetError("DOWNLOAD missing level value for NETRC.");
return false;
}
} else if (*i == "EXPECTED_MD5") {
++i;
if (i == args.end()) {
- this->SetError("DOWNLOAD missing sum value for EXPECTED_MD5.");
+ status.SetError("DOWNLOAD missing sum value for EXPECTED_MD5.");
return false;
}
hash = cm::make_unique<cmCryptoHash>(cmCryptoHash::AlgoMD5);
@@ -1749,7 +1699,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
} else if (*i == "EXPECTED_HASH") {
++i;
if (i == args.end()) {
- this->SetError("DOWNLOAD missing ALGO=value for EXPECTED_HASH.");
+ status.SetError("DOWNLOAD missing ALGO=value for EXPECTED_HASH.");
return false;
}
std::string::size_type pos = i->find("=");
@@ -1757,7 +1707,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
std::string err =
"DOWNLOAD EXPECTED_HASH expects ALGO=value but got: ";
err += *i;
- this->SetError(err);
+ status.SetError(err);
return false;
}
std::string algo = i->substr(0, pos);
@@ -1766,21 +1716,21 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if (!hash) {
std::string err = "DOWNLOAD EXPECTED_HASH given unknown ALGO: ";
err += algo;
- this->SetError(err);
+ status.SetError(err);
return false;
}
hashMatchMSG = algo + " hash";
} else if (*i == "USERPWD") {
++i;
if (i == args.end()) {
- this->SetError("DOWNLOAD missing string for USERPWD.");
+ status.SetError("DOWNLOAD missing string for USERPWD.");
return false;
}
userpwd = *i;
} else if (*i == "HTTPHEADER") {
++i;
if (i == args.end()) {
- this->SetError("DOWNLOAD missing string for HTTPHEADER.");
+ status.SetError("DOWNLOAD missing string for HTTPHEADER.");
return false;
}
curl_headers.push_back(*i);
@@ -1788,7 +1738,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
// Do not return error for compatibility reason.
std::string err = "Unexpected argument: ";
err += *i;
- this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, err);
+ status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, err);
}
++i;
}
@@ -1806,7 +1756,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if (!statusVar.empty()) {
std::ostringstream result;
result << 0 << ";\"" << msg;
- this->Makefile->AddDefinition(statusVar, result.str());
+ status.GetMakefile().AddDefinition(statusVar, result.str());
}
return true;
}
@@ -1819,13 +1769,13 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
std::string errstring = "DOWNLOAD error: cannot create directory '" + dir +
"' - Specify file by full path name and verify that you "
"have directory creation and file write privileges.";
- this->SetError(errstring);
+ status.SetError(errstring);
return false;
}
cmsys::ofstream fout(file.c_str(), std::ios::binary);
if (!fout) {
- this->SetError("DOWNLOAD cannot open file for write.");
+ status.SetError("DOWNLOAD cannot open file for write.");
return false;
}
@@ -1837,7 +1787,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
::curl_global_init(CURL_GLOBAL_DEFAULT);
curl = ::curl_easy_init();
if (!curl) {
- this->SetError("DOWNLOAD error initializing curl.");
+ status.SetError("DOWNLOAD error initializing curl.");
return false;
}
@@ -1871,7 +1821,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
// command arg comes first
std::string const& cainfo_err = cmCurlSetCAInfo(curl, cainfo);
if (!cainfo_err.empty()) {
- this->SetError(cainfo_err);
+ status.SetError(cainfo_err);
return false;
}
@@ -1881,7 +1831,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
std::string const& netrc_option_err =
cmCurlSetNETRCOption(curl, netrc_level, netrc_file);
if (!netrc_option_err.empty()) {
- this->SetError(netrc_option_err);
+ status.SetError(netrc_option_err);
return false;
}
@@ -1917,7 +1867,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
// scope intentionally, rather than inside the "if(showProgress)"
// block...
//
- cURLProgressHelper helper(this, "download");
+ cURLProgressHelper helper(&status.GetMakefile(), "download");
if (showProgress) {
res = ::curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
@@ -1955,7 +1905,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
std::ostringstream result;
result << static_cast<int>(res) << ";\"" << ::curl_easy_strerror(res)
<< "\"";
- this->Makefile->AddDefinition(statusVar, result.str());
+ status.GetMakefile().AddDefinition(statusVar, result.str());
}
::curl_global_cleanup();
@@ -1970,7 +1920,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if (hash) {
std::string actualHash = hash->HashFile(file);
if (actualHash.empty()) {
- this->SetError("DOWNLOAD cannot compute hash on downloaded file");
+ status.SetError("DOWNLOAD cannot compute hash on downloaded file");
return false;
}
@@ -1984,34 +1934,36 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
<< ::curl_easy_strerror(res) << "\"]" << std::endl;
if (!statusVar.empty() && res == 0) {
- std::string status = "1;HASH mismatch: "
- "expected: " +
- expectedHash + " actual: " + actualHash;
- this->Makefile->AddDefinition(statusVar, status);
+ status.GetMakefile().AddDefinition(statusVar,
+ "1;HASH mismatch: "
+ "expected: " +
+ expectedHash +
+ " actual: " + actualHash);
}
- this->SetError(oss.str());
+ status.SetError(oss.str());
return false;
}
}
if (!logVar.empty()) {
chunkDebug.push_back(0);
- this->Makefile->AddDefinition(logVar, chunkDebug.data());
+ status.GetMakefile().AddDefinition(logVar, chunkDebug.data());
}
return true;
#else
- this->SetError("DOWNLOAD not supported by bootstrap cmake.");
+ status.SetError("DOWNLOAD not supported by bootstrap cmake.");
return false;
#endif
}
-bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
+bool HandleUploadCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
if (args.size() < 3) {
- this->SetError("UPLOAD must be called with at least three arguments.");
+ status.SetError("UPLOAD must be called with at least three arguments.");
return false;
}
std::vector<std::string>::const_iterator i = args.begin();
@@ -2027,9 +1979,10 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
std::string statusVar;
bool showProgress = false;
std::string userpwd;
- std::string netrc_level = this->Makefile->GetSafeDefinition("CMAKE_NETRC");
+ std::string netrc_level =
+ status.GetMakefile().GetSafeDefinition("CMAKE_NETRC");
std::string netrc_file =
- this->Makefile->GetSafeDefinition("CMAKE_NETRC_FILE");
+ status.GetMakefile().GetSafeDefinition("CMAKE_NETRC_FILE");
std::vector<std::string> curl_headers;
@@ -2039,7 +1992,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
if (i != args.end()) {
timeout = atol(i->c_str());
} else {
- this->SetError("UPLOAD missing time for TIMEOUT.");
+ status.SetError("UPLOAD missing time for TIMEOUT.");
return false;
}
} else if (*i == "INACTIVITY_TIMEOUT") {
@@ -2047,20 +2000,20 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
if (i != args.end()) {
inactivity_timeout = atol(i->c_str());
} else {
- this->SetError("UPLOAD missing time for INACTIVITY_TIMEOUT.");
+ status.SetError("UPLOAD missing time for INACTIVITY_TIMEOUT.");
return false;
}
} else if (*i == "LOG") {
++i;
if (i == args.end()) {
- this->SetError("UPLOAD missing VAR for LOG.");
+ status.SetError("UPLOAD missing VAR for LOG.");
return false;
}
logVar = *i;
} else if (*i == "STATUS") {
++i;
if (i == args.end()) {
- this->SetError("UPLOAD missing VAR for STATUS.");
+ status.SetError("UPLOAD missing VAR for STATUS.");
return false;
}
statusVar = *i;
@@ -2071,7 +2024,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
if (i != args.end()) {
netrc_file = *i;
} else {
- this->SetError("UPLOAD missing file value for NETRC_FILE.");
+ status.SetError("UPLOAD missing file value for NETRC_FILE.");
return false;
}
} else if (*i == "NETRC") {
@@ -2079,20 +2032,20 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
if (i != args.end()) {
netrc_level = *i;
} else {
- this->SetError("UPLOAD missing level value for NETRC.");
+ status.SetError("UPLOAD missing level value for NETRC.");
return false;
}
} else if (*i == "USERPWD") {
++i;
if (i == args.end()) {
- this->SetError("UPLOAD missing string for USERPWD.");
+ status.SetError("UPLOAD missing string for USERPWD.");
return false;
}
userpwd = *i;
} else if (*i == "HTTPHEADER") {
++i;
if (i == args.end()) {
- this->SetError("UPLOAD missing string for HTTPHEADER.");
+ status.SetError("UPLOAD missing string for HTTPHEADER.");
return false;
}
curl_headers.push_back(*i);
@@ -2100,7 +2053,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
// Do not return error for compatibility reason.
std::string err = "Unexpected argument: ";
err += *i;
- this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, err);
+ status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, err);
}
++i;
@@ -2112,7 +2065,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
if (!fin) {
std::string errStr = "UPLOAD cannot open file '";
errStr += filename + "' for reading.";
- this->SetError(errStr);
+ status.SetError(errStr);
return false;
}
@@ -2126,7 +2079,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
::curl_global_init(CURL_GLOBAL_DEFAULT);
curl = ::curl_easy_init();
if (!curl) {
- this->SetError("UPLOAD error initializing curl.");
+ status.SetError("UPLOAD error initializing curl.");
fclose(fin);
return false;
}
@@ -2185,7 +2138,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
// scope intentionally, rather than inside the "if(showProgress)"
// block...
//
- cURLProgressHelper helper(this, "upload");
+ cURLProgressHelper helper(&status.GetMakefile(), "upload");
if (showProgress) {
res = ::curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
@@ -2220,7 +2173,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
std::string const& netrc_option_err =
cmCurlSetNETRCOption(curl, netrc_level, netrc_file);
if (!netrc_option_err.empty()) {
- this->SetError(netrc_option_err);
+ status.SetError(netrc_option_err);
return false;
}
@@ -2242,7 +2195,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
std::ostringstream result;
result << static_cast<int>(res) << ";\"" << ::curl_easy_strerror(res)
<< "\"";
- this->Makefile->AddDefinition(statusVar, result.str());
+ status.GetMakefile().AddDefinition(statusVar, result.str());
}
::curl_global_cleanup();
@@ -2267,22 +2220,22 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
log += "\n";
}
- this->Makefile->AddDefinition(logVar, log);
+ status.GetMakefile().AddDefinition(logVar, log);
}
return true;
#else
- this->SetError("UPLOAD not supported by bootstrap cmake.");
+ status.SetError("UPLOAD not supported by bootstrap cmake.");
return false;
#endif
}
-void cmFileCommand::AddEvaluationFile(const std::string& inputName,
- const std::string& outputExpr,
- const std::string& condition,
- bool inputIsContent)
+void AddEvaluationFile(const std::string& inputName,
+ const std::string& outputExpr,
+ const std::string& condition, bool inputIsContent,
+ cmExecutionStatus& status)
{
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+ cmListFileBacktrace lfbt = status.GetMakefile().GetBacktrace();
cmGeneratorExpression outputGe(lfbt);
std::unique_ptr<cmCompiledGeneratorExpression> outputCge =
@@ -2292,52 +2245,54 @@ void cmFileCommand::AddEvaluationFile(const std::string& inputName,
std::unique_ptr<cmCompiledGeneratorExpression> conditionCge =
conditionGe.Parse(condition);
- this->Makefile->AddEvaluationFile(inputName, std::move(outputCge),
- std::move(conditionCge), inputIsContent);
+ status.GetMakefile().AddEvaluationFile(
+ inputName, std::move(outputCge), std::move(conditionCge), inputIsContent);
}
-bool cmFileCommand::HandleGenerateCommand(std::vector<std::string> const& args)
+bool HandleGenerateCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 5) {
- this->SetError("Incorrect arguments to GENERATE subcommand.");
+ status.SetError("Incorrect arguments to GENERATE subcommand.");
return false;
}
if (args[1] != "OUTPUT") {
- this->SetError("Incorrect arguments to GENERATE subcommand.");
+ status.SetError("Incorrect arguments to GENERATE subcommand.");
return false;
}
std::string condition;
if (args.size() > 5) {
if (args[5] != "CONDITION") {
- this->SetError("Incorrect arguments to GENERATE subcommand.");
+ status.SetError("Incorrect arguments to GENERATE subcommand.");
return false;
}
if (args.size() != 7) {
- this->SetError("Incorrect arguments to GENERATE subcommand.");
+ status.SetError("Incorrect arguments to GENERATE subcommand.");
return false;
}
condition = args[6];
if (condition.empty()) {
- this->SetError("CONDITION of sub-command GENERATE must not be empty if "
- "specified.");
+ status.SetError("CONDITION of sub-command GENERATE must not be empty if "
+ "specified.");
return false;
}
}
std::string output = args[2];
const bool inputIsContent = args[3] != "INPUT";
if (inputIsContent && args[3] != "CONTENT") {
- this->SetError("Incorrect arguments to GENERATE subcommand.");
+ status.SetError("Incorrect arguments to GENERATE subcommand.");
return false;
}
std::string input = args[4];
- this->AddEvaluationFile(input, output, condition, inputIsContent);
+ AddEvaluationFile(input, output, condition, inputIsContent, status);
return true;
}
-bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
+bool HandleLockCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
// Default values
bool directory = false;
bool release = false;
@@ -2353,7 +2308,7 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
// Parse arguments
if (args.size() < 2) {
- this->Makefile->IssueMessage(
+ status.GetMakefile().IssueMessage(
MessageType::FATAL_ERROR,
"sub-command LOCK requires at least two arguments.");
return false;
@@ -2369,7 +2324,7 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
++i;
const char* merr = "expected FUNCTION, FILE or PROCESS after GUARD";
if (i >= args.size()) {
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, merr);
+ status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, merr);
return false;
}
if (args[i] == "FUNCTION") {
@@ -2381,14 +2336,14 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
} else {
std::ostringstream e;
e << merr << ", but got:\n \"" << args[i] << "\".";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
} else if (args[i] == "RESULT_VARIABLE") {
++i;
if (i >= args.size()) {
- this->Makefile->IssueMessage(
+ status.GetMakefile().IssueMessage(
MessageType::FATAL_ERROR,
"expected variable name after RESULT_VARIABLE");
return false;
@@ -2397,8 +2352,8 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
} else if (args[i] == "TIMEOUT") {
++i;
if (i >= args.size()) {
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR,
- "expected timeout value after TIMEOUT");
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR, "expected timeout value after TIMEOUT");
return false;
}
long scanned;
@@ -2406,7 +2361,7 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
scanned < 0) {
std::ostringstream e;
e << "TIMEOUT value \"" << args[i] << "\" is not an unsigned integer.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
timeout = static_cast<unsigned long>(scanned);
@@ -2414,7 +2369,7 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
std::ostringstream e;
e << "expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or TIMEOUT\n";
e << "but got: \"" << args[i] << "\".";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
}
@@ -2424,7 +2379,7 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
}
if (!cmsys::SystemTools::FileIsFullPath(path)) {
- path = this->Makefile->GetCurrentSourceDirectory() + "/" + path;
+ path = status.GetMakefile().GetCurrentSourceDirectory() + "/" + path;
}
// Unify path (remove '//', '/../', ...)
@@ -2436,7 +2391,7 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
std::ostringstream e;
e << "directory\n \"" << parentDir << "\"\ncreation failed ";
e << "(check permissions).";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -2444,7 +2399,7 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
if (!file) {
std::ostringstream e;
e << "file\n \"" << path << "\"\ncreation failed (check permissions).";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -2452,7 +2407,7 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
// Actual lock/unlock
cmFileLockPool& lockPool =
- this->Makefile->GetGlobalGenerator()->GetFileLockPool();
+ status.GetMakefile().GetGlobalGenerator()->GetFileLockPool();
cmFileLockResult fileLockResult(cmFileLockResult::MakeOk());
if (release) {
@@ -2479,32 +2434,32 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
if (resultVariable.empty() && !fileLockResult.IsOk()) {
std::ostringstream e;
e << "error locking file\n \"" << path << "\"\n" << result << ".";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
if (!resultVariable.empty()) {
- this->Makefile->AddDefinition(resultVariable, result);
+ status.GetMakefile().AddDefinition(resultVariable, result);
}
return true;
#else
static_cast<void>(args);
- this->SetError("sub-command LOCK not implemented in bootstrap cmake");
+ status.SetError("sub-command LOCK not implemented in bootstrap cmake");
return false;
#endif
}
-bool cmFileCommand::HandleTimestampCommand(
- std::vector<std::string> const& args)
+bool HandleTimestampCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("sub-command TIMESTAMP requires at least two arguments.");
+ status.SetError("sub-command TIMESTAMP requires at least two arguments.");
return false;
}
if (args.size() > 5) {
- this->SetError("sub-command TIMESTAMP takes at most four arguments.");
+ status.SetError("sub-command TIMESTAMP takes at most four arguments.");
return false;
}
@@ -2526,7 +2481,7 @@ bool cmFileCommand::HandleTimestampCommand(
} else {
std::string e = " TIMESTAMP sub-command does not recognize option " +
args[argsIndex] + ".";
- this->SetError(e);
+ status.SetError(e);
return false;
}
}
@@ -2534,17 +2489,18 @@ bool cmFileCommand::HandleTimestampCommand(
cmTimestamp timestamp;
std::string result =
timestamp.FileModificationTime(filename.c_str(), formatString, utcFlag);
- this->Makefile->AddDefinition(outputVariable, result);
+ status.GetMakefile().AddDefinition(outputVariable, result);
return true;
}
-bool cmFileCommand::HandleSizeCommand(std::vector<std::string> const& args)
+bool HandleSizeCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 3) {
std::ostringstream e;
e << args[0] << " requires a file name and output variable";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
@@ -2557,23 +2513,23 @@ bool cmFileCommand::HandleSizeCommand(std::vector<std::string> const& args)
if (!cmSystemTools::FileExists(filename, true)) {
std::ostringstream e;
e << "SIZE requested of path that is not readable:\n " << filename;
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
- this->Makefile->AddDefinition(
+ status.GetMakefile().AddDefinition(
outputVariable, std::to_string(cmSystemTools::FileLength(filename)));
return true;
}
-bool cmFileCommand::HandleReadSymlinkCommand(
- std::vector<std::string> const& args)
+bool HandleReadSymlinkCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 3) {
std::ostringstream e;
e << args[0] << " requires a file name and output variable";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
@@ -2585,21 +2541,21 @@ bool cmFileCommand::HandleReadSymlinkCommand(
std::ostringstream e;
e << "READ_SYMLINK requested of path that is not a symlink:\n "
<< filename;
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
- this->Makefile->AddDefinition(outputVariable, result);
+ status.GetMakefile().AddDefinition(outputVariable, result);
return true;
}
-bool cmFileCommand::HandleCreateLinkCommand(
- std::vector<std::string> const& args)
+bool HandleCreateLinkCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("CREATE_LINK must be called with at least two additional "
- "arguments");
+ status.SetError("CREATE_LINK must be called with at least two additional "
+ "arguments");
return false;
}
@@ -2624,7 +2580,7 @@ bool cmFileCommand::HandleCreateLinkCommand(
parser.Parse(cmMakeRange(args).advance(3), &unconsumedArgs);
if (!unconsumedArgs.empty()) {
- this->SetError("unknown argument: \"" + unconsumedArgs.front() + '\"');
+ status.SetError("unknown argument: \"" + unconsumedArgs.front() + '\"');
return false;
}
@@ -2635,10 +2591,10 @@ bool cmFileCommand::HandleCreateLinkCommand(
if (fileName == newFileName) {
result = "CREATE_LINK cannot use same file and newfile";
if (!arguments.Result.empty()) {
- this->Makefile->AddDefinition(arguments.Result, result);
+ status.GetMakefile().AddDefinition(arguments.Result, result);
return true;
}
- this->SetError(result);
+ status.SetError(result);
return false;
}
@@ -2646,10 +2602,10 @@ bool cmFileCommand::HandleCreateLinkCommand(
if (!arguments.Symbolic && !cmSystemTools::FileExists(fileName)) {
result = "Cannot hard link \'" + fileName + "\' as it does not exist.";
if (!arguments.Result.empty()) {
- this->Makefile->AddDefinition(arguments.Result, result);
+ status.GetMakefile().AddDefinition(arguments.Result, result);
return true;
}
- this->SetError(result);
+ status.SetError(result);
return false;
}
@@ -2663,10 +2619,10 @@ bool cmFileCommand::HandleCreateLinkCommand(
<< cmSystemTools::GetLastSystemError() << "\n";
if (!arguments.Result.empty()) {
- this->Makefile->AddDefinition(arguments.Result, e.str());
+ status.GetMakefile().AddDefinition(arguments.Result, e.str());
return true;
}
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
@@ -2693,45 +2649,46 @@ bool cmFileCommand::HandleCreateLinkCommand(
result = "0";
} else if (arguments.Result.empty()) {
// The operation failed and the result is not reported in a variable.
- this->SetError(result);
+ status.SetError(result);
return false;
}
if (!arguments.Result.empty()) {
- this->Makefile->AddDefinition(arguments.Result, result);
+ status.GetMakefile().AddDefinition(arguments.Result, result);
}
return true;
}
-bool cmFileCommand::HandleGetRuntimeDependenciesCommand(
- std::vector<std::string> const& args)
+bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
static const std::set<std::string> supportedPlatforms = { "Windows", "Linux",
"Darwin" };
std::string platform =
- this->Makefile->GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME");
+ status.GetMakefile().GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME");
if (!supportedPlatforms.count(platform)) {
std::ostringstream e;
e << "GET_RUNTIME_DEPENDENCIES is not supported on system \"" << platform
<< "\"";
- this->SetError(e.str());
+ status.SetError(e.str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
- if (this->Makefile->GetState()->GetMode() == cmState::Project) {
- this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING,
- "You have used file(GET_RUNTIME_DEPENDENCIES)"
- " in project mode. This is probably not what "
- "you intended to do. Instead, please consider"
- " using it in an install(CODE) or "
- "install(SCRIPT) command. For example:"
- "\n install(CODE [["
- "\n file(GET_RUNTIME_DEPENDENCIES"
- "\n # ..."
- "\n )"
- "\n ]])");
+ if (status.GetMakefile().GetState()->GetMode() == cmState::Project) {
+ status.GetMakefile().IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ "You have used file(GET_RUNTIME_DEPENDENCIES)"
+ " in project mode. This is probably not what "
+ "you intended to do. Instead, please consider"
+ " using it in an install(CODE) or "
+ "install(SCRIPT) command. For example:"
+ "\n install(CODE [["
+ "\n file(GET_RUNTIME_DEPENDENCIES"
+ "\n # ..."
+ "\n )"
+ "\n ]])");
}
struct Arguments
@@ -2776,7 +2733,7 @@ bool cmFileCommand::HandleGetRuntimeDependenciesCommand(
if (argIt != unrecognizedArguments.end()) {
std::ostringstream e;
e << "Unrecognized argument: \"" << *argIt << "\"";
- this->SetError(e.str());
+ status.SetError(e.str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -2784,13 +2741,13 @@ bool cmFileCommand::HandleGetRuntimeDependenciesCommand(
if (argIt != keywordsMissingValues.end()) {
std::ostringstream e;
e << "Keyword missing value: " << *argIt;
- this->SetError(e.str());
+ status.SetError(e.str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
cmRuntimeDependencyArchive archive(
- this, parsedArgs.Directories, parsedArgs.BundleExecutable,
+ status, parsedArgs.Directories, parsedArgs.BundleExecutable,
parsedArgs.PreIncludeRegexes, parsedArgs.PreExcludeRegexes,
parsedArgs.PostIncludeRegexes, parsedArgs.PostExcludeRegexes);
if (!archive.Prepare()) {
@@ -2826,14 +2783,14 @@ bool cmFileCommand::HandleGetRuntimeDependenciesCommand(
std::string varName =
parsedArgs.ConflictingDependenciesPrefix + "_" + val.first;
std::string pathsStr = cmJoin(paths, ";");
- this->Makefile->AddDefinition(varName, pathsStr);
+ status.GetMakefile().AddDefinition(varName, pathsStr);
} else {
std::ostringstream e;
e << "Multiple conflicting paths found for " << val.first << ":";
for (auto const& path : val.second) {
e << "\n " << path;
}
- this->SetError(e.str());
+ status.SetError(e.str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -2848,7 +2805,7 @@ bool cmFileCommand::HandleGetRuntimeDependenciesCommand(
assert(it != archive.GetUnresolvedPaths().end());
std::ostringstream e;
e << "Could not resolve file " << *it;
- this->SetError(e.str());
+ status.SetError(e.str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -2856,16 +2813,76 @@ bool cmFileCommand::HandleGetRuntimeDependenciesCommand(
if (!parsedArgs.ResolvedDependenciesVar.empty()) {
std::string val = cmJoin(deps, ";");
- this->Makefile->AddDefinition(parsedArgs.ResolvedDependenciesVar, val);
+ status.GetMakefile().AddDefinition(parsedArgs.ResolvedDependenciesVar,
+ val);
}
if (!parsedArgs.UnresolvedDependenciesVar.empty()) {
std::string val = cmJoin(unresolvedDeps, ";");
- this->Makefile->AddDefinition(parsedArgs.UnresolvedDependenciesVar, val);
+ status.GetMakefile().AddDefinition(parsedArgs.UnresolvedDependenciesVar,
+ val);
}
if (!parsedArgs.ConflictingDependenciesPrefix.empty()) {
std::string val = cmJoin(conflictingDeps, ";");
- this->Makefile->AddDefinition(
+ status.GetMakefile().AddDefinition(
parsedArgs.ConflictingDependenciesPrefix + "_FILENAMES", val);
}
return true;
}
+
+} // namespace
+
+bool cmFileCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.size() < 2) {
+ status.SetError("must be called with at least two arguments.");
+ return false;
+ }
+
+ static cmSubcommandTable const subcommand{
+ { "WRITE"_s, HandleWriteCommand },
+ { "APPEND"_s, HandleAppendCommand },
+ { "DOWNLOAD"_s, HandleDownloadCommand },
+ { "UPLOAD"_s, HandleUploadCommand },
+ { "READ"_s, HandleReadCommand },
+ { "MD5"_s, HandleHashCommand },
+ { "SHA1"_s, HandleHashCommand },
+ { "SHA224"_s, HandleHashCommand },
+ { "SHA256"_s, HandleHashCommand },
+ { "SHA384"_s, HandleHashCommand },
+ { "SHA512"_s, HandleHashCommand },
+ { "SHA3_224"_s, HandleHashCommand },
+ { "SHA3_256"_s, HandleHashCommand },
+ { "SHA3_384"_s, HandleHashCommand },
+ { "SHA3_512"_s, HandleHashCommand },
+ { "STRINGS"_s, HandleStringsCommand },
+ { "GLOB"_s, HandleGlobCommand },
+ { "GLOB_RECURSE"_s, HandleGlobRecurseCommand },
+ { "MAKE_DIRECTORY"_s, HandleMakeDirectoryCommand },
+ { "RENAME"_s, HandleRename },
+ { "REMOVE"_s, HandleRemove },
+ { "REMOVE_RECURSE"_s, HandleRemoveRecurse },
+ { "COPY"_s, HandleCopyCommand },
+ { "INSTALL"_s, HandleInstallCommand },
+ { "DIFFERENT"_s, HandleDifferentCommand },
+ { "RPATH_CHANGE"_s, HandleRPathChangeCommand },
+ { "CHRPATH"_s, HandleRPathChangeCommand },
+ { "RPATH_CHECK"_s, HandleRPathCheckCommand },
+ { "RPATH_REMOVE"_s, HandleRPathRemoveCommand },
+ { "READ_ELF"_s, HandleReadElfCommand },
+ { "RELATIVE_PATH"_s, HandleRelativePathCommand },
+ { "TO_CMAKE_PATH"_s, HandleCMakePathCommand },
+ { "TO_NATIVE_PATH"_s, HandleNativePathCommand },
+ { "TOUCH"_s, HandleTouchCommand },
+ { "TOUCH_NOCREATE"_s, HandleTouchNocreateCommand },
+ { "TIMESTAMP"_s, HandleTimestampCommand },
+ { "GENERATE"_s, HandleGenerateCommand },
+ { "LOCK"_s, HandleLockCommand },
+ { "SIZE"_s, HandleSizeCommand },
+ { "READ_SYMLINK"_s, HandleReadSymlinkCommand },
+ { "CREATE_LINK"_s, HandleCreateLinkCommand },
+ { "GET_RUNTIME_DEPENDENCIES"_s, HandleGetRuntimeDependenciesCommand },
+ };
+
+ return subcommand(args[0], args, status);
+}
diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h
index d4b980e..8c9b219 100644
--- a/Source/cmFileCommand.h
+++ b/Source/cmFileCommand.h
@@ -8,72 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmFileCommand
- * \brief Command for manipulation of files
- *
- */
-class cmFileCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmFileCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-
-protected:
- bool HandleRename(std::vector<std::string> const& args);
- bool HandleRemove(std::vector<std::string> const& args, bool recurse);
- bool HandleWriteCommand(std::vector<std::string> const& args, bool append);
- bool HandleReadCommand(std::vector<std::string> const& args);
- bool HandleHashCommand(std::vector<std::string> const& args);
- bool HandleStringsCommand(std::vector<std::string> const& args);
- bool HandleGlobCommand(std::vector<std::string> const& args, bool recurse);
- bool HandleTouchCommand(std::vector<std::string> const& args, bool create);
- bool HandleMakeDirectoryCommand(std::vector<std::string> const& args);
-
- bool HandleRelativePathCommand(std::vector<std::string> const& args);
- bool HandleCMakePathCommand(std::vector<std::string> const& args,
- bool nativePath);
- bool HandleReadElfCommand(std::vector<std::string> const& args);
- bool HandleRPathChangeCommand(std::vector<std::string> const& args);
- bool HandleRPathCheckCommand(std::vector<std::string> const& args);
- bool HandleRPathRemoveCommand(std::vector<std::string> const& args);
- bool HandleDifferentCommand(std::vector<std::string> const& args);
-
- bool HandleCopyCommand(std::vector<std::string> const& args);
- bool HandleInstallCommand(std::vector<std::string> const& args);
- bool HandleDownloadCommand(std::vector<std::string> const& args);
- bool HandleUploadCommand(std::vector<std::string> const& args);
-
- bool HandleTimestampCommand(std::vector<std::string> const& args);
- bool HandleGenerateCommand(std::vector<std::string> const& args);
- bool HandleLockCommand(std::vector<std::string> const& args);
- bool HandleSizeCommand(std::vector<std::string> const& args);
- bool HandleReadSymlinkCommand(std::vector<std::string> const& args);
- bool HandleCreateLinkCommand(std::vector<std::string> const& args);
- bool HandleGetRuntimeDependenciesCommand(
- std::vector<std::string> const& args);
-
-private:
- void AddEvaluationFile(const std::string& inputName,
- const std::string& outputExpr,
- const std::string& condition, bool inputIsContent);
-};
+bool cmFileCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmFileCopier.cxx b/Source/cmFileCopier.cxx
index 71493bb..62f132d 100644
--- a/Source/cmFileCopier.cxx
+++ b/Source/cmFileCopier.cxx
@@ -3,8 +3,8 @@
#include "cmFileCopier.h"
+#include "cmExecutionStatus.h"
#include "cmFSPermissions.h"
-#include "cmFileCommand.h"
#include "cmFileTimes.h"
#include "cmMakefile.h"
#include "cmStringAlgorithms.h"
@@ -21,9 +21,9 @@
using namespace cmFSPermissions;
-cmFileCopier::cmFileCopier(cmFileCommand* command, const char* name)
- : FileCommand(command)
- , Makefile(command->GetMakefile())
+cmFileCopier::cmFileCopier(cmExecutionStatus& status, const char* name)
+ : Status(status)
+ , Makefile(&status.GetMakefile())
, Name(name)
, Always(false)
, MatchlessFiles(true)
@@ -92,7 +92,7 @@ bool cmFileCopier::SetPermissions(const std::string& toFile,
if (!cmSystemTools::SetPermissions(toFile, permissions)) {
std::ostringstream e;
e << this->Name << " cannot set permissions on \"" << toFile << "\"";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
return false;
}
}
@@ -106,7 +106,7 @@ bool cmFileCopier::CheckPermissions(std::string const& arg,
if (!cmFSPermissions::stringToModeT(arg, permissions)) {
std::ostringstream e;
e << this->Name << " given invalid permission \"" << arg << "\".";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
return false;
}
return true;
@@ -122,7 +122,7 @@ bool cmFileCopier::ReportMissing(const std::string& fromFile)
// The input file does not exist and installation is not optional.
std::ostringstream e;
e << this->Name << " cannot find \"" << fromFile << "\".";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
return false;
}
@@ -130,7 +130,7 @@ void cmFileCopier::NotBeforeMatch(std::string const& arg)
{
std::ostringstream e;
e << "option " << arg << " may not appear before PATTERN or REGEX.";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
this->Doing = DoingError;
}
@@ -138,7 +138,7 @@ void cmFileCopier::NotAfterMatch(std::string const& arg)
{
std::ostringstream e;
e << "option " << arg << " may not appear after PATTERN or REGEX.";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
this->Doing = DoingError;
}
@@ -175,7 +175,7 @@ bool cmFileCopier::GetDefaultDirectoryPermissions(mode_t** mode)
cmSystemTools::ExpandListArgument(default_dir_install_permissions, items);
for (const auto& arg : items) {
if (!this->CheckPermissions(arg, **mode)) {
- this->FileCommand->SetError(
+ this->Status.SetError(
" Set with CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS variable.");
return false;
}
@@ -195,7 +195,7 @@ bool cmFileCopier::Parse(std::vector<std::string> const& args)
if (!this->CheckKeyword(args[i]) && !this->CheckValue(args[i])) {
std::ostringstream e;
e << "called with unknown argument \"" << args[i] << "\".";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
return false;
}
@@ -209,7 +209,7 @@ bool cmFileCopier::Parse(std::vector<std::string> const& args)
if (this->Destination.empty()) {
std::ostringstream e;
e << this->Name << " given no DESTINATION";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
return false;
}
@@ -342,7 +342,7 @@ bool cmFileCopier::CheckValue(std::string const& arg)
} else {
std::ostringstream e;
e << "could not compile PATTERN \"" << arg << "\".";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
this->Doing = DoingError;
}
} break;
@@ -354,7 +354,7 @@ bool cmFileCopier::CheckValue(std::string const& arg)
} else {
std::ostringstream e;
e << "could not compile REGEX \"" << arg << "\".";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
this->Doing = DoingError;
}
break;
@@ -397,8 +397,8 @@ bool cmFileCopier::Run(std::vector<std::string> const& args)
file += "/";
file += f;
} else if (!this->FilesFromDir.empty()) {
- this->FileCommand->SetError("option FILES_FROM_DIR requires all files "
- "to be specified as relative paths.");
+ this->Status.SetError("option FILES_FROM_DIR requires all files "
+ "to be specified as relative paths.");
return false;
} else {
file = f;
@@ -447,7 +447,7 @@ bool cmFileCopier::Install(const std::string& fromFile,
if (fromFile.empty()) {
std::ostringstream e;
e << "INSTALL encountered an empty string input file name.";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
return false;
}
@@ -515,7 +515,7 @@ bool cmFileCopier::InstallSymlinkChain(std::string& fromFile,
if (!cmSystemTools::CreateSymlink(symlinkTarget, toFile)) {
std::ostringstream e;
e << this->Name << " cannot create symlink \"" << toFile << "\".";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
return false;
}
}
@@ -536,7 +536,7 @@ bool cmFileCopier::InstallSymlink(const std::string& fromFile,
std::ostringstream e;
e << this->Name << " cannot read symlink \"" << fromFile
<< "\" to duplicate at \"" << toFile << "\".";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
return false;
}
@@ -567,7 +567,7 @@ bool cmFileCopier::InstallSymlink(const std::string& fromFile,
std::ostringstream e;
e << this->Name << " cannot duplicate symlink \"" << fromFile
<< "\" at \"" << toFile << "\".";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
return false;
}
}
@@ -596,7 +596,7 @@ bool cmFileCopier::InstallFile(const std::string& fromFile,
std::ostringstream e;
e << this->Name << " cannot copy file \"" << fromFile << "\" to \""
<< toFile << "\".";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
return false;
}
@@ -612,7 +612,7 @@ bool cmFileCopier::InstallFile(const std::string& fromFile,
std::ostringstream e;
e << this->Name << " cannot set modification time on \"" << toFile
<< "\"";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
return false;
}
}
@@ -649,7 +649,7 @@ bool cmFileCopier::InstallDirectory(const std::string& source,
std::ostringstream e;
e << this->Name << " cannot make directory \"" << destination
<< "\": " << cmSystemTools::GetLastSystemError();
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
return false;
}
diff --git a/Source/cmFileCopier.h b/Source/cmFileCopier.h
index a79a60b..263a365 100644
--- a/Source/cmFileCopier.h
+++ b/Source/cmFileCopier.h
@@ -12,19 +12,19 @@
#include <string>
#include <vector>
-class cmFileCommand;
+class cmExecutionStatus;
class cmMakefile;
// File installation helper class.
struct cmFileCopier
{
- cmFileCopier(cmFileCommand* command, const char* name = "COPY");
+ cmFileCopier(cmExecutionStatus& status, const char* name = "COPY");
virtual ~cmFileCopier();
bool Run(std::vector<std::string> const& args);
protected:
- cmFileCommand* FileCommand;
+ cmExecutionStatus& Status;
cmMakefile* Makefile;
const char* Name;
bool Always;
diff --git a/Source/cmFileInstaller.cxx b/Source/cmFileInstaller.cxx
index 9378439..d28ef41 100644
--- a/Source/cmFileInstaller.cxx
+++ b/Source/cmFileInstaller.cxx
@@ -3,8 +3,8 @@
#include "cmFileInstaller.h"
+#include "cmExecutionStatus.h"
#include "cmFSPermissions.h"
-#include "cmFileCommand.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
@@ -14,8 +14,8 @@
using namespace cmFSPermissions;
-cmFileInstaller::cmFileInstaller(cmFileCommand* command)
- : cmFileCopier(command, "INSTALL")
+cmFileInstaller::cmFileInstaller(cmExecutionStatus& status)
+ : cmFileCopier(status, "INSTALL")
, InstallType(cmInstallType_FILES)
, Optional(false)
, MessageAlways(false)
@@ -111,19 +111,19 @@ bool cmFileInstaller::Parse(std::vector<std::string> const& args)
if (!this->Rename.empty()) {
if (!this->FilesFromDir.empty()) {
- this->FileCommand->SetError("INSTALL option RENAME may not be "
- "combined with FILES_FROM_DIR.");
+ this->Status.SetError("INSTALL option RENAME may not be "
+ "combined with FILES_FROM_DIR.");
return false;
}
if (this->InstallType != cmInstallType_FILES &&
this->InstallType != cmInstallType_PROGRAMS) {
- this->FileCommand->SetError("INSTALL option RENAME may be used "
- "only with FILES or PROGRAMS.");
+ this->Status.SetError("INSTALL option RENAME may be used "
+ "only with FILES or PROGRAMS.");
return false;
}
if (this->Files.size() > 1) {
- this->FileCommand->SetError("INSTALL option RENAME may be used "
- "only with one file.");
+ this->Status.SetError("INSTALL option RENAME may be used "
+ "only with one file.");
return false;
}
}
@@ -134,9 +134,9 @@ bool cmFileInstaller::Parse(std::vector<std::string> const& args)
if (((this->MessageAlways ? 1 : 0) + (this->MessageLazy ? 1 : 0) +
(this->MessageNever ? 1 : 0)) > 1) {
- this->FileCommand->SetError("INSTALL options MESSAGE_ALWAYS, "
- "MESSAGE_LAZY, and MESSAGE_NEVER "
- "are mutually exclusive.");
+ this->Status.SetError("INSTALL options MESSAGE_ALWAYS, "
+ "MESSAGE_LAZY, and MESSAGE_NEVER "
+ "are mutually exclusive.");
return false;
}
@@ -213,7 +213,7 @@ bool cmFileInstaller::CheckKeyword(std::string const& arg)
e << "INSTALL called with old-style " << arg << " argument. "
<< "This script was generated with an older version of CMake. "
<< "Re-run this cmake version on your build tree.";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
this->Doing = DoingError;
} else {
return this->cmFileCopier::CheckKeyword(arg);
@@ -257,7 +257,7 @@ bool cmFileInstaller::GetTargetTypeFromString(const std::string& stype)
} else {
std::ostringstream e;
e << "Option TYPE given unknown value \"" << stype << "\".";
- this->FileCommand->SetError(e.str());
+ this->Status.SetError(e.str());
return false;
}
return true;
@@ -269,8 +269,8 @@ bool cmFileInstaller::HandleInstallDestination()
// allow for / to be a valid destination
if (destination.size() < 2 && destination != "/") {
- this->FileCommand->SetError("called with inappropriate arguments. "
- "No DESTINATION provided or .");
+ this->Status.SetError("called with inappropriate arguments. "
+ "No DESTINATION provided or .");
return false;
}
@@ -300,7 +300,7 @@ bool cmFileInstaller::HandleInstallDestination()
if (relative) {
// This is relative path on unix or windows. Since we are doing
// destdir, this case does not make sense.
- this->FileCommand->SetError(
+ this->Status.SetError(
"called with relative DESTINATION. This "
"does not make sense when using DESTDIR. Specify "
"absolute path or remove DESTDIR environment variable.");
@@ -315,7 +315,7 @@ bool cmFileInstaller::HandleInstallDestination()
"absolute path or remove DESTDIR environment variable."
"\nDESTINATION=\n";
message += destination;
- this->FileCommand->SetError(message);
+ this->Status.SetError(message);
return false;
}
}
@@ -335,14 +335,14 @@ bool cmFileInstaller::HandleInstallDestination()
if (!cmSystemTools::MakeDirectory(destination, default_dir_mode)) {
std::string errstring = "cannot create directory: " + destination +
". Maybe need administrative privileges.";
- this->FileCommand->SetError(errstring);
+ this->Status.SetError(errstring);
return false;
}
}
if (!cmSystemTools::FileIsDirectory(destination)) {
std::string errstring =
"INSTALL destination: " + destination + " is not a directory.";
- this->FileCommand->SetError(errstring);
+ this->Status.SetError(errstring);
return false;
}
}
diff --git a/Source/cmFileInstaller.h b/Source/cmFileInstaller.h
index 312529a..fd883ea 100644
--- a/Source/cmFileInstaller.h
+++ b/Source/cmFileInstaller.h
@@ -12,11 +12,11 @@
#include <string>
#include <vector>
-class cmFileCommand;
+class cmExecutionStatus;
struct cmFileInstaller : public cmFileCopier
{
- cmFileInstaller(cmFileCommand* command);
+ cmFileInstaller(cmExecutionStatus& status);
~cmFileInstaller() override;
protected:
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index 1d961be..a565786 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -74,9 +74,8 @@ bool cmForEachFunctionBlocker::Replay(
// set the variable to the loop value
mf.AddDefinition(this->Args[0], arg);
// Invoke all the functions that were collected in the block.
- cmExecutionStatus status(mf);
for (cmListFileFunction const& func : functions) {
- status.Clear();
+ cmExecutionStatus status(mf);
mf.ExecuteCommand(func, status);
if (status.GetReturnInvoked()) {
inStatus.SetReturnInvoked();
diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx
index 2f47788..7475e9f 100644
--- a/Source/cmGeneratedFileStream.cxx
+++ b/Source/cmGeneratedFileStream.cxx
@@ -6,14 +6,14 @@
#include "cmSystemTools.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# include "cm_codecvt.hxx"
# include "cm_zlib.h"
#endif
cmGeneratedFileStream::cmGeneratedFileStream(Encoding encoding)
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
if (encoding != codecvt::None) {
imbue(std::locale(getloc(), new codecvt(encoding)));
}
@@ -32,7 +32,7 @@ cmGeneratedFileStream::cmGeneratedFileStream(std::string const& name,
cmSystemTools::Error("Cannot open file for write: " + this->TempName);
cmSystemTools::ReportLastSystemError("");
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
if (encoding != codecvt::None) {
imbue(std::locale(getloc(), new codecvt(encoding)));
}
@@ -169,7 +169,7 @@ bool cmGeneratedFileStreamBase::Close()
return replaced;
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
int cmGeneratedFileStreamBase::CompressFile(std::string const& oldname,
std::string const& newname)
{
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 03fc5ae..c07d7af 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -2526,7 +2526,7 @@ void cmGeneratorTarget::ComputeModuleDefinitionInfo(
info.WindowsExportAllSymbols =
this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS") &&
this->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS");
-#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
info.DefFileGenerated =
info.WindowsExportAllSymbols || info.Sources.size() > 1;
#else
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 88da5eb..4db5ca8 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -44,7 +44,7 @@
#include "cmWorkingDirectory.h"
#include "cmake.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# include "cmCryptoHash.h"
# include "cmQtAutoGenGlobalInitializer.h"
# include "cm_jsoncpp_value.h"
@@ -114,7 +114,7 @@ cmGlobalGenerator::~cmGlobalGenerator()
this->ClearGeneratorMembers();
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
Json::Value cmGlobalGenerator::GetJson() const
{
Json::Value generator = Json::objectValue;
@@ -1547,7 +1547,7 @@ bool cmGlobalGenerator::ComputeTargetDepends()
bool cmGlobalGenerator::QtAutoGen()
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmQtAutoGenGlobalInitializer initializer(this->LocalGenerators);
return initializer.generate();
#else
@@ -2270,14 +2270,6 @@ bool cmGlobalGenerator::NameResolvesToFramework(
return false;
}
-inline std::string removeQuotes(const std::string& s)
-{
- if (s.front() == '\"' && s.back() == '\"') {
- return s.substr(1, s.size() - 2);
- }
- return s;
-}
-
bool cmGlobalGenerator::CheckCMP0037(std::string const& targetName,
std::string const& reason) const
{
@@ -2829,7 +2821,7 @@ std::set<std::string> const& cmGlobalGenerator::GetDirectoryContent(
void cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs,
std::string const& content)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
// Ignore if there are no outputs.
if (outputs.empty()) {
return;
@@ -2859,7 +2851,7 @@ void cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs,
void cmGlobalGenerator::CheckRuleHashes()
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
std::string home = this->GetCMakeInstance()->GetHomeOutputDirectory();
std::string pfile = home;
pfile += "/CMakeFiles";
@@ -2963,7 +2955,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
file += "/Labels.txt";
std::string json_file = dir + "/Labels.json";
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
// Check whether labels are enabled for this target.
const char* targetLabels = target->GetProperty("LABELS");
const char* directoryLabels =
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index ea40ebc..830974d 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -25,7 +25,7 @@
#include "cmTargetDepend.h"
#include "cm_codecvt.hxx"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# include "cmFileLockPool.h"
# include "cm_jsoncpp_value.h"
#endif
@@ -109,7 +109,7 @@ public:
return codecvt::None;
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
/** Get a JSON object describing the generator. */
virtual Json::Value GetJson() const;
#endif
@@ -462,7 +462,7 @@ public:
const std::set<const cmGeneratorTarget*>& GetFilenameTargetDepends(
cmSourceFile* sf) const;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
cmFileLockPool& GetFileLockPool() { return FileLockPool; }
#endif
@@ -665,7 +665,7 @@ private:
mutable std::map<cmSourceFile*, std::set<cmGeneratorTarget const*>>
FilenameTargetDepends;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
// Pool of file locks
cmFileLockPool FileLockPool;
#endif
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index ca80d3b..cd1ff61 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -256,7 +256,7 @@ cmLocalGenerator* cmGlobalVisualStudio7Generator::CreateLocalGenerator(
return lg;
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
Json::Value cmGlobalVisualStudio7Generator::GetJson() const
{
Json::Value generator = this->cmGlobalVisualStudioGenerator::GetJson();
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index f004afb..9b84732 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -23,7 +23,7 @@ public:
//! Create a local generator appropriate to this Global Generator
cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
Json::Value GetJson() const override;
#endif
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 029b976..e3cafe3 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -38,12 +38,12 @@
struct cmLinkImplementation;
-#if defined(CMAKE_BUILD_WITH_CMAKE) && defined(__APPLE__)
+#if !defined(CMAKE_BOOTSTRAP) && defined(__APPLE__)
# define HAVE_APPLICATION_SERVICES
# include <ApplicationServices/ApplicationServices.h>
#endif
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# include "cmXMLParser.h"
// parse the xml file storing the installed version of Xcode on
@@ -188,7 +188,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator(
if (name != GetActualName()) {
return nullptr;
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
cmXcodeVersionParser parser;
std::string versionFile;
{
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index c5cfd8c..7b49ae7 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -61,7 +61,6 @@ bool cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
{
cmMakefile& mf = inStatus.GetMakefile();
// execute the functions for the true parts of the if statement
- cmExecutionStatus status(mf);
int scopeDepth = 0;
for (cmListFileFunction const& func : functions) {
// keep track of scope depth
@@ -147,7 +146,7 @@ bool cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
// should we execute?
else if (!this->IsBlocking) {
- status.Clear();
+ cmExecutionStatus status(mf);
mf.ExecuteCommand(func, status);
if (status.GetReturnInvoked()) {
inStatus.SetReturnInvoked();
diff --git a/Source/cmIncludeGuardCommand.cxx b/Source/cmIncludeGuardCommand.cxx
index 3b126b0..e560910 100644
--- a/Source/cmIncludeGuardCommand.cxx
+++ b/Source/cmIncludeGuardCommand.cxx
@@ -21,7 +21,7 @@ enum IncludeGuardScope
std::string GetIncludeGuardVariableName(std::string const& filePath)
{
std::string result = "__INCGUARD_";
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
result += cmSystemTools::ComputeStringMD5(filePath);
#else
result += cmSystemTools::MakeCidentifier(filePath);
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 5349a9d..76dafd9 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -1268,7 +1268,7 @@ bool cmInstallCommand::HandleDirectoryMode(
bool cmInstallCommand::HandleExportAndroidMKMode(
std::vector<std::string> const& args)
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
// This is the EXPORT mode.
cmInstallCommandArguments ica(this->DefaultComponentName);
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index f5bedab..af06b9d 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -7,7 +7,7 @@
#include <sstream>
#include <utility>
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
# include "cmExportInstallAndroidMKGenerator.h"
#endif
#include "cmExportInstallFileGenerator.h"
@@ -31,7 +31,7 @@ cmInstallExportGenerator::cmInstallExportGenerator(
, LocalGenerator(nullptr)
{
if (android) {
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
this->EFGen = new cmExportInstallAndroidMKGenerator(this);
#endif
} else {
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index ae1b6d2..228495b 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -29,7 +29,7 @@
#include "cmake.h"
#include "cmsys/RegularExpression.hxx"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# define CM_LG_ENCODE_OBJECT_NAMES
# include "cmCryptoHash.h"
#endif
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index f0c6806..455e491 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -461,7 +461,7 @@ private:
void ComputeObjectMaxPath();
};
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
bool cmLocalGeneratorCheckObjectName(std::string& objName,
std::string::size_type dir_len,
std::string::size_type max_total_len);
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index c6b63ba..cfad31a 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -40,7 +40,7 @@
// Include dependency scanners for supported languages. Only the
// C/C++ scanner is needed for bootstrapping CMake.
#include "cmDependsC.h"
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
# include "cmDependsFortran.h"
# include "cmDependsJava.h"
#endif
@@ -1477,7 +1477,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
// TODO: Handle RC (resource files) dependencies correctly.
scanner = cm::make_unique<cmDependsC>(this, targetDir, lang, &validDeps);
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
else if (lang == "Fortran") {
ruleFileStream << "# Note that incremental build could trigger "
<< "a call to cmake_copy_f90_mod on each re-build\n";
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 86a002f..f6f4737 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -47,7 +47,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
# include "cmVariableWatch.h"
#endif
@@ -97,7 +97,7 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
// cmListFileCache in the top level if necessary.
this->CheckCMP0000 = false;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->AddSourceGroup("", "^.*$");
this->AddSourceGroup("Source Files", CM_SOURCE_REGEX);
this->AddSourceGroup("Header Files", CM_HEADER_REGEX);
@@ -1425,7 +1425,7 @@ void cmMakefile::PushFunctionScope(std::string const& fileName,
this->PushLoopBlockBarrier();
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->GetGlobalGenerator()->GetFileLockPool().PushFunctionScope();
#endif
@@ -1442,7 +1442,7 @@ void cmMakefile::PopFunctionScope(bool reportError)
this->PopFunctionBlockerBarrier(reportError);
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->GetGlobalGenerator()->GetFileLockPool().PopFunctionScope();
#endif
@@ -1497,7 +1497,7 @@ public:
this->Snapshot = this->GG->GetCMakeInstance()->GetCurrentSnapshot();
this->GG->GetCMakeInstance()->SetCurrentSnapshot(this->Snapshot);
this->GG->SetCurrentMakefile(mf);
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->GG->GetFileLockPool().PushFileScope();
#endif
}
@@ -1506,7 +1506,7 @@ public:
{
this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
this->Makefile->PopSnapshot(this->ReportError);
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->GG->GetFileLockPool().PopFileScope();
#endif
this->GG->SetCurrentMakefile(this->CurrentMakefile);
@@ -1800,7 +1800,7 @@ void cmMakefile::AddDefinition(const std::string& name, cm::string_view value)
}
this->StateSnapshot.SetDefinition(name, value);
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmVariableWatch* vv = this->GetVariableWatch();
if (vv) {
vv->VariableAccessed(name, cmVariableWatch::VARIABLE_MODIFIED_ACCESS,
@@ -1921,7 +1921,7 @@ void cmMakefile::RemoveDefinition(const std::string& name)
this->LogUnused("unsetting", name);
}
this->StateSnapshot.RemoveDefinition(name);
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmVariableWatch* vv = this->GetVariableWatch();
if (vv) {
vv->VariableAccessed(name, cmVariableWatch::VARIABLE_REMOVED_ACCESS,
@@ -2079,7 +2079,7 @@ cmSourceFile* cmMakefile::GetSourceFileWithOutput(
return nullptr;
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
cmSourceGroup* cmMakefile::GetSourceGroup(
const std::vector<std::string>& name) const
{
@@ -2460,7 +2460,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const
if (!def) {
def = this->GetState()->GetInitializedCacheValue(name);
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
if (cmVariableWatch* vv = this->GetVariableWatch()) {
if (!def) {
vv->VariableAccessed(
@@ -2477,7 +2477,7 @@ const std::string* cmMakefile::GetDef(const std::string& name) const
if (!def) {
def = this->GetState()->GetInitializedCacheValue(name);
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmVariableWatch* vv = this->GetVariableWatch();
if (vv && !this->SuppressSideEffects) {
bool const watch_function_executed =
@@ -3327,7 +3327,7 @@ void cmMakefile::AddTargetObject(std::string const& tgtName,
cmSourceFile* sf = this->GetOrCreateSource(objFile, true);
sf->SetObjectLibrary(tgtName);
sf->SetProperty("EXTERNAL_OBJECT", "1");
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->SourceGroups[this->ObjectLibrariesSourceGroupIndex].AddGroupFile(
sf->GetFullPath());
#endif
@@ -3509,7 +3509,7 @@ cmGlobalGenerator* cmMakefile::GetGlobalGenerator() const
return this->GlobalGenerator;
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmVariableWatch* cmMakefile::GetVariableWatch() const
{
if (this->GetCMakeInstance() &&
@@ -3931,14 +3931,14 @@ void cmMakefile::PushScope()
this->GetState()->CreateVariableScopeSnapshot(this->StateSnapshot);
this->PushLoopBlockBarrier();
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->GetGlobalGenerator()->GetFileLockPool().PushFunctionScope();
#endif
}
void cmMakefile::PopScope()
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->GetGlobalGenerator()->GetFileLockPool().PopFunctionScope();
#endif
@@ -3962,7 +3962,7 @@ void cmMakefile::RaiseScope(const std::string& var, const char* varDef)
return;
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmVariableWatch* vv = this->GetVariableWatch();
if (vv) {
vv->VariableAccessed(var, cmVariableWatch::VARIABLE_MODIFIED_ACCESS,
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 4d61c05..a6d1757 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -30,7 +30,7 @@
#include "cmStringAlgorithms.h"
#include "cmTarget.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# include "cmSourceGroup.h"
#endif
@@ -503,7 +503,7 @@ public:
*/
bool CanIWriteThisFile(std::string const& fileName) const;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
/**
* Get the vector source groups.
*/
@@ -649,7 +649,7 @@ public:
* Get the variable watch. This is used to determine when certain variables
* are accessed.
*/
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmVariableWatch* GetVariableWatch() const;
#endif
@@ -945,7 +945,7 @@ protected:
// Track the value of the computed DEFINITIONS property.
std::string DefineFlagsOrig;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
std::vector<cmSourceGroup> SourceGroups;
size_t ObjectLibrariesSourceGroupIndex;
#endif
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 19c667e..31ee4fa 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -83,7 +83,7 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles()
void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
bool relink)
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
const bool requiresDeviceLinking = requireDeviceLinking(
*this->GeneratorTarget, *this->LocalGenerator, this->ConfigName);
if (!requiresDeviceLinking) {
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 8d342f3..4621da4 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -236,7 +236,7 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules(
const std::string& linkRuleVar, bool relink)
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
// TODO: Merge the methods that call this method to avoid
// code duplication.
std::vector<std::string> commands;
diff --git a/Source/cmMessenger.cxx b/Source/cmMessenger.cxx
index 07d011e..af83478 100644
--- a/Source/cmMessenger.cxx
+++ b/Source/cmMessenger.cxx
@@ -6,7 +6,7 @@
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# include "cmsys/SystemInformation.hxx"
#endif
@@ -106,7 +106,7 @@ void displayMessage(MessageType t, std::ostringstream& msg)
// Add a terminating blank line.
msg << "\n";
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
// Add a C++ stack trace to internal errors.
if (t == MessageType::INTERNAL_ERROR) {
std::string stack = cmsys::SystemInformation::GetProgramStack(0, 0);
diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx
index 712e22c..3026b33 100644
--- a/Source/cmQtAutoGen.cxx
+++ b/Source/cmQtAutoGen.cxx
@@ -353,9 +353,8 @@ bool cmQtAutoGen::RccLister::list(std::string const& qrcFile,
// Log command
if (verbose) {
- std::string msg = "Running command:\n";
- msg += QuotedCommand(cmd);
- msg += '\n';
+ std::string msg =
+ cmStrCat("Running command:\n", QuotedCommand(cmd), '\n');
cmSystemTools::Stdout(msg);
}
diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx
index f172b77..ca5a587 100644
--- a/Source/cmQtAutoGenGlobalInitializer.cxx
+++ b/Source/cmQtAutoGenGlobalInitializer.cxx
@@ -1,8 +1,6 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmQtAutoGenGlobalInitializer.h"
-#include "cmQtAutoGen.h"
-#include "cmQtAutoGenInitializer.h"
#include "cmCustomCommandLines.h"
#include "cmDuration.h"
@@ -11,15 +9,18 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmProcessOutput.h"
+#include "cmQtAutoGen.h"
+#include "cmQtAutoGenInitializer.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include <utility>
-
#include "cm_memory.hxx"
+#include <utility>
+
cmQtAutoGenGlobalInitializer::Keywords::Keywords()
: AUTOMOC("AUTOMOC")
, AUTOUIC("AUTOUIC")
@@ -119,23 +120,17 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer(
bool const uicDisabled = (uic && !uicAvailable);
bool const rccDisabled = (rcc && !rccAvailable);
if (mocDisabled || uicDisabled || rccDisabled) {
- std::string msg = "AUTOGEN: No valid Qt version found for target ";
- msg += target->GetName();
- msg += ". ";
- msg += cmQtAutoGen::Tools(mocDisabled, uicDisabled, rccDisabled);
- msg += " disabled. Consider adding:\n";
- {
- std::string version = (qtVersion.second == 0)
- ? std::string("<QTVERSION>")
- : std::to_string(qtVersion.second);
- std::string comp = uicDisabled ? "Widgets" : "Core";
- msg += " find_package(Qt";
- msg += version;
- msg += " COMPONENTS ";
- msg += comp;
- msg += ")\n";
- }
- msg += "to your CMakeLists.txt file.";
+ cmAlphaNum version = (qtVersion.second == 0)
+ ? cmAlphaNum("<QTVERSION>")
+ : cmAlphaNum(qtVersion.second);
+ cmAlphaNum component = uicDisabled ? "Widgets" : "Core";
+
+ std::string const msg = cmStrCat(
+ "AUTOGEN: No valid Qt version found for target ",
+ target->GetName(), ". ",
+ cmQtAutoGen::Tools(mocDisabled, uicDisabled, rccDisabled),
+ " disabled. Consider adding:\n", " find_package(Qt", version,
+ " COMPONENTS ", component, ")\n", "to your CMakeLists.txt file.");
target->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, msg);
}
if (mocIsValid || uicIsValid || rccIsValid) {
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index da6094d..360df25 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -156,30 +156,27 @@ std::string cmQtAutoGenInitializer::InfoWriter::ListJoin(IT it_begin,
return res;
}
-std::string cmQtAutoGenInitializer::InfoWriter::ConfigKey(
- const char* key, std::string const& config)
+inline std::string cmQtAutoGenInitializer::InfoWriter::ConfigKey(
+ cm::string_view key, std::string const& config)
{
- std::string ckey = key;
- ckey += '_';
- ckey += config;
- return ckey;
+ return cmStrCat(key, "_", config);
}
-void cmQtAutoGenInitializer::InfoWriter::Write(const char* key,
+void cmQtAutoGenInitializer::InfoWriter::Write(cm::string_view key,
std::string const& value)
{
Ofs_ << "set(" << key << " " << cmOutputConverter::EscapeForCMake(value)
<< ")\n";
};
-void cmQtAutoGenInitializer::InfoWriter::WriteUInt(const char* key,
+void cmQtAutoGenInitializer::InfoWriter::WriteUInt(cm::string_view key,
unsigned int value)
{
Ofs_ << "set(" << key << " " << value << ")\n";
};
template <class C>
-void cmQtAutoGenInitializer::InfoWriter::WriteStrings(const char* key,
+void cmQtAutoGenInitializer::InfoWriter::WriteStrings(cm::string_view key,
C const& container)
{
Ofs_ << "set(" << key << " \""
@@ -187,31 +184,29 @@ void cmQtAutoGenInitializer::InfoWriter::WriteStrings(const char* key,
}
void cmQtAutoGenInitializer::InfoWriter::WriteConfig(
- const char* key, std::map<std::string, std::string> const& map)
+ cm::string_view key, std::map<std::string, std::string> const& map)
{
for (auto const& item : map) {
- Write(ConfigKey(key, item.first).c_str(), item.second);
+ Write(ConfigKey(key, item.first), item.second);
}
};
template <class C>
void cmQtAutoGenInitializer::InfoWriter::WriteConfigStrings(
- const char* key, std::map<std::string, C> const& map)
+ cm::string_view key, std::map<std::string, C> const& map)
{
for (auto const& item : map) {
- WriteStrings(ConfigKey(key, item.first).c_str(), item.second);
+ WriteStrings(ConfigKey(key, item.first), item.second);
}
}
void cmQtAutoGenInitializer::InfoWriter::WriteNestedLists(
- const char* key, std::vector<std::vector<std::string>> const& lists)
+ cm::string_view key, std::vector<std::vector<std::string>> const& lists)
{
std::vector<std::string> seplist;
- for (const std::vector<std::string>& list : lists) {
- std::string blist = "{";
- blist += ListJoin(list.begin(), list.end());
- blist += "}";
- seplist.push_back(std::move(blist));
+ seplist.reserve(lists.size());
+ for (std::vector<std::string> const& list : lists) {
+ seplist.push_back(cmStrCat("{", ListJoin(list.begin(), list.end()), "}"));
}
Write(key, cmJoin(seplist, cmQtAutoGen::ListSep));
};
@@ -721,14 +716,13 @@ bool cmQtAutoGenInitializer::InitScanFiles()
if (muf.MocIt || muf.UicIt) {
// Search for the default header file and a private header
std::string const& srcPath = muf.SF->GetFullPath();
- std::string basePath = cmQtAutoGen::SubDirPrefix(srcPath);
- basePath += cmSystemTools::GetFilenameWithoutLastExtension(srcPath);
+ std::string basePath =
+ cmStrCat(cmQtAutoGen::SubDirPrefix(srcPath),
+ cmSystemTools::GetFilenameWithoutLastExtension(srcPath));
for (auto const& suffix : suffixes) {
std::string const suffixedPath = basePath + suffix;
for (auto const& ext : exts) {
- std::string fullPath = suffixedPath;
- fullPath += '.';
- fullPath += ext;
+ std::string fullPath = cmStrCat(suffixedPath, '.', ext);
auto constexpr locationKind = cmSourceFileLocationKind::Known;
cmSourceFile* sf = makefile->GetSource(fullPath, locationKind);
@@ -833,9 +827,8 @@ bool cmQtAutoGenInitializer::InitScanFiles()
this->AutogenTarget.DependFiles.insert(muf->RealPath);
}
} else if (this->CMP0071Warn) {
- std::string msg;
- msg += cmPolicies::GetPolicyWarning(cmPolicies::CMP0071);
- msg += '\n';
+ std::string msg =
+ cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0071), '\n');
std::string property;
if (this->Moc.Enabled && this->Uic.Enabled) {
property = kw.SKIP_AUTOGEN;
@@ -888,18 +881,10 @@ bool cmQtAutoGenInitializer::InitScanFiles()
for (Qrc& qrc : this->Rcc.Qrcs) {
qrc.PathChecksum = fpathCheckSum.getPart(qrc.QrcFile);
// RCC output file name
+ qrc.RccFile = cmStrCat(this->Dir.Build + "/", qrc.PathChecksum,
+ "/qrc_", qrc.QrcName, ".cpp");
{
- std::string rccFile = this->Dir.Build + "/";
- rccFile += qrc.PathChecksum;
- rccFile += "/qrc_";
- rccFile += qrc.QrcName;
- rccFile += ".cpp";
- qrc.RccFile = std::move(rccFile);
- }
- {
- std::string base = this->Dir.Info;
- base += "/RCC";
- base += qrc.QrcName;
+ std::string base = cmStrCat(this->Dir.Info, "/RCC", qrc.QrcName);
if (!qrc.Unique) {
base += qrc.PathChecksum;
}
@@ -932,8 +917,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
// Replace '-' with '_'. The former is not valid for symbol names.
std::replace(name.begin(), name.end(), '-', '_');
if (!qrc.Unique) {
- name += "_";
- name += qrc.PathChecksum;
+ name += cmStrCat("_", qrc.PathChecksum);
}
std::vector<std::string> nameOpts;
nameOpts.emplace_back("-name");
@@ -1157,8 +1141,8 @@ bool cmQtAutoGenInitializer::InitRccTargets()
currentLine.push_back("$<CONFIG>");
commandLines.push_back(std::move(currentLine));
}
- std::string ccComment = "Automatic RCC for ";
- ccComment += FileProjectRelativePath(makefile, qrc.QrcFile);
+ std::string ccComment = cmStrCat(
+ "Automatic RCC for ", FileProjectRelativePath(makefile, qrc.QrcFile));
if (qrc.Generated || this->Rcc.GlobalTarget) {
// Create custom rcc target
@@ -1226,9 +1210,8 @@ bool cmQtAutoGenInitializer::SetupCustomTargets()
{
// Create info directory on demand
if (!cmSystemTools::MakeDirectory(this->Dir.Info)) {
- std::string emsg = ("AutoGen: Could not create directory: ");
- emsg += Quoted(this->Dir.Info);
- cmSystemTools::Error(emsg);
+ cmSystemTools::Error(cmStrCat("AutoGen: Could not create directory: ",
+ Quoted(this->Dir.Info)));
return false;
}
@@ -1311,10 +1294,8 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
}
if (muf->MocIt || muf->UicIt) {
headers.emplace_back(muf->RealPath);
- std::string flags;
- flags += muf->MocIt ? 'M' : 'm';
- flags += muf->UicIt ? 'U' : 'u';
- headersFlags.emplace_back(std::move(flags));
+ headersFlags.emplace_back(
+ cmStrCat(muf->MocIt ? "M" : "m", muf->UicIt ? "U" : "u"));
}
}
}
@@ -1323,14 +1304,13 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
cmFilePathChecksum const fpathCheckSum(makefile);
std::unordered_set<std::string> emitted;
for (std::string const& hdr : headers) {
- std::string basePath = fpathCheckSum.getPart(hdr);
- basePath += "/moc_";
- basePath += cmSystemTools::GetFilenameWithoutLastExtension(hdr);
- for (unsigned int ii = 1; ii != 1024; ++ii) {
+ std::string basePath =
+ cmStrCat(fpathCheckSum.getPart(hdr), "/moc_",
+ cmSystemTools::GetFilenameWithoutLastExtension(hdr));
+ for (int ii = 1; ii != 1024; ++ii) {
std::string path = basePath;
if (ii > 1) {
- path += '_';
- path += std::to_string(ii);
+ path += cmStrCat("_", ii);
}
path += ".cpp";
if (emitted.emplace(path).second) {
@@ -1369,10 +1349,8 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
}
if (muf->MocIt || muf->UicIt) {
sources.emplace_back(muf->RealPath);
- std::string flags;
- flags += muf->MocIt ? 'M' : 'm';
- flags += muf->UicIt ? 'U' : 'u';
- sourcesFlags.emplace_back(std::move(flags));
+ sourcesFlags.emplace_back(
+ cmStrCat(muf->MocIt ? "M" : "m", muf->UicIt ? "U" : "u"));
}
}
}
@@ -1426,9 +1404,8 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
ofs.WriteStrings("AM_UIC_SEARCH_PATHS", this->Uic.SearchPaths);
}
} else {
- std::string err = "AutoGen: Could not write file ";
- err += this->AutogenTarget.InfoFile;
- cmSystemTools::Error(err);
+ cmSystemTools::Error(cmStrCat("AutoGen: Could not write file ",
+ this->AutogenTarget.InfoFile));
return false;
}
@@ -1467,9 +1444,8 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo()
ofs.WriteStrings("ARCC_OPTIONS", qrc.Options);
ofs.WriteStrings("ARCC_INPUTS", qrc.Resources);
} else {
- std::string err = "AutoRcc: Could not write file ";
- err += qrc.InfoFile;
- cmSystemTools::Error(err);
+ cmSystemTools::Error(
+ cmStrCat("AutoRcc: Could not write file ", qrc.InfoFile));
return false;
}
}
@@ -1524,13 +1500,10 @@ bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
if (!groupName.empty()) {
sourceGroup = makefile->GetOrCreateSourceGroup(groupName);
if (sourceGroup == nullptr) {
- std::string err;
- err += genNameUpper;
- err += " error in ";
- err += property;
- err += ": Could not find or create the source group ";
- err += cmQtAutoGen::Quoted(groupName);
- cmSystemTools::Error(err);
+ cmSystemTools::Error(
+ cmStrCat(genNameUpper, " error in ", property,
+ ": Could not find or create the source group ",
+ cmQtAutoGen::Quoted(groupName)));
return false;
}
}
@@ -1622,12 +1595,8 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars,
bool ignoreMissingTarget) const
{
auto print_err = [this, &genVars](std::string const& err) {
- std::string msg = genVars.GenNameUpper;
- msg += " for target ";
- msg += this->Target->GetName();
- msg += ": ";
- msg += err;
- cmSystemTools::Error(msg);
+ cmSystemTools::Error(cmStrCat(genVars.GenNameUpper, " for target ",
+ this->Target->GetName(), ": ", err));
};
// Custom executable
@@ -1687,11 +1656,8 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars,
std::make_shared<cmQtAutoGen::CompilerFeatures>();
return true;
}
- std::string err = "Could not find ";
- err += executable;
- err += " executable target ";
- err += targetName;
- print_err(err);
+ print_err(cmStrCat("Could not find ", executable, " executable target ",
+ targetName));
return false;
}
}
diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h
index eb0d35e..7d72cad 100644
--- a/Source/cmQtAutoGenInitializer.h
+++ b/Source/cmQtAutoGenInitializer.h
@@ -6,6 +6,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmGeneratedFileStream.h"
#include "cmQtAutoGen.h"
+#include "cm_string_view.hxx"
#include <map>
#include <memory>
@@ -85,24 +86,24 @@ public:
/// @return True if the file is open
explicit operator bool() const { return static_cast<bool>(Ofs_); }
- void Write(const char* text) { Ofs_ << text; }
- void Write(const char* key, std::string const& value);
- void WriteUInt(const char* key, unsigned int value);
+ void Write(cm::string_view text) { Ofs_ << text; }
+ void Write(cm::string_view, std::string const& value);
+ void WriteUInt(cm::string_view, unsigned int value);
template <class C>
- void WriteStrings(const char* key, C const& container);
- void WriteConfig(const char* key,
+ void WriteStrings(cm::string_view, C const& container);
+ void WriteConfig(cm::string_view,
std::map<std::string, std::string> const& map);
template <class C>
- void WriteConfigStrings(const char* key,
+ void WriteConfigStrings(cm::string_view,
std::map<std::string, C> const& map);
- void WriteNestedLists(const char* key,
+ void WriteNestedLists(cm::string_view,
std::vector<std::vector<std::string>> const& lists);
private:
template <class IT>
static std::string ListJoin(IT it_begin, IT it_end);
- static std::string ConfigKey(const char* key, std::string const& config);
+ static std::string ConfigKey(cm::string_view, std::string const& config);
private:
cmGeneratedFileStream Ofs_;
diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx
index 2516d84..0ad87b1 100644
--- a/Source/cmQtAutoGenerator.cxx
+++ b/Source/cmQtAutoGenerator.cxx
@@ -1,17 +1,17 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmQtAutoGenerator.h"
-#include "cmQtAutoGen.h"
-
-#include "cmsys/FStream.hxx"
#include "cm_memory.hxx"
+#include "cmsys/FStream.hxx"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
+#include "cmQtAutoGen.h"
#include "cmState.h"
#include "cmStateDirectory.h"
#include "cmStateSnapshot.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
@@ -60,19 +60,13 @@ void cmQtAutoGenerator::Logger::SetColorOutput(bool value)
std::string cmQtAutoGenerator::Logger::HeadLine(std::string const& title)
{
- std::string head = title;
- head += '\n';
- head.append(head.size() - 1, '-');
- head += '\n';
- return head;
+ return cmStrCat(title, "\n", std::string(title.size(), '-'), "\n");
}
void cmQtAutoGenerator::Logger::Info(GenT genType,
std::string const& message) const
{
- std::string msg = GeneratorName(genType);
- msg += ": ";
- msg += message;
+ std::string msg = cmStrCat(GeneratorName(genType), ": ", message);
if (msg.back() != '\n') {
msg.push_back('\n');
}
@@ -110,19 +104,13 @@ void cmQtAutoGenerator::Logger::WarningFile(GenT genType,
std::string const& filename,
std::string const& message) const
{
- std::string msg = " ";
- msg += Quoted(filename);
- msg.push_back('\n');
- // Message
- msg += message;
- Warning(genType, msg);
+ Warning(genType, cmStrCat(" ", Quoted(filename), "\n", message));
}
void cmQtAutoGenerator::Logger::Error(GenT genType,
std::string const& message) const
{
- std::string msg;
- msg += HeadLine(GeneratorName(genType) + " error");
+ std::string msg = HeadLine(GeneratorName(genType) + " error");
// Message
msg += message;
if (msg.back() != '\n') {
@@ -139,12 +127,7 @@ void cmQtAutoGenerator::Logger::ErrorFile(GenT genType,
std::string const& filename,
std::string const& message) const
{
- std::string emsg = " ";
- emsg += Quoted(filename);
- emsg += '\n';
- // Message
- emsg += message;
- Error(genType, emsg);
+ Error(genType, cmStrCat(" ", Quoted(filename), '\n', message));
}
void cmQtAutoGenerator::Logger::ErrorCommand(
@@ -280,10 +263,8 @@ bool cmQtAutoGenerator::Run(std::string const& infoFile,
InfoFile_ = infoFile;
cmSystemTools::ConvertToUnixSlashes(InfoFile_);
if (!InfoFileTime_.Load(InfoFile_)) {
- std::string msg = "AutoGen: The info file ";
- msg += Quoted(InfoFile_);
- msg += " is not readable\n";
- cmSystemTools::Stderr(msg);
+ cmSystemTools::Stderr(cmStrCat("AutoGen: The info file ",
+ Quoted(InfoFile_), " is not readable\n"));
return false;
}
InfoDir_ = cmSystemTools::GetFilenamePath(infoFile);
diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx
index 0801c24..e693816 100644
--- a/Source/cmQtAutoMocUic.cxx
+++ b/Source/cmQtAutoMocUic.cxx
@@ -302,10 +302,9 @@ void cmQtAutoMocUic::JobMocPredefsT::Process()
}
// Execute command
if (!RunProcess(GenT::MOC, result, cmd, reason.get())) {
- std::string msg = "The content generation command for ";
- msg += Quoted(predefsFileRel);
- msg += " failed.\n";
- msg += result.ErrorMessage;
+ std::string msg =
+ cmStrCat("The content generation command for ",
+ Quoted(predefsFileRel), " failed.\n", result.ErrorMessage);
LogCommandError(GenT::MOC, msg, cmd, result.StdOut);
return;
}
@@ -314,9 +313,8 @@ void cmQtAutoMocUic::JobMocPredefsT::Process()
// (Re)write predefs file only on demand
if (cmQtAutoGenerator::FileDiffers(predefsFileAbs, result.StdOut)) {
if (!cmQtAutoGenerator::FileWrite(predefsFileAbs, result.StdOut)) {
- std::string msg = "Writing ";
- msg += Quoted(predefsFileRel);
- msg += " failed.";
+ std::string msg =
+ cmStrCat("Writing ", Quoted(predefsFileRel), " failed.");
LogFileError(GenT::MOC, predefsFileAbs, msg);
return;
}
@@ -326,9 +324,8 @@ void cmQtAutoMocUic::JobMocPredefsT::Process()
Log().Info(GenT::MOC, "Touching " + Quoted(predefsFileRel));
}
if (!cmSystemTools::Touch(predefsFileAbs, false)) {
- std::string msg = "Touching ";
- msg += Quoted(predefsFileAbs);
- msg += " failed.";
+ std::string msg =
+ cmStrCat("Touching ", Quoted(predefsFileAbs), " failed.");
LogFileError(GenT::MOC, predefsFileAbs, msg);
return;
}
@@ -663,13 +660,11 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource(
if (!sourceIncludesDotMoc && !parseData.Macro.empty() &&
!(relaxedMode && sourceIncludesMocUnderscore)) {
{
- std::string emsg = "The file contains a ";
- emsg += Quoted(parseData.Macro);
- emsg += " macro, but does not include ";
- emsg += Quoted(sourceBase + ".moc");
- emsg += "!\nConsider to\n - add #include \"";
- emsg += sourceBase;
- emsg += ".moc\"\n - enable SKIP_AUTOMOC for this file";
+ std::string emsg =
+ cmStrCat("The file contains a ", Quoted(parseData.Macro),
+ " macro, but does not include ", Quoted(sourceBase + ".moc"),
+ "!\nConsider to\n - add #include \"", sourceBase,
+ ".moc\"\n - enable SKIP_AUTOMOC for this file");
LogFileError(GenT::MOC, sourceFile.FileName, emsg);
}
return false;
@@ -700,18 +695,14 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource(
// used. This is for KDE4 compatibility.
{
// Issue a warning
- std::string msg = "The file contains a ";
- msg += Quoted(parseData.Macro);
- msg += " macro, but does not include ";
- msg += Quoted(sourceBase + ".moc");
- msg += ".\nInstead it includes ";
- msg += Quoted(incKey.Key);
- msg += ".\nRunning moc on the source\n ";
- msg += Quoted(sourceFile.FileName);
- msg += "!\nBetter include ";
- msg += Quoted(sourceBase + ".moc");
- msg += " for compatibility with regular mode.\n";
- msg += "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n";
+ std::string msg = cmStrCat(
+ "The file contains a ", Quoted(parseData.Macro),
+ " macro, but does not include ", Quoted(sourceBase + ".moc"),
+ ".\nInstead it includes ", Quoted(incKey.Key),
+ ".\nRunning moc on the source\n ", Quoted(sourceFile.FileName),
+ "!\nBetter include ", Quoted(sourceBase + ".moc"),
+ " for compatibility with regular mode.\n",
+ "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n");
Log().WarningFile(GenT::MOC, sourceFile.FileName, msg);
}
// Create mapping
@@ -764,28 +755,22 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource(
}
// Issue a warning
if (ownMoc && parseData.Macro.empty()) {
- std::string msg = "The file includes the moc file ";
- msg += Quoted(incKey.Key);
- msg += ", but does not contain a\n";
- msg += MocConst().MacrosString();
- msg += " macro.\nRunning moc on the header\n ";
- msg += Quoted(header->FileName);
- msg += "!\nBetter include ";
- msg += Quoted("moc_" + incKey.Base + ".cpp");
- msg += " for a compatibility with regular mode.\n";
- msg += "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n";
+ std::string msg = cmStrCat(
+ "The file includes the moc file ", Quoted(incKey.Key),
+ ", but does not contain a\n", MocConst().MacrosString(),
+ " macro.\nRunning moc on the header\n ", Quoted(header->FileName),
+ "!\nBetter include ", Quoted("moc_" + incKey.Base + ".cpp"),
+ " for a compatibility with regular mode.\n",
+ "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n");
Log().WarningFile(GenT::MOC, sourceFile.FileName, msg);
} else {
- std::string msg = "The file includes the moc file ";
- msg += Quoted(incKey.Key);
- msg += " instead of ";
- msg += Quoted("moc_" + incKey.Base + ".cpp");
- msg += ".\nRunning moc on the header\n ";
- msg += Quoted(header->FileName);
- msg += "!\nBetter include ";
- msg += Quoted("moc_" + incKey.Base + ".cpp");
- msg += " for compatibility with regular mode.\n";
- msg += "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n";
+ std::string msg = cmStrCat(
+ "The file includes the moc file ", Quoted(incKey.Key),
+ " instead of ", Quoted("moc_" + incKey.Base + ".cpp"),
+ ".\nRunning moc on the header\n ", Quoted(header->FileName),
+ "!\nBetter include ", Quoted("moc_" + incKey.Base + ".cpp"),
+ " for compatibility with regular mode.\n",
+ "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n");
Log().WarningFile(GenT::MOC, sourceFile.FileName, msg);
}
// Create mapping
@@ -811,11 +796,9 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource(
}
// Accept but issue a warning if moc isn't required
if (parseData.Macro.empty()) {
- std::string msg = "The file includes the moc file ";
- msg += Quoted(incKey.Key);
- msg += ", but does not contain a ";
- msg += MocConst().MacrosString();
- msg += " macro.";
+ std::string msg = cmStrCat(
+ "The file includes the moc file ", Quoted(incKey.Key),
+ ", but does not contain a ", MocConst().MacrosString(), " macro.");
Log().WarningFile(GenT::MOC, sourceFile.FileName, msg);
}
// Create mapping
@@ -841,9 +824,7 @@ cmQtAutoMocUic::JobEvaluateT::MocFindIncludedHeader(
}
// Search in include directories
for (std::string const& path : MocConst().IncludePaths) {
- std::string testPath = path;
- testPath += '/';
- testPath += includeBase;
+ std::string testPath = cmStrCat(path, '/', includeBase);
SourceFileHandleT res = MocFindHeader(testPath);
if (res) {
return res;
@@ -893,10 +874,9 @@ std::string cmQtAutoMocUic::JobEvaluateT::MocMessageTestHeaders(
{
std::ostringstream res;
{
- std::string exts = ".{";
- exts += cmJoin(BaseConst().HeaderExtensions, ",");
- exts += '}';
- // Compose result string
+ std::string exts =
+ cmStrCat(".{", cmJoin(BaseConst().HeaderExtensions, ","),
+ '}'); // Compose result string
res << " " << fileBase << exts << '\n';
for (std::string const& path : MocConst().IncludePaths) {
res << " " << path << '/' << fileBase << exts << '\n';
@@ -914,9 +894,8 @@ bool cmQtAutoMocUic::JobEvaluateT::MocRegisterIncluded(
if (handle) {
// Check if the output file would be generated from different source files
if (handle->SourceFile != sourceFileHandle) {
- std::string msg = "The source files\n ";
- msg += Quoted(includerFileHandle->FileName);
- msg += '\n';
+ std::string msg = cmStrCat("The source files\n ",
+ Quoted(includerFileHandle->FileName), '\n');
for (auto const& item : handle->IncluderFiles) {
msg += " ";
msg += Quoted(item->FileName);
@@ -1020,9 +999,8 @@ bool cmQtAutoMocUic::JobEvaluateT::UicRegisterMapping(
MappingHandleT const& handle = it->second;
if (handle->SourceFile != uiFileHandle) {
// The output file already gets generated - from a different .ui file!
- std::string msg = "The source files\n ";
- msg += Quoted(includerFileHandle->FileName);
- msg += '\n';
+ std::string msg = cmStrCat("The source files\n ",
+ Quoted(includerFileHandle->FileName), '\n');
for (auto const& item : handle->IncluderFiles) {
msg += " ";
msg += Quoted(item->FileName);
@@ -1063,8 +1041,7 @@ cmQtAutoMocUic::JobEvaluateT::UicFindIncludedUi(
std::string const& sourceFile, std::string const& sourceDir,
IncludeKeyT const& incKey) const
{
- std::string searchFileName = incKey.Base;
- searchFileName += ".ui";
+ std::string searchFileName = cmStrCat(incKey.Base, ".ui");
// Collect search paths list
std::vector<std::string> testFiles;
{
@@ -1074,26 +1051,17 @@ cmQtAutoMocUic::JobEvaluateT::UicFindIncludedUi(
// Vicinity of the source
testFiles.emplace_back(sourceDir + searchFileName);
if (!incKey.Dir.empty()) {
- std::string path = sourceDir;
- path += incKey.Dir;
- path += searchFileName;
- testFiles.emplace_back(path);
+ testFiles.emplace_back(cmStrCat(sourceDir, incKey.Dir, searchFileName));
}
// AUTOUIC search paths
if (!searchPaths.empty()) {
for (std::string const& sPath : searchPaths) {
- std::string path = sPath;
- path += '/';
- path += searchFileName;
- testFiles.emplace_back(std::move(path));
+ testFiles.emplace_back(cmStrCat(sPath, '/', searchFileName));
}
if (!incKey.Dir.empty()) {
for (std::string const& sPath : searchPaths) {
- std::string path = sPath;
- path += '/';
- path += incKey.Dir;
- path += searchFileName;
- testFiles.emplace_back(std::move(path));
+ testFiles.emplace_back(
+ cmStrCat(sPath, '/', incKey.Dir, searchFileName));
}
}
}
@@ -1118,11 +1086,10 @@ cmQtAutoMocUic::JobEvaluateT::UicFindIncludedUi(
// Log error
{
- std::string msg = "The file includes the uic file ";
- msg += Quoted(incKey.Key);
- msg += ",\nbut the user interface file ";
- msg += Quoted(searchFileName);
- msg += "\ncould not be found in the following locations\n";
+ std::string msg =
+ cmStrCat("The file includes the uic file ", Quoted(incKey.Key),
+ ",\nbut the user interface file ", Quoted(searchFileName),
+ "\ncould not be found in the following locations\n");
for (std::string const& testFile : testFiles) {
msg += " ";
msg += Quoted(testFile);
@@ -1418,10 +1385,9 @@ void cmQtAutoMocUic::JobMocT::Process()
}
} else {
// Moc command failed
- std::string msg = "The moc process failed to compile\n ";
- msg += Quoted(sourceFile);
- msg += "\ninto\n ";
- msg += Quoted(outputFile);
+ std::string msg =
+ cmStrCat("The moc process failed to compile\n ", Quoted(sourceFile),
+ "\ninto\n ", Quoted(outputFile));
if (Mapping->IncluderFiles.empty()) {
msg += ".\n";
} else {
@@ -1467,11 +1433,9 @@ void cmQtAutoMocUic::JobUicT::Process()
}
} else {
// Uic command failed
- std::string msg = "The uic process failed to compile\n ";
- msg += Quoted(sourceFile);
- msg += "\ninto\n ";
- msg += Quoted(outputFile);
- msg += "\nincluded by\n";
+ std::string msg =
+ cmStrCat("The uic process failed to compile\n ", Quoted(sourceFile),
+ "\ninto\n ", Quoted(outputFile), "\nincluded by\n");
for (auto const& item : Mapping->IncluderFiles) {
msg += " ";
msg += Quoted(item->FileName);
@@ -1564,12 +1528,8 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile)
if (length >= 2) {
std::string::const_iterator itBeg = value.begin() + (pos + 1);
std::string::const_iterator itEnd = itBeg + (length - 2);
- {
- std::string subValue(itBeg, itEnd);
- std::vector<std::string> list;
- cmSystemTools::ExpandListArgument(subValue, list);
- lists.push_back(std::move(list));
- }
+ lists.emplace_back(
+ cmSystemTools::ExpandedListArgument(std::string(itBeg, itEnd)));
}
pos += length;
pos += ListSep.size();
@@ -1580,9 +1540,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile)
auto InfoGetConfig = [makefile, this](const char* key) -> std::string {
const char* valueConf = nullptr;
{
- std::string keyConf = key;
- keyConf += '_';
- keyConf += InfoConfig();
+ std::string keyConf = cmStrCat(key, '_', InfoConfig());
valueConf = makefile->GetDefinition(keyConf);
}
if (valueConf == nullptr) {
@@ -1653,9 +1611,9 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile)
return LogInfoError("CMake executable file name missing.");
}
if (!BaseConst_.CMakeExecutableTime.Load(BaseConst_.CMakeExecutable)) {
- std::string error = "The CMake executable ";
- error += Quoted(BaseConst_.CMakeExecutable);
- error += " does not exist.";
+ std::string error =
+ cmStrCat("The CMake executable ", Quoted(BaseConst_.CMakeExecutable),
+ " does not exist.");
return LogInfoError(error);
}
BaseConst_.ParseCacheFile = InfoGetConfig("AM_PARSE_CACHE_FILE");
@@ -1684,9 +1642,9 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile)
MocConst_.Enabled = true;
// Load the executable file time
if (!MocConst_.ExecutableTime.Load(MocConst_.Executable)) {
- std::string error = "The moc executable ";
- error += Quoted(MocConst_.Executable);
- error += " does not exist.";
+ std::string error =
+ cmStrCat("The moc executable ", Quoted(MocConst_.Executable),
+ " does not exist.");
return LogInfoError(error);
}
for (std::string& sfl : InfoGetList("AM_MOC_SKIP")) {
@@ -1752,9 +1710,9 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile)
UicConst_.Enabled = true;
// Load the executable file time
if (!UicConst_.ExecutableTime.Load(UicConst_.Executable)) {
- std::string error = "The uic executable ";
- error += Quoted(UicConst_.Executable);
- error += " does not exist.";
+ std::string error =
+ cmStrCat("The uic executable ", Quoted(UicConst_.Executable),
+ " does not exist.");
return LogInfoError(error);
}
for (std::string& sfl : InfoGetList("AM_UIC_SKIP")) {
diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx
index 59f632d..c75b2ca 100644
--- a/Source/cmQtAutoRcc.cxx
+++ b/Source/cmQtAutoRcc.cxx
@@ -36,9 +36,7 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile)
this](std::string const& key) -> std::string {
const char* valueConf = nullptr;
{
- std::string keyConf = key;
- keyConf += '_';
- keyConf += InfoConfig();
+ std::string keyConf = cmStrCat(key, '_', InfoConfig());
valueConf = makefile->GetDefinition(keyConf);
}
if (valueConf == nullptr) {
@@ -82,9 +80,8 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile)
// - Rcc executable
RccExecutable_ = InfoGet("ARCC_RCC_EXECUTABLE");
if (!RccExecutableTime_.Load(RccExecutable_)) {
- std::string error = "The rcc executable ";
- error += Quoted(RccExecutable_);
- error += " does not exist.";
+ std::string error = cmStrCat("The rcc executable ", Quoted(RccExecutable_),
+ " does not exist.");
return LogInfoError(error);
}
RccListOptions_ = InfoGetList("ARCC_RCC_LIST_OPTIONS");
@@ -179,10 +176,8 @@ bool cmQtAutoRcc::Process()
std::string cmQtAutoRcc::MultiConfigOutput() const
{
static std::string const suffix = "_CMAKE_";
- std::string res;
- res += RccPathChecksum_;
- res += '/';
- res += AppendFilenameSuffix(RccFileName_, suffix);
+ std::string res = cmStrCat(RccPathChecksum_, '/',
+ AppendFilenameSuffix(RccFileName_, suffix));
return res;
}
@@ -273,9 +268,7 @@ bool cmQtAutoRcc::SettingsFileWrite()
Log().Info(GenT::RCC, "Writing settings file " + Quoted(SettingsFile_));
}
// Write settings file
- std::string content = "rcc:";
- content += SettingsString_;
- content += '\n';
+ std::string content = cmStrCat("rcc:", SettingsString_, '\n');
std::string error;
if (!FileWrite(SettingsFile_, content, &error)) {
Log().ErrorFile(GenT::RCC, SettingsFile_,
@@ -403,10 +396,9 @@ bool cmQtAutoRcc::TestInfoFile()
// Test if the rcc output file is older than the info file
if (RccFileTime_.Older(InfoFileTime())) {
if (Log().Verbose()) {
- std::string reason = "Touching ";
- reason += Quoted(RccFileOutput_);
- reason += " because it is older than ";
- reason += Quoted(InfoFile());
+ std::string reason =
+ cmStrCat("Touching ", Quoted(RccFileOutput_),
+ " because it is older than ", Quoted(InfoFile()));
Log().Info(GenT::RCC, reason);
}
// Touch build file
@@ -457,10 +449,9 @@ bool cmQtAutoRcc::GenerateRcc()
if (!result || (retVal != 0)) {
// rcc process failed
{
- std::string err = "The rcc process failed to compile\n ";
- err += Quoted(QrcFile_);
- err += "\ninto\n ";
- err += Quoted(RccFileOutput_);
+ std::string err =
+ cmStrCat("The rcc process failed to compile\n ", Quoted(QrcFile_),
+ "\ninto\n ", Quoted(RccFileOutput_));
Log().ErrorCommand(GenT::RCC, err, cmd, rccStdOut + rccStdErr);
}
cmSystemTools::RemoveFile(RccFileOutput_);
@@ -482,12 +473,10 @@ bool cmQtAutoRcc::GenerateWrapper()
// Generate a wrapper source file on demand
if (IsMultiConfig()) {
// Wrapper file content
- std::string content;
- content += "// This is an autogenerated configuration wrapper file.\n";
- content += "// Changes will be overwritten.\n";
- content += "#include <";
- content += MultiConfigOutput();
- content += ">\n";
+ std::string content =
+ cmStrCat("// This is an autogenerated configuration wrapper file.\n",
+ "// Changes will be overwritten.\n", "#include <",
+ MultiConfigOutput(), ">\n");
// Compare with existing file content
bool fileDiffers = true;
diff --git a/Source/cmRuntimeDependencyArchive.cxx b/Source/cmRuntimeDependencyArchive.cxx
index 45aff69..37a87e5 100644
--- a/Source/cmRuntimeDependencyArchive.cxx
+++ b/Source/cmRuntimeDependencyArchive.cxx
@@ -6,14 +6,14 @@
#include "cmBinUtilsLinuxELFLinker.h"
#include "cmBinUtilsMacOSMachOLinker.h"
#include "cmBinUtilsWindowsPELinker.h"
-#include "cmCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#if defined(_WIN32)
# include "cmGlobalGenerator.h"
-# ifdef CMAKE_BUILD_WITH_CMAKE
+# ifndef CMAKE_BOOTSTRAP
# include "cmGlobalVisualStudioVersionedGenerator.h"
# endif
# include "cmVSSetupHelper.h"
@@ -36,7 +36,7 @@ static void AddVisualStudioPath(std::vector<std::string>& paths,
// If generating for the VS IDE, use the same instance.
std::string vsloc;
bool found = false;
-# ifdef CMAKE_BUILD_WITH_CMAKE
+# ifndef CMAKE_BOOTSTRAP
if (gg->GetName().find(prefix) == 0) {
cmGlobalVisualStudioVersionedGenerator* vsgen =
static_cast<cmGlobalVisualStudioVersionedGenerator*>(gg);
@@ -108,13 +108,13 @@ static cmsys::RegularExpression TransformCompile(const std::string& str)
}
cmRuntimeDependencyArchive::cmRuntimeDependencyArchive(
- cmCommand* command, std::vector<std::string> searchDirectories,
+ cmExecutionStatus& status, std::vector<std::string> searchDirectories,
std::string bundleExecutable,
const std::vector<std::string>& preIncludeRegexes,
const std::vector<std::string>& preExcludeRegexes,
const std::vector<std::string>& postIncludeRegexes,
const std::vector<std::string>& postExcludeRegexes)
- : Command(command)
+ : Status(status)
, SearchDirectories(std::move(searchDirectories))
, BundleExecutable(std::move(bundleExecutable))
, PreIncludeRegexes(preIncludeRegexes.size())
@@ -190,7 +190,7 @@ bool cmRuntimeDependencyArchive::GetRuntimeDependencies(
void cmRuntimeDependencyArchive::SetError(const std::string& e)
{
- this->Command->SetError(e);
+ this->Status.SetError(e);
}
std::string cmRuntimeDependencyArchive::GetBundleExecutable()
@@ -361,7 +361,7 @@ void cmRuntimeDependencyArchive::AddUnresolvedPath(const std::string& name)
cmMakefile* cmRuntimeDependencyArchive::GetMakefile()
{
- return this->Command->GetMakefile();
+ return &this->Status.GetMakefile();
}
const std::map<std::string, std::set<std::string>>&
diff --git a/Source/cmRuntimeDependencyArchive.h b/Source/cmRuntimeDependencyArchive.h
index 67efec7..e063121 100644
--- a/Source/cmRuntimeDependencyArchive.h
+++ b/Source/cmRuntimeDependencyArchive.h
@@ -14,14 +14,14 @@
#include <string>
#include <vector>
-class cmCommand;
+class cmExecutionStatus;
class cmMakefile;
class cmRuntimeDependencyArchive
{
public:
explicit cmRuntimeDependencyArchive(
- cmCommand* command, std::vector<std::string> searchDirectories,
+ cmExecutionStatus& status, std::vector<std::string> searchDirectories,
std::string bundleExecutable,
const std::vector<std::string>& preIncludeRegexes,
const std::vector<std::string>& preExcludeRegexes,
@@ -51,7 +51,7 @@ public:
const std::set<std::string>& GetUnresolvedPaths();
private:
- cmCommand* Command;
+ cmExecutionStatus& Status;
std::unique_ptr<cmBinUtilsLinker> Linker;
std::string GetRuntimeDependenciesTool;
diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx
index 5867a44..eca761b 100644
--- a/Source/cmStringAlgorithms.cxx
+++ b/Source/cmStringAlgorithms.cxx
@@ -21,6 +21,20 @@ std::string cmTrimWhitespace(cm::string_view str)
return std::string(start, stop + 1);
}
+std::string cmRemoveQuotes(cm::string_view str)
+{
+ // We process only strings that have two quotes at least.
+ // Also front() and back() are only defined behavior on non empty strings.
+ if (str.size() >= 2 && //
+ str.front() == '"' && //
+ str.back() == '"') {
+ // Remove a quote from the front and back
+ str.remove_prefix(1);
+ str.remove_suffix(1);
+ }
+ return std::string(str);
+}
+
std::string cmEscapeQuotes(cm::string_view str)
{
std::string result;
diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h
index 1898649..44b01b8 100644
--- a/Source/cmStringAlgorithms.h
+++ b/Source/cmStringAlgorithms.h
@@ -41,6 +41,9 @@ inline bool cmIsSpace(char ch)
/** Returns a string that has whitespace removed from the start and the end. */
std::string cmTrimWhitespace(cm::string_view str);
+/** Returns a string that has quotes removed from the start and the end. */
+std::string cmRemoveQuotes(cm::string_view str);
+
/** Escape quotes in a string. */
std::string cmEscapeQuotes(cm::string_view str);
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 8b3b1e3..46d9459 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -113,7 +113,7 @@ bool cmStringCommand::InitialPass(std::vector<std::string> const& args,
bool cmStringCommand::HandleHashCommand(std::vector<std::string> const& args)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
if (args.size() != 3) {
std::ostringstream e;
e << args[0] << " requires an output variable and an input string";
@@ -878,7 +878,7 @@ bool cmStringCommand::HandleTimestampCommand(
bool cmStringCommand::HandleUuidCommand(std::vector<std::string> const& args)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
unsigned int argsIndex = 1;
if (args.size() < 2) {
diff --git a/Source/cmSubcommandTable.cxx b/Source/cmSubcommandTable.cxx
new file mode 100644
index 0000000..f6194f8
--- /dev/null
+++ b/Source/cmSubcommandTable.cxx
@@ -0,0 +1,31 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmSubcommandTable.h"
+
+#include <algorithm>
+
+#include "cmExecutionStatus.h"
+#include "cmStringAlgorithms.h"
+
+cmSubcommandTable::cmSubcommandTable(std::initializer_list<InitElem> init)
+ : Impl(init.begin(), init.end())
+{
+ std::sort(this->Impl.begin(), this->Impl.end(),
+ [](Elem const& left, Elem const& right) {
+ return left.first < right.first;
+ });
+}
+
+bool cmSubcommandTable::operator()(cm::string_view key,
+ std::vector<std::string> const& args,
+ cmExecutionStatus& status) const
+{
+ auto const it = std::lower_bound(
+ this->Impl.begin(), this->Impl.end(), key,
+ [](Elem const& elem, cm::string_view k) { return elem.first < k; });
+ if (it != this->Impl.end() && it->first == key) {
+ return it->second(args, status);
+ }
+ status.SetError(cmStrCat("does not recognize sub-command ", key));
+ return false;
+}
diff --git a/Source/cmSubcommandTable.h b/Source/cmSubcommandTable.h
new file mode 100644
index 0000000..21342bb
--- /dev/null
+++ b/Source/cmSubcommandTable.h
@@ -0,0 +1,36 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmSubcommandTable_h
+#define cmSubcommandTable_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include "cm_static_string_view.hxx"
+#include "cm_string_view.hxx"
+
+#include <initializer_list>
+#include <string>
+#include <utility>
+#include <vector>
+
+class cmExecutionStatus;
+
+class cmSubcommandTable
+{
+public:
+ using Command = bool (*)(std::vector<std::string> const&,
+ cmExecutionStatus&);
+
+ using Elem = std::pair<cm::string_view, Command>;
+ using InitElem = std::pair<cm::static_string_view, Command>;
+
+ cmSubcommandTable(std::initializer_list<InitElem> init);
+
+ bool operator()(cm::string_view key, std::vector<std::string> const& args,
+ cmExecutionStatus& status) const;
+
+private:
+ std::vector<Elem> Impl;
+};
+
+#endif
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 7baf5ed..785e221 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -9,7 +9,7 @@
#include "cmStringAlgorithms.h"
#include "cm_uv.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# include "cmArchiveWrite.h"
# include "cmLocale.h"
# include "cm_libarchive.h"
@@ -21,7 +21,7 @@
# endif
#endif
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# include "cmCryptoHash.h"
#endif
@@ -93,7 +93,7 @@ extern char** environ;
# endif
#endif
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
static std::string cm_archive_entry_pathname(struct archive_entry* entry)
{
# if cmsys_STL_HAS_WSTRING
@@ -944,7 +944,7 @@ bool cmSystemTools::RenameFile(const std::string& oldname,
std::string cmSystemTools::ComputeFileHash(const std::string& source,
cmCryptoHash::Algo algo)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
cmCryptoHash hash(algo);
return hash.HashFile(source);
#else
@@ -957,7 +957,7 @@ std::string cmSystemTools::ComputeFileHash(const std::string& source,
std::string cmSystemTools::ComputeStringMD5(const std::string& input)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
cmCryptoHash md5(cmCryptoHash::AlgoMD5);
return md5.HashString(input);
#else
@@ -973,7 +973,7 @@ std::string cmSystemTools::ComputeCertificateThumbprint(
{
std::string thumbprint;
-#if defined(CMAKE_BUILD_WITH_CMAKE) && defined(_WIN32)
+#if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32)
BYTE* certData = NULL;
CRYPT_INTEGER_BLOB cryptBlob;
HCERTSTORE certStore = NULL;
@@ -1331,7 +1331,7 @@ std::string cmSystemTools::ForceToRelativePath(std::string const& local_path,
return relative;
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
bool cmSystemTools::UnsetEnv(const char* value)
{
# if !defined(HAVE_UNSETENV)
@@ -1396,7 +1396,7 @@ void cmSystemTools::EnableVSConsoleOutput()
// output and allow it to be captured on the fly.
cmSystemTools::PutEnv("vsconsoleoutput=1");
-# ifdef CMAKE_BUILD_WITH_CMAKE
+# ifndef CMAKE_BOOTSTRAP
// VS sets an environment variable to tell MS tools like "cl" to report
// output through a backdoor pipe instead of stdout/stderr. Unset the
// environment variable to close this backdoor for any path of process
@@ -1418,7 +1418,7 @@ bool cmSystemTools::CreateTar(const std::string& outFileName,
std::string const& mtime,
std::string const& format)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
cmsys::ofstream fout(outFileName.c_str(), std::ios::out | std::ios::binary);
if (!fout) {
@@ -1472,7 +1472,7 @@ bool cmSystemTools::CreateTar(const std::string& outFileName,
#endif
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
namespace {
# define BSDTAR_FILESIZE_PRINTF "%lu"
# define BSDTAR_FILESIZE_TYPE unsigned long
@@ -1768,7 +1768,7 @@ bool cmSystemTools::ExtractTar(const std::string& outFileName,
const std::vector<std::string>& files,
bool verbose)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
return extract_tar(outFileName, files, verbose, true);
#else
(void)outFileName;
@@ -1782,7 +1782,7 @@ bool cmSystemTools::ListTar(const std::string& outFileName,
const std::vector<std::string>& files,
bool verbose)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
return extract_tar(outFileName, files, verbose, false);
#else
(void)outFileName;
@@ -2111,7 +2111,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
cmSystemToolsCMakeCommand = exe_dir;
cmSystemToolsCMakeCommand += "/cmake";
cmSystemToolsCMakeCommand += cmSystemTools::GetExecutableExtension();
-#ifndef CMAKE_BUILD_WITH_CMAKE
+#ifdef CMAKE_BOOTSTRAP
// The bootstrap cmake does not provide the other tools,
// so use the directory where they are about to be built.
exe_dir = CMAKE_BOOTSTRAP_BINARY_DIR "/bin";
@@ -2141,7 +2141,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
cmSystemToolsCMClDepsCommand.clear();
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
// Install tree has
// - "<prefix><CMAKE_BIN_DIR>/cmake"
// - "<prefix><CMAKE_DATA_DIR>"
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index d3fcb64..4f76b00 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -387,7 +387,7 @@ public:
static std::string ForceToRelativePath(std::string const& local_path,
std::string const& remote_path);
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
/** Remove an environment variable */
static bool UnsetEnv(const char* value);
diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx
index da5d21e..0915986 100644
--- a/Source/cmTimestamp.cxx
+++ b/Source/cmTimestamp.cxx
@@ -109,7 +109,7 @@ time_t cmTimestamp::CreateUtcTimeTFromTm(struct tm& tm) const
time_t result = mktime(&tm);
-# ifdef CMAKE_BUILD_WITH_CMAKE
+# ifndef CMAKE_BOOTSTRAP
if (tz_was_set) {
cmSystemTools::PutEnv(tz_old);
} else {
diff --git a/Source/cmUVHandlePtr.cxx b/Source/cmUVHandlePtr.cxx
index db67463..97c27cb 100644
--- a/Source/cmUVHandlePtr.cxx
+++ b/Source/cmUVHandlePtr.cxx
@@ -122,7 +122,7 @@ uv_handle_ptr_<T>::operator T*() const
return this->handle.get();
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
template <>
struct uv_handle_deleter<uv_async_t>
{
@@ -230,7 +230,7 @@ int uv_timer_ptr::start(uv_timer_cb cb, uint64_t timeout, uint64_t repeat)
return uv_timer_start(*this, cb, timeout, repeat);
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
uv_tty_ptr::operator uv_stream_t*() const
{
return reinterpret_cast<uv_stream_t*>(handle.get());
@@ -259,7 +259,7 @@ UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(process)
UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(timer)
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(async)
UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(tty)
diff --git a/Source/cmUnsetCommand.cxx b/Source/cmUnsetCommand.cxx
index 0e903c7..3eb293a 100644
--- a/Source/cmUnsetCommand.cxx
+++ b/Source/cmUnsetCommand.cxx
@@ -24,7 +24,7 @@ bool cmUnsetCommand::InitialPass(std::vector<std::string> const& args,
// what is the variable name
auto const& envVarName = variable.substr(4, variable.size() - 5);
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmSystemTools::UnsetEnv(envVarName.c_str());
#endif
return true;
diff --git a/Source/cm_codecvt.hxx b/Source/cm_codecvt.hxx
index 2df3961..2060584 100644
--- a/Source/cm_codecvt.hxx
+++ b/Source/cm_codecvt.hxx
@@ -18,7 +18,7 @@ public:
ANSI
};
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
codecvt(Encoding e);
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 3cc6776..af73c8d 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -31,7 +31,7 @@
#include "cm_string_view.hxx"
#include "cm_sys_stat.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# include "cm_jsoncpp_writer.h"
# include "cmFileAPI.h"
@@ -40,11 +40,11 @@
# include <unordered_map>
#endif
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# define CMAKE_USE_ECLIPSE
#endif
-#if defined(__MINGW32__) && !defined(CMAKE_BUILD_WITH_CMAKE)
+#if defined(__MINGW32__) && defined(CMAKE_BOOTSTRAP)
# define CMAKE_BOOT_MINGW
#endif
@@ -72,7 +72,7 @@
# include "cmGlobalWatcomWMakeGenerator.h"
#endif
#include "cmGlobalUnixMakefileGenerator3.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# include "cmGlobalNinjaGenerator.h"
#endif
#include "cmExtraCodeLiteGenerator.h"
@@ -92,7 +92,7 @@
#endif
#if defined(__APPLE__)
-# if defined(CMAKE_BUILD_WITH_CMAKE)
+# if !defined(CMAKE_BOOTSTRAP)
# include "cmGlobalXCodeGenerator.h"
# define CMAKE_USE_XCODE 1
@@ -115,7 +115,7 @@
namespace {
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
typedef std::unordered_map<std::string, Json::Value> JsonValueMapType;
#endif
@@ -134,7 +134,7 @@ static void cmWarnUnusedCliWarning(const std::string& variable, int /*unused*/,
cmake::cmake(Role role, cmState::Mode mode)
: FileTimeCache(cm::make_unique<cmFileTimeCache>())
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
, VariableWatch(cm::make_unique<cmVariableWatch>())
#endif
, State(cm::make_unique<cmState>())
@@ -203,7 +203,7 @@ cmake::~cmake()
cmDeleteAll(this->Generators);
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
Json::Value cmake::ReportVersionJson() const
{
Json::Value version = Json::objectValue;
@@ -262,7 +262,7 @@ Json::Value cmake::ReportCapabilitiesJson() const
std::string cmake::ReportCapabilities() const
{
std::string result;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
Json::FastWriter writer;
result = writer.write(this->ReportCapabilitiesJson());
#else
@@ -968,7 +968,7 @@ int cmake::AddCMakePaths()
this->AddCacheEntry("CMAKE_COMMAND",
cmSystemTools::GetCMakeCommand().c_str(),
"Path to CMake executable.", cmStateEnums::INTERNAL);
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
this->AddCacheEntry(
"CMAKE_CTEST_COMMAND", cmSystemTools::GetCTestCommand().c_str(),
"Path to ctest program executable.", cmStateEnums::INTERNAL);
@@ -994,7 +994,7 @@ int cmake::AddCMakePaths()
void cmake::AddDefaultExtraGenerators()
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->ExtraGenerators.push_back(cmExtraCodeBlocksGenerator::GetFactory());
this->ExtraGenerators.push_back(cmExtraCodeLiteGenerator::GetFactory());
this->ExtraGenerators.push_back(cmExtraSublimeTextGenerator::GetFactory());
@@ -1521,7 +1521,7 @@ int cmake::ActualConfigure()
this->TruncateOutputLog("CMakeError.log");
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->FileAPI = cm::make_unique<cmFileAPI>(this);
this->FileAPI->ReadQueries();
#endif
@@ -1789,7 +1789,7 @@ int cmake::Generate()
// for the Visual Studio and Xcode generators.)
this->SaveCache(this->GetHomeOutputDirectory());
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->FileAPI->WriteReplies();
#endif
@@ -1895,7 +1895,7 @@ void cmake::AddDefaultGenerators()
this->Generators.push_back(cmGlobalMinGWMakefileGenerator::NewFactory());
#endif
this->Generators.push_back(cmGlobalUnixMakefileGenerator3::NewFactory());
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# if defined(__linux__) || defined(_WIN32)
this->Generators.push_back(cmGlobalGhsMultiGenerator::NewFactory());
# endif
@@ -2054,7 +2054,7 @@ std::vector<cmDocumentationEntry> cmake::GetGeneratorsDocumentation()
void cmake::PrintGeneratorList()
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmDocumentation doc;
auto generators = this->GetGeneratorsDocumentation();
doc.AppendSection("Generators", generators);
@@ -2270,14 +2270,6 @@ void cmake::TruncateOutputLog(const char* fname)
}
}
-inline std::string removeQuotes(const std::string& s)
-{
- if (s.front() == '\"' && s.back() == '\"') {
- return s.substr(1, s.size() - 2);
- }
- return s;
-}
-
void cmake::MarkCliAsUsed(const std::string& variable)
{
this->UsedCliVariables[variable] = true;
@@ -2285,7 +2277,7 @@ void cmake::MarkCliAsUsed(const std::string& variable)
void cmake::GenerateGraphViz(const std::string& fileName) const
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmGraphVizWriter gvWriter(this->GetGlobalGenerator());
std::string settingsFile = this->GetHomeOutputDirectory();
@@ -2744,7 +2736,7 @@ bool cmake::Open(const std::string& dir, bool dryRun)
void cmake::WatchUnusedCli(const std::string& var)
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
this->VariableWatch->AddWatch(var, cmWarnUnusedCliWarning, this);
if (this->UsedCliVariables.find(var) == this->UsedCliVariables.end()) {
this->UsedCliVariables[var] = false;
@@ -2754,7 +2746,7 @@ void cmake::WatchUnusedCli(const std::string& var)
void cmake::UnwatchUnusedCli(const std::string& var)
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
this->VariableWatch->RemoveWatch(var, cmWarnUnusedCliWarning);
this->UsedCliVariables.erase(var);
#endif
@@ -2762,7 +2754,7 @@ void cmake::UnwatchUnusedCli(const std::string& var)
void cmake::RunCheckForUnusedVariables()
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
bool haveUnused = false;
std::ostringstream msg;
msg << "Manually-specified variables were not used by the project:";
diff --git a/Source/cmake.h b/Source/cmake.h
index 92494ae..4c73519 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -20,7 +20,7 @@
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# include "cm_jsoncpp_value.h"
#endif
@@ -145,7 +145,7 @@ public:
cmake(cmake const&) = delete;
cmake& operator=(cmake const&) = delete;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
Json::Value ReportVersionJson() const;
Json::Value ReportCapabilitiesJson() const;
#endif
@@ -334,7 +334,7 @@ public:
//! this is called by generators to update the progress
void UpdateProgress(const std::string& msg, float prog);
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
//! Get the variable watch object
cmVariableWatch* GetVariableWatch() { return this->VariableWatch.get(); }
#endif
@@ -570,7 +570,7 @@ private:
std::string GraphVizFile;
InstalledFilesMap InstalledFiles;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
std::unique_ptr<cmVariableWatch> VariableWatch;
std::unique_ptr<cmFileAPI> FileAPI;
#endif
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 10a6825..522f9a4 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -12,7 +12,7 @@
#include "cmake.h"
#include "cmcmd.h"
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
# include "cmDocumentation.h"
# include "cmDynamicLoader.h"
#endif
@@ -20,7 +20,7 @@
#include "cm_uv.h"
#include "cmsys/Encoding.hxx"
-#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
# include "cmsys/ConsoleBuf.hxx"
#endif
@@ -33,7 +33,7 @@
#include <vector>
namespace {
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
const char* cmDocumentationName[][2] = {
{ nullptr, " cmake - Cross-Platform Makefile Generator." },
{ nullptr, nullptr }
@@ -156,7 +156,7 @@ int do_cmake(int ac, char const* const* av)
return 1;
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmDocumentation doc;
doc.addCMakeStandardDocSections();
if (doc.CheckOptions(ac, av)) {
@@ -339,7 +339,7 @@ int extract_job_number(int& index, char const* current, char const* next,
int do_build(int ac, char const* const* av)
{
-#ifndef CMAKE_BUILD_WITH_CMAKE
+#ifdef CMAKE_BOOTSTRAP
std::cerr << "This cmake does not support --build\n";
return -1;
#else
@@ -503,7 +503,7 @@ int do_build(int ac, char const* const* av)
int do_install(int ac, char const* const* av)
{
-#ifndef CMAKE_BUILD_WITH_CMAKE
+#ifdef CMAKE_BOOTSTRAP
std::cerr << "This cmake does not support --install\n";
return -1;
#else
@@ -624,7 +624,7 @@ int do_install(int ac, char const* const* av)
int do_open(int ac, char const* const* av)
{
-#ifndef CMAKE_BUILD_WITH_CMAKE
+#ifdef CMAKE_BOOTSTRAP
std::cerr << "This cmake does not support --open\n";
return -1;
#else
@@ -669,7 +669,7 @@ int do_open(int ac, char const* const* av)
int main(int ac, char const* const* av)
{
cmSystemTools::EnsureStdPipes();
-#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
// Replace streambuf so we can output Unicode to console
cmsys::ConsoleBuf::Manager consoleOut(std::cout);
consoleOut.SetUTF8Pipes();
@@ -699,7 +699,7 @@ int main(int ac, char const* const* av)
}
}
int ret = do_cmake(ac, av);
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmDynamicLoader::FlushCache();
#endif
uv_loop_close(uv_default_loop());
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index aecc978..69d5fcd 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -19,18 +19,18 @@
#include "cmVersion.h"
#include "cmake.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# include "cmDependsFortran.h" // For -E cmake_copy_f90_mod callback.
# include "cmServer.h"
# include "cmServerConnection.h"
#endif
-#if defined(CMAKE_BUILD_WITH_CMAKE) && defined(_WIN32)
+#if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32)
# include "bindexplib.h"
# include "cmsys/ConsoleBuf.hxx"
#endif
-#if defined(CMAKE_BUILD_WITH_CMAKE) && defined(_WIN32) && !defined(__CYGWIN__)
+#if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32) && !defined(__CYGWIN__)
# include "cmVisualStudioWCEPlatformParser.h"
#endif
@@ -61,7 +61,7 @@ void CMakeCommandUsage(const char* program)
{
std::ostringstream errorStream;
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
/* clang-format off */
errorStream
<< "cmake version " << cmVersion::GetCMakeVersion() << "\n";
@@ -561,7 +561,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
return 0;
}
-#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
else if (args[1] == "__create_def") {
if (args.size() < 4) {
std::cerr
@@ -654,7 +654,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
return 1;
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
if (args[1] == "environment") {
for (auto const& env : cmSystemTools::GetEnvironmentVariables()) {
std::cout << env << std::endl;
@@ -994,7 +994,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
return cmcmd::ExecuteLinkScript(args);
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
// Internal CMake ninja dependency scanning support.
if (args[1] == "cmake_ninja_depends") {
return cmcmd_cmake_ninja_depends(args.begin() + 2, args.end());
@@ -1029,7 +1029,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
return cmcmd::ExecuteEchoColor(args);
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
if ((args[1] == "cmake_autogen") && (args.size() >= 4)) {
cmQtAutoMocUic autoGen;
std::string const& infoDir = args[2];
@@ -1210,7 +1210,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
return 1;
}
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
cmConnection* conn;
if (isDebug) {
conn = new cmServerStdIoConnection;
@@ -1231,7 +1231,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
return 1;
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
// Internal CMake Fortran module support.
if (args[1] == "cmake_copy_f90_mod" && args.size() >= 4) {
return cmDependsFortran::CopyModule(args) ? 0 : 1;
@@ -1547,7 +1547,7 @@ int cmcmd::ExecuteLinkScript(std::vector<std::string> const& args)
int cmcmd::WindowsCEEnvironment(const char* version, const std::string& name)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE) && defined(_WIN32) && !defined(__CYGWIN__)
+#if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32) && !defined(__CYGWIN__)
cmVisualStudioWCEPlatformParser parser(name.c_str());
parser.ParseVersion(version);
if (parser.Found()) {
@@ -1605,7 +1605,7 @@ private:
// still works.
int cmcmd::VisualStudioLink(std::vector<std::string> const& args, int type)
{
-#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
// Replace streambuf so we output in the system codepage. CMake is set up
// to output in Unicode (see SetUTF8Pipes) but the Visual Studio linker
// outputs using the system codepage so we need to change behavior when
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index 3b3630f..77a84fd 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -8,7 +8,7 @@
#include "cmSystemTools.h"
#include "cmsys/Encoding.hxx"
-#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
# include "cmsys/ConsoleBuf.hxx"
#endif
#include <iostream>
@@ -144,7 +144,7 @@ static const char* cmDocumentationOptions[][2] = {
int main(int argc, char const* const* argv)
{
cmSystemTools::EnsureStdPipes();
-#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
// Replace streambuf so we can output Unicode to console
cmsys::ConsoleBuf::Manager consoleOut(std::cout);
consoleOut.SetUTF8Pipes();