cmCacheManager.cxx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmCacheManager.h"
  14. #include "cmSystemTools.h"
  15. #include "cmCacheManager.h"
  16. #include "cmMakefile.h"
  17. #include "cmRegularExpression.h"
  18. #include "stdio.h"
  19. #if defined(_WIN32) || defined(__CYGWIN__)
  20. # include <windows.h>
  21. #endif // _WIN32
  22. const char* cmCacheManagerTypes[] =
  23. { "BOOL",
  24. "PATH",
  25. "FILEPATH",
  26. "STRING",
  27. "INTERNAL",
  28. "STATIC",
  29. "UNINITIALIZED",
  30. 0
  31. };
  32. cmCacheManager::CacheEntryType cmCacheManager::StringToType(const char* s)
  33. {
  34. int i = 0;
  35. while(cmCacheManagerTypes[i])
  36. {
  37. if(strcmp(s, cmCacheManagerTypes[i]) == 0)
  38. {
  39. return static_cast<CacheEntryType>(i);
  40. }
  41. ++i;
  42. }
  43. return STRING;
  44. }
  45. bool cmCacheManager::LoadCache(cmMakefile* mf)
  46. {
  47. return this->LoadCache(mf->GetHomeOutputDirectory());
  48. }
  49. bool cmCacheManager::LoadCache(const char* path)
  50. {
  51. return this->LoadCache(path,true);
  52. }
  53. bool cmCacheManager::LoadCache(const char* path,
  54. bool internal)
  55. {
  56. std::set<std::string> emptySet;
  57. return this->LoadCache(path, internal, emptySet, emptySet);
  58. }
  59. bool cmCacheManager::ParseEntry(const char* entry,
  60. std::string& var,
  61. std::string& value,
  62. CacheEntryType& type)
  63. {
  64. // input line is: key:type=value
  65. cmRegularExpression reg("^([^:]*):([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
  66. // input line is: "key":type=value
  67. cmRegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
  68. bool flag = false;
  69. if(regQuoted.find(entry))
  70. {
  71. var = regQuoted.match(1);
  72. type = cmCacheManager::StringToType(regQuoted.match(2).c_str());
  73. value = regQuoted.match(3);
  74. flag = true;
  75. }
  76. else if (reg.find(entry))
  77. {
  78. var = reg.match(1);
  79. type = cmCacheManager::StringToType(reg.match(2).c_str());
  80. value = reg.match(3);
  81. flag = true;
  82. }
  83. // if value is enclosed in single quotes ('foo') then remove them
  84. // it is used to enclose trailing space or tab
  85. if (flag &&
  86. value.size() >= 2 &&
  87. value[0] == '\'' &&
  88. value[value.size() - 1] == '\'')
  89. {
  90. value = value.substr(1,
  91. value.size() - 2);
  92. }
  93. return flag;
  94. }
  95. bool cmCacheManager::LoadCache(const char* path,
  96. bool internal,
  97. std::set<std::string>& excludes,
  98. std::set<std::string>& includes)
  99. {
  100. std::string cacheFile = path;
  101. cacheFile += "/CMakeCache.txt";
  102. // clear the old cache, if we are reading in internal values
  103. if ( internal )
  104. {
  105. m_Cache.clear();
  106. }
  107. std::ifstream fin(cacheFile.c_str());
  108. if(!fin)
  109. {
  110. return false;
  111. }
  112. const int bsize = 4096;
  113. char buffer[bsize];
  114. char *realbuffer;
  115. std::string entryKey;
  116. while(fin)
  117. {
  118. // Format is key:type=value
  119. CacheEntry e;
  120. fin.getline(buffer, bsize);
  121. realbuffer = buffer;
  122. while(*realbuffer != '0' &&
  123. (*realbuffer == ' ' ||
  124. *realbuffer == '\t' ||
  125. *realbuffer == '\n'))
  126. {
  127. realbuffer++;
  128. }
  129. // skip blank lines and comment lines
  130. if(realbuffer[0] == '#' || realbuffer[0] == 0)
  131. {
  132. continue;
  133. }
  134. while(realbuffer[0] == '/' && realbuffer[1] == '/')
  135. {
  136. e.m_Properties["HELPSTRING"] += &realbuffer[2];
  137. fin.getline(realbuffer, bsize);
  138. if(!fin)
  139. {
  140. continue;
  141. }
  142. }
  143. if(cmCacheManager::ParseEntry(realbuffer, entryKey, e.m_Value, e.m_Type))
  144. {
  145. if ( excludes.find(entryKey) == excludes.end() )
  146. {
  147. // Load internal values if internal is set.
  148. // If the entry is not internal to the cache being loaded
  149. // or if it is in the list of internal entries to be
  150. // imported, load it.
  151. if ( internal || (e.m_Type != INTERNAL) ||
  152. (includes.find(entryKey) != includes.end()) )
  153. {
  154. // If we are loading the cache from another project,
  155. // make all loaded entries internal so that it is
  156. // not visible in the gui
  157. if (!internal)
  158. {
  159. e.m_Type = INTERNAL;
  160. e.m_Properties["HELPSTRING"] = "DO NOT EDIT, ";
  161. e.m_Properties["HELPSTRING"] += entryKey;
  162. e.m_Properties["HELPSTRING"] += " loaded from external file. "
  163. "To change this value edit this file: ";
  164. e.m_Properties["HELPSTRING"] += path;
  165. e.m_Properties["HELPSTRING"] += "/CMakeCache.txt" ;
  166. }
  167. if ( e.m_Type == cmCacheManager::INTERNAL &&
  168. (entryKey.size() > strlen("-ADVANCED")) &&
  169. strcmp(entryKey.c_str() + (entryKey.size() - strlen("-ADVANCED")),
  170. "-ADVANCED") == 0 )
  171. {
  172. std::string akey = entryKey.substr(0, (entryKey.size() - strlen("-ADVANCED")));
  173. cmCacheManager::CacheIterator it = this->GetCacheIterator(akey.c_str());
  174. if ( it.IsAtEnd() )
  175. {
  176. e.m_Type = cmCacheManager::UNINITIALIZED;
  177. m_Cache[akey] = e;
  178. }
  179. else
  180. {
  181. it.SetProperty("ADVANCED", true);
  182. }
  183. }
  184. else
  185. {
  186. m_Cache[entryKey] = e;
  187. }
  188. }
  189. }
  190. }
  191. else
  192. {
  193. cmSystemTools::Error("Parse error in cache file ", cacheFile.c_str(),
  194. ". Offending entry: ", realbuffer);
  195. }
  196. }
  197. // if CMAKE version not found in the list file
  198. // add them as version 0.0
  199. if(!this->GetCacheValue("CMAKE_CACHE_MINOR_VERSION"))
  200. {
  201. this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", "0",
  202. "Minor version of cmake used to create the "
  203. "current loaded cache", cmCacheManager::INTERNAL);
  204. this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", "0",
  205. "Major version of cmake used to create the "
  206. "current loaded cache", cmCacheManager::INTERNAL);
  207. }
  208. // check to make sure the cache directory has not
  209. // been moved
  210. if ( internal && this->GetCacheValue("CMAKE_CACHEFILE_DIR") )
  211. {
  212. std::string currentcwd = path;
  213. std::string oldcwd = this->GetCacheValue("CMAKE_CACHEFILE_DIR");
  214. cmSystemTools::ConvertToUnixSlashes(currentcwd);
  215. currentcwd += "/CMakeCache.txt";
  216. oldcwd += "/CMakeCache.txt";
  217. if(!cmSystemTools::SameFile(oldcwd.c_str(), currentcwd.c_str()))
  218. {
  219. std::string message =
  220. std::string("The current CMakeCache.txt directory ") +
  221. currentcwd + std::string(" is different than the directory ") +
  222. std::string(this->GetCacheValue("CMAKE_CACHEFILE_DIR")) +
  223. std::string(" where CMackeCache.txt was created. This may result "
  224. "in binaries being created in the wrong place. If you "
  225. "are not sure, reedit the CMakeCache.txt");
  226. cmSystemTools::Error(message.c_str());
  227. }
  228. }
  229. return true;
  230. }
  231. bool cmCacheManager::SaveCache(cmMakefile* mf)
  232. {
  233. return this->SaveCache(mf->GetHomeOutputDirectory());
  234. }
  235. bool cmCacheManager::SaveCache(const char* path)
  236. {
  237. std::string cacheFile = path;
  238. cacheFile += "/CMakeCache.txt";
  239. std::string tempFile = cacheFile;
  240. tempFile += ".tmp";
  241. std::ofstream fout(tempFile.c_str());
  242. if(!fout)
  243. {
  244. cmSystemTools::Error("Unable to open cache file for save. ",
  245. cacheFile.c_str());
  246. return false;
  247. }
  248. // before writting the cache, update the version numbers
  249. // to the
  250. char temp[1024];
  251. sprintf(temp, "%d", cmMakefile::GetMinorVersion());
  252. this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", temp,
  253. "Minor version of cmake used to create the "
  254. "current loaded cache", cmCacheManager::INTERNAL);
  255. sprintf(temp, "%d", cmMakefile::GetMajorVersion());
  256. this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", temp,
  257. "Major version of cmake used to create the "
  258. "current loaded cache", cmCacheManager::INTERNAL);
  259. // Let us store the current working directory so that if somebody
  260. // Copies it, he will not be surprised
  261. std::string currentcwd = path;
  262. if ( currentcwd[0] >= 'A' && currentcwd[0] <= 'Z' &&
  263. currentcwd[1] == ':' )
  264. {
  265. currentcwd[0] = currentcwd[0] - 'A' + 'a';
  266. }
  267. cmSystemTools::ConvertToUnixSlashes(currentcwd);
  268. this->AddCacheEntry("CMAKE_CACHEFILE_DIR", currentcwd.c_str(),
  269. "This is the directory where this CMakeCahe.txt"
  270. " was created", cmCacheManager::INTERNAL);
  271. fout << "# This is the CMakeCache file.\n"
  272. << "# For build in directory: " << currentcwd << "\n"
  273. << "# You can edit this file to change values found and used by cmake.\n"
  274. << "# If you do not want to change any of the values, simply exit the editor.\n"
  275. << "# If you do want to change a value, simply edit, save, and exit the editor.\n"
  276. << "# The syntax for the file is as follows:\n"
  277. << "# KEY:TYPE=VALUE\n"
  278. << "# KEY is the name of a varible in the cache.\n"
  279. << "# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!.\n"
  280. << "# VALUE is the current value for the KEY.\n\n";
  281. fout << "########################\n";
  282. fout << "# EXTERNAL cache entries\n";
  283. fout << "########################\n";
  284. fout << "\n";
  285. for( std::map<cmStdString, CacheEntry>::const_iterator i = m_Cache.begin();
  286. i != m_Cache.end(); ++i)
  287. {
  288. const CacheEntry& ce = (*i).second;
  289. CacheEntryType t = ce.m_Type;
  290. if(t == cmCacheManager::UNINITIALIZED)
  291. {
  292. /*
  293. // This should be added in, but is not for now.
  294. cmSystemTools::Error("Cache entry \"", (*i).first.c_str(),
  295. "\" is uninitialized");
  296. */
  297. }
  298. else if(t != INTERNAL)
  299. {
  300. // Format is key:type=value
  301. std::map<cmStdString,cmStdString>::const_iterator it =
  302. ce.m_Properties.find("HELPSTRING");
  303. if ( it == ce.m_Properties.end() )
  304. {
  305. cmCacheManager::OutputHelpString(fout, "Missing description");
  306. }
  307. else
  308. {
  309. cmCacheManager::OutputHelpString(fout, it->second);
  310. }
  311. std::string key;
  312. // support : in key name by double quoting
  313. if((*i).first.find(':') != std::string::npos ||
  314. (*i).first.find("//") == 0)
  315. {
  316. key = "\"";
  317. key += i->first;
  318. key += "\"";
  319. }
  320. else
  321. {
  322. key = i->first;
  323. }
  324. fout << key.c_str() << ":"
  325. << cmCacheManagerTypes[t] << "=";
  326. // if value has trailing space or tab, enclose it in single quotes
  327. if (ce.m_Value.size() &&
  328. (ce.m_Value[ce.m_Value.size() - 1] == ' ' ||
  329. ce.m_Value[ce.m_Value.size() - 1] == '\t'))
  330. {
  331. fout << '\'' << ce.m_Value << '\'';
  332. }
  333. else
  334. {
  335. fout << ce.m_Value;
  336. }
  337. fout << "\n\n";
  338. }
  339. }
  340. fout << "\n";
  341. fout << "########################\n";
  342. fout << "# INTERNAL cache entries\n";
  343. fout << "########################\n";
  344. fout << "\n";
  345. for( cmCacheManager::CacheIterator i = this->NewIterator();
  346. !i.IsAtEnd(); i.Next())
  347. {
  348. CacheEntryType t = i.GetType();
  349. bool advanced = i.PropertyExists("ADVANCED");
  350. if ( advanced )
  351. {
  352. // Format is key:type=value
  353. std::string key;
  354. std::string rkey = i.GetName();
  355. std::string helpstring;
  356. // If this is advanced variable, we have to do some magic for
  357. // backward compatibility
  358. helpstring = "Advanced flag for variable: ";
  359. helpstring += i.GetName();
  360. rkey += "-ADVANCED";
  361. cmCacheManager::OutputHelpString(fout, helpstring.c_str());
  362. // support : in key name by double quoting
  363. if(rkey.find(':') != std::string::npos ||
  364. rkey.find("//") == 0)
  365. {
  366. key = "\"";
  367. key += rkey;
  368. key += "\"";
  369. }
  370. else
  371. {
  372. key = rkey;
  373. }
  374. fout << key.c_str() << ":INTERNAL="
  375. << (i.GetPropertyAsBool("ADVANCED") ? "1" : "0") << "\n";
  376. }
  377. if(t == cmCacheManager::INTERNAL)
  378. {
  379. // Format is key:type=value
  380. std::string key;
  381. std::string rkey = i.GetName();
  382. std::string helpstring;
  383. const char* hs = i.GetProperty("HELPSTRING");
  384. if ( hs )
  385. {
  386. helpstring = i.GetProperty("HELPSTRING");
  387. }
  388. else
  389. {
  390. helpstring = "";
  391. }
  392. cmCacheManager::OutputHelpString(fout, helpstring.c_str());
  393. // support : in key name by double quoting
  394. if(rkey.find(':') != std::string::npos ||
  395. rkey.find("//") == 0)
  396. {
  397. key = "\"";
  398. key += rkey;
  399. key += "\"";
  400. }
  401. else
  402. {
  403. key = rkey;
  404. }
  405. fout << key.c_str() << ":"
  406. << cmCacheManagerTypes[t] << "=";
  407. // if value has trailing space or tab, enclose it in single quotes
  408. std::string value = i.GetValue();
  409. if (value.size() &&
  410. (value[value.size() - 1] == ' ' ||
  411. value[value.size() - 1] == '\t'))
  412. {
  413. fout << '\'' << value << '\'';
  414. }
  415. else
  416. {
  417. fout << value;
  418. }
  419. fout << "\n";
  420. }
  421. }
  422. fout << "\n";
  423. fout.close();
  424. cmSystemTools::CopyFileIfDifferent(tempFile.c_str(),
  425. cacheFile.c_str());
  426. cmSystemTools::RemoveFile(tempFile.c_str());
  427. return true;
  428. }
  429. void cmCacheManager::OutputHelpString(std::ofstream& fout,
  430. const std::string& helpString)
  431. {
  432. std::string::size_type end = helpString.size();
  433. if(end == 0)
  434. {
  435. return;
  436. }
  437. std::string oneLine;
  438. std::string::size_type pos = 0;
  439. std::string::size_type nextBreak = 60;
  440. bool done = false;
  441. while(!done)
  442. {
  443. if(nextBreak >= end)
  444. {
  445. nextBreak = end;
  446. done = true;
  447. }
  448. else
  449. {
  450. while(nextBreak < end && helpString[nextBreak] != ' ')
  451. {
  452. nextBreak++;
  453. }
  454. }
  455. oneLine = helpString.substr(pos, nextBreak - pos);
  456. fout << "//" << oneLine.c_str() << "\n";
  457. pos = nextBreak;
  458. nextBreak += 60;
  459. }
  460. }
  461. void cmCacheManager::RemoveCacheEntry(const char* key)
  462. {
  463. CacheEntryMap::iterator i = m_Cache.find(key);
  464. if(i != m_Cache.end())
  465. {
  466. m_Cache.erase(i);
  467. }
  468. else
  469. {
  470. std::cerr << "Failed to remove entry:" << key << std::endl;
  471. }
  472. }
  473. cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(const char* key)
  474. {
  475. CacheEntryMap::iterator i = m_Cache.find(key);
  476. if(i != m_Cache.end())
  477. {
  478. return &i->second;
  479. }
  480. return 0;
  481. }
  482. cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(const char *key)
  483. {
  484. return CacheIterator(*this, key);
  485. }
  486. const char* cmCacheManager::GetCacheValue(const char* key) const
  487. {
  488. CacheEntryMap::const_iterator i = m_Cache.find(key);
  489. if(i != m_Cache.end() && i->second.m_Type != cmCacheManager::UNINITIALIZED)
  490. {
  491. return i->second.m_Value.c_str();
  492. }
  493. return 0;
  494. }
  495. void cmCacheManager::PrintCache(std::ostream& out) const
  496. {
  497. out << "=================================================" << std::endl;
  498. out << "CMakeCache Contents:" << std::endl;
  499. for(std::map<cmStdString, CacheEntry>::const_iterator i = m_Cache.begin();
  500. i != m_Cache.end(); ++i)
  501. {
  502. if((*i).second.m_Type != INTERNAL)
  503. {
  504. out << (*i).first.c_str() << " = " << (*i).second.m_Value.c_str() << std::endl;
  505. }
  506. }
  507. out << "\n\n";
  508. out << "To change values in the CMakeCache, \nedit CMakeCache.txt in your output directory.\n";
  509. out << "=================================================" << std::endl;
  510. }
  511. void cmCacheManager::AddCacheEntry(const char* key,
  512. const char* value,
  513. const char* helpString,
  514. CacheEntryType type)
  515. {
  516. CacheEntry& e = m_Cache[key];
  517. if ( value )
  518. {
  519. e.m_Value = value;
  520. }
  521. else
  522. {
  523. e.m_Value = "(none)";
  524. }
  525. e.m_Type = type;
  526. // make sure we only use unix style paths
  527. if(type == FILEPATH || type == PATH)
  528. {
  529. cmSystemTools::ConvertToUnixSlashes(e.m_Value);
  530. }
  531. if ( helpString )
  532. {
  533. e.m_Properties["HELPSTRING"] = helpString;
  534. }
  535. else
  536. {
  537. e.m_Properties["HELPSTRING"] = "(This variable does not exists and should not be used)";
  538. }
  539. m_Cache[key] = e;
  540. }
  541. void cmCacheManager::AddCacheEntry(const char* key, bool v,
  542. const char* helpString)
  543. {
  544. if(v)
  545. {
  546. this->AddCacheEntry(key, "ON", helpString, cmCacheManager::BOOL);
  547. }
  548. else
  549. {
  550. this->AddCacheEntry(key, "OFF", helpString, cmCacheManager::BOOL);
  551. }
  552. }
  553. bool cmCacheManager::CacheIterator::IsAtEnd()
  554. {
  555. return m_Position == m_Container.m_Cache.end();
  556. }
  557. void cmCacheManager::CacheIterator::Begin()
  558. {
  559. m_Position = m_Container.m_Cache.begin();
  560. }
  561. bool cmCacheManager::CacheIterator::Find(const char* key)
  562. {
  563. m_Position = m_Container.m_Cache.find(key);
  564. return !this->IsAtEnd();
  565. }
  566. void cmCacheManager::CacheIterator::Next()
  567. {
  568. ++m_Position;
  569. }
  570. void cmCacheManager::CacheIterator::SetValue(const char* value)
  571. {
  572. CacheEntry* entry = &this->GetEntry();
  573. entry->m_Value = value;
  574. }
  575. const char* cmCacheManager::CacheIterator::GetProperty(const char* property) const
  576. {
  577. if ( !strcmp(property, "TYPE") || !strcmp(property, "VALUE") )
  578. {
  579. cmSystemTools::Error("Property \"", property,
  580. "\" cannot be accessed through the GetProperty()");
  581. return 0;
  582. }
  583. const CacheEntry* ent = &this->GetEntry();
  584. std::map<cmStdString,cmStdString>::const_iterator it =
  585. ent->m_Properties.find(property);
  586. if ( it == ent->m_Properties.end() )
  587. {
  588. return 0;
  589. }
  590. return it->second.c_str();
  591. }
  592. void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v)
  593. {
  594. if ( !strcmp(p, "TYPE") || !strcmp(p, "VALUE") )
  595. {
  596. cmSystemTools::Error("Property \"", p,
  597. "\" cannot be accessed through the SetProperty()");
  598. return;
  599. }
  600. CacheEntry* ent = &this->GetEntry();
  601. ent->m_Properties[p] = v;
  602. }
  603. bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* property) const
  604. {
  605. if ( !strcmp(property, "TYPE") || !strcmp(property, "VALUE") )
  606. {
  607. cmSystemTools::Error("Property \"", property,
  608. "\" cannot be accessed through the GetPropertyAsBool()");
  609. return false;
  610. }
  611. const CacheEntry* ent = &this->GetEntry();
  612. std::map<cmStdString,cmStdString>::const_iterator it =
  613. ent->m_Properties.find(property);
  614. if ( it == ent->m_Properties.end() )
  615. {
  616. return false;
  617. }
  618. return cmSystemTools::IsOn(it->second.c_str());
  619. }
  620. void cmCacheManager::CacheIterator::SetProperty(const char* p, bool v)
  621. {
  622. if ( !strcmp(p, "TYPE") || !strcmp(p, "VALUE") )
  623. {
  624. cmSystemTools::Error("Property \"", p,
  625. "\" cannot be accessed through the SetProperty()");
  626. return;
  627. }
  628. CacheEntry* ent = &this->GetEntry();
  629. ent->m_Properties[p] = v ? "ON" : "OFF";
  630. }
  631. bool cmCacheManager::CacheIterator::PropertyExists(const char* property) const
  632. {
  633. if ( !strcmp(property, "TYPE") || !strcmp(property, "VALUE") )
  634. {
  635. cmSystemTools::Error("Property \"", property,
  636. "\" cannot be accessed through the PropertyExists()");
  637. return false;
  638. }
  639. const CacheEntry* ent = &this->GetEntry();
  640. std::map<cmStdString,cmStdString>::const_iterator it =
  641. ent->m_Properties.find(property);
  642. if ( it == ent->m_Properties.end() )
  643. {
  644. return false;
  645. }
  646. return true;
  647. }