| 1867 | } |
| 1868 | |
| 1869 | void 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 | |
| 1922 | void cmMakefile::MarkVariableAsUsed(std::string const& var) |
| 1923 | { |
no test coverage detected