1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #include "cmGlobalVisualStudio7Generator.h"
12 #include <cm/string_view>
16 #include "cmGeneratedFileStream.h"
17 #include "cmGeneratorExpression.h"
18 #include "cmGeneratorTarget.h"
19 #include "cmGlobalGenerator.h"
20 #include "cmLocalGenerator.h"
21 #include "cmLocalVisualStudio7Generator.h"
22 #include "cmMakefile.h"
23 #include "cmMessageType.h"
25 #include "cmStateTypes.h"
26 #include "cmStringAlgorithms.h"
27 #include "cmSystemTools.h"
29 #include "cmTargetDepend.h"
31 #include "cmVisualStudioGeneratorOptions.h"
34 static cmVS7FlagTable cmVS7ExtraFlagTable[] = {
35 // Precompiled header and related options. Note that the
36 // UsePrecompiledHeader entries are marked as "Continue" so that the
37 // corresponding PrecompiledHeaderThrough entry can be found.
38 { "UsePrecompiledHeader", "YX", "Automatically Generate", "2",
39 cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
40 { "PrecompiledHeaderThrough", "YX", "Precompiled Header Name", "",
41 cmVS7FlagTable::UserValueRequired },
42 { "UsePrecompiledHeader", "Yu", "Use Precompiled Header", "3",
43 cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
44 { "PrecompiledHeaderThrough", "Yu", "Precompiled Header Name", "",
45 cmVS7FlagTable::UserValueRequired },
46 { "UsePrecompiledHeader", "Y-", "Don't use precompiled header", "0", 0 },
47 { "WholeProgramOptimization", "LTCG", "WholeProgramOptimization", "true",
50 // Exception handling mode. If no entries match, it will be FALSE.
51 { "ExceptionHandling", "GX", "enable c++ exceptions", "true", 0 },
52 { "ExceptionHandling", "EHsc", "enable c++ exceptions", "true", 0 },
53 // The EHa option does not have an IDE setting. Let it go to false,
54 // and have EHa passed on the command line by leaving out the table
61 std::string GetSLNFile(cmLocalGenerator* root)
63 return cmStrCat(root->GetCurrentBinaryDirectory(), '/',
64 root->GetProjectName(), ".sln");
68 cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
69 cmake* cm, std::string const& platformInGeneratorName)
70 : cmGlobalVisualStudioGenerator(cm, platformInGeneratorName)
72 this->DevEnvCommandInitialized = false;
73 this->MasmEnabled = false;
74 this->NasmEnabled = false;
75 this->ExtraFlagTable = cmVS7ExtraFlagTable;
78 cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator()
82 // Package GUID of Intel Visual Fortran plugin to VS IDE
83 #define CM_INTEL_PLUGIN_GUID "{B68A201D-CB9B-47AF-A52F-7EEC72E217E4}"
85 const std::string& cmGlobalVisualStudio7Generator::GetIntelProjectVersion()
87 if (this->IntelProjectVersion.empty()) {
88 // Compute the version of the Intel plugin to the VS IDE.
89 // If the key does not exist then use a default guess.
90 std::string intelVersion;
92 cmStrCat(this->GetRegistryBase(),
93 "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion");
94 cmSystemTools::ReadRegistryValue(vskey, intelVersion,
95 cmSystemTools::KeyWOW64_32);
96 unsigned int intelVersionNumber = ~0u;
97 sscanf(intelVersion.c_str(), "%u", &intelVersionNumber);
98 if (intelVersionNumber >= 11) {
99 // Default to latest known project file version.
100 intelVersion = "11.0";
101 } else if (intelVersionNumber == 10) {
102 // Version 10.x actually uses 9.10 in project files!
103 intelVersion = "9.10";
105 // Version <= 9: use ProductVersion from registry.
107 this->IntelProjectVersion = intelVersion;
109 return this->IntelProjectVersion;
112 void cmGlobalVisualStudio7Generator::EnableLanguage(
113 std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
115 mf->AddDefinition("CMAKE_GENERATOR_RC", "rc");
116 mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
117 mf->InitCMAKE_CONFIGURATION_TYPES("Debug;Release;MinSizeRel;RelWithDebInfo");
119 // Create list of configurations requested by user's cache, if any.
120 this->cmGlobalVisualStudioGenerator::EnableLanguage(lang, mf, optional);
122 // if this environment variable is set, then copy it to
123 // a static cache entry. It will be used by
124 // cmLocalGenerator::ConstructScript, to add an extra PATH
125 // to all custom commands. This is because the VS IDE
126 // does not use the environment it is run in, and this allows
127 // for running commands and using dll's that the IDE environment
128 // does not know about.
129 std::string extraPath;
130 if (cmSystemTools::GetEnv("CMAKE_MSVCIDE_RUN_PATH", extraPath)) {
131 mf->AddCacheDefinition("CMAKE_MSVCIDE_RUN_PATH", extraPath,
132 "Saved environment variable CMAKE_MSVCIDE_RUN_PATH",
133 cmStateEnums::STATIC);
137 bool cmGlobalVisualStudio7Generator::FindMakeProgram(cmMakefile* mf)
139 if (!this->cmGlobalVisualStudioGenerator::FindMakeProgram(mf)) {
142 mf->AddDefinition("CMAKE_VS_DEVENV_COMMAND", this->GetDevEnvCommand());
146 std::string const& cmGlobalVisualStudio7Generator::GetDevEnvCommand()
148 if (!this->DevEnvCommandInitialized) {
149 this->DevEnvCommandInitialized = true;
150 this->DevEnvCommand = this->FindDevEnvCommand();
152 return this->DevEnvCommand;
155 std::string cmGlobalVisualStudio7Generator::FindDevEnvCommand()
160 // Search in standard location.
161 vskey = this->GetRegistryBase() + ";InstallDir";
162 if (cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd,
163 cmSystemTools::KeyWOW64_32)) {
164 cmSystemTools::ConvertToUnixSlashes(vscmd);
165 vscmd += "/devenv.com";
166 if (cmSystemTools::FileExists(vscmd, true)) {
171 // Search where VS15Preview places it.
173 "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;",
174 this->GetIDEVersion());
175 if (cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd,
176 cmSystemTools::KeyWOW64_32)) {
177 cmSystemTools::ConvertToUnixSlashes(vscmd);
178 vscmd += "/Common7/IDE/devenv.com";
179 if (cmSystemTools::FileExists(vscmd, true)) {
184 vscmd = "devenv.com";
188 const char* cmGlobalVisualStudio7Generator::ExternalProjectType(
189 const std::string& location)
191 std::string extension = cmSystemTools::GetFilenameLastExtension(location);
192 if (extension == ".vbproj") {
193 return "F184B08F-C81C-45F6-A57F-5ABD9991F28F";
194 } else if (extension == ".csproj") {
195 return "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC";
196 } else if (extension == ".fsproj") {
197 return "F2A71F9B-5D33-465A-A702-920D77279786";
198 } else if (extension == ".vdproj") {
199 return "54435603-DBB4-11D2-8724-00A0C9A8B90C";
200 } else if (extension == ".dbproj") {
201 return "C8D11400-126E-41CD-887F-60BD40844F9E";
202 } else if (extension == ".wixproj") {
203 return "930C7802-8A8C-48F9-8165-68863BCCD9DD";
204 } else if (extension == ".pyproj") {
205 return "888888A0-9F3D-457C-B088-3A5042F75D52";
207 return "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942";
210 std::vector<cmGlobalGenerator::GeneratedMakeCommand>
211 cmGlobalVisualStudio7Generator::GenerateBuildCommand(
212 const std::string& makeProgram, const std::string& projectName,
213 const std::string& /*projectDir*/,
214 std::vector<std::string> const& targetNames, const std::string& config,
215 int /*jobs*/, bool /*verbose*/, const cmBuildOptions& /*buildOptions*/,
216 std::vector<std::string> const& makeOptions)
218 // Select the caller- or user-preferred make program, else devenv.
219 std::string makeProgramSelected =
220 this->SelectMakeProgram(makeProgram, this->GetDevEnvCommand());
222 // Ignore the above preference if it is msbuild.
223 // Assume any other value is either a devenv or
224 // command-line compatible with devenv.
225 std::string makeProgramLower = makeProgramSelected;
226 cmSystemTools::LowerCase(makeProgramLower);
227 if (makeProgramLower.find("msbuild") != std::string::npos) {
228 makeProgramSelected = this->GetDevEnvCommand();
231 // Workaround to convince VCExpress.exe to produce output.
232 const bool requiresOutputForward =
233 (makeProgramLower.find("vcexpress") != std::string::npos);
234 std::vector<GeneratedMakeCommand> makeCommands;
236 std::vector<std::string> realTargetNames = targetNames;
237 if (targetNames.empty() ||
238 ((targetNames.size() == 1) && targetNames.front().empty())) {
239 realTargetNames = { "ALL_BUILD" };
241 for (const auto& tname : realTargetNames) {
242 std::string realTarget;
243 if (!tname.empty()) {
249 if (realTarget == "clean") {
251 realTarget = "ALL_BUILD";
253 GeneratedMakeCommand makeCommand;
254 makeCommand.RequiresOutputForward = requiresOutputForward;
255 makeCommand.Add(makeProgramSelected);
256 makeCommand.Add(projectName + ".sln");
257 makeCommand.Add((clean ? "/clean" : "/build"));
258 makeCommand.Add((config.empty() ? "Debug" : config));
259 makeCommand.Add("/project");
260 makeCommand.Add(realTarget);
261 makeCommand.Add(makeOptions.begin(), makeOptions.end());
262 makeCommands.emplace_back(std::move(makeCommand));
267 //! Create a local generator appropriate to this Global Generator
268 std::unique_ptr<cmLocalGenerator>
269 cmGlobalVisualStudio7Generator::CreateLocalGenerator(cmMakefile* mf)
271 auto lg = cm::make_unique<cmLocalVisualStudio7Generator>(this, mf);
272 return std::unique_ptr<cmLocalGenerator>(std::move(lg));
275 #if !defined(CMAKE_BOOTSTRAP)
276 Json::Value cmGlobalVisualStudio7Generator::GetJson() const
278 Json::Value generator = this->cmGlobalVisualStudioGenerator::GetJson();
279 generator["platform"] = this->GetPlatformName();
284 bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s,
287 mf->AddDefinition("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION",
288 this->GetIntelProjectVersion());
289 return this->cmGlobalVisualStudioGenerator::SetSystemName(s, mf);
292 void cmGlobalVisualStudio7Generator::Generate()
294 // first do the superclass method
295 this->cmGlobalVisualStudioGenerator::Generate();
297 // Now write out the DSW
298 this->OutputSLNFile();
299 // If any solution or project files changed during the generation,
300 // tell Visual Studio to reload them...
301 if (!cmSystemTools::GetErrorOccurredFlag() &&
302 !this->LocalGenerators.empty()) {
303 this->CallVisualStudioMacro(MacroReload,
304 GetSLNFile(this->LocalGenerators[0].get()));
307 if (this->Version == VSVersion::VS11 &&
308 !this->CMakeInstance->GetIsInTryCompile()) {
309 std::string cmakeWarnVS11;
310 if (cmValue cached = this->CMakeInstance->GetState()->GetCacheEntryValue(
311 "CMAKE_WARN_VS11")) {
312 this->CMakeInstance->MarkCliAsUsed("CMAKE_WARN_VS11");
313 cmakeWarnVS11 = *cached;
315 cmSystemTools::GetEnv("CMAKE_WARN_VS11", cmakeWarnVS11);
317 if (cmakeWarnVS11.empty() || !cmIsOff(cmakeWarnVS11)) {
318 this->CMakeInstance->IssueMessage(
319 MessageType::WARNING,
320 "The \"Visual Studio 11 2012\" generator is deprecated "
321 "and will be removed in a future version of CMake."
323 "Add CMAKE_WARN_VS11=OFF to the cache to disable this warning.");
328 void cmGlobalVisualStudio7Generator::OutputSLNFile(
329 cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
331 if (generators.empty()) {
334 this->CurrentProject = root->GetProjectName();
335 std::string fname = GetSLNFile(root);
336 cmGeneratedFileStream fout(fname.c_str());
337 fout.SetCopyIfDifferent(true);
341 this->WriteSLNFile(fout, root, generators);
343 this->FileReplacedDuringGenerate(fname);
347 // output the SLN file
348 void cmGlobalVisualStudio7Generator::OutputSLNFile()
350 for (auto& it : this->ProjectMap) {
351 this->OutputSLNFile(it.second[0], it.second);
355 void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
356 std::ostream& fout, std::vector<std::string> const& configs,
357 OrderedTargetDependSet const& projectTargets)
359 // loop over again and write out configurations for each target
361 for (cmGeneratorTarget const* target : projectTargets) {
362 if (!this->IsInSolution(target)) {
365 cmValue expath = target->GetProperty("EXTERNAL_MSPROJECT");
367 std::set<std::string> allConfigurations(configs.begin(), configs.end());
368 cmValue mapping = target->GetProperty("VS_PLATFORM_MAPPING");
369 this->WriteProjectConfigurations(fout, target->GetName(), *target,
370 configs, allConfigurations,
371 mapping ? *mapping : "");
373 const std::set<std::string>& configsPartOfDefaultBuild =
374 this->IsPartOfDefaultBuild(configs, projectTargets, target);
375 cmValue vcprojName = target->GetProperty("GENERATOR_FILE_NAME");
379 // On VS 19 and above, always map .NET SDK projects to "Any CPU".
380 if (target->IsDotNetSdkTarget() &&
381 this->GetVersion() >= VSVersion::VS16 &&
382 !this->IsReservedTarget(target->GetName())) {
385 this->WriteProjectConfigurations(fout, *vcprojName, *target, configs,
386 configsPartOfDefaultBuild, mapping);
392 void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
393 std::ostream& fout, cmLocalGenerator* root,
394 OrderedTargetDependSet const& projectTargets)
396 VisualStudioFolders.clear();
398 std::vector<std::string> configs =
399 root->GetMakefile()->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig);
401 for (cmGeneratorTarget const* target : projectTargets) {
402 if (!this->IsInSolution(target)) {
405 bool written = false;
407 for (auto const& c : configs) {
408 target->CheckCxxModuleStatus(c);
411 if (target->HaveCxx20ModuleSources() && !this->SupportsCxxModuleDyndep()) {
412 root->GetMakefile()->IssueMessage(
413 MessageType::FATAL_ERROR,
414 cmStrCat("The \"", target->GetName(),
415 "\" target contains C++ module sources which are not "
416 "supported by the generator"));
419 // handle external vc project files
420 cmValue expath = target->GetProperty("EXTERNAL_MSPROJECT");
422 std::string project = target->GetName();
423 std::string location = *expath;
425 this->WriteExternalProject(fout, project, location,
426 target->GetProperty("VS_PROJECT_TYPE"),
427 target->GetUtilities());
430 cmValue vcprojName = target->GetProperty("GENERATOR_FILE_NAME");
432 cmLocalGenerator* lg = target->GetLocalGenerator();
433 std::string dir = lg->GetCurrentBinaryDirectory();
434 dir = root->MaybeRelativeToCurBinDir(dir);
436 dir.clear(); // msbuild cannot handle ".\" prefix
438 this->WriteProject(fout, *vcprojName, dir, target);
443 // Create "solution folder" information from FOLDER target property
445 if (written && this->UseFolderProperty()) {
446 const std::string targetFolder = target->GetEffectiveFolderName();
447 if (!targetFolder.empty()) {
448 std::vector<std::string> tokens =
449 cmSystemTools::SplitString(targetFolder, '/', false);
451 std::string cumulativePath;
453 for (std::string const& iter : tokens) {
458 if (cumulativePath.empty()) {
459 cumulativePath = "CMAKE_FOLDER_GUID_" + iter;
461 VisualStudioFolders[cumulativePath].insert(cumulativePath + "/" +
464 cumulativePath = cumulativePath + "/" + iter;
468 if (!cumulativePath.empty()) {
469 VisualStudioFolders[cumulativePath].insert(target->GetName());
476 void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout)
478 cm::string_view const prefix = "CMAKE_FOLDER_GUID_";
479 std::string guidProjectTypeFolder = "2150E333-8FDC-42A3-9474-1A3956D46DE8";
480 for (auto const& iter : VisualStudioFolders) {
481 std::string fullName = iter.first;
482 std::string guid = this->GetGUID(fullName);
484 std::replace(fullName.begin(), fullName.end(), '/', '\\');
485 if (cmHasPrefix(fullName, prefix)) {
486 fullName = fullName.substr(prefix.size());
489 std::string nameOnly = cmSystemTools::GetFilenameName(fullName);
491 fout << "Project(\"{" << guidProjectTypeFolder << "}\") = \"" << nameOnly
492 << "\", \"" << fullName << "\", \"{" << guid << "}\"\nEndProject\n";
496 void cmGlobalVisualStudio7Generator::WriteFoldersContent(std::ostream& fout)
498 for (auto const& iter : VisualStudioFolders) {
499 std::string key(iter.first);
500 std::string guidParent(this->GetGUID(key));
502 for (std::string const& it : iter.second) {
503 std::string value(it);
504 std::string guid(this->GetGUID(value));
506 fout << "\t\t{" << guid << "} = {" << guidParent << "}\n";
511 std::string cmGlobalVisualStudio7Generator::ConvertToSolutionPath(
512 const std::string& path)
514 // Convert to backslashes. Do not use ConvertToOutputPath because
515 // we will add quoting ourselves, and we know these projects always
516 // use windows slashes.
517 std::string d = path;
518 std::string::size_type pos = 0;
519 while ((pos = d.find('/', pos)) != d.npos) {
525 void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections(
526 std::ostream& fout, cmLocalGenerator* root)
528 std::string const guid = this->GetGUID(root->GetProjectName() + ".sln");
529 bool extensibilityGlobalsOverridden = false;
530 bool extensibilityAddInsOverridden = false;
531 const std::vector<std::string> propKeys =
532 root->GetMakefile()->GetPropertyKeys();
533 for (std::string const& it : propKeys) {
534 if (cmHasLiteralPrefix(it, "VS_GLOBAL_SECTION_")) {
535 std::string sectionType;
536 std::string name = it.substr(18);
537 if (cmHasLiteralPrefix(name, "PRE_")) {
538 name = name.substr(4);
539 sectionType = "preSolution";
540 } else if (cmHasLiteralPrefix(name, "POST_")) {
541 name = name.substr(5);
542 sectionType = "postSolution";
546 bool addGuid = false;
547 if (name == "ExtensibilityGlobals" && sectionType == "postSolution") {
549 extensibilityGlobalsOverridden = true;
550 } else if (name == "ExtensibilityAddIns" &&
551 sectionType == "postSolution") {
552 extensibilityAddInsOverridden = true;
554 fout << "\tGlobalSection(" << name << ") = " << sectionType << "\n";
555 cmValue p = root->GetMakefile()->GetProperty(it);
556 std::vector<std::string> keyValuePairs = cmExpandedList(p ? *p : "");
557 for (std::string const& itPair : keyValuePairs) {
558 const std::string::size_type posEqual = itPair.find('=');
559 if (posEqual != std::string::npos) {
560 const std::string key =
561 cmTrimWhitespace(itPair.substr(0, posEqual));
562 const std::string value =
563 cmTrimWhitespace(itPair.substr(posEqual + 1));
564 fout << "\t\t" << key << " = " << value << "\n";
565 if (key == "SolutionGuid") {
571 fout << "\t\tSolutionGuid = {" << guid << "}\n";
573 fout << "\tEndGlobalSection\n";
577 if (!extensibilityGlobalsOverridden) {
578 fout << "\tGlobalSection(ExtensibilityGlobals) = postSolution\n"
579 << "\t\tSolutionGuid = {" << guid << "}\n"
580 << "\tEndGlobalSection\n";
582 if (!extensibilityAddInsOverridden)
583 fout << "\tGlobalSection(ExtensibilityAddIns) = postSolution\n"
584 << "\tEndGlobalSection\n";
587 // Standard end of dsw file
588 void cmGlobalVisualStudio7Generator::WriteSLNFooter(std::ostream& fout)
590 fout << "EndGlobal\n";
593 std::string cmGlobalVisualStudio7Generator::WriteUtilityDepend(
594 cmGeneratorTarget const* target)
596 std::vector<std::string> configs =
597 target->Target->GetMakefile()->GetGeneratorConfigs(
598 cmMakefile::ExcludeEmptyConfig);
599 std::string pname = cmStrCat(target->GetName(), "_UTILITY");
601 cmStrCat(target->GetLocalGenerator()->GetCurrentBinaryDirectory(), '/',
603 cmGeneratedFileStream fout(fname.c_str());
604 fout.SetCopyIfDifferent(true);
605 std::string guid = this->GetGUID(pname.c_str());
607 /* clang-format off */
609 "<?xml version=\"1.0\" encoding = \""
610 << this->Encoding() << "\"?>\n"
611 "<VisualStudioProject\n"
612 "\tProjectType=\"Visual C++\"\n"
613 "\tVersion=\"" << this->GetIDEVersion() << "0\"\n"
614 "\tName=\"" << pname << "\"\n"
615 "\tProjectGUID=\"{" << guid << "}\"\n"
616 "\tKeyword=\"Win32Proj\">\n"
617 "\t<Platforms><Platform Name=\"Win32\"/></Platforms>\n"
618 "\t<Configurations>\n"
620 /* clang-format on */
621 for (std::string const& i : configs) {
622 /* clang-format off */
624 "\t\t<Configuration\n"
625 "\t\t\tName=\"" << i << "|Win32\"\n"
626 "\t\t\tOutputDirectory=\"" << i << "\"\n"
627 "\t\t\tIntermediateDirectory=\"" << pname << ".dir\\" << i << "\"\n"
628 "\t\t\tConfigurationType=\"10\"\n"
629 "\t\t\tUseOfMFC=\"0\"\n"
630 "\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n"
631 "\t\t\tCharacterSet=\"2\">\n"
632 "\t\t</Configuration>\n"
634 /* clang-format on */
636 /* clang-format off */
638 "\t</Configurations>\n"
639 "\t<Files></Files>\n"
640 "\t<Globals></Globals>\n"
641 "</VisualStudioProject>\n"
643 /* clang-format on */
646 this->FileReplacedDuringGenerate(fname);
651 std::string cmGlobalVisualStudio7Generator::GetGUID(std::string const& name)
653 std::string const& guidStoreName = name + "_GUID_CMAKE";
654 if (cmValue storedGUID =
655 this->CMakeInstance->GetCacheDefinition(guidStoreName)) {
658 // Compute a GUID that is deterministic but unique to the build tree.
660 cmStrCat(this->CMakeInstance->GetState()->GetBinaryDirectory(), '|', name);
662 cmUuid uuidGenerator;
664 std::vector<unsigned char> uuidNamespace;
665 uuidGenerator.StringToBinary("ee30c4be-5192-4fb0-b335-722a2dffe760",
668 std::string guid = uuidGenerator.FromMd5(uuidNamespace, input);
670 return cmSystemTools::UpperCase(guid);
673 void cmGlobalVisualStudio7Generator::AppendDirectoryForConfig(
674 const std::string& prefix, const std::string& config,
675 const std::string& suffix, std::string& dir)
677 if (!config.empty()) {
684 std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
685 std::vector<std::string> const& configs,
686 OrderedTargetDependSet const& projectTargets,
687 cmGeneratorTarget const* target)
689 std::set<std::string> activeConfigs;
690 // if it is a utilitiy target then only make it part of the
691 // default build if another target depends on it
692 int type = target->GetType();
693 if (type == cmStateEnums::GLOBAL_TARGET) {
694 std::vector<std::string> targetNames;
695 targetNames.push_back("INSTALL");
696 targetNames.push_back("PACKAGE");
697 for (std::string const& t : targetNames) {
698 // check if target <t> is part of default build
699 if (target->GetName() == t) {
700 const std::string propertyName =
701 "CMAKE_VS_INCLUDE_" + t + "_TO_DEFAULT_BUILD";
702 // inspect CMAKE_VS_INCLUDE_<t>_TO_DEFAULT_BUILD properties
703 for (std::string const& i : configs) {
704 cmValue propertyValue =
705 target->Target->GetMakefile()->GetDefinition(propertyName);
707 cmIsOn(cmGeneratorExpression::Evaluate(
708 *propertyValue, target->GetLocalGenerator(), i))) {
709 activeConfigs.insert(i);
714 return activeConfigs;
716 if (type == cmStateEnums::UTILITY &&
717 !this->IsDependedOn(projectTargets, target)) {
718 return activeConfigs;
720 // inspect EXCLUDE_FROM_DEFAULT_BUILD[_<CONFIG>] properties
721 for (std::string const& i : configs) {
722 if (cmIsOff(target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i))) {
723 activeConfigs.insert(i);
726 return activeConfigs;
729 bool cmGlobalVisualStudio7Generator::IsDependedOn(
730 OrderedTargetDependSet const& projectTargets, cmGeneratorTarget const* gtIn)
732 for (cmTargetDepend const& l : projectTargets) {
733 TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(l);
734 if (tgtdeps.count(gtIn)) {
741 std::string cmGlobalVisualStudio7Generator::Encoding()