Imported Upstream version 2.8.12.2
[platform/upstream/cmake.git] / Source / cmCMakeHostSystemInformationCommand.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2013 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #ifndef cmCMakeHostSystemInformationCommand_h
13 #define cmCMakeHostSystemInformationCommand_h
14
15 #include "cmCommand.h"
16
17 #include <cmsys/SystemInformation.hxx>
18
19 /** \class cmCMakeHostSystemInformationCommand
20  * \brief Query host system specific information
21  *
22  * cmCMakeHostSystemInformationCommand queries system information of
23  * the sytem on which CMake runs.
24  */
25 class cmCMakeHostSystemInformationCommand : public cmCommand
26 {
27 public:
28   /**
29    * This is a virtual constructor for the command.
30    */
31   virtual cmCommand* Clone()
32     {
33     return new cmCMakeHostSystemInformationCommand;
34     }
35
36   /**
37    * This is called when the command is first encountered in
38    * the CMakeLists.txt file.
39    */
40   virtual bool InitialPass(std::vector<std::string> const& args,
41                cmExecutionStatus &status);
42
43    /**
44    * This determines if the command is invoked when in script mode.
45    */
46   virtual bool IsScriptable() const { return true; }
47
48    /**
49    * The name of the command as specified in CMakeList.txt.
50    */
51   virtual const char* GetName() const
52     {
53     return "cmake_host_system_information";
54     }
55
56    /**
57    * Succinct documentation.
58    */
59   virtual const char* GetTerseDocumentation() const
60     {
61     return "Query host system specific information.";
62     }
63
64   /**
65    * More documentation.
66    */
67   virtual const char* GetFullDocumentation() const
68     {
69     return
70     "  cmake_host_system_information(RESULT <variable> QUERY <key> ...)\n"
71     "Queries system information of the host system on which cmake runs. "
72     "One or more <key> can be provided to "
73     "select the information to be queried. "
74     "The list of queried values is stored in <variable>.\n"
75     "<key> can be one of the following values:\n"
76     "  NUMBER_OF_LOGICAL_CORES   = Number of logical cores.\n"
77     "  NUMBER_OF_PHYSICAL_CORES  = Number of physical cores.\n"
78     "  HOSTNAME                  = Hostname.\n"
79     "  FQDN                      = Fully qualified domain name.\n"
80     "  TOTAL_VIRTUAL_MEMORY      = "
81       "Total virtual memory in megabytes.\n"
82     "  AVAILABLE_VIRTUAL_MEMORY  = "
83       "Available virtual memory in megabytes.\n"
84     "  TOTAL_PHYSICAL_MEMORY     = "
85       "Total physical memory in megabytes.\n"
86     "  AVAILABLE_PHYSICAL_MEMORY = "
87       "Available physical memory in megabytes.\n"
88     ;
89     }
90
91   cmTypeMacro(cmCMakeHostSystemInformationCommand, cmCommand);
92
93 private:
94   bool GetValue(cmsys::SystemInformation &info,
95     std::string const& key, std::string &value);
96
97   std::string ValueToString(size_t value) const;
98   std::string ValueToString(const char *value) const;
99   std::string ValueToString(std::string const& value) const;
100 };
101
102 #endif