cmake/Source/cmGlobalVisualStudio9Generator.cxx

159 lines
5.0 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalVisualStudio9Generator.h"
2016-07-09 11:21:54 +02:00
2020-08-30 11:54:41 +02:00
#include <utility>
2017-04-14 19:02:05 +02:00
#include "cmDocumentationEntry.h"
#include "cmLocalVisualStudio7Generator.h"
#include "cmMakefile.h"
2019-11-11 23:01:05 +01:00
#include "cmMessageType.h"
2013-03-16 19:13:01 +02:00
#include "cmVisualStudioWCEPlatformParser.h"
2013-03-16 19:13:01 +02:00
static const char vs9generatorName[] = "Visual Studio 9 2008";
2016-07-09 11:21:54 +02:00
class cmGlobalVisualStudio9Generator::Factory : public cmGlobalGeneratorFactory
2013-03-16 19:13:01 +02:00
{
public:
2020-08-30 11:54:41 +02:00
std::unique_ptr<cmGlobalGenerator> CreateGlobalGenerator(
2021-09-14 00:13:48 +02:00
const std::string& name, bool allowArch, cmake* cm) const override
2016-07-09 11:21:54 +02:00
{
if (strncmp(name.c_str(), vs9generatorName,
sizeof(vs9generatorName) - 1) != 0) {
2020-08-30 11:54:41 +02:00
return std::unique_ptr<cmGlobalGenerator>();
2016-07-09 11:21:54 +02:00
}
2013-03-16 19:13:01 +02:00
2015-04-27 22:25:09 +02:00
const char* p = name.c_str() + sizeof(vs9generatorName) - 1;
2016-07-09 11:21:54 +02:00
if (p[0] == '\0') {
2020-08-30 11:54:41 +02:00
return std::unique_ptr<cmGlobalGenerator>(
new cmGlobalVisualStudio9Generator(cm, name, ""));
2016-07-09 11:21:54 +02:00
}
2013-03-16 19:13:01 +02:00
2021-09-14 00:13:48 +02:00
if (!allowArch || p[0] != ' ') {
2020-08-30 11:54:41 +02:00
return std::unique_ptr<cmGlobalGenerator>();
2016-07-09 11:21:54 +02:00
}
2013-03-16 19:13:01 +02:00
++p;
2016-07-09 11:21:54 +02:00
if (!strcmp(p, "IA64")) {
2020-08-30 11:54:41 +02:00
return std::unique_ptr<cmGlobalGenerator>(
new cmGlobalVisualStudio9Generator(cm, name, "Itanium"));
2016-07-09 11:21:54 +02:00
}
2013-03-16 19:13:01 +02:00
2016-07-09 11:21:54 +02:00
if (!strcmp(p, "Win64")) {
2020-08-30 11:54:41 +02:00
return std::unique_ptr<cmGlobalGenerator>(
new cmGlobalVisualStudio9Generator(cm, name, "x64"));
2016-07-09 11:21:54 +02:00
}
2013-03-16 19:13:01 +02:00
cmVisualStudioWCEPlatformParser parser(p);
parser.ParseVersion("9.0");
2016-07-09 11:21:54 +02:00
if (!parser.Found()) {
2020-08-30 11:54:41 +02:00
return std::unique_ptr<cmGlobalGenerator>();
2016-07-09 11:21:54 +02:00
}
2013-03-16 19:13:01 +02:00
2020-08-30 11:54:41 +02:00
auto ret = std::unique_ptr<cmGlobalVisualStudio9Generator>(
new cmGlobalVisualStudio9Generator(cm, name, p));
2013-03-16 19:13:01 +02:00
ret->WindowsCEVersion = parser.GetOSVersion();
2020-08-30 11:54:41 +02:00
return std::unique_ptr<cmGlobalGenerator>(std::move(ret));
2013-03-16 19:13:01 +02:00
}
2018-01-26 17:06:56 +01:00
void GetDocumentation(cmDocumentationEntry& entry) const override
2016-07-09 11:21:54 +02:00
{
2015-08-17 11:37:30 +02:00
entry.Name = std::string(vs9generatorName) + " [arch]";
2016-07-09 11:21:54 +02:00
entry.Brief = "Generates Visual Studio 2008 project files. "
"Optional [arch] can be \"Win64\" or \"IA64\".";
2013-03-16 19:13:01 +02:00
}
2019-11-11 23:01:05 +01:00
std::vector<std::string> GetGeneratorNames() const override
2016-07-09 11:21:54 +02:00
{
2019-11-11 23:01:05 +01:00
std::vector<std::string> names;
2013-03-16 19:13:01 +02:00
names.push_back(vs9generatorName);
2019-11-11 23:01:05 +01:00
return names;
}
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
{
std::vector<std::string> names;
2013-03-16 19:13:01 +02:00
names.push_back(vs9generatorName + std::string(" Win64"));
names.push_back(vs9generatorName + std::string(" IA64"));
cmVisualStudioWCEPlatformParser parser;
parser.ParseVersion("9.0");
const std::vector<std::string>& availablePlatforms =
parser.GetAvailablePlatforms();
2018-04-23 21:13:27 +02:00
for (std::string const& i : availablePlatforms) {
names.push_back("Visual Studio 9 2008 " + i);
2016-07-09 11:21:54 +02:00
}
2019-11-11 23:01:05 +01:00
return names;
2013-03-16 19:13:01 +02:00
}
2016-03-13 13:35:51 +01:00
2018-01-26 17:06:56 +01:00
bool SupportsToolset() const override { return false; }
bool SupportsPlatform() const override { return true; }
2019-11-11 23:01:05 +01:00
std::vector<std::string> GetKnownPlatforms() const override
{
std::vector<std::string> platforms;
platforms.emplace_back("x64");
platforms.emplace_back("Win32");
platforms.emplace_back("Itanium");
cmVisualStudioWCEPlatformParser parser;
parser.ParseVersion("9.0");
const std::vector<std::string>& availablePlatforms =
parser.GetAvailablePlatforms();
for (std::string const& i : availablePlatforms) {
platforms.emplace_back(i);
}
return platforms;
}
std::string GetDefaultPlatformName() const override { return "Win32"; }
2013-03-16 19:13:01 +02:00
};
2020-08-30 11:54:41 +02:00
std::unique_ptr<cmGlobalGeneratorFactory>
cmGlobalVisualStudio9Generator::NewFactory()
{
2020-08-30 11:54:41 +02:00
return std::unique_ptr<cmGlobalGeneratorFactory>(new Factory);
}
2016-07-09 11:21:54 +02:00
cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
2019-11-11 23:01:05 +01:00
cmake* cm, const std::string& name,
std::string const& platformInGeneratorName)
: cmGlobalVisualStudio8Generator(cm, name, platformInGeneratorName)
{
2015-08-17 11:37:30 +02:00
this->Version = VS9;
2016-07-09 11:21:54 +02:00
std::string vc9Express;
this->ExpressEdition = cmSystemTools::ReadRegistryValue(
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\9.0\\Setup\\VC;"
"ProductDir",
vc9Express, cmSystemTools::KeyWOW64_32);
}
std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
{
std::string base;
std::string path;
// base begins with the VisualStudioProjectsLocation reg value...
if (cmSystemTools::ReadRegistryValue(
2016-07-09 11:21:54 +02:00
"HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\9.0;"
"VisualStudioProjectsLocation",
base)) {
cmSystemTools::ConvertToUnixSlashes(base);
// 9.0 macros folder:
path = base + "/VSMacros80";
2016-07-09 11:21:54 +02:00
// *NOT* a typo; right now in Visual Studio 2008 beta the macros
// folder is VSMacros80... They may change it to 90 before final
// release of 2008 or they may not... we'll have to keep our eyes
// on it
}
// path is (correctly) still empty if we did not read the base value from
// the Registry value
return path;
}
std::string cmGlobalVisualStudio9Generator::GetUserMacrosRegKeyBase()
{
return "Software\\Microsoft\\VisualStudio\\9.0\\vsmacros";
}