mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 10:50:16 -06:00
cmLocalVisualStudio7Generator: Consolidate target iteration
Combine iteration with `cmLocalVisualStudio10Generator` and dispatch generation of each target with a virtual `GenerateTarget` method.
This commit is contained in:
@@ -68,9 +68,6 @@ cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator()
|
||||
|
||||
void cmLocalVisualStudio10Generator::GenerateTarget(cmGeneratorTarget* target)
|
||||
{
|
||||
if (!target->IsInBuildSystem()) {
|
||||
return;
|
||||
}
|
||||
auto& targetVisited = this->GetSourcesVisited(target);
|
||||
auto& deps = this->GlobalGenerator->GetTargetDirectDepends(target);
|
||||
for (auto& d : deps) {
|
||||
@@ -80,7 +77,7 @@ void cmLocalVisualStudio10Generator::GenerateTarget(cmGeneratorTarget* target)
|
||||
}
|
||||
if (static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
|
||||
->TargetIsFortranOnly(target)) {
|
||||
this->CreateSingleVCProj(target->GetName(), target);
|
||||
this->cmLocalVisualStudio7Generator::GenerateTarget(target);
|
||||
} else {
|
||||
cmVisualStudio10TargetGenerator tg(
|
||||
target,
|
||||
@@ -90,15 +87,6 @@ void cmLocalVisualStudio10Generator::GenerateTarget(cmGeneratorTarget* target)
|
||||
}
|
||||
}
|
||||
|
||||
void cmLocalVisualStudio10Generator::Generate()
|
||||
{
|
||||
for (cmGeneratorTarget* gt :
|
||||
this->GlobalGenerator->GetLocalGeneratorTargetsInOrder(this)) {
|
||||
this->GenerateTarget(gt);
|
||||
}
|
||||
this->WriteStampFiles();
|
||||
}
|
||||
|
||||
void cmLocalVisualStudio10Generator::ReadAndStoreExternalGUID(
|
||||
const std::string& name, const char* path)
|
||||
{
|
||||
|
||||
@@ -25,10 +25,6 @@ public:
|
||||
|
||||
virtual ~cmLocalVisualStudio10Generator();
|
||||
|
||||
/**
|
||||
* Generate the makefile for this directory.
|
||||
*/
|
||||
void Generate() override;
|
||||
void ReadAndStoreExternalGUID(const std::string& name,
|
||||
const char* path) override;
|
||||
|
||||
@@ -43,7 +39,7 @@ protected:
|
||||
bool CustomCommandUseLocal() const override { return true; }
|
||||
|
||||
private:
|
||||
void GenerateTarget(cmGeneratorTarget* target);
|
||||
void GenerateTarget(cmGeneratorTarget* target) override;
|
||||
|
||||
std::map<cmGeneratorTarget const*, std::set<cmSourceFile const*>>
|
||||
SourcesVisited;
|
||||
|
||||
@@ -80,7 +80,15 @@ void cmLocalVisualStudio7Generator::AddHelperCommands()
|
||||
|
||||
void cmLocalVisualStudio7Generator::Generate()
|
||||
{
|
||||
this->WriteProjectFiles();
|
||||
// Create the project file for each target.
|
||||
for (cmGeneratorTarget* gt :
|
||||
this->GlobalGenerator->GetLocalGeneratorTargetsInOrder(this)) {
|
||||
if (!gt->IsInBuildSystem() || gt->GetProperty("EXTERNAL_MSPROJECT")) {
|
||||
continue;
|
||||
}
|
||||
this->GenerateTarget(gt);
|
||||
}
|
||||
|
||||
this->WriteStampFiles();
|
||||
}
|
||||
|
||||
@@ -111,36 +119,6 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
// for CommandLine= need to repleace quotes with "
|
||||
// write out configurations
|
||||
void cmLocalVisualStudio7Generator::WriteProjectFiles()
|
||||
{
|
||||
// If not an in source build, then create the output directory
|
||||
if (this->GetCurrentBinaryDirectory() != this->GetSourceDirectory()) {
|
||||
if (!cmSystemTools::MakeDirectory(this->GetCurrentBinaryDirectory())) {
|
||||
cmSystemTools::Error("Error creating directory " +
|
||||
this->GetCurrentBinaryDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
// Get the set of targets in this directory.
|
||||
const auto& tgts =
|
||||
this->GlobalGenerator->GetLocalGeneratorTargetsInOrder(this);
|
||||
|
||||
// Create the project file for each target.
|
||||
for (const auto& l : tgts) {
|
||||
if (!l->IsInBuildSystem()) {
|
||||
continue;
|
||||
}
|
||||
// INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
|
||||
// so don't build a projectfile for it
|
||||
if (!l->GetProperty("EXTERNAL_MSPROJECT")) {
|
||||
this->CreateSingleVCProj(l->GetName(), l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cmLocalVisualStudio7Generator::WriteStampFiles()
|
||||
{
|
||||
// Touch a timestamp file used to determine when the project file is
|
||||
@@ -179,9 +157,9 @@ void cmLocalVisualStudio7Generator::WriteStampFiles()
|
||||
}
|
||||
}
|
||||
|
||||
void cmLocalVisualStudio7Generator::CreateSingleVCProj(
|
||||
const std::string& lname, cmGeneratorTarget* target)
|
||||
void cmLocalVisualStudio7Generator::GenerateTarget(cmGeneratorTarget* target)
|
||||
{
|
||||
std::string const& lname = target->GetName();
|
||||
cmGlobalVisualStudioGenerator* gg =
|
||||
static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator);
|
||||
this->FortranProject = gg->TargetIsFortranOnly(target);
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
const char* path);
|
||||
|
||||
protected:
|
||||
void CreateSingleVCProj(const std::string& lname, cmGeneratorTarget* tgt);
|
||||
virtual void GenerateTarget(cmGeneratorTarget* target);
|
||||
|
||||
private:
|
||||
using Options = cmVS7GeneratorOptions;
|
||||
@@ -92,7 +92,6 @@ private:
|
||||
std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
|
||||
const std::string& configName);
|
||||
void FixGlobalTargets();
|
||||
void WriteProjectFiles();
|
||||
void WriteVCProjHeader(std::ostream& fout, const std::string& libName,
|
||||
cmGeneratorTarget* tgt,
|
||||
std::vector<cmSourceGroup>& sgs);
|
||||
|
||||
@@ -314,10 +314,6 @@ std::ostream& cmVisualStudio10TargetGenerator::Elem::WriteString(
|
||||
|
||||
void cmVisualStudio10TargetGenerator::Generate()
|
||||
{
|
||||
// do not generate external ms projects
|
||||
if (this->GeneratorTarget->GetProperty("EXTERNAL_MSPROJECT")) {
|
||||
return;
|
||||
}
|
||||
const std::string ProjectFileExtension =
|
||||
computeProjectFileExtension(this->GeneratorTarget);
|
||||
if (ProjectFileExtension == ".vcxproj") {
|
||||
|
||||
Reference in New Issue
Block a user