ENH: make sure CTEST_CURL_OPTIONS work from script mode
[cmake.git] / Source / cmOptionCommand.cxx
blob0b1c4d775e94a8e963735d61f2a5e5da84a4a5fa
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmOptionCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2008-01-23 15:27:59 $
7 Version: $Revision: 1.23 $
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 return true;
63 if ( it.GetValue() )
65 initialValue = it.GetValue();
68 if(args.size() == 3)
70 initialValue = args[2];
72 this->Makefile->AddCacheDefinition(args[0].c_str(),
73 cmSystemTools::IsOn(initialValue.c_str()),
74 args[1].c_str());
76 return true;