resolve cyclic dependency with zstd
[platform/upstream/cmake.git] / Source / cmCommand.cxx
1 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2    file Copyright.txt or https://cmake.org/licensing for details.  */
3 #include "cmCommand.h"
4
5 #include <utility>
6
7 #include "cmExecutionStatus.h"
8 #include "cmMakefile.h"
9
10 struct cmListFileArgument;
11
12 void cmCommand::SetExecutionStatus(cmExecutionStatus* status)
13 {
14   this->Status = status;
15   this->Makefile = &status->GetMakefile();
16 }
17
18 bool cmCommand::InvokeInitialPass(const std::vector<cmListFileArgument>& args,
19                                   cmExecutionStatus& status)
20 {
21   std::vector<std::string> expandedArguments;
22   if (!this->Makefile->ExpandArguments(args, expandedArguments)) {
23     // There was an error expanding arguments.  It was already
24     // reported, so we can skip this command without error.
25     return true;
26   }
27   return this->InitialPass(expandedArguments, status);
28 }
29
30 void cmCommand::SetError(const std::string& e)
31 {
32   this->Status->SetError(e);
33 }
34
35 cmLegacyCommandWrapper::cmLegacyCommandWrapper(std::unique_ptr<cmCommand> cmd)
36   : Command(std::move(cmd))
37 {
38 }
39
40 cmLegacyCommandWrapper::cmLegacyCommandWrapper(
41   cmLegacyCommandWrapper const& other)
42   : Command(other.Command->Clone())
43 {
44 }
45
46 cmLegacyCommandWrapper& cmLegacyCommandWrapper::operator=(
47   cmLegacyCommandWrapper const& other)
48 {
49   this->Command = other.Command->Clone();
50   return *this;
51 }
52
53 bool cmLegacyCommandWrapper::operator()(
54   std::vector<cmListFileArgument> const& args, cmExecutionStatus& status) const
55 {
56   auto cmd = this->Command->Clone();
57   cmd->SetExecutionStatus(&status);
58   return cmd->InvokeInitialPass(args, status);
59 }