cmCMakeHostSystemInformationCommand.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 cmCMakeHostSystemInformationCommand_h
  4. #define cmCMakeHostSystemInformationCommand_h
  5. #include <cmConfigure.h>
  6. #include <stddef.h>
  7. #include <string>
  8. #include <vector>
  9. #include "cmCommand.h"
  10. #include "cmTypeMacro.h"
  11. class cmExecutionStatus;
  12. namespace cmsys {
  13. class SystemInformation;
  14. } // namespace cmsys
  15. /** \class cmCMakeHostSystemInformationCommand
  16. * \brief Query host system specific information
  17. *
  18. * cmCMakeHostSystemInformationCommand queries system information of
  19. * the sytem on which CMake runs.
  20. */
  21. class cmCMakeHostSystemInformationCommand : public cmCommand
  22. {
  23. public:
  24. /**
  25. * This is a virtual constructor for the command.
  26. */
  27. cmCommand* Clone() CM_OVERRIDE
  28. {
  29. return new cmCMakeHostSystemInformationCommand;
  30. }
  31. /**
  32. * This is called when the command is first encountered in
  33. * the CMakeLists.txt file.
  34. */
  35. bool InitialPass(std::vector<std::string> const& args,
  36. cmExecutionStatus& status) CM_OVERRIDE;
  37. /**
  38. * This determines if the command is invoked when in script mode.
  39. */
  40. bool IsScriptable() const CM_OVERRIDE { return true; }
  41. /**
  42. * The name of the command as specified in CMakeList.txt.
  43. */
  44. std::string GetName() const CM_OVERRIDE
  45. {
  46. return "cmake_host_system_information";
  47. }
  48. cmTypeMacro(cmCMakeHostSystemInformationCommand, cmCommand);
  49. private:
  50. bool GetValue(cmsys::SystemInformation& info, std::string const& key,
  51. std::string& value);
  52. std::string ValueToString(size_t value) const;
  53. std::string ValueToString(const char* value) const;
  54. std::string ValueToString(std::string const& value) const;
  55. };
  56. #endif