Fix Xcode project references to the source tree
[cmake.git] / Source / cmOptionCommand.cxx
blob4473ee3f022f520b9d45b18fe13b2887570c0e4b
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmOptionCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2009-09-11 14:03:59 $
7 Version: $Revision: 1.26 $
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 "cmOptionCommand.h"
19 // cmOptionCommand
20 bool cmOptionCommand
21 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
23 bool argError = false;
24 if(args.size() < 2)
26 argError = true;
28 // for VTK 4.0 we have to support the option command with more than 3
29 // arguments if CMAKE_MINIMUM_REQUIRED_VERSION is not defined, if
30 // CMAKE_MINIMUM_REQUIRED_VERSION is defined, then we can have stricter
31 // checking.
32 if(this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION"))
34 if(args.size() > 3)
36 argError = true;
39 if(argError)
41 std::string m = "called with incorrect number of arguments: ";
42 for(size_t i =0; i < args.size(); ++i)
44 m += args[i];
45 m += " ";
47 this->SetError(m.c_str());
48 return false;
51 std::string initialValue = "Off";
52 // Now check and see if the value has been stored in the cache
53 // already, if so use that value and don't look for the program
54 cmCacheManager::CacheIterator it =
55 this->Makefile->GetCacheManager()->GetCacheIterator(args[0].c_str());
56 if(!it.IsAtEnd())
58 if ( it.GetType() != cmCacheManager::UNINITIALIZED )
60 it.SetProperty("HELPSTRING", args[1].c_str());
61 this->Makefile->UseCacheDefinition(it);
62 return true;
64 if ( it.GetValue() )
66 initialValue = it.GetValue();
69 if(args.size() == 3)
71 initialValue = args[2];
73 bool init = cmSystemTools::IsOn(initialValue.c_str());
74 this->Makefile->AddCacheDefinition(args[0].c_str(), init? "ON":"OFF",
75 args[1].c_str(), cmCacheManager::BOOL);
76 return true;