| 112 | } |
| 113 | |
| 114 | void cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os, |
| 115 | Indent indent) |
| 116 | { |
| 117 | // Create the main install rules first. |
| 118 | this->cmInstallGenerator::GenerateScriptConfigs(os, indent); |
| 119 | |
| 120 | // Now create a configuration-specific install rule for the import |
| 121 | // file of each configuration. |
| 122 | std::vector<std::string> files; |
| 123 | for (auto const& i : this->EFGen->GetConfigImportFiles()) { |
| 124 | files.push_back(i.second); |
| 125 | std::string config_test = this->CreateConfigTest(i.first); |
| 126 | os << indent << "if(" << config_test << ")\n"; |
| 127 | this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files, |
| 128 | false, this->FilePermissions.c_str(), nullptr, |
| 129 | nullptr, nullptr, indent.Next()); |
| 130 | os << indent << "endif()\n"; |
| 131 | files.clear(); |
| 132 | } |
| 133 | |
| 134 | // Now create a configuration-specific install rule for the C++ module import |
| 135 | // property file of each configuration. |
| 136 | auto const cxxModuleDestination = |
| 137 | cmStrCat(this->Destination, '/', this->CxxModulesDirectory); |
| 138 | auto const cxxModuleInstallFilePath = this->EFGen->GetCxxModuleFile(); |
| 139 | auto const configImportFilesGlob = this->EFGen->GetConfigImportFileGlob(); |
| 140 | if (!cxxModuleInstallFilePath.empty() && !configImportFilesGlob.empty()) { |
| 141 | auto const cxxModuleFilename = |
| 142 | cmSystemTools::GetFilenameName(cxxModuleInstallFilePath); |
| 143 | |
| 144 | // Remove old per-configuration export files if the main changes. |
| 145 | std::string installedDir = |
| 146 | cmStrCat("$ENV{DESTDIR}", |
| 147 | ConvertToAbsoluteDestination(cxxModuleDestination), '/'); |
| 148 | std::string installedFile = cmStrCat(installedDir, cxxModuleFilename); |
| 149 | os << indent << "if(EXISTS \"" << installedFile << "\")\n"; |
| 150 | Indent indentN = indent.Next(); |
| 151 | Indent indentNN = indentN.Next(); |
| 152 | Indent indentNNN = indentNN.Next(); |
| 153 | os << indentN << "file(DIFFERENT _cmake_export_file_changed FILES\n" |
| 154 | << indentN << " \"" << installedFile << "\"\n" |
| 155 | << indentN << " \"" << cxxModuleInstallFilePath << "\")\n"; |
| 156 | os << indentN << "if(_cmake_export_file_changed)\n"; |
| 157 | os << indentNN << "file(GLOB _cmake_old_config_files \"" << installedDir |
| 158 | << configImportFilesGlob << "\")\n"; |
| 159 | os << indentNN << "if(_cmake_old_config_files)\n"; |
| 160 | os << indentNNN |
| 161 | << "string(REPLACE \";\" \", \" _cmake_old_config_files_text " |
| 162 | "\"${_cmake_old_config_files}\")\n"; |
| 163 | os << indentNNN << R"(message(STATUS "Old C++ module export file \")" |
| 164 | << installedFile |
| 165 | << "\\\" will be replaced. " |
| 166 | "Removing files [${_cmake_old_config_files_text}].\")\n"; |
| 167 | os << indentNNN << "unset(_cmake_old_config_files_text)\n"; |
| 168 | os << indentNNN << "file(REMOVE ${_cmake_old_config_files})\n"; |
| 169 | os << indentNN << "endif()\n"; |
| 170 | os << indentNN << "unset(_cmake_old_config_files)\n"; |
| 171 | os << indentN << "endif()\n"; |
nothing calls this directly
no test coverage detected