cmSourceGroupCommand.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmSourceGroupCommand_h
  4. #define cmSourceGroupCommand_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include <map>
  7. #include <string>
  8. #include <vector>
  9. #include "cm_memory.hxx"
  10. #include "cmCommand.h"
  11. class cmExecutionStatus;
  12. /** \class cmSourceGroupCommand
  13. * \brief Adds a cmSourceGroup to the cmMakefile.
  14. *
  15. * cmSourceGroupCommand is used to define cmSourceGroups which split up
  16. * source files in to named, organized groups in the generated makefiles.
  17. */
  18. class cmSourceGroupCommand : public cmCommand
  19. {
  20. public:
  21. /**
  22. * This is a virtual constructor for the command.
  23. */
  24. std::unique_ptr<cmCommand> Clone() override
  25. {
  26. return cm::make_unique<cmSourceGroupCommand>();
  27. }
  28. /**
  29. * This is called when the command is first encountered in
  30. * the CMakeLists.txt file.
  31. */
  32. bool InitialPass(std::vector<std::string> const& args,
  33. cmExecutionStatus& status) override;
  34. private:
  35. using ParsedArguments = std::map<std::string, std::vector<std::string>>;
  36. using ExpectedOptions = std::vector<std::string>;
  37. ExpectedOptions getExpectedOptions() const;
  38. bool isExpectedOption(const std::string& argument,
  39. const ExpectedOptions& expectedOptions);
  40. void parseArguments(const std::vector<std::string>& args,
  41. cmSourceGroupCommand::ParsedArguments& parsedArguments);
  42. bool processTree(ParsedArguments& parsedArguments, std::string& errorMsg);
  43. bool checkArgumentsPreconditions(const ParsedArguments& parsedArguments,
  44. std::string& errorMsg) const;
  45. bool checkSingleParameterArgumentPreconditions(
  46. const std::string& argument, const ParsedArguments& parsedArguments,
  47. std::string& errorMsg) const;
  48. };
  49. #endif