Fix Xcode project references to the source tree
[cmake.git] / Source / cmVariableRequiresCommand.cxx
blob5554cf2c1d86729d197150e25437e9db2ba2d9b7
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmVariableRequiresCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2008-01-23 15:27:59 $
7 Version: $Revision: 1.15 $
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 "cmVariableRequiresCommand.h"
18 #include "cmCacheManager.h"
20 // cmLibraryCommand
21 bool cmVariableRequiresCommand
22 ::InitialPass(std::vector<std::string>const& args, cmExecutionStatus &)
24 if(args.size() < 3 )
26 this->SetError("called with incorrect number of arguments");
27 return false;
30 std::string testVariable = args[0];
31 if(!this->Makefile->IsOn(testVariable.c_str()))
33 return true;
35 std::string resultVariable = args[1];
36 bool requirementsMet = true;
37 std::string notSet;
38 bool hasAdvanced = false;
39 for(unsigned int i = 2; i < args.size(); ++i)
41 if(!this->Makefile->IsOn(args[i].c_str()))
43 requirementsMet = false;
44 notSet += args[i];
45 notSet += "\n";
46 cmCacheManager::CacheIterator it =
47 this->Makefile->GetCacheManager()->GetCacheIterator(args[i].c_str());
48 if(!it.IsAtEnd() && it.GetPropertyAsBool("ADVANCED"))
50 hasAdvanced = true;
54 const char* reqVar = this->Makefile->GetDefinition(resultVariable.c_str());
55 // if reqVar is unset, then set it to requirementsMet
56 // if reqVar is set to true, but requirementsMet is false , then
57 // set reqVar to false.
58 if(!reqVar || (!requirementsMet && this->Makefile->IsOn(reqVar)))
60 this->Makefile->AddDefinition(resultVariable.c_str(), requirementsMet);
63 if(!requirementsMet)
65 std::string message = "Variable assertion failed:\n";
66 message += testVariable +
67 " Requires that the following unset variables are set:\n";
68 message += notSet;
69 message += "\nPlease set them, or set ";
70 message += testVariable + " to false, and re-configure.\n";
71 if(hasAdvanced)
73 message +=
74 "One or more of the required variables is advanced."
75 " To set the variable, you must turn on advanced mode in cmake.";
77 cmSystemTools::Error(message.c_str());
80 return true;