VS: Move version information to global generator.

This commit is contained in:
Stephen Kelly 2015-05-17 11:33:09 +02:00 committed by Brad King
parent b5f093f096
commit e435f875ec
22 changed files with 136 additions and 106 deletions

View File

@ -105,6 +105,7 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
this->SystemIsWindowsPhone = false; this->SystemIsWindowsPhone = false;
this->SystemIsWindowsStore = false; this->SystemIsWindowsStore = false;
this->MSBuildCommandInitialized = false; this->MSBuildCommandInitialized = false;
this->Version = VS10;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -311,8 +312,7 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
cmLocalGenerator * cmLocalGenerator *
cmGlobalVisualStudio10Generator::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalVisualStudio10Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
return new cmLocalVisualStudio10Generator( return new cmLocalVisualStudio10Generator(this, parent);
cmLocalVisualStudioGenerator::VS10, this, parent);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -117,6 +117,7 @@ cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator(
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\11.0\\Setup\\VC;" "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\11.0\\Setup\\VC;"
"ProductDir", vc11Express, cmSystemTools::KeyWOW64_32); "ProductDir", vc11Express, cmSystemTools::KeyWOW64_32);
this->DefaultPlatformToolset = "v110"; this->DefaultPlatformToolset = "v110";
this->Version = VS11;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -240,8 +241,7 @@ void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout)
cmLocalGenerator * cmLocalGenerator *
cmGlobalVisualStudio11Generator::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalVisualStudio11Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
return new cmLocalVisualStudio10Generator( return new cmLocalVisualStudio10Generator(this, parent);
cmLocalVisualStudioGenerator::VS11, this, parent);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -97,6 +97,7 @@ cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator(
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\12.0\\Setup\\VC;" "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\12.0\\Setup\\VC;"
"ProductDir", vc12Express, cmSystemTools::KeyWOW64_32); "ProductDir", vc12Express, cmSystemTools::KeyWOW64_32);
this->DefaultPlatformToolset = "v120"; this->DefaultPlatformToolset = "v120";
this->Version = VS12;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -220,8 +221,7 @@ void cmGlobalVisualStudio12Generator::WriteSLNHeader(std::ostream& fout)
cmLocalGenerator * cmLocalGenerator *
cmGlobalVisualStudio12Generator::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalVisualStudio12Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
return new cmLocalVisualStudio10Generator( return new cmLocalVisualStudio10Generator(this, parent);
cmLocalVisualStudioGenerator::VS12, this, parent);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -97,6 +97,7 @@ cmGlobalVisualStudio14Generator::cmGlobalVisualStudio14Generator(
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\14.0\\Setup\\VC;" "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\14.0\\Setup\\VC;"
"ProductDir", vc14Express, cmSystemTools::KeyWOW64_32); "ProductDir", vc14Express, cmSystemTools::KeyWOW64_32);
this->DefaultPlatformToolset = "v140"; this->DefaultPlatformToolset = "v140";
this->Version = VS14;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -131,6 +132,5 @@ void cmGlobalVisualStudio14Generator::WriteSLNHeader(std::ostream& fout)
cmLocalGenerator * cmLocalGenerator *
cmGlobalVisualStudio14Generator::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalVisualStudio14Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
return new cmLocalVisualStudio10Generator( return new cmLocalVisualStudio10Generator(this, parent);
cmLocalVisualStudioGenerator::VS14, this, parent);
} }

View File

@ -34,6 +34,7 @@ std::string GetVS6TargetName(const std::string& targetName)
cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator() cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator()
{ {
this->MSDevCommandInitialized = false; this->MSDevCommandInitialized = false;
this->Version = VS6;
} }
void cmGlobalVisualStudio6Generator void cmGlobalVisualStudio6Generator

View File

@ -21,6 +21,7 @@ cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator(
: cmGlobalVisualStudio7Generator(platformName) : cmGlobalVisualStudio7Generator(platformName)
{ {
this->ProjectConfigurationSectionName = "ProjectConfiguration"; this->ProjectConfigurationSectionName = "ProjectConfiguration";
this->Version = VS71;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -29,8 +30,7 @@ cmLocalGenerator *
cmGlobalVisualStudio71Generator::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalVisualStudio71Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalVisualStudio7Generator *lg = cmLocalVisualStudio7Generator *lg =
new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS71, new cmLocalVisualStudio7Generator(this, parent);
this, parent);
return lg; return lg;
} }

View File

@ -60,6 +60,7 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
this->DefaultPlatformName = platformName; this->DefaultPlatformName = platformName;
} }
this->ExtraFlagTable = cmVS7ExtraFlagTable; this->ExtraFlagTable = cmVS7ExtraFlagTable;
this->Version = VS7;
} }
cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator() cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator()
@ -281,8 +282,7 @@ cmLocalGenerator *
cmGlobalVisualStudio7Generator::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalVisualStudio7Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalVisualStudio7Generator *lg = cmLocalVisualStudio7Generator *lg =
new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS7, new cmLocalVisualStudio7Generator(this, parent);
this, parent);
return lg; return lg;
} }

View File

@ -102,6 +102,7 @@ cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator(
this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms";
this->Name = name; this->Name = name;
this->ExtraFlagTable = this->GetExtraFlagTableVS8(); this->ExtraFlagTable = this->GetExtraFlagTableVS8();
this->Version = VS8;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -130,8 +131,7 @@ cmLocalGenerator *
cmGlobalVisualStudio8Generator::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalVisualStudio8Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalVisualStudio7Generator *lg = cmLocalVisualStudio7Generator *lg =
new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS8, new cmLocalVisualStudio7Generator(this, parent);
this, parent);
return lg; return lg;
} }

View File

@ -104,6 +104,7 @@ cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
const std::string& name, const std::string& platformName) const std::string& name, const std::string& platformName)
: cmGlobalVisualStudio8Generator(name, platformName) : cmGlobalVisualStudio8Generator(name, platformName)
{ {
this->Version = VS9;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -118,8 +119,7 @@ cmLocalGenerator *
cmGlobalVisualStudio9Generator::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalVisualStudio9Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalVisualStudio7Generator *lg cmLocalVisualStudio7Generator *lg
= new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9, = new cmLocalVisualStudio7Generator(this, parent);
this, parent);
return lg; return lg;
} }

View File

@ -32,6 +32,19 @@ cmGlobalVisualStudioGenerator::~cmGlobalVisualStudioGenerator()
{ {
} }
//----------------------------------------------------------------------------
cmGlobalVisualStudioGenerator::VSVersion
cmGlobalVisualStudioGenerator::GetVersion() const
{
return this->Version;
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudioGenerator::SetVersion(VSVersion v)
{
this->Version = v;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmGlobalVisualStudioGenerator::GetRegistryBase() std::string cmGlobalVisualStudioGenerator::GetRegistryBase()
{ {

View File

@ -23,9 +23,27 @@
class cmGlobalVisualStudioGenerator : public cmGlobalGenerator class cmGlobalVisualStudioGenerator : public cmGlobalGenerator
{ {
public: public:
/** Known versions of Visual Studio. */
enum VSVersion
{
VS6 = 60,
VS7 = 70,
VS71 = 71,
VS8 = 80,
VS9 = 90,
VS10 = 100,
VS11 = 110,
VS12 = 120,
/* VS13 = 130 was skipped */
VS14 = 140
};
cmGlobalVisualStudioGenerator(); cmGlobalVisualStudioGenerator();
virtual ~cmGlobalVisualStudioGenerator(); virtual ~cmGlobalVisualStudioGenerator();
VSVersion GetVersion() const;
void SetVersion(VSVersion v);
/** /**
* Configure CMake's Visual Studio macros file into the user's Visual * Configure CMake's Visual Studio macros file into the user's Visual
* Studio macros directory. * Studio macros directory.
@ -107,6 +125,9 @@ protected:
typedef std::map<cmTarget const*, std::string> UtilityDependsMap; typedef std::map<cmTarget const*, std::string> UtilityDependsMap;
UtilityDependsMap UtilityDepends; UtilityDependsMap UtilityDepends;
protected:
VSVersion Version;
private: private:
virtual std::string GetVSMakeProgram() = 0; virtual std::string GetVSMakeProgram() = 0;
void PrintCompilerAdvice(std::ostream&, std::string const&, void PrintCompilerAdvice(std::ostream&, std::string const&,

View File

@ -62,9 +62,9 @@ class cmVS10XMLParser : public cmXMLParser
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmLocalVisualStudio10Generator cmLocalVisualStudio10Generator
::cmLocalVisualStudio10Generator(VSVersion v, cmGlobalGenerator* gg, ::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg,
cmLocalGenerator* parent): cmLocalGenerator* parent):
cmLocalVisualStudio7Generator(v, gg, parent) cmLocalVisualStudio7Generator(gg, parent)
{ {
} }

View File

@ -25,7 +25,7 @@ class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator
{ {
public: public:
///! Set cache only and recurse to false by default. ///! Set cache only and recurse to false by default.
cmLocalVisualStudio10Generator(VSVersion v, cmGlobalGenerator* gg, cmLocalVisualStudio10Generator(cmGlobalGenerator* gg,
cmLocalGenerator* parent); cmLocalGenerator* parent);
virtual ~cmLocalVisualStudio10Generator(); virtual ~cmLocalVisualStudio10Generator();

View File

@ -26,7 +26,7 @@
cmLocalVisualStudio6Generator cmLocalVisualStudio6Generator
::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, ::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg,
cmLocalGenerator* parent): cmLocalGenerator* parent):
cmLocalVisualStudioGenerator(VS6, gg, parent) cmLocalVisualStudioGenerator(gg, parent)
{ {
} }

View File

@ -55,9 +55,9 @@ static void cmConvertToWindowsSlash(std::string& s)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmLocalVisualStudio7Generator cmLocalVisualStudio7Generator
::cmLocalVisualStudio7Generator(VSVersion v, cmGlobalGenerator* gg, ::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg,
cmLocalGenerator* parent): cmLocalGenerator* parent):
cmLocalVisualStudioGenerator(v, gg, parent) cmLocalVisualStudioGenerator(gg, parent)
{ {
this->Internal = new cmLocalVisualStudio7GeneratorInternals(this); this->Internal = new cmLocalVisualStudio7GeneratorInternals(this);
} }
@ -240,18 +240,17 @@ void cmLocalVisualStudio7Generator::WriteStampFiles()
void cmLocalVisualStudio7Generator void cmLocalVisualStudio7Generator
::CreateSingleVCProj(const std::string& lname, cmTarget &target) ::CreateSingleVCProj(const std::string& lname, cmTarget &target)
{ {
this->FortranProject = cmGlobalVisualStudioGenerator* gg
static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator) = static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator);
->TargetIsFortranOnly(target); this->FortranProject = gg->TargetIsFortranOnly(target);
this->WindowsCEProject = this->WindowsCEProject = gg->TargetsWindowsCE();
static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
->TargetsWindowsCE();
// Intel Fortran for VS10 uses VS9 format ".vfproj" files. // Intel Fortran for VS10 uses VS9 format ".vfproj" files.
VSVersion realVersion = this->Version; cmGlobalVisualStudioGenerator::VSVersion realVersion = gg->GetVersion();
if(this->FortranProject && this->Version >= VS10) if(this->FortranProject
&& gg->GetVersion() >= cmGlobalVisualStudioGenerator::VS10)
{ {
this->Version = VS9; gg->SetVersion(cmGlobalVisualStudioGenerator::VS9);
} }
// add to the list of projects // add to the list of projects
@ -281,7 +280,7 @@ void cmLocalVisualStudio7Generator
this->GlobalGenerator->FileReplacedDuringGenerate(fname); this->GlobalGenerator->FileReplacedDuringGenerate(fname);
} }
this->Version = realVersion; gg->SetVersion(realVersion);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -994,7 +993,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
// end of <Tool Name=VCMIDLTool // end of <Tool Name=VCMIDLTool
// Check if we need the FAT32 workaround. // Check if we need the FAT32 workaround.
if(targetBuilds && this->Version >= VS8) if(targetBuilds && this->GetVersion() >= cmGlobalVisualStudioGenerator::VS8)
{ {
// Check the filesystem type where the target will be written. // Check the filesystem type where the target will be written.
if(cmLVS6G_IsFAT(target.GetDirectory(configName).c_str())) if(cmLVS6G_IsFAT(target.GetDirectory(configName).c_str()))
@ -1129,7 +1128,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
fout << "\t\t\t<Tool\n" fout << "\t\t\t<Tool\n"
<< "\t\t\t\tName=\"" << tool << "\"\n"; << "\t\t\t\tName=\"" << tool << "\"\n";
if(this->GetVersion() < VS8 || this->FortranProject) if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS8
|| this->FortranProject)
{ {
std::ostringstream libdeps; std::ostringstream libdeps;
this->Internal->OutputObjects(libdeps, &target); this->Internal->OutputObjects(libdeps, &target);
@ -1189,7 +1189,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
// libraries which may be set by the user to something bad. // libraries which may be set by the user to something bad.
fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) " fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
<< this->Makefile->GetSafeDefinition(standardLibsVar.c_str()); << this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
if(this->GetVersion() < VS8 || this->FortranProject) if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS8
|| this->FortranProject)
{ {
this->Internal->OutputObjects(fout, &target, " "); this->Internal->OutputObjects(fout, &target, " ");
} }
@ -1217,7 +1218,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
} }
if(this->WindowsCEProject) if(this->WindowsCEProject)
{ {
if(this->GetVersion() < VS9) if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS9)
{ {
fout << "\t\t\t\tSubSystem=\"9\"\n"; fout << "\t\t\t\tSubSystem=\"9\"\n";
} }
@ -1287,7 +1288,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
// libraries which may be set by the user to something bad. // libraries which may be set by the user to something bad.
fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) " fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
<< this->Makefile->GetSafeDefinition(standardLibsVar.c_str()); << this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
if(this->GetVersion() < VS8 || this->FortranProject) if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS8
|| this->FortranProject)
{ {
this->Internal->OutputObjects(fout, &target, " "); this->Internal->OutputObjects(fout, &target, " ");
} }
@ -1315,7 +1317,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
} }
if ( this->WindowsCEProject ) if ( this->WindowsCEProject )
{ {
if(this->GetVersion() < VS9) if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS9)
{ {
fout << "\t\t\t\tSubSystem=\"9\"\n"; fout << "\t\t\t\tSubSystem=\"9\"\n";
} }
@ -1516,7 +1518,8 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
this->WriteGroup(&sg, target, fout, libName, configs); this->WriteGroup(&sg, target, fout, libName, configs);
} }
if(this->GetVersion() >= VS8 && !this->FortranProject) if(this->GetVersion() >= cmGlobalVisualStudioGenerator::VS8
&& !this->FortranProject)
{ {
// VS >= 8 support per-config source locations so we // VS >= 8 support per-config source locations so we
// list object library content as external objects. // list object library content as external objects.
@ -2148,13 +2151,13 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
<< gg->Encoding() << "\"?>\n" << gg->Encoding() << "\"?>\n"
<< "<VisualStudioProject\n" << "<VisualStudioProject\n"
<< "\tProjectType=\"Visual C++\"\n"; << "\tProjectType=\"Visual C++\"\n";
if(this->Version == VS71) if(gg->GetVersion() == cmGlobalVisualStudioGenerator::VS71)
{ {
fout << "\tVersion=\"7.10\"\n"; fout << "\tVersion=\"7.10\"\n";
} }
else else
{ {
fout << "\tVersion=\"" << (this->Version/10) << ".00\"\n"; fout << "\tVersion=\"" << (gg->GetVersion()/10) << ".00\"\n";
} }
const char* projLabel = target.GetProperty("PROJECT_LABEL"); const char* projLabel = target.GetProperty("PROJECT_LABEL");
if(!projLabel) if(!projLabel)
@ -2167,7 +2170,7 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
keyword = "Win32Proj"; keyword = "Win32Proj";
} }
fout << "\tName=\"" << projLabel << "\"\n"; fout << "\tName=\"" << projLabel << "\"\n";
if(this->Version >= VS8) if(gg->GetVersion() >= cmGlobalVisualStudioGenerator::VS8)
{ {
fout << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\"\n"; fout << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\"\n";
} }

View File

@ -35,7 +35,7 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator
{ {
public: public:
///! Set cache only and recurse to false by default. ///! Set cache only and recurse to false by default.
cmLocalVisualStudio7Generator(VSVersion v, cmGlobalGenerator* gg, cmLocalVisualStudio7Generator(cmGlobalGenerator* gg,
cmLocalGenerator* parent); cmLocalGenerator* parent);
virtual ~cmLocalVisualStudio7Generator(); virtual ~cmLocalVisualStudio7Generator();

View File

@ -19,11 +19,10 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmLocalVisualStudioGenerator cmLocalVisualStudioGenerator
::cmLocalVisualStudioGenerator(VSVersion v, cmGlobalGenerator* gg, ::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg,
cmLocalGenerator* parent) cmLocalGenerator* parent)
: cmLocalGenerator(gg, parent) : cmLocalGenerator(gg, parent)
{ {
this->Version = v;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -31,6 +30,15 @@ cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator()
{ {
} }
//----------------------------------------------------------------------------
cmGlobalVisualStudioGenerator::VSVersion
cmLocalVisualStudioGenerator::GetVersion() const
{
cmGlobalVisualStudioGenerator* gg =
static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator);
return gg->GetVersion();
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmLocalVisualStudioGenerator::ComputeObjectFilenames( void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
std::map<cmSourceFile const*, std::string>& mapping, std::map<cmSourceFile const*, std::string>& mapping,

View File

@ -13,6 +13,7 @@
#define cmLocalVisualStudioGenerator_h #define cmLocalVisualStudioGenerator_h
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cmGlobalVisualStudioGenerator.h"
#include <cmsys/auto_ptr.hxx> #include <cmsys/auto_ptr.hxx>
@ -30,22 +31,7 @@ class cmCustomCommandGenerator;
class cmLocalVisualStudioGenerator : public cmLocalGenerator class cmLocalVisualStudioGenerator : public cmLocalGenerator
{ {
public: public:
/** Known versions of Visual Studio. */ cmLocalVisualStudioGenerator(cmGlobalGenerator* gg,
enum VSVersion
{
VS6 = 60,
VS7 = 70,
VS71 = 71,
VS8 = 80,
VS9 = 90,
VS10 = 100,
VS11 = 110,
VS12 = 120,
/* VS13 = 130 was skipped */
VS14 = 140
};
cmLocalVisualStudioGenerator(VSVersion v, cmGlobalGenerator* gg,
cmLocalGenerator* parent); cmLocalGenerator* parent);
virtual ~cmLocalVisualStudioGenerator(); virtual ~cmLocalVisualStudioGenerator();
@ -57,8 +43,7 @@ public:
sequence of custom commands. */ sequence of custom commands. */
const char* GetReportErrorLabel() const; const char* GetReportErrorLabel() const;
/** Version of Visual Studio. */ cmGlobalVisualStudioGenerator::VSVersion GetVersion() const;
VSVersion GetVersion() const { return this->Version; }
virtual std::string ComputeLongestObjectDirectory(cmTarget&) const = 0; virtual std::string ComputeLongestObjectDirectory(cmTarget&) const = 0;
@ -76,8 +61,6 @@ protected:
cmsys::auto_ptr<cmCustomCommand> cmsys::auto_ptr<cmCustomCommand>
MaybeCreateImplibDir(cmTarget& target, const std::string& config, MaybeCreateImplibDir(cmTarget& target, const std::string& config,
bool isFortran); bool isFortran);
VSVersion Version;
}; };
#endif #endif

View File

@ -20,7 +20,7 @@
#include "cmAlgorithms.h" #include "cmAlgorithms.h"
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
# include "cmLocalVisualStudioGenerator.h" # include "cmGlobalVisualStudioGenerator.h"
#endif #endif
#include <sys/stat.h> #include <sys/stat.h>
@ -372,13 +372,13 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
cmGlobalGenerator* gg = localGen->GetGlobalGenerator(); cmGlobalGenerator* gg = localGen->GetGlobalGenerator();
if(gg->GetName().find("Visual Studio") != std::string::npos) if(gg->GetName().find("Visual Studio") != std::string::npos)
{ {
cmLocalVisualStudioGenerator* vslg = cmGlobalVisualStudioGenerator* vsgg =
static_cast<cmLocalVisualStudioGenerator*>(localGen); static_cast<cmGlobalVisualStudioGenerator*>(gg);
// Under VS >= 7 use a PRE_BUILD event instead of a separate target to // Under VS >= 7 use a PRE_BUILD event instead of a separate target to
// reduce the number of targets loaded into the IDE. // reduce the number of targets loaded into the IDE.
// This also works around a VS 11 bug that may skip updating the target: // This also works around a VS 11 bug that may skip updating the target:
// https://connect.microsoft.com/VisualStudio/feedback/details/769495 // https://connect.microsoft.com/VisualStudio/feedback/details/769495
usePRE_BUILD = vslg->GetVersion() >= cmLocalVisualStudioGenerator::VS7; usePRE_BUILD = vsgg->GetVersion() >= cmGlobalVisualStudioGenerator::VS7;
if(usePRE_BUILD) if(usePRE_BUILD)
{ {
for (std::vector<std::string>::iterator it = depends.begin(); for (std::vector<std::string>::iterator it = depends.begin();

View File

@ -47,13 +47,13 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetClFlagTable() const
{ {
if(this->MSTools) if(this->MSTools)
{ {
cmLocalVisualStudioGenerator::VSVersion cmGlobalVisualStudioGenerator::VSVersion
v = this->LocalGenerator->GetVersion(); v = this->LocalGenerator->GetVersion();
if(v >= cmLocalVisualStudioGenerator::VS14) if(v >= cmGlobalVisualStudioGenerator::VS14)
{ return cmVS14CLFlagTable; } { return cmVS14CLFlagTable; }
else if(v >= cmLocalVisualStudioGenerator::VS12) else if(v >= cmGlobalVisualStudioGenerator::VS12)
{ return cmVS12CLFlagTable; } { return cmVS12CLFlagTable; }
else if(v == cmLocalVisualStudioGenerator::VS11) else if(v == cmGlobalVisualStudioGenerator::VS11)
{ return cmVS11CLFlagTable; } { return cmVS11CLFlagTable; }
else else
{ return cmVS10CLFlagTable; } { return cmVS10CLFlagTable; }
@ -65,13 +65,13 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetRcFlagTable() const
{ {
if(this->MSTools) if(this->MSTools)
{ {
cmLocalVisualStudioGenerator::VSVersion cmGlobalVisualStudioGenerator::VSVersion
v = this->LocalGenerator->GetVersion(); v = this->LocalGenerator->GetVersion();
if(v >= cmLocalVisualStudioGenerator::VS14) if(v >= cmGlobalVisualStudioGenerator::VS14)
{ return cmVS14RCFlagTable; } { return cmVS14RCFlagTable; }
else if(v >= cmLocalVisualStudioGenerator::VS12) else if(v >= cmGlobalVisualStudioGenerator::VS12)
{ return cmVS12RCFlagTable; } { return cmVS12RCFlagTable; }
else if(v == cmLocalVisualStudioGenerator::VS11) else if(v == cmGlobalVisualStudioGenerator::VS11)
{ return cmVS11RCFlagTable; } { return cmVS11RCFlagTable; }
else else
{ return cmVS10RCFlagTable; } { return cmVS10RCFlagTable; }
@ -83,13 +83,13 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLibFlagTable() const
{ {
if(this->MSTools) if(this->MSTools)
{ {
cmLocalVisualStudioGenerator::VSVersion cmGlobalVisualStudioGenerator::VSVersion
v = this->LocalGenerator->GetVersion(); v = this->LocalGenerator->GetVersion();
if(v >= cmLocalVisualStudioGenerator::VS14) if(v >= cmGlobalVisualStudioGenerator::VS14)
{ return cmVS14LibFlagTable; } { return cmVS14LibFlagTable; }
else if(v >= cmLocalVisualStudioGenerator::VS12) else if(v >= cmGlobalVisualStudioGenerator::VS12)
{ return cmVS12LibFlagTable; } { return cmVS12LibFlagTable; }
else if(v == cmLocalVisualStudioGenerator::VS11) else if(v == cmGlobalVisualStudioGenerator::VS11)
{ return cmVS11LibFlagTable; } { return cmVS11LibFlagTable; }
else else
{ return cmVS10LibFlagTable; } { return cmVS10LibFlagTable; }
@ -101,13 +101,13 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLinkFlagTable() const
{ {
if(this->MSTools) if(this->MSTools)
{ {
cmLocalVisualStudioGenerator::VSVersion cmGlobalVisualStudioGenerator::VSVersion
v = this->LocalGenerator->GetVersion(); v = this->LocalGenerator->GetVersion();
if(v >= cmLocalVisualStudioGenerator::VS14) if(v >= cmGlobalVisualStudioGenerator::VS14)
{ return cmVS14LinkFlagTable; } { return cmVS14LinkFlagTable; }
else if(v >= cmLocalVisualStudioGenerator::VS12) else if(v >= cmGlobalVisualStudioGenerator::VS12)
{ return cmVS12LinkFlagTable; } { return cmVS12LinkFlagTable; }
else if(v == cmLocalVisualStudioGenerator::VS11) else if(v == cmGlobalVisualStudioGenerator::VS11)
{ return cmVS11LinkFlagTable; } { return cmVS11LinkFlagTable; }
else else
{ return cmVS10LinkFlagTable; } { return cmVS10LinkFlagTable; }
@ -119,13 +119,13 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetMasmFlagTable() const
{ {
if(this->MSTools) if(this->MSTools)
{ {
cmLocalVisualStudioGenerator::VSVersion cmGlobalVisualStudioGenerator::VSVersion
v = this->LocalGenerator->GetVersion(); v = this->LocalGenerator->GetVersion();
if(v >= cmLocalVisualStudioGenerator::VS14) if(v >= cmGlobalVisualStudioGenerator::VS14)
{ return cmVS14MASMFlagTable; } { return cmVS14MASMFlagTable; }
else if(v >= cmLocalVisualStudioGenerator::VS12) else if(v >= cmGlobalVisualStudioGenerator::VS12)
{ return cmVS12MASMFlagTable; } { return cmVS12MASMFlagTable; }
else if(v == cmLocalVisualStudioGenerator::VS11) else if(v == cmGlobalVisualStudioGenerator::VS11)
{ return cmVS11MASMFlagTable; } { return cmVS11MASMFlagTable; }
else else
{ return cmVS10MASMFlagTable; } { return cmVS10MASMFlagTable; }
@ -911,7 +911,8 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source,
sep = ";"; sep = ";";
} }
(*this->BuildFileStream ) << "</Outputs>\n"; (*this->BuildFileStream ) << "</Outputs>\n";
if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10) if(this->LocalGenerator->GetVersion()
> cmGlobalVisualStudioGenerator::VS10)
{ {
// VS >= 11 let us turn off linking of custom command outputs. // VS >= 11 let us turn off linking of custom command outputs.
this->WritePlatformConfigTag("LinkObjects", i->c_str(), 3); this->WritePlatformConfigTag("LinkObjects", i->c_str(), 3);
@ -1416,7 +1417,7 @@ void cmVisualStudio10TargetGenerator::WriteSource(
// conversion uses full paths when possible to allow deeper trees. // conversion uses full paths when possible to allow deeper trees.
bool forceRelative = false; bool forceRelative = false;
std::string sourceFile = this->ConvertPath(sf->GetFullPath(), false); std::string sourceFile = this->ConvertPath(sf->GetFullPath(), false);
if(this->LocalGenerator->GetVersion() == cmLocalVisualStudioGenerator::VS10 if(this->LocalGenerator->GetVersion() == cmGlobalVisualStudioGenerator::VS10
&& cmSystemTools::FileIsFullPath(sourceFile.c_str())) && cmSystemTools::FileIsFullPath(sourceFile.c_str()))
{ {
// Normal path conversion resulted in a full path. VS 10 (but not 11) // Normal path conversion resulted in a full path. VS 10 (but not 11)
@ -1544,7 +1545,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
++si; ++si;
} }
} }
if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10) if(this->LocalGenerator->GetVersion() > cmGlobalVisualStudioGenerator::VS10)
{ {
// For VS >= 11 we use LinkObjects to avoid linking custom command // For VS >= 11 we use LinkObjects to avoid linking custom command
// outputs. Use Object for all external objects, generated or not. // outputs. Use Object for all external objects, generated or not.

View File

@ -96,14 +96,14 @@ void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault()
// remove the flag we need to override the IDE default of on. // remove the flag we need to override the IDE default of on.
switch (this->Version) switch (this->Version)
{ {
case cmLocalVisualStudioGenerator::VS7: case cmGlobalVisualStudioGenerator::VS7:
case cmLocalVisualStudioGenerator::VS71: case cmGlobalVisualStudioGenerator::VS71:
this->FlagMap["ExceptionHandling"] = "FALSE"; this->FlagMap["ExceptionHandling"] = "FALSE";
break; break;
case cmLocalVisualStudioGenerator::VS10: case cmGlobalVisualStudioGenerator::VS10:
case cmLocalVisualStudioGenerator::VS11: case cmGlobalVisualStudioGenerator::VS11:
case cmLocalVisualStudioGenerator::VS12: case cmGlobalVisualStudioGenerator::VS12:
case cmLocalVisualStudioGenerator::VS14: case cmGlobalVisualStudioGenerator::VS14:
// by default VS puts <ExceptionHandling></ExceptionHandling> empty // by default VS puts <ExceptionHandling></ExceptionHandling> empty
// for a project, to make our projects look the same put a new line // for a project, to make our projects look the same put a new line
// and space over for the closing </ExceptionHandling> as the default // and space over for the closing </ExceptionHandling> as the default
@ -132,7 +132,7 @@ void cmVisualStudioGeneratorOptions::SetVerboseMakefile(bool verbose)
this->FlagMap.find("SuppressStartupBanner") == this->FlagMap.end()) this->FlagMap.find("SuppressStartupBanner") == this->FlagMap.end())
{ {
this->FlagMap["SuppressStartupBanner"] = this->FlagMap["SuppressStartupBanner"] =
this->Version < cmLocalVisualStudioGenerator::VS10 ? "FALSE" : ""; this->Version < cmGlobalVisualStudioGenerator::VS10 ? "FALSE" : "";
} }
} }
@ -270,7 +270,7 @@ cmVisualStudioGeneratorOptions
{ {
return; return;
} }
if(this->Version >= cmLocalVisualStudioGenerator::VS10) if(this->Version >= cmGlobalVisualStudioGenerator::VS10)
{ {
// if there are configuration specific flags, then // if there are configuration specific flags, then
// use the configuration specific tag for PreprocessorDefinitions // use the configuration specific tag for PreprocessorDefinitions
@ -298,7 +298,7 @@ cmVisualStudioGeneratorOptions
{ {
// Escape the definition for the compiler. // Escape the definition for the compiler.
std::string define; std::string define;
if(this->Version < cmLocalVisualStudioGenerator::VS10) if(this->Version < cmGlobalVisualStudioGenerator::VS10)
{ {
define = define =
this->LocalGenerator->EscapeForShell(di->c_str(), true); this->LocalGenerator->EscapeForShell(di->c_str(), true);
@ -308,7 +308,7 @@ cmVisualStudioGeneratorOptions
define = *di; define = *di;
} }
// Escape this flag for the IDE. // Escape this flag for the IDE.
if(this->Version >= cmLocalVisualStudioGenerator::VS10) if(this->Version >= cmGlobalVisualStudioGenerator::VS10)
{ {
define = cmVisualStudio10GeneratorOptionsEscapeForXML(define); define = cmVisualStudio10GeneratorOptionsEscapeForXML(define);
@ -325,7 +325,7 @@ cmVisualStudioGeneratorOptions
fout << sep << define; fout << sep << define;
sep = ";"; sep = ";";
} }
if(this->Version >= cmLocalVisualStudioGenerator::VS10) if(this->Version >= cmGlobalVisualStudioGenerator::VS10)
{ {
fout << ";%(PreprocessorDefinitions)</PreprocessorDefinitions>" << suffix; fout << ";%(PreprocessorDefinitions)</PreprocessorDefinitions>" << suffix;
} }
@ -340,7 +340,7 @@ void
cmVisualStudioGeneratorOptions cmVisualStudioGeneratorOptions
::OutputFlagMap(std::ostream& fout, const char* indent) ::OutputFlagMap(std::ostream& fout, const char* indent)
{ {
if(this->Version >= cmLocalVisualStudioGenerator::VS10) if(this->Version >= cmGlobalVisualStudioGenerator::VS10)
{ {
for(std::map<std::string, FlagValue>::iterator m = this->FlagMap.begin(); for(std::map<std::string, FlagValue>::iterator m = this->FlagMap.begin();
m != this->FlagMap.end(); ++m) m != this->FlagMap.end(); ++m)
@ -395,7 +395,7 @@ cmVisualStudioGeneratorOptions
{ {
if(!this->FlagString.empty()) if(!this->FlagString.empty())
{ {
if(this->Version >= cmLocalVisualStudioGenerator::VS10) if(this->Version >= cmGlobalVisualStudioGenerator::VS10)
{ {
fout << prefix; fout << prefix;
if(this->Configuration.size()) if(this->Configuration.size())

View File

@ -73,7 +73,7 @@ public:
void SetConfiguration(const char* config); void SetConfiguration(const char* config);
private: private:
cmLocalVisualStudioGenerator* LocalGenerator; cmLocalVisualStudioGenerator* LocalGenerator;
cmLocalVisualStudioGenerator::VSVersion Version; cmGlobalVisualStudioGenerator::VSVersion Version;
std::string Configuration; std::string Configuration;
Tool CurrentTool; Tool CurrentTool;