CMake Nightly Date Stamp
[kiteware-cmake.git] / Source / cmTargetCompileFeaturesCommand.cxx
blob37c125bd39805c373a41ede2b89f33531eebf724
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"
5 #include "cmList.h"
6 #include "cmMakefile.h"
7 #include "cmMessageType.h"
8 #include "cmStandardLevelResolver.h"
9 #include "cmStringAlgorithms.h"
10 #include "cmTargetPropCommandBase.h"
12 class cmTarget;
14 namespace {
16 class TargetCompileFeaturesImpl : public cmTargetPropCommandBase
18 public:
19 using cmTargetPropCommandBase::cmTargetPropCommandBase;
21 private:
22 void HandleMissingTarget(const std::string& name) override
24 this->Makefile->IssueMessage(
25 MessageType::FATAL_ERROR,
26 cmStrCat("Cannot specify compile features for target \"", name,
27 "\" which is not built by this project."));
30 bool HandleDirectContent(cmTarget* tgt,
31 const std::vector<std::string>& content,
32 bool /*prepend*/, bool /*system*/) override
34 cmStandardLevelResolver standardResolver(this->Makefile);
35 for (std::string const& it : content) {
36 std::string error;
37 if (!standardResolver.AddRequiredTargetFeature(tgt, it, &error)) {
38 this->SetError(error);
39 return false; // Not (successfully) handled.
42 return true; // Successfully handled.
45 std::string Join(const std::vector<std::string>& content) override
47 return cmList::to_string(content);
51 } // namespace
53 bool cmTargetCompileFeaturesCommand(std::vector<std::string> const& args,
54 cmExecutionStatus& status)
56 return TargetCompileFeaturesImpl(status).HandleArguments(args,
57 "COMPILE_FEATURES");