try_compile: Simplify generator platform and toolset propagation

We don't need to save the `CMAKE_GENERATOR_{PLATFORM,TOOLSET}` values
from the cache back into the `cmake` instance.  They were used only to
propagate the settings into `cmake` instances for `try_compile`, but we
already have their values in the `cmMakefile`'s variables anyway.  In
fact those variables are the ones we actually give to the generators.
This commit is contained in:
Brad King
2017-09-26 15:04:56 -04:00
parent 068effa4d8
commit 298493769f
3 changed files with 5 additions and 20 deletions
+2 -2
View File
@@ -3186,8 +3186,8 @@ int cmMakefile::TryCompile(const std::string& srcdir,
// do a configure
cm.SetHomeDirectory(srcdir);
cm.SetHomeOutputDirectory(bindir);
cm.SetGeneratorPlatform(this->GetCMakeInstance()->GetGeneratorPlatform());
cm.SetGeneratorToolset(this->GetCMakeInstance()->GetGeneratorToolset());
cm.SetGeneratorPlatform(this->GetSafeDefinition("CMAKE_GENERATOR_PLATFORM"));
cm.SetGeneratorToolset(this->GetSafeDefinition("CMAKE_GENERATOR_TOOLSET"));
cm.LoadCache();
if (!gg->IsMultiConfig()) {
if (const char* config =
+3 -6
View File
@@ -1328,9 +1328,8 @@ int cmake::ActualConfigure()
if (const char* platformName =
this->State->GetInitializedCacheValue("CMAKE_GENERATOR_PLATFORM")) {
if (this->GeneratorPlatform.empty()) {
this->GeneratorPlatform = platformName;
} else if (this->GeneratorPlatform != platformName) {
if (!this->GeneratorPlatform.empty() &&
this->GeneratorPlatform != platformName) {
std::string message = "Error: generator platform: ";
message += this->GeneratorPlatform;
message += "\nDoes not match the platform used previously: ";
@@ -1348,9 +1347,7 @@ int cmake::ActualConfigure()
if (const char* tsName =
this->State->GetInitializedCacheValue("CMAKE_GENERATOR_TOOLSET")) {
if (this->GeneratorToolset.empty()) {
this->GeneratorToolset = tsName;
} else if (this->GeneratorToolset != tsName) {
if (!this->GeneratorToolset.empty() && this->GeneratorToolset != tsName) {
std::string message = "Error: generator toolset: ";
message += this->GeneratorToolset;
message += "\nDoes not match the toolset used previously: ";
-12
View File
@@ -209,24 +209,12 @@ public:
this->GeneratorPlatform = ts;
}
///! Get the name of the selected generator-specific platform.
std::string const& GetGeneratorPlatform() const
{
return this->GeneratorPlatform;
}
///! Set the name of the selected generator-specific toolset.
void SetGeneratorToolset(std::string const& ts)
{
this->GeneratorToolset = ts;
}
///! Get the name of the selected generator-specific toolset.
std::string const& GetGeneratorToolset() const
{
return this->GeneratorToolset;
}
const std::vector<std::string>& GetSourceExtensions() const
{
return this->SourceFileExtensions;