cmCacheManager.cxx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmCacheManager.h"
  4. #include <algorithm>
  5. #include <cstdio>
  6. #include <cstring>
  7. #include <sstream>
  8. #include <string>
  9. #include "cmsys/FStream.hxx"
  10. #include "cmsys/Glob.hxx"
  11. #include "cmGeneratedFileStream.h"
  12. #include "cmList.h"
  13. #include "cmMessageType.h"
  14. #include "cmMessenger.h"
  15. #include "cmState.h"
  16. #include "cmStringAlgorithms.h"
  17. #include "cmSystemTools.h"
  18. #include "cmVersion.h"
  19. void cmCacheManager::CleanCMakeFiles(const std::string& path)
  20. {
  21. std::string glob = cmStrCat(path, "/CMakeFiles/*.cmake");
  22. cmsys::Glob globIt;
  23. globIt.FindFiles(glob);
  24. std::vector<std::string> files = globIt.GetFiles();
  25. std::for_each(files.begin(), files.end(), cmSystemTools::RemoveFile);
  26. }
  27. bool cmCacheManager::LoadCache(const std::string& path, bool internal,
  28. std::set<std::string>& excludes,
  29. std::set<std::string>& includes)
  30. {
  31. std::string cacheFile = cmStrCat(path, "/CMakeCache.txt");
  32. // clear the old cache, if we are reading in internal values
  33. if (internal) {
  34. this->Cache.clear();
  35. }
  36. if (!cmSystemTools::FileExists(cacheFile)) {
  37. this->CleanCMakeFiles(path);
  38. return false;
  39. }
  40. cmsys::ifstream fin(cacheFile.c_str());
  41. if (!fin) {
  42. return false;
  43. }
  44. const char* realbuffer;
  45. std::string buffer;
  46. std::string entryKey;
  47. unsigned int lineno = 0;
  48. while (fin) {
  49. // Format is key:type=value
  50. std::string helpString;
  51. CacheEntry e;
  52. cmSystemTools::GetLineFromStream(fin, buffer);
  53. lineno++;
  54. realbuffer = buffer.c_str();
  55. while (*realbuffer != '0' &&
  56. (*realbuffer == ' ' || *realbuffer == '\t' || *realbuffer == '\r' ||
  57. *realbuffer == '\n')) {
  58. if (*realbuffer == '\n') {
  59. lineno++;
  60. }
  61. realbuffer++;
  62. }
  63. // skip blank lines and comment lines
  64. if (realbuffer[0] == '#' || realbuffer[0] == 0) {
  65. continue;
  66. }
  67. while (realbuffer[0] == '/' && realbuffer[1] == '/') {
  68. if ((realbuffer[2] == '\\') && (realbuffer[3] == 'n')) {
  69. helpString += '\n';
  70. helpString += &realbuffer[4];
  71. } else {
  72. helpString += &realbuffer[2];
  73. }
  74. cmSystemTools::GetLineFromStream(fin, buffer);
  75. lineno++;
  76. realbuffer = buffer.c_str();
  77. if (!fin) {
  78. continue;
  79. }
  80. }
  81. e.SetProperty("HELPSTRING", helpString);
  82. if (cmState::ParseCacheEntry(realbuffer, entryKey, e.Value, e.Type)) {
  83. if (excludes.find(entryKey) == excludes.end()) {
  84. // Load internal values if internal is set.
  85. // If the entry is not internal to the cache being loaded
  86. // or if it is in the list of internal entries to be
  87. // imported, load it.
  88. if (internal || (e.Type != cmStateEnums::INTERNAL) ||
  89. (includes.find(entryKey) != includes.end())) {
  90. // If we are loading the cache from another project,
  91. // make all loaded entries internal so that it is
  92. // not visible in the gui
  93. if (!internal) {
  94. e.Type = cmStateEnums::INTERNAL;
  95. helpString = cmStrCat("DO NOT EDIT, ", entryKey,
  96. " loaded from external file. "
  97. "To change this value edit this file: ",
  98. path, "/CMakeCache.txt");
  99. e.SetProperty("HELPSTRING", helpString);
  100. }
  101. if (!this->ReadPropertyEntry(entryKey, e)) {
  102. e.Initialized = true;
  103. this->Cache[entryKey] = e;
  104. }
  105. }
  106. }
  107. } else {
  108. std::ostringstream error;
  109. error << "Parse error in cache file " << cacheFile << " on line "
  110. << lineno << ". Offending entry: " << realbuffer;
  111. cmSystemTools::Error(error.str());
  112. }
  113. }
  114. this->CacheMajorVersion = 0;
  115. this->CacheMinorVersion = 0;
  116. if (cmValue cmajor =
  117. this->GetInitializedCacheValue("CMAKE_CACHE_MAJOR_VERSION")) {
  118. unsigned int v = 0;
  119. if (sscanf(cmajor->c_str(), "%u", &v) == 1) {
  120. this->CacheMajorVersion = v;
  121. }
  122. if (cmValue cminor =
  123. this->GetInitializedCacheValue("CMAKE_CACHE_MINOR_VERSION")) {
  124. if (sscanf(cminor->c_str(), "%u", &v) == 1) {
  125. this->CacheMinorVersion = v;
  126. }
  127. }
  128. } else {
  129. // CMake version not found in the list file.
  130. // Set as version 0.0
  131. this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", "0",
  132. "Minor version of cmake used to create the "
  133. "current loaded cache",
  134. cmStateEnums::INTERNAL);
  135. this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", "0",
  136. "Major version of cmake used to create the "
  137. "current loaded cache",
  138. cmStateEnums::INTERNAL);
  139. }
  140. // check to make sure the cache directory has not
  141. // been moved
  142. cmValue oldDir = this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
  143. if (internal && oldDir) {
  144. std::string currentcwd = path;
  145. std::string oldcwd = *oldDir;
  146. cmSystemTools::ConvertToUnixSlashes(currentcwd);
  147. currentcwd += "/CMakeCache.txt";
  148. oldcwd += "/CMakeCache.txt";
  149. if (!cmSystemTools::SameFile(oldcwd, currentcwd)) {
  150. cmValue dir = this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
  151. std::ostringstream message;
  152. message << "The current CMakeCache.txt directory " << currentcwd
  153. << " is different than the directory " << (dir ? *dir : "")
  154. << " where CMakeCache.txt was created. This may result "
  155. "in binaries being created in the wrong place. If you "
  156. "are not sure, reedit the CMakeCache.txt";
  157. cmSystemTools::Error(message.str());
  158. }
  159. }
  160. this->CacheLoaded = true;
  161. return true;
  162. }
  163. const char* cmCacheManager::PersistentProperties[] = { "ADVANCED", "MODIFIED",
  164. "STRINGS" };
  165. bool cmCacheManager::ReadPropertyEntry(const std::string& entryKey,
  166. const CacheEntry& e)
  167. {
  168. // All property entries are internal.
  169. if (e.Type != cmStateEnums::INTERNAL) {
  170. return false;
  171. }
  172. const char* end = entryKey.c_str() + entryKey.size();
  173. for (const char* p : cmCacheManager::PersistentProperties) {
  174. std::string::size_type plen = strlen(p) + 1;
  175. if (entryKey.size() > plen && *(end - plen) == '-' &&
  176. strcmp(end - plen + 1, p) == 0) {
  177. std::string key = entryKey.substr(0, entryKey.size() - plen);
  178. if (auto* entry = this->GetCacheEntry(key)) {
  179. // Store this property on its entry.
  180. entry->SetProperty(p, e.Value);
  181. } else {
  182. // Create an entry and store the property.
  183. CacheEntry& ne = this->Cache[key];
  184. ne.SetProperty(p, e.Value);
  185. }
  186. return true;
  187. }
  188. }
  189. return false;
  190. }
  191. void cmCacheManager::WritePropertyEntries(std::ostream& os,
  192. const std::string& entryKey,
  193. const CacheEntry& e,
  194. cmMessenger* messenger) const
  195. {
  196. for (const char* p : cmCacheManager::PersistentProperties) {
  197. if (cmValue value = e.GetProperty(p)) {
  198. std::string helpstring =
  199. cmStrCat(p, " property for variable: ", entryKey);
  200. cmCacheManager::OutputHelpString(os, helpstring);
  201. std::string key = cmStrCat(entryKey, '-', p);
  202. cmCacheManager::OutputKey(os, key);
  203. os << ":INTERNAL=";
  204. cmCacheManager::OutputValue(os, *value);
  205. os << '\n';
  206. cmCacheManager::OutputNewlineTruncationWarning(os, key, *value,
  207. messenger);
  208. }
  209. }
  210. }
  211. bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
  212. {
  213. std::string cacheFile = cmStrCat(path, "/CMakeCache.txt");
  214. cmGeneratedFileStream fout(cacheFile);
  215. fout.SetCopyIfDifferent(true);
  216. if (!fout) {
  217. cmSystemTools::Error("Unable to open cache file for save. " + cacheFile);
  218. cmSystemTools::ReportLastSystemError("");
  219. return false;
  220. }
  221. // before writing the cache, update the version numbers
  222. // to the
  223. this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION",
  224. std::to_string(cmVersion::GetMajorVersion()),
  225. "Major version of cmake used to create the "
  226. "current loaded cache",
  227. cmStateEnums::INTERNAL);
  228. this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION",
  229. std::to_string(cmVersion::GetMinorVersion()),
  230. "Minor version of cmake used to create the "
  231. "current loaded cache",
  232. cmStateEnums::INTERNAL);
  233. this->AddCacheEntry("CMAKE_CACHE_PATCH_VERSION",
  234. std::to_string(cmVersion::GetPatchVersion()),
  235. "Patch version of cmake used to create the "
  236. "current loaded cache",
  237. cmStateEnums::INTERNAL);
  238. // Let us store the current working directory so that if somebody
  239. // Copies it, he will not be surprised
  240. std::string currentcwd = path;
  241. if (currentcwd[0] >= 'A' && currentcwd[0] <= 'Z' && currentcwd[1] == ':') {
  242. // Cast added to avoid compiler warning. Cast is ok because
  243. // value is guaranteed to fit in char by the above if...
  244. currentcwd[0] = static_cast<char>(currentcwd[0] - 'A' + 'a');
  245. }
  246. cmSystemTools::ConvertToUnixSlashes(currentcwd);
  247. this->AddCacheEntry("CMAKE_CACHEFILE_DIR", currentcwd,
  248. "This is the directory where this CMakeCache.txt"
  249. " was created",
  250. cmStateEnums::INTERNAL);
  251. /* clang-format off */
  252. fout << "# This is the CMakeCache file.\n"
  253. "# For build in directory: " << currentcwd << "\n"
  254. "# It was generated by CMake: "
  255. << cmSystemTools::GetCMakeCommand()
  256. << "\n"
  257. "# You can edit this file to change values found and used by cmake."
  258. "\n"
  259. "# If you do not want to change any of the values, simply exit the "
  260. "editor.\n"
  261. "# If you do want to change a value, simply edit, save, and exit "
  262. "the editor.\n"
  263. "# The syntax for the file is as follows:\n"
  264. "# KEY:TYPE=VALUE\n"
  265. "# KEY is the name of a variable in the cache.\n"
  266. "# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!."
  267. "\n"
  268. "# VALUE is the current value for the KEY.\n"
  269. "\n"
  270. "########################\n"
  271. "# EXTERNAL cache entries\n"
  272. "########################\n"
  273. "\n";
  274. /* clang-format on */
  275. for (auto const& i : this->Cache) {
  276. CacheEntry const& ce = i.second;
  277. cmStateEnums::CacheEntryType t = ce.Type;
  278. if (!ce.Initialized) {
  279. /*
  280. // This should be added in, but is not for now.
  281. cmSystemTools::Error("Cache entry \"" + i.first + "\" is uninitialized");
  282. */
  283. } else if (t != cmStateEnums::INTERNAL) {
  284. // Format is key:type=value
  285. if (cmValue help = ce.GetProperty("HELPSTRING")) {
  286. cmCacheManager::OutputHelpString(fout, *help);
  287. } else {
  288. cmCacheManager::OutputHelpString(fout, "Missing description");
  289. }
  290. cmCacheManager::OutputKey(fout, i.first);
  291. fout << ':' << cmState::CacheEntryTypeToString(t) << '=';
  292. cmCacheManager::OutputValue(fout, ce.Value);
  293. fout << '\n';
  294. cmCacheManager::OutputNewlineTruncationWarning(fout, i.first, ce.Value,
  295. messenger);
  296. fout << '\n';
  297. }
  298. }
  299. fout << "\n"
  300. "########################\n"
  301. "# INTERNAL cache entries\n"
  302. "########################\n"
  303. "\n";
  304. for (auto const& i : this->Cache) {
  305. if (!i.second.Initialized) {
  306. continue;
  307. }
  308. cmStateEnums::CacheEntryType t = i.second.GetType();
  309. this->WritePropertyEntries(fout, i.first, i.second, messenger);
  310. if (t == cmStateEnums::INTERNAL) {
  311. // Format is key:type=value
  312. if (cmValue help = i.second.GetProperty("HELPSTRING")) {
  313. cmCacheManager::OutputHelpString(fout, *help);
  314. }
  315. cmCacheManager::OutputKey(fout, i.first);
  316. fout << ':' << cmState::CacheEntryTypeToString(t) << '=';
  317. cmCacheManager::OutputValue(fout, i.second.GetValue());
  318. fout << '\n';
  319. cmCacheManager::OutputNewlineTruncationWarning(
  320. fout, i.first, i.second.GetValue(), messenger);
  321. }
  322. }
  323. fout << '\n';
  324. fout.Close();
  325. std::string checkCacheFile = cmStrCat(path, "/CMakeFiles");
  326. cmSystemTools::MakeDirectory(checkCacheFile);
  327. checkCacheFile += "/cmake.check_cache";
  328. cmsys::ofstream checkCache(checkCacheFile.c_str());
  329. if (!checkCache) {
  330. cmSystemTools::Error("Unable to open check cache file for write. " +
  331. checkCacheFile);
  332. return false;
  333. }
  334. checkCache << "# This file is generated by cmake for dependency checking "
  335. "of the CMakeCache.txt file\n";
  336. return true;
  337. }
  338. bool cmCacheManager::DeleteCache(const std::string& path)
  339. {
  340. std::string cacheFile = path;
  341. cmSystemTools::ConvertToUnixSlashes(cacheFile);
  342. std::string cmakeFiles = cacheFile;
  343. cacheFile += "/CMakeCache.txt";
  344. if (cmSystemTools::FileExists(cacheFile)) {
  345. cmSystemTools::RemoveFile(cacheFile);
  346. // now remove the files in the CMakeFiles directory
  347. // this cleans up language cache files
  348. cmakeFiles += "/CMakeFiles";
  349. if (cmSystemTools::FileIsDirectory(cmakeFiles)) {
  350. cmSystemTools::RemoveADirectory(cmakeFiles);
  351. }
  352. }
  353. return true;
  354. }
  355. void cmCacheManager::OutputKey(std::ostream& fout, std::string const& key)
  356. {
  357. // support : in key name by double quoting
  358. const char* q =
  359. (key.find(':') != std::string::npos || cmHasLiteralPrefix(key, "//"))
  360. ? "\""
  361. : "";
  362. fout << q << key << q;
  363. }
  364. void cmCacheManager::OutputValue(std::ostream& fout, std::string const& value)
  365. {
  366. // look for and truncate newlines
  367. std::string::size_type newline = value.find('\n');
  368. if (newline != std::string::npos) {
  369. std::string truncated = value.substr(0, newline);
  370. OutputValueNoNewlines(fout, truncated);
  371. } else {
  372. OutputValueNoNewlines(fout, value);
  373. }
  374. }
  375. void cmCacheManager::OutputValueNoNewlines(std::ostream& fout,
  376. std::string const& value)
  377. {
  378. // if value has trailing space or tab, enclose it in single quotes
  379. if (!value.empty() && (value.back() == ' ' || value.back() == '\t')) {
  380. fout << '\'' << value << '\'';
  381. } else {
  382. fout << value;
  383. }
  384. }
  385. void cmCacheManager::OutputHelpString(std::ostream& fout,
  386. const std::string& helpString)
  387. {
  388. std::string::size_type end = helpString.size();
  389. if (end == 0) {
  390. return;
  391. }
  392. std::string oneLine;
  393. std::string::size_type pos = 0;
  394. for (std::string::size_type i = 0; i <= end; i++) {
  395. if ((i == end) || (helpString[i] == '\n') ||
  396. ((i - pos >= 60) && (helpString[i] == ' '))) {
  397. fout << "//";
  398. if (helpString[pos] == '\n') {
  399. pos++;
  400. fout << "\\n";
  401. }
  402. oneLine = helpString.substr(pos, i - pos);
  403. fout << oneLine << '\n';
  404. pos = i;
  405. }
  406. }
  407. }
  408. void cmCacheManager::OutputWarningComment(std::ostream& fout,
  409. std::string const& message,
  410. bool wrapSpaces)
  411. {
  412. std::string::size_type end = message.size();
  413. std::string oneLine;
  414. std::string::size_type pos = 0;
  415. for (std::string::size_type i = 0; i <= end; i++) {
  416. if ((i == end) || (message[i] == '\n') ||
  417. ((i - pos >= 60) && (message[i] == ' ') && wrapSpaces)) {
  418. fout << "# ";
  419. if (message[pos] == '\n') {
  420. pos++;
  421. fout << "\\n";
  422. }
  423. oneLine = message.substr(pos, i - pos);
  424. fout << oneLine << '\n';
  425. pos = i;
  426. }
  427. }
  428. }
  429. void cmCacheManager::OutputNewlineTruncationWarning(std::ostream& fout,
  430. std::string const& key,
  431. std::string const& value,
  432. cmMessenger* messenger)
  433. {
  434. if (value.find('\n') != std::string::npos) {
  435. if (messenger) {
  436. std::string message =
  437. cmStrCat("Value of ", key, " contained a newline; truncating");
  438. messenger->IssueMessage(MessageType::WARNING, message);
  439. }
  440. std::string comment =
  441. cmStrCat("WARNING: Value of ", key,
  442. " contained a newline and was truncated. Original value:");
  443. OutputWarningComment(fout, comment, true);
  444. OutputWarningComment(fout, value, false);
  445. }
  446. }
  447. void cmCacheManager::RemoveCacheEntry(const std::string& key)
  448. {
  449. this->Cache.erase(key);
  450. }
  451. cmCacheManager::CacheEntry* cmCacheManager::GetCacheEntry(
  452. const std::string& key)
  453. {
  454. auto i = this->Cache.find(key);
  455. if (i != this->Cache.end()) {
  456. return &i->second;
  457. }
  458. return nullptr;
  459. }
  460. const cmCacheManager::CacheEntry* cmCacheManager::GetCacheEntry(
  461. const std::string& key) const
  462. {
  463. auto i = this->Cache.find(key);
  464. if (i != this->Cache.end()) {
  465. return &i->second;
  466. }
  467. return nullptr;
  468. }
  469. cmValue cmCacheManager::GetInitializedCacheValue(const std::string& key) const
  470. {
  471. if (const auto* entry = this->GetCacheEntry(key)) {
  472. if (entry->Initialized) {
  473. return cmValue(entry->GetValue());
  474. }
  475. }
  476. return nullptr;
  477. }
  478. void cmCacheManager::PrintCache(std::ostream& out) const
  479. {
  480. out << "=================================================\n"
  481. "CMakeCache Contents:\n";
  482. for (auto const& i : this->Cache) {
  483. if (i.second.Type != cmStateEnums::INTERNAL) {
  484. out << i.first << " = " << i.second.Value << '\n';
  485. }
  486. }
  487. out << "\n\n"
  488. "To change values in the CMakeCache, \n"
  489. "edit CMakeCache.txt in your output directory.\n"
  490. "=================================================\n";
  491. }
  492. void cmCacheManager::AddCacheEntry(const std::string& key, cmValue value,
  493. cmValue helpString,
  494. cmStateEnums::CacheEntryType type)
  495. {
  496. CacheEntry& e = this->Cache[key];
  497. e.SetValue(value);
  498. e.Type = type;
  499. // make sure we only use unix style paths
  500. if (type == cmStateEnums::FILEPATH || type == cmStateEnums::PATH) {
  501. if (e.Value.find(';') != std::string::npos) {
  502. cmList paths{ e.Value };
  503. for (std::string& i : paths) {
  504. cmSystemTools::ConvertToUnixSlashes(i);
  505. }
  506. e.Value = paths.to_string();
  507. } else {
  508. cmSystemTools::ConvertToUnixSlashes(e.Value);
  509. }
  510. }
  511. e.SetProperty(
  512. "HELPSTRING",
  513. helpString ? *helpString
  514. : std::string{
  515. "(This variable does not exist and should not be used)" });
  516. }
  517. void cmCacheManager::CacheEntry::SetValue(cmValue value)
  518. {
  519. if (value) {
  520. this->Value = *value;
  521. this->Initialized = true;
  522. } else {
  523. this->Value.clear();
  524. }
  525. }
  526. std::vector<std::string> cmCacheManager::CacheEntry::GetPropertyList() const
  527. {
  528. return this->Properties.GetKeys();
  529. }
  530. cmValue cmCacheManager::CacheEntry::GetProperty(const std::string& prop) const
  531. {
  532. if (prop == "TYPE") {
  533. return cmValue(cmState::CacheEntryTypeToString(this->Type));
  534. }
  535. if (prop == "VALUE") {
  536. return cmValue(this->Value);
  537. }
  538. return this->Properties.GetPropertyValue(prop);
  539. }
  540. bool cmCacheManager::CacheEntry::GetPropertyAsBool(
  541. const std::string& prop) const
  542. {
  543. return cmIsOn(this->GetProperty(prop));
  544. }
  545. void cmCacheManager::CacheEntry::SetProperty(const std::string& prop,
  546. const std::string& value)
  547. {
  548. if (prop == "TYPE") {
  549. this->Type = cmState::StringToCacheEntryType(value);
  550. } else if (prop == "VALUE") {
  551. this->Value = value;
  552. } else {
  553. this->Properties.SetProperty(prop, value);
  554. }
  555. }
  556. void cmCacheManager::CacheEntry::SetProperty(const std::string& p, bool v)
  557. {
  558. this->SetProperty(p, v ? std::string{ "ON" } : std::string{ "OFF" });
  559. }
  560. void cmCacheManager::CacheEntry::SetProperty(const std::string& prop,
  561. std::nullptr_t)
  562. {
  563. if (prop == "TYPE") {
  564. this->Type = cmState::StringToCacheEntryType("STRING");
  565. } else if (prop == "VALUE") {
  566. this->Value = "";
  567. } else {
  568. this->Properties.SetProperty(prop, cmValue{ nullptr });
  569. }
  570. }
  571. void cmCacheManager::CacheEntry::AppendProperty(const std::string& prop,
  572. const std::string& value,
  573. bool asString)
  574. {
  575. if (prop == "TYPE") {
  576. this->Type =
  577. cmState::StringToCacheEntryType(!value.empty() ? value : "STRING");
  578. } else if (prop == "VALUE") {
  579. if (!value.empty()) {
  580. if (!this->Value.empty() && !asString) {
  581. this->Value += ";";
  582. }
  583. this->Value += value;
  584. }
  585. } else {
  586. this->Properties.AppendProperty(prop, value, asString);
  587. }
  588. }