| 202 | } |
| 203 | |
| 204 | void cmInstallExportGenerator::GenerateScriptActions(std::ostream& os, |
| 205 | Indent indent) |
| 206 | { |
| 207 | auto const configImportFilesGlob = this->EFGen->GetConfigImportFileGlob(); |
| 208 | if (!configImportFilesGlob.empty()) { |
| 209 | // Remove old per-configuration export files if the main changes. |
| 210 | std::string installedDir = cmStrCat( |
| 211 | "$ENV{DESTDIR}", ConvertToAbsoluteDestination(this->Destination), '/'); |
| 212 | std::string installedFile = cmStrCat(installedDir, this->FileName); |
| 213 | os << indent << "if(EXISTS \"" << installedFile << "\")\n"; |
| 214 | Indent indentN = indent.Next(); |
| 215 | Indent indentNN = indentN.Next(); |
| 216 | Indent indentNNN = indentNN.Next(); |
| 217 | os << indentN << "file(DIFFERENT _cmake_export_file_changed FILES\n" |
| 218 | << indentN << " \"" << installedFile << "\"\n" |
| 219 | << indentN << " \"" << this->MainImportFile << "\")\n"; |
| 220 | os << indentN << "if(_cmake_export_file_changed)\n"; |
| 221 | os << indentNN << "file(GLOB _cmake_old_config_files \"" << installedDir |
| 222 | << configImportFilesGlob << "\")\n"; |
| 223 | os << indentNN << "if(_cmake_old_config_files)\n"; |
| 224 | os << indentNNN |
| 225 | << "string(REPLACE \";\" \", \" _cmake_old_config_files_text " |
| 226 | "\"${_cmake_old_config_files}\")\n"; |
| 227 | os << indentNNN << R"(message(STATUS "Old export file \")" << installedFile |
| 228 | << "\\\" will be replaced. " |
| 229 | "Removing files [${_cmake_old_config_files_text}].\")\n"; |
| 230 | os << indentNNN << "unset(_cmake_old_config_files_text)\n"; |
| 231 | os << indentNNN << "file(REMOVE ${_cmake_old_config_files})\n"; |
| 232 | os << indentNN << "endif()\n"; |
| 233 | os << indentNN << "unset(_cmake_old_config_files)\n"; |
| 234 | os << indentN << "endif()\n"; |
| 235 | os << indentN << "unset(_cmake_export_file_changed)\n"; |
| 236 | os << indent << "endif()\n"; |
| 237 | } |
| 238 | |
| 239 | // Install the main export file. |
| 240 | std::vector<std::string> files; |
| 241 | files.push_back(this->MainImportFile); |
| 242 | this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files, |
| 243 | false, this->FilePermissions.c_str(), nullptr, nullptr, |
| 244 | nullptr, indent); |
| 245 | } |
| 246 | |
| 247 | std::string cmInstallExportGenerator::GetDestinationFile() const |
| 248 | { |
nothing calls this directly
no test coverage detected