MCPcopy Create free account
hub / github.com/Kitware/CMake / AddCacheDefinition

Method AddCacheDefinition

Source/cmMakefile.cxx:1869–1920  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1867}
1868
1869void cmMakefile::AddCacheDefinition(std::string const& name, cmValue value,
1870 cmValue doc,
1871 cmStateEnums::CacheEntryType type,
1872 bool force)
1873{
1874 cmValue existingValue = this->GetState()->GetInitializedCacheValue(name);
1875 // must be outside the following if() to keep it alive long enough
1876 std::string nvalue;
1877
1878 if (existingValue &&
1879 (this->GetState()->GetCacheEntryType(name) ==
1880 cmStateEnums::UNINITIALIZED)) {
1881 // if this is not a force, then use the value from the cache
1882 // if it is a force, then use the value being passed in
1883 if (!force) {
1884 value = existingValue;
1885 }
1886 if (type == cmStateEnums::PATH || type == cmStateEnums::FILEPATH) {
1887 cmList files(value);
1888 for (auto& file : files) {
1889 if (!cmIsOff(file)) {
1890 file = cmSystemTools::ToNormalizedPathOnDisk(file);
1891 }
1892 }
1893 nvalue = files.to_string();
1894 value = cmValue{ nvalue };
1895
1896 this->GetCMakeInstance()->AddCacheEntry(name, value, doc, type);
1897 value = this->GetState()->GetInitializedCacheValue(name);
1898 }
1899 }
1900 this->GetCMakeInstance()->AddCacheEntry(name, value, doc, type);
1901 switch (this->GetPolicyStatus(cmPolicies::CMP0126)) {
1902 case cmPolicies::WARN:
1903 if (this->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0126") &&
1904 this->IsNormalDefinitionSet(name)) {
1905 this->IssueMessage(
1906 MessageType::AUTHOR_WARNING,
1907 cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0126),
1908 "\nFor compatibility with older versions of CMake, normal "
1909 "variable \"",
1910 name, "\" will be removed from the current scope."));
1911 }
1912 CM_FALLTHROUGH;
1913 case cmPolicies::OLD:
1914 // if there was a definition then remove it
1915 this->StateSnapshot.RemoveDefinition(name);
1916 break;
1917 case cmPolicies::NEW:
1918 break;
1919 }
1920}
1921
1922void cmMakefile::MarkVariableAsUsed(std::string const& var)
1923{

Callers 15

AddEnvVarMethod · 0.45
FindMakeProgramMethod · 0.45
EnableLanguageMethod · 0.45
cmSetCommandFunction · 0.45
AddLinkLibraryMethod · 0.45
SetGeneratorToolsetMethod · 0.45
cmProjectCommandFunction · 0.45
TopLevelCMakeVarCondSetFunction · 0.45
cmSiteNameCommandFunction · 0.45
NormalizeFindResultMethod · 0.45

Calls 13

GetStateMethod · 0.95
GetCMakeInstanceMethod · 0.95
GetPolicyStatusMethod · 0.95
IsNormalDefinitionSetMethod · 0.95
IssueMessageMethod · 0.95
cmIsOffFunction · 0.85
to_stringMethod · 0.80
cmStrCatFunction · 0.70
GetCacheEntryTypeMethod · 0.45
AddCacheEntryMethod · 0.45

Tested by

no test coverage detected