resolve cyclic dependency with zstd
[platform/upstream/cmake.git] / Source / cmTargetCompileFeaturesCommand.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 "cmTargetCompileFeaturesCommand.h"
4
5 #include "cmMakefile.h"
6 #include "cmMessageType.h"
7 #include "cmStandardLevelResolver.h"
8 #include "cmStringAlgorithms.h"
9 #include "cmTargetPropCommandBase.h"
10
11 class cmTarget;
12
13 namespace {
14
15 class TargetCompileFeaturesImpl : public cmTargetPropCommandBase
16 {
17 public:
18   using cmTargetPropCommandBase::cmTargetPropCommandBase;
19
20 private:
21   void HandleMissingTarget(const std::string& name) override
22   {
23     this->Makefile->IssueMessage(
24       MessageType::FATAL_ERROR,
25       cmStrCat("Cannot specify compile features for target \"", name,
26                "\" which is not built by this project."));
27   }
28
29   bool HandleDirectContent(cmTarget* tgt,
30                            const std::vector<std::string>& content,
31                            bool /*prepend*/, bool /*system*/) override
32   {
33     cmStandardLevelResolver standardResolver(this->Makefile);
34     for (std::string const& it : content) {
35       std::string error;
36       if (!standardResolver.AddRequiredTargetFeature(tgt, it, &error)) {
37         this->SetError(error);
38         return false; // Not (successfully) handled.
39       }
40     }
41     return true; // Successfully handled.
42   }
43
44   std::string Join(const std::vector<std::string>& content) override
45   {
46     return cmJoin(content, ";");
47   }
48 };
49
50 } // namespace
51
52 bool cmTargetCompileFeaturesCommand(std::vector<std::string> const& args,
53                                     cmExecutionStatus& status)
54 {
55   return TargetCompileFeaturesImpl(status).HandleArguments(args,
56                                                            "COMPILE_FEATURES");
57 }