| 218 | } |
| 219 | |
| 220 | bool cmGlobalVisualStudio8Generator::AddCheckTarget() |
| 221 | { |
| 222 | // Add a special target on which all other targets depend that |
| 223 | // checks the build system and optionally re-runs CMake. |
| 224 | // Skip the target if no regeneration is to be done. |
| 225 | if (this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION")) { |
| 226 | return false; |
| 227 | } |
| 228 | |
| 229 | std::vector<std::unique_ptr<cmLocalGenerator>> const& generators = |
| 230 | this->LocalGenerators; |
| 231 | auto& lg = |
| 232 | cm::static_reference_cast<cmLocalVisualStudio7Generator>(generators[0]); |
| 233 | |
| 234 | auto cc = cm::make_unique<cmCustomCommand>(); |
| 235 | cmTarget* tgt = lg.AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, |
| 236 | std::move(cc)); |
| 237 | |
| 238 | // Collect the input files used to generate all targets in this |
| 239 | // project. |
| 240 | std::vector<std::string> listFiles; |
| 241 | for (auto const& gen : generators) { |
| 242 | cm::append(listFiles, gen->GetMakefile()->GetListFiles()); |
| 243 | } |
| 244 | // Sort the list of input files and remove duplicates. |
| 245 | std::sort(listFiles.begin(), listFiles.end(), std::less<std::string>()); |
| 246 | auto new_end = std::unique(listFiles.begin(), listFiles.end()); |
| 247 | listFiles.erase(new_end, listFiles.end()); |
| 248 | |
| 249 | auto ptr = cm::make_unique<cmGeneratorTarget>(tgt, &lg); |
| 250 | auto* gt = ptr.get(); |
| 251 | lg.AddGeneratorTarget(std::move(ptr)); |
| 252 | |
| 253 | // Organize in the "predefined targets" folder: |
| 254 | // |
| 255 | if (this->UseFolderProperty()) { |
| 256 | tgt->SetProperty("FOLDER", this->GetPredefinedTargetsFolder()); |
| 257 | } |
| 258 | |
| 259 | // Create a list of all stamp files for this project. |
| 260 | std::vector<std::string> stamps; |
| 261 | std::string stampList = cmStrCat( |
| 262 | "CMakeFiles/", cmGlobalVisualStudio8Generator::GetGenerateStampList()); |
| 263 | { |
| 264 | std::string stampListFile = |
| 265 | cmStrCat(generators[0]->GetMakefile()->GetCurrentBinaryDirectory(), '/', |
| 266 | stampList); |
| 267 | std::string stampFile; |
| 268 | cmGeneratedFileStream fout(stampListFile); |
| 269 | for (auto const& gi : generators) { |
| 270 | stampFile = cmStrCat(gi->GetMakefile()->GetCurrentBinaryDirectory(), |
| 271 | "/CMakeFiles/generate.stamp"); |
| 272 | fout << stampFile << '\n'; |
| 273 | stamps.push_back(stampFile); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | // Add a custom rule to re-run CMake if any input files changed. |
no test coverage detected