diff options
Diffstat (limited to 'Source/cmGlobalVisualStudio10Generator.cxx')
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 114 |
1 files changed, 64 insertions, 50 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 6983ef9..c1b087a 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -21,13 +21,14 @@ static const char vs10generatorName[] = "Visual Studio 10 2010"; // Map generator name without year to name with year. -static const char* cmVS10GenName(const char* name, std::string& genName) +static const char* cmVS10GenName(const std::string& name, std::string& genName) { - if(strncmp(name, vs10generatorName, sizeof(vs10generatorName)-6) != 0) + if(strncmp(name.c_str(), vs10generatorName, + sizeof(vs10generatorName)-6) != 0) { return 0; } - const char* p = name + sizeof(vs10generatorName) - 6; + const char* p = name.c_str() + sizeof(vs10generatorName) - 6; if(cmHasLiteralPrefix(p, " 2010")) { p += 5; @@ -40,27 +41,29 @@ class cmGlobalVisualStudio10Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { std::string genName; const char* p = cmVS10GenName(name, genName); if(!p) { return 0; } - name = genName.c_str(); - if(strcmp(p, "") == 0) + if(!*p) { return new cmGlobalVisualStudio10Generator( - name, NULL, NULL); + genName, ""); } - if(strcmp(p, " Win64") == 0) + if(*p++ != ' ') + { return 0; } + if(strcmp(p, "Win64") == 0) { return new cmGlobalVisualStudio10Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64"); } - if(strcmp(p, " IA64") == 0) + if(strcmp(p, "IA64") == 0) { return new cmGlobalVisualStudio10Generator( - name, "Itanium", "CMAKE_FORCE_IA64"); + genName, "Itanium"); } return 0; } @@ -87,10 +90,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( - const char* name, const char* platformName, - const char* additionalPlatformDefinition) - : cmGlobalVisualStudio8Generator(name, platformName, - additionalPlatformDefinition) + const std::string& name, const std::string& platformName) + : cmGlobalVisualStudio8Generator(name, platformName) { std::string vc10Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( @@ -102,7 +103,8 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( //---------------------------------------------------------------------------- bool -cmGlobalVisualStudio10Generator::MatchesGeneratorName(const char* name) const +cmGlobalVisualStudio10Generator::MatchesGeneratorName( + const std::string& name) const { std::string genName; if(cmVS10GenName(name, genName)) @@ -114,20 +116,36 @@ cmGlobalVisualStudio10Generator::MatchesGeneratorName(const char* name) const //---------------------------------------------------------------------------- bool -cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts) +cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts, + cmMakefile* mf) { - this->PlatformToolset = ts; + this->GeneratorToolset = ts; + this->AddVSPlatformToolsetDefinition(mf); return true; } //---------------------------------------------------------------------------- -void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf) +bool cmGlobalVisualStudio10Generator::SetSystemName(std::string const& s, + cmMakefile* mf) { - cmGlobalVisualStudio8Generator::AddPlatformDefinitions(mf); - if(!this->PlatformToolset.empty()) + if(this->PlatformName == "Itanium" || this->PlatformName == "x64") { - mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET", - this->PlatformToolset.c_str()); + if(this->IsExpressEdition() && !this->Find64BitTools(mf)) + { + return false; + } + } + this->AddVSPlatformToolsetDefinition(mf); + return this->cmGlobalVisualStudio8Generator::SetSystemName(s, mf); +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio10Generator +::AddVSPlatformToolsetDefinition(cmMakefile* mf) const +{ + if(const char* toolset = this->GetPlatformToolset()) + { + mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET", toolset); } } @@ -150,7 +168,6 @@ cmLocalGenerator *cmGlobalVisualStudio10Generator::CreateLocalGenerator() { cmLocalVisualStudio10Generator* lg = new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS10); - lg->SetPlatformName(this->GetPlatformName()); lg->SetGlobalGenerator(this); return lg; } @@ -192,14 +209,6 @@ void cmGlobalVisualStudio10Generator ::EnableLanguage(std::vector<std::string>const & lang, cmMakefile *mf, bool optional) { - if(this->PlatformName == "Itanium" || this->PlatformName == "x64") - { - if(this->IsExpressEdition() && !this->Find64BitTools(mf)) - { - return; - } - } - for(std::vector<std::string>::const_iterator it = lang.begin(); it != lang.end(); ++it) { @@ -213,11 +222,15 @@ void cmGlobalVisualStudio10Generator } //---------------------------------------------------------------------------- -const char* cmGlobalVisualStudio10Generator::GetPlatformToolset() +const char* cmGlobalVisualStudio10Generator::GetPlatformToolset() const { - if(!this->PlatformToolset.empty()) + if(!this->GeneratorToolset.empty()) + { + return this->GeneratorToolset.c_str(); + } + if(!this->DefaultPlatformToolset.empty()) { - return this->PlatformToolset.c_str(); + return this->DefaultPlatformToolset.c_str(); } return 0; } @@ -310,11 +323,11 @@ std::string cmGlobalVisualStudio10Generator::FindDevEnvCommand() //---------------------------------------------------------------------------- void cmGlobalVisualStudio10Generator::GenerateBuildCommand( std::vector<std::string>& makeCommand, - const char* makeProgram, - const char* projectName, - const char* projectDir, - const char* targetName, - const char* config, + const std::string& makeProgram, + const std::string& projectName, + const std::string& projectDir, + const std::string& targetName, + const std::string& config, bool fast, std::vector<std::string> const& makeOptions) { @@ -334,7 +347,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( cmSlnData slnData; { std::string slnFile; - if(projectDir && *projectDir) + if(!projectDir.empty()) { slnFile = projectDir; slnFile += "/"; @@ -369,25 +382,26 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( makeCommand.push_back(makeProgramSelected); + std::string realTarget = targetName; // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD - if(!targetName || strlen(targetName) == 0) + if(realTarget.empty()) { - targetName = "ALL_BUILD"; + realTarget = "ALL_BUILD"; } - if ( targetName && strcmp(targetName, "clean") == 0 ) + if ( realTarget == "clean" ) { makeCommand.push_back(std::string(projectName)+".sln"); makeCommand.push_back("/t:Clean"); } else { - std::string targetProject(targetName); + std::string targetProject(realTarget); targetProject += ".vcxproj"; if (targetProject.find('/') == std::string::npos) { // it might be in a subdir if (cmSlnProjectEntry const* proj = - slnData.GetProjectByName(targetName)) + slnData.GetProjectByName(realTarget)) { targetProject = proj->GetRelativePath(); cmSystemTools::ConvertToUnixSlashes(targetProject); @@ -396,7 +410,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( makeCommand.push_back(targetProject); } std::string configArg = "/p:Configuration="; - if(config && strlen(config)) + if(!config.empty()) { configArg += config; } @@ -414,7 +428,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( //---------------------------------------------------------------------------- bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf) { - if(!this->PlatformToolset.empty()) + if(this->GetPlatformToolset()) { return true; } @@ -432,7 +446,7 @@ bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf) cmOStringStream m; m << "Found Windows SDK v7.1: " << winSDK_7_1; mf->DisplayStatus(m.str().c_str(), -1); - this->PlatformToolset = "Windows7.1SDK"; + this->DefaultPlatformToolset = "Windows7.1SDK"; return true; } else @@ -467,7 +481,7 @@ cmGlobalVisualStudio10Generator //---------------------------------------------------------------------------- void cmGlobalVisualStudio10Generator::PathTooLong( - cmTarget* target, cmSourceFile* sf, std::string const& sfRel) + cmTarget* target, cmSourceFile const* sf, std::string const& sfRel) { size_t len = (strlen(target->GetMakefile()->GetCurrentOutputDirectory()) + 1 + sfRel.length()); |