diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2008-01-30 17:04:38 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2008-01-30 17:04:38 (GMT) |
commit | 8a83f096371ecc4f73afe43830e94899c704d5cf (patch) | |
tree | e035e45d661fcc35189daafa686484577b502ddc /Source/cmGlobalVisualStudio71Generator.cxx | |
parent | 21e6791789be947c471d0c551e69364e9f475b7e (diff) | |
download | CMake-8a83f096371ecc4f73afe43830e94899c704d5cf.zip CMake-8a83f096371ecc4f73afe43830e94899c704d5cf.tar.gz CMake-8a83f096371ecc4f73afe43830e94899c704d5cf.tar.bz2 |
ENH: fix for bug 3218 dependant projects are written out automatically if they are in the project. Also fix bug 5829, remove hard coded CMAKE_CONFIGURATION_TYPES from vs 7 generator
Diffstat (limited to 'Source/cmGlobalVisualStudio71Generator.cxx')
-rw-r--r-- | Source/cmGlobalVisualStudio71Generator.cxx | 231 |
1 files changed, 20 insertions, 211 deletions
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 48efee1..26a095e 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -45,228 +45,34 @@ void cmGlobalVisualStudio71Generator::AddPlatformDefinitions(cmMakefile* mf) mf->AddDefinition("MSVC71", "1"); } -// Write a SLN file to the stream + void cmGlobalVisualStudio71Generator ::WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators) -{ +{ // Write out the header for a SLN file this->WriteSLNHeader(fout); - // Get the start directory with the trailing slash - std::string rootdir = root->GetMakefile()->GetStartOutputDirectory(); - rootdir += "/"; - bool doneAllBuild = false; - bool doneCheckBuild = false; - bool doneRunTests = false; - bool doneInstall = false; - bool doneEditCache = false; - bool doneRebuildCache = false; - bool donePackage = false; - - // For each cmMakefile, create a VCProj for it, and - // add it to this SLN file - unsigned int i; - for(i = 0; i < generators.size(); ++i) - { - if(this->IsExcluded(root, generators[i])) - { - continue; - } - cmMakefile* mf = generators[i]->GetMakefile(); - - // Get the source directory from the makefile - std::string dir = mf->GetStartOutputDirectory(); - // remove the home directory and / from the source directory - // this gives a relative path - cmSystemTools::ReplaceString(dir, rootdir.c_str(), ""); - - // Get the list of create dsp files names from the cmVCProjWriter, more - // than one dsp could have been created per input CMakeLists.txt file - // for each target - cmTargets &tgts = generators[i]->GetMakefile()->GetTargets(); - cmTargets::iterator l = tgts.begin(); - for(; l != tgts.end(); ++l) - { - // special handling for the current makefile - if(mf == generators[0]->GetMakefile()) - { - dir = "."; // no subdirectory for project generated - // if this is the special ALL_BUILD utility, then - // make it depend on every other non UTILITY project. - // This is done by adding the names to the GetUtilities - // vector on the makefile - if(l->first == "ALL_BUILD" && !doneAllBuild) - { - unsigned int j; - for(j = 0; j < generators.size(); ++j) - { - cmTargets &atgts = generators[j]->GetMakefile()->GetTargets(); - for(cmTargets::iterator al = atgts.begin(); - al != atgts.end(); ++al) - { - if (!al->second.GetPropertyAsBool("EXCLUDE_FROM_ALL")) - { - if (al->second.GetType() == cmTarget::UTILITY || - al->second.GetType() == cmTarget::GLOBAL_TARGET) - { - l->second.AddUtility(al->first.c_str()); - } - else - { - l->second.AddLinkLibrary(al->first,cmTarget::GENERAL); - } - } - } - } - } - } - // Write the project into the SLN file - if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0) - { - cmCustomCommand cc = l->second.GetPostBuildCommands()[0]; - const cmCustomCommandLines& cmds = cc.GetCommandLines(); - std::string project = cmds[0][0]; - std::string location = cmds[0][1]; - this->WriteExternalProject(fout, project.c_str(), - location.c_str(), cc.GetDepends()); - } - else - { - bool skip = false; - if(l->first == "ALL_BUILD" ) - { - if(doneAllBuild) - { - skip = true; - } - else - { - doneAllBuild = true; - } - } - if(l->first == CMAKE_CHECK_BUILD_SYSTEM_TARGET) - { - if(doneCheckBuild) - { - skip = true; - } - else - { - doneCheckBuild = true; - } - } - if(l->first == "INSTALL") - { - if(doneInstall) - { - skip = true; - } - else - { - doneInstall = true; - } - } - if(l->first == "RUN_TESTS") - { - if(doneRunTests) - { - skip = true; - } - else - { - doneRunTests = true; - } - } - if(l->first == "EDIT_CACHE") - { - if(doneEditCache) - { - skip = true; - } - else - { - doneEditCache = true; - } - } - if(l->first == "REBUILD_CACHE") - { - if(doneRebuildCache) - { - skip = true; - } - else - { - doneRebuildCache = true; - } - } - if(l->first == "PACKAGE") - { - if(donePackage) - { - skip = true; - } - else - { - donePackage = true; - } - } - if(!skip) - { - const char *dspname = - l->second.GetProperty("GENERATOR_FILE_NAME"); - if (dspname) - { - this->WriteProject(fout, dspname, dir.c_str(),l->second); - } - } - } - } - } + // collect the set of targets for this project by + // tracing depends of all targets. + // also collect the set of targets that are explicitly + // in this project. + cmGlobalGenerator::TargetDependSet projectTargets; + cmGlobalGenerator::TargetDependSet originalTargets; + this->GetTargetSets(projectTargets, + originalTargets, + root, generators); + this->WriteTargetsToSolution(fout, root, projectTargets, originalTargets); + // Write out the configurations information for the solution fout << "Global\n"; + // Write out the configurations for the solution this->WriteSolutionConfigurations(fout); fout << "\tGlobalSection(" << this->ProjectConfigurationSectionName << ") = postSolution\n"; - // loop over again and compute the depends - for(i = 0; i < generators.size(); ++i) - { - cmMakefile* mf = generators[i]->GetMakefile(); - cmLocalVisualStudio7Generator* pg = - static_cast<cmLocalVisualStudio7Generator*>(generators[i]); - // Get the list of create dsp files names from the cmVCProjWriter, more - // than one dsp could have been created per input CMakeLists.txt file - // for each target - cmTargets &tgts = pg->GetMakefile()->GetTargets(); - cmTargets::iterator l = tgts.begin(); - std::string dir = mf->GetStartDirectory(); - for(; l != tgts.end(); ++l) - { - if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0) - { - cmCustomCommand cc = l->second.GetPostBuildCommands()[0]; - const cmCustomCommandLines& cmds = cc.GetCommandLines(); - std::string project = cmds[0][0]; - this->WriteProjectConfigurations(fout, project.c_str(), - true); - } - else - { - bool partOfDefaultBuild = this->IsPartOfDefaultBuild( - root->GetMakefile()->GetProjectName(), - &l->second); - const char *dspname = - l->second.GetProperty("GENERATOR_FILE_NAME"); - if (dspname) - { - this->WriteProjectConfigurations(fout, dspname, - partOfDefaultBuild); - } - } - } - } + // Write out the configurations for all the targets in the project + this->WriteTargetConfigurations(fout, root, projectTargets); fout << "\tEndGlobalSection\n"; - // Write the footer for the SLN file this->WriteSLNFooter(fout); } @@ -338,7 +144,9 @@ cmGlobalVisualStudio71Generator if(j->first != dspname) { // is the library part of this SLN ? If so add dependency - if(this->FindTarget(this->CurrentProject.c_str(), j->first.c_str())) + // find target anywhere because all depend libraries are + // brought in as well + if(this->FindTarget(0, j->first.c_str())) { fout << "\t\t{" << this->GetGUID(j->first.c_str()) << "} = {" << this->GetGUID(j->first.c_str()) << "}\n"; @@ -379,6 +187,7 @@ void cmGlobalVisualStudio71Generator const char* location, const std::vector<std::string>& depends) { + std::cout << "WriteExternalProject vs71\n"; fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" << name << "\", \"" << this->ConvertToSolutionPath(location) << "\", \"{" |