VS: Expose Intel Fortran .vfproj format version to CMake language

Lookup the Intel VS plugin version on demand in the VS global generator,
compute the corresponding .vfproj format version number, and memoize it.
Add it as a CMAKE_VS_INTEL_Fortran_PROJECT_VERSION platform definition.
This commit is contained in:
Brad King 2013-10-16 15:48:44 -04:00
parent 2d36c9ab60
commit b8522a8c8a
5 changed files with 58 additions and 29 deletions

View File

@ -61,6 +61,7 @@ Variables that Provide Information
/variable/CMAKE_TWEAK_VERSION /variable/CMAKE_TWEAK_VERSION
/variable/CMAKE_VERBOSE_MAKEFILE /variable/CMAKE_VERBOSE_MAKEFILE
/variable/CMAKE_VERSION /variable/CMAKE_VERSION
/variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION
/variable/CMAKE_VS_PLATFORM_TOOLSET /variable/CMAKE_VS_PLATFORM_TOOLSET
/variable/CMAKE_XCODE_PLATFORM_TOOLSET /variable/CMAKE_XCODE_PLATFORM_TOOLSET
/variable/PROJECT_BINARY_DIR /variable/PROJECT_BINARY_DIR

View File

@ -0,0 +1,7 @@
CMAKE_VS_INTEL_Fortran_PROJECT_VERSION
--------------------------------------
When generating for Visual Studio 7 or greater with the Intel Fortran
plugin installed, this specifies the .vfproj project file format
version. This is intended for internal use by CMake and should not be
used by project code.

View File

@ -21,6 +21,7 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
const char* platformName) const char* platformName)
{ {
this->FindMakeProgramFile = "CMakeVS7FindMake.cmake"; this->FindMakeProgramFile = "CMakeVS7FindMake.cmake";
this->IntelProjectVersion = 0;
if (!platformName) if (!platformName)
{ {
@ -29,6 +30,45 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
this->PlatformName = platformName; this->PlatformName = platformName;
} }
cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator()
{
free(this->IntelProjectVersion);
}
// Package GUID of Intel Visual Fortran plugin to VS IDE
#define CM_INTEL_PLUGIN_GUID "{B68A201D-CB9B-47AF-A52F-7EEC72E217E4}"
const char* cmGlobalVisualStudio7Generator::GetIntelProjectVersion()
{
if(!this->IntelProjectVersion)
{
// Compute the version of the Intel plugin to the VS IDE.
// If the key does not exist then use a default guess.
std::string intelVersion;
std::string vskey = this->GetRegistryBase();
vskey += "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion";
cmSystemTools::ReadRegistryValue(vskey.c_str(), intelVersion,
cmSystemTools::KeyWOW64_32);
unsigned int intelVersionNumber = ~0u;
sscanf(intelVersion.c_str(), "%u", &intelVersionNumber);
if(intelVersionNumber >= 11)
{
// Default to latest known project file version.
intelVersion = "11.0";
}
else if(intelVersionNumber == 10)
{
// Version 10.x actually uses 9.10 in project files!
intelVersion = "9.10";
}
else
{
// Version <= 9: use ProductVersion from registry.
}
this->IntelProjectVersion = strdup(intelVersion.c_str());
}
return this->IntelProjectVersion;
}
void cmGlobalVisualStudio7Generator void cmGlobalVisualStudio7Generator
::EnableLanguage(std::vector<std::string>const & lang, ::EnableLanguage(std::vector<std::string>const & lang,
@ -156,6 +196,8 @@ void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf)
{ {
cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf); cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf);
mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName()); mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName());
mf->AddDefinition("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION",
this->GetIntelProjectVersion());
} }
void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf) void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf)

View File

@ -27,6 +27,8 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator
{ {
public: public:
cmGlobalVisualStudio7Generator(const char* platformName = NULL); cmGlobalVisualStudio7Generator(const char* platformName = NULL);
~cmGlobalVisualStudio7Generator();
static cmGlobalGeneratorFactory* NewFactory() { static cmGlobalGeneratorFactory* NewFactory() {
return new cmGlobalGeneratorSimpleFactory return new cmGlobalGeneratorSimpleFactory
<cmGlobalVisualStudio7Generator>(); } <cmGlobalVisualStudio7Generator>(); }
@ -101,6 +103,8 @@ public:
LinkLibraryDependencies and link to .sln dependencies. */ LinkLibraryDependencies and link to .sln dependencies. */
virtual bool NeedLinkLibraryDependencies(cmTarget&) { return false; } virtual bool NeedLinkLibraryDependencies(cmTarget&) { return false; }
const char* GetIntelProjectVersion();
protected: protected:
virtual const char* GetIDEVersion() { return "7.0"; } virtual const char* GetIDEVersion() { return "7.0"; }
@ -159,6 +163,9 @@ protected:
// There is one SLN file per project. // There is one SLN file per project.
std::string CurrentProject; std::string CurrentProject;
std::string PlatformName; std::string PlatformName;
private:
char* IntelProjectVersion;
}; };
#define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK" #define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK"

View File

@ -27,9 +27,6 @@
#include <ctype.h> // for isspace #include <ctype.h> // for isspace
// Package GUID of Intel Visual Fortran plugin to VS IDE
#define CM_INTEL_PLUGIN_GUID "{B68A201D-CB9B-47AF-A52F-7EEC72E217E4}"
static bool cmLVS6G_IsFAT(const char* dir); static bool cmLVS6G_IsFAT(const char* dir);
class cmLocalVisualStudio7GeneratorInternals class cmLocalVisualStudio7GeneratorInternals
@ -1961,35 +1958,10 @@ cmLocalVisualStudio7Generator
cmGlobalVisualStudio7Generator* gg = cmGlobalVisualStudio7Generator* gg =
static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
// Compute the version of the Intel plugin to the VS IDE.
// If the key does not exist then use a default guess.
std::string intelVersion;
std::string vskey = gg->GetRegistryBase();
vskey += "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion";
cmSystemTools::ReadRegistryValue(vskey.c_str(), intelVersion,
cmSystemTools::KeyWOW64_32);
unsigned int intelVersionNumber = ~0u;
sscanf(intelVersion.c_str(), "%u", &intelVersionNumber);
if(intelVersionNumber >= 11)
{
// Default to latest known project file version.
intelVersion = "11.0";
}
else if(intelVersionNumber == 10)
{
// Version 10.x actually uses 9.10 in project files!
intelVersion = "9.10";
}
else
{
// Version <= 9: use ProductVersion from registry.
}
fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n" fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
<< "<VisualStudioProject\n" << "<VisualStudioProject\n"
<< "\tProjectCreator=\"Intel Fortran\"\n" << "\tProjectCreator=\"Intel Fortran\"\n"
<< "\tVersion=\"" << intelVersion << "\"\n"; << "\tVersion=\"" << gg->GetIntelProjectVersion() << "\"\n";
const char* keyword = target.GetProperty("VS_KEYWORD"); const char* keyword = target.GetProperty("VS_KEYWORD");
if(!keyword) if(!keyword)
{ {