Updated formatting of documentation plus a little reorganization.
[cmake.git] / Source / cmGetCMakePropertyCommand.cxx
blob9b0b92b9713e439691b6436ddd0c7b0e89c7130d
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmGetCMakePropertyCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2008-07-08 15:52:25 $
7 Version: $Revision: 1.9 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmGetCMakePropertyCommand.h"
19 #include "cmake.h"
21 // cmGetCMakePropertyCommand
22 bool cmGetCMakePropertyCommand
23 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
25 if(args.size() < 2 )
27 this->SetError("called with incorrect number of arguments");
28 return false;
31 std::vector<std::string>::size_type cc;
32 std::string variable = args[0];
33 std::string output = "NOTFOUND";
35 if ( args[1] == "VARIABLES")
37 int cacheonly = 0;
38 std::vector<std::string> vars = this->Makefile->GetDefinitions(cacheonly);
39 for ( cc = 0; cc < vars.size(); cc ++ )
41 if ( cc > 0 )
43 output += ";";
45 output += vars[cc];
48 else if ( args[1] == "MACROS" )
50 this->Makefile->GetListOfMacros(output);
52 else if ( args[1] == "COMPONENTS" )
54 const std::set<cmStdString>* components
55 = this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
56 ->GetInstallComponents();
57 std::set<cmStdString>::const_iterator compIt;
58 output = "";
59 for (compIt = components->begin(); compIt != components->end(); ++compIt)
61 if (compIt != components->begin())
63 output += ";";
65 output += *compIt;
68 else
70 const char *prop =
71 this->Makefile->GetCMakeInstance()->GetProperty(args[1].c_str());
72 if (prop)
74 output = prop;
77 this->Makefile->AddDefinition(variable.c_str(), output.c_str());
79 return true;