1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2013 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
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
15 #include "cmCommand.h"
17 #include <cmsys/SystemInformation.hxx>
19 /** \class cmCMakeHostSystemInformationCommand
20 * \brief Query host system specific information
22 * cmCMakeHostSystemInformationCommand queries system information of
23 * the sytem on which CMake runs.
25 class cmCMakeHostSystemInformationCommand : public cmCommand
29 * This is a virtual constructor for the command.
31 virtual cmCommand* Clone()
33 return new cmCMakeHostSystemInformationCommand;
37 * This is called when the command is first encountered in
38 * the CMakeLists.txt file.
40 virtual bool InitialPass(std::vector<std::string> const& args,
41 cmExecutionStatus &status);
44 * This determines if the command is invoked when in script mode.
46 virtual bool IsScriptable() const { return true; }
49 * The name of the command as specified in CMakeList.txt.
51 virtual const char* GetName() const
53 return "cmake_host_system_information";
57 * Succinct documentation.
59 virtual const char* GetTerseDocumentation() const
61 return "Query host system specific information.";
67 virtual const char* GetFullDocumentation() const
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"
91 cmTypeMacro(cmCMakeHostSystemInformationCommand, cmCommand);
94 bool GetValue(cmsys::SystemInformation &info,
95 std::string const& key, std::string &value);
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;