VS: Cleanup AddPlatformDefinitions() of Visual Studio generators

Move adding of definitions into cmGlobalVisualStudioGenerator to
share code and avoid duplicate architecture string literals.
This commit is contained in:
Patrick Gansterer 2012-07-21 15:37:46 +02:00 committed by Brad King
parent addefc2ae3
commit 2c7a451de0
21 changed files with 43 additions and 78 deletions

View File

@ -19,6 +19,7 @@
cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator()
{
this->VersionId = "MSVC10";
this->FindMakeProgramFile = "CMakeVS10FindMake.cmake";
std::string vc10Express;
this->ExpressEdition = cmSystemTools::ReadRegistryValue(
@ -26,14 +27,6 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator()
"ProductDir", vc10Express, cmSystemTools::KeyWOW64_32);
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf)
{
mf->AddDefinition("MSVC10", "1");
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86");
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86");
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
{

View File

@ -38,7 +38,6 @@ public:
virtual const char* GetName() const {
return cmGlobalVisualStudio10Generator::GetActualName();}
static const char* GetActualName() {return "Visual Studio 10";}
virtual void AddPlatformDefinitions(cmMakefile* mf);
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry) const;

View File

@ -16,6 +16,7 @@
//----------------------------------------------------------------------------
cmGlobalVisualStudio10IA64Generator::cmGlobalVisualStudio10IA64Generator()
{
this->ArchitectureId = "x64";
}
//----------------------------------------------------------------------------
@ -33,8 +34,6 @@ void cmGlobalVisualStudio10IA64Generator
{
this->cmGlobalVisualStudio10Generator::AddPlatformDefinitions(mf);
mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE");
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "x64");
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "x64");
}
//----------------------------------------------------------------------------

View File

@ -16,6 +16,7 @@
//----------------------------------------------------------------------------
cmGlobalVisualStudio10Win64Generator::cmGlobalVisualStudio10Win64Generator()
{
this->ArchitectureId = "x64";
}
//----------------------------------------------------------------------------
@ -33,8 +34,6 @@ void cmGlobalVisualStudio10Win64Generator
{
this->cmGlobalVisualStudio10Generator::AddPlatformDefinitions(mf);
mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE");
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "x64");
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "x64");
}
//----------------------------------------------------------------------------

View File

@ -13,6 +13,12 @@
#include "cmMakefile.h"
#include "cmake.h"
//----------------------------------------------------------------------------
cmGlobalVisualStudio11ARMGenerator::cmGlobalVisualStudio11ARMGenerator()
{
this->ArchitectureId = "ARM";
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio11ARMGenerator
::GetDocumentation(cmDocumentationEntry& entry) const
@ -21,12 +27,3 @@ void cmGlobalVisualStudio11ARMGenerator
entry.Brief = "Generates Visual Studio 11 ARM project files.";
entry.Full = "";
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio11ARMGenerator
::AddPlatformDefinitions(cmMakefile* mf)
{
this->cmGlobalVisualStudio11Generator::AddPlatformDefinitions(mf);
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "ARM");
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "ARM");
}

View File

@ -18,7 +18,7 @@ class cmGlobalVisualStudio11ARMGenerator :
public cmGlobalVisualStudio11Generator
{
public:
cmGlobalVisualStudio11ARMGenerator() {}
cmGlobalVisualStudio11ARMGenerator();
static cmGlobalGenerator* New() {
return new cmGlobalVisualStudio11ARMGenerator; }
@ -31,7 +31,5 @@ public:
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry) const;
virtual void AddPlatformDefinitions(cmMakefile* mf);
};
#endif

View File

@ -16,19 +16,12 @@
//----------------------------------------------------------------------------
cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator()
{
this->VersionId = "MSVC11";
this->FindMakeProgramFile = "CMakeVS11FindMake.cmake";
this->ExpressEdition = false; // TODO: VS 11 Express support
this->PlatformToolset = "v110";
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio11Generator::AddPlatformDefinitions(cmMakefile* mf)
{
mf->AddDefinition("MSVC11", "1");
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86");
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86");
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout)
{

View File

@ -28,7 +28,6 @@ public:
virtual const char* GetName() const {
return cmGlobalVisualStudio11Generator::GetActualName();}
static const char* GetActualName() {return "Visual Studio 11";}
virtual void AddPlatformDefinitions(cmMakefile* mf);
virtual void WriteSLNHeader(std::ostream& fout);

View File

@ -13,6 +13,12 @@
#include "cmMakefile.h"
#include "cmake.h"
//----------------------------------------------------------------------------
cmGlobalVisualStudio11Win64Generator::cmGlobalVisualStudio11Win64Generator()
{
this->ArchitectureId = "x64";
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio11Win64Generator
::GetDocumentation(cmDocumentationEntry& entry) const
@ -28,6 +34,4 @@ void cmGlobalVisualStudio11Win64Generator
{
this->cmGlobalVisualStudio11Generator::AddPlatformDefinitions(mf);
mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE");
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "x64");
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "x64");
}

View File

@ -18,7 +18,7 @@ class cmGlobalVisualStudio11Win64Generator :
public cmGlobalVisualStudio11Generator
{
public:
cmGlobalVisualStudio11Win64Generator() {}
cmGlobalVisualStudio11Win64Generator();
static cmGlobalGenerator* New() {
return new cmGlobalVisualStudio11Win64Generator; }

View File

@ -32,6 +32,7 @@ std::string GetVS6TargetName(const std::string& targetName)
cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator()
{
this->VersionId = "MSVC60";
this->FindMakeProgramFile = "CMakeVS6FindMake.cmake";
}
@ -40,14 +41,12 @@ void cmGlobalVisualStudio6Generator
cmMakefile *mf,
bool optional)
{
cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf);
mf->AddDefinition("CMAKE_GENERATOR_CC", "cl");
mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl");
mf->AddDefinition("CMAKE_GENERATOR_RC", "rc");
mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
mf->AddDefinition("CMAKE_GENERATOR_Fortran", "ifort");
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86");
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86");
mf->AddDefinition("MSVC60", "1");
this->GenerateConfigurations(mf);
this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
}

View File

@ -18,6 +18,7 @@
//----------------------------------------------------------------------------
cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator()
{
this->VersionId = "MSVC71";
this->FindMakeProgramFile = "CMakeVS71FindMake.cmake";
this->ProjectConfigurationSectionName = "ProjectConfiguration";
}
@ -33,14 +34,6 @@ cmLocalGenerator *cmGlobalVisualStudio71Generator::CreateLocalGenerator()
return lg;
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio71Generator::AddPlatformDefinitions(cmMakefile* mf)
{
this->cmGlobalVisualStudio7Generator::AddPlatformDefinitions(mf);
mf->RemoveDefinition("MSVC70");
mf->AddDefinition("MSVC71", "1");
}
//----------------------------------------------------------------------------
std::string cmGlobalVisualStudio71Generator::GetUserMacrosDirectory()
{

View File

@ -53,7 +53,6 @@ public:
protected:
virtual const char* GetIDEVersion() { return "7.1"; }
virtual void AddPlatformDefinitions(cmMakefile* mf);
virtual void WriteSLNFile(std::ostream& fout,
cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);

View File

@ -18,6 +18,7 @@
cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator()
{
this->VersionId = "MSVC70";
this->FindMakeProgramFile = "CMakeVS7FindMake.cmake";
}
@ -55,13 +56,6 @@ void cmGlobalVisualStudio7Generator
}
void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf)
{
mf->AddDefinition("MSVC70", "1");
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86");
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86");
}
std::string cmGlobalVisualStudio7Generator
::GenerateBuildCommand(const char* makeProgram,
const char *projectName,

View File

@ -112,7 +112,6 @@ protected:
virtual void WriteSLNFooter(std::ostream& fout);
virtual void WriteSLNHeader(std::ostream& fout);
virtual std::string WriteUtilityDepend(cmTarget* target);
virtual void AddPlatformDefinitions(cmMakefile* mf);
virtual void WriteTargetsToSolution(
std::ostream& fout,

View File

@ -19,9 +19,9 @@
//----------------------------------------------------------------------------
cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator()
{
this->VersionId = "MSVC80";
this->FindMakeProgramFile = "CMakeVS8FindMake.cmake";
this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms";
this->ArchitectureId = "X86";
}
//----------------------------------------------------------------------------
@ -53,14 +53,6 @@ void cmGlobalVisualStudio8Generator
entry.Full = "";
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf)
{
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", this->ArchitectureId);
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", this->ArchitectureId);
mf->AddDefinition("MSVC80", "1");
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio8Generator::Configure()
{

View File

@ -72,7 +72,6 @@ protected:
void AddCheckTarget();
static cmIDEFlagTable const* GetExtraFlagTableVS8();
virtual void AddPlatformDefinitions(cmMakefile* mf);
virtual void WriteSLNHeader(std::ostream& fout);
virtual void WriteSolutionConfigurations(std::ostream& fout);
virtual void WriteProjectConfigurations(std::ostream& fout,
@ -82,7 +81,5 @@ protected:
virtual bool ComputeTargetDepends();
virtual void WriteProjectDepends(std::ostream& fout, const char* name,
const char* path, cmTarget &t);
const char* ArchitectureId;
};
#endif

View File

@ -19,17 +19,10 @@
cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator()
{
this->VersionId = "MSVC90";
this->FindMakeProgramFile = "CMakeVS9FindMake.cmake";
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio9Generator::AddPlatformDefinitions(cmMakefile* mf)
{
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", this->ArchitectureId);
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", this->ArchitectureId);
mf->AddDefinition("MSVC90", "1");
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout)
{

View File

@ -32,7 +32,6 @@ public:
virtual const char* GetName() const {
return cmGlobalVisualStudio9Generator::GetActualName();}
static const char* GetActualName() {return "Visual Studio 9 2008";}
virtual void AddPlatformDefinitions(cmMakefile* mf);
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry) const;

View File

@ -21,6 +21,8 @@
//----------------------------------------------------------------------------
cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator()
{
this->ArchitectureId = "X86";
this->VersionId = 0;
}
//----------------------------------------------------------------------------
@ -488,6 +490,18 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target)
}
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf)
{
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", this->ArchitectureId);
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", this->ArchitectureId);
if (this->VersionId)
{
mf->AddDefinition(this->VersionId, "1");
}
}
//----------------------------------------------------------------------------
std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget* target)
{

View File

@ -84,6 +84,8 @@ protected:
virtual const char* GetIDEVersion() = 0;
virtual void AddPlatformDefinitions(cmMakefile* mf);
virtual bool ComputeTargetDepends();
class VSDependSet: public std::set<cmStdString> {};
class VSDependMap: public std::map<cmTarget*, VSDependSet> {};
@ -96,6 +98,9 @@ protected:
std::string GetUtilityDepend(cmTarget* target);
typedef std::map<cmTarget*, cmStdString> UtilityDependsMap;
UtilityDependsMap UtilityDepends;
const char* ArchitectureId;
const char* VersionId;
private:
void ComputeTargetObjects(cmGeneratorTarget* gt) const;