1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 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 #include "cmVariableRequiresCommand.h"
13 #include "cmCacheManager.h"
16 bool cmVariableRequiresCommand
17 ::InitialPass(std::vector<std::string>const& args, cmExecutionStatus &)
21 this->SetError("called with incorrect number of arguments");
25 std::string testVariable = args[0];
26 if(!this->Makefile->IsOn(testVariable.c_str()))
30 std::string resultVariable = args[1];
31 bool requirementsMet = true;
33 bool hasAdvanced = false;
34 for(unsigned int i = 2; i < args.size(); ++i)
36 if(!this->Makefile->IsOn(args[i].c_str()))
38 requirementsMet = false;
41 cmCacheManager::CacheIterator it =
42 this->Makefile->GetCacheManager()->GetCacheIterator(args[i].c_str());
43 if(!it.IsAtEnd() && it.GetPropertyAsBool("ADVANCED"))
49 const char* reqVar = this->Makefile->GetDefinition(resultVariable.c_str());
50 // if reqVar is unset, then set it to requirementsMet
51 // if reqVar is set to true, but requirementsMet is false , then
52 // set reqVar to false.
53 if(!reqVar || (!requirementsMet && this->Makefile->IsOn(reqVar)))
55 this->Makefile->AddDefinition(resultVariable.c_str(), requirementsMet);
60 std::string message = "Variable assertion failed:\n";
61 message += testVariable +
62 " Requires that the following unset variables are set:\n";
64 message += "\nPlease set them, or set ";
65 message += testVariable + " to false, and re-configure.\n";
69 "One or more of the required variables is advanced."
70 " To set the variable, you must turn on advanced mode in cmake.";
72 cmSystemTools::Error(message.c_str());