| 664 | } |
| 665 | |
| 666 | void cmGlobalVisualStudioGenerator::AddSymbolExportCommand( |
| 667 | cmGeneratorTarget* gt, std::vector<cmCustomCommand>& commands, |
| 668 | std::string const& configName) |
| 669 | { |
| 670 | cmGeneratorTarget::ModuleDefinitionInfo const* mdi = |
| 671 | gt->GetModuleDefinitionInfo(configName); |
| 672 | if (!mdi || !mdi->DefFileGenerated) { |
| 673 | return; |
| 674 | } |
| 675 | |
| 676 | std::vector<std::string> outputs; |
| 677 | outputs.push_back(mdi->DefFile); |
| 678 | std::vector<std::string> empty; |
| 679 | std::vector<cmSourceFile const*> objectSources; |
| 680 | gt->GetObjectSources(objectSources, configName); |
| 681 | std::map<cmSourceFile const*, cmObjectLocations> mapping; |
| 682 | for (cmSourceFile const* it : objectSources) { |
| 683 | mapping[it]; |
| 684 | } |
| 685 | gt->LocalGenerator->ComputeObjectFilenames(mapping, configName, gt); |
| 686 | std::string obj_dir = gt->ObjectDirectory; |
| 687 | std::string cmakeCommand = cmSystemTools::GetCMakeCommand(); |
| 688 | std::string obj_dir_expanded = obj_dir; |
| 689 | cmSystemTools::ReplaceString(obj_dir_expanded, this->GetCMakeCFGIntDir(), |
| 690 | configName.c_str()); |
| 691 | cmSystemTools::MakeDirectory(obj_dir_expanded); |
| 692 | std::string const objs_file = cmStrCat(obj_dir_expanded, "/objects.txt"); |
| 693 | cmGeneratedFileStream fout(objs_file.c_str()); |
| 694 | if (!fout) { |
| 695 | cmSystemTools::Error(cmStrCat("could not open ", objs_file)); |
| 696 | return; |
| 697 | } |
| 698 | |
| 699 | auto const useShortPaths = this->UseShortObjectNames() |
| 700 | ? cmObjectLocations::UseShortPath::Yes |
| 701 | : cmObjectLocations::UseShortPath::No; |
| 702 | |
| 703 | if (mdi->WindowsExportAllSymbols) { |
| 704 | std::vector<std::string> objs; |
| 705 | for (cmSourceFile const* it : objectSources) { |
| 706 | // Find the object file name corresponding to this source file. |
| 707 | // It must exist because we populated the mapping just above. |
| 708 | auto const& locs = mapping[it]; |
| 709 | std::string const& v = locs.GetPath(useShortPaths); |
| 710 | assert(!v.empty()); |
| 711 | std::string objFile = cmStrCat(obj_dir, v); |
| 712 | objs.push_back(objFile); |
| 713 | } |
| 714 | std::vector<cmSourceFile const*> externalObjectSources; |
| 715 | gt->GetExternalObjects(externalObjectSources, configName); |
| 716 | for (cmSourceFile const* it : externalObjectSources) { |
| 717 | objs.push_back(it->GetFullPath()); |
| 718 | } |
| 719 | |
| 720 | for (std::string const& it : objs) { |
| 721 | std::string objFile = it; |
| 722 | // replace $(ConfigurationName) in the object names |
| 723 | cmSystemTools::ReplaceString(objFile, this->GetCMakeCFGIntDir(), |
no test coverage detected