summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-06-04 17:21:55 (GMT)
committerBrad King <brad.king@kitware.com>2014-06-04 18:27:02 (GMT)
commit528e8af19f68c01c3a42af9e74801a39c16237dd (patch)
treed6af200ff75eb396cf5157ff9bc12f797ed8ef7c /Source
parent98afb4549f66c692eeec8bbc8a1f7b333d3051a5 (diff)
downloadCMake-528e8af19f68c01c3a42af9e74801a39c16237dd.zip
CMake-528e8af19f68c01c3a42af9e74801a39c16237dd.tar.gz
CMake-528e8af19f68c01c3a42af9e74801a39c16237dd.tar.bz2
Allow a toolchain file to specify a generator toolset
Delay use of CMAKE_GENERATOR_TOOLSET until the CMakeSystem.cmake file has been configured and loaded during the first project() or enable_language() command. This gives the toolchain file named by CMAKE_TOOLCHAIN_FILE a chance to set CMAKE_GENERATOR_TOOLSET. This point is still early enough to set the generator toolset prior to the initialization of any languages that might use the toolset. The cmake::GeneratorToolset member variable remains an indication of what was specified by the -T option or loaded from the cache. It does not need to be updated based on the toolchain file setting. The cmMakefile::TryCompile can still pass cmake::GeneratorToolset into the inner instance because the try-compiled project will do platform and language initialization using the CMakeSystem module configured for the outer project. Extend the RunCMake.GeneratorToolset test with cases that use a toolchain file to set CMAKE_GENERATOR_TOOLSET.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalGenerator.cxx15
-rw-r--r--Source/cmGlobalGenerator.h2
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx4
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h2
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx12
-rw-r--r--Source/cmGlobalXCodeGenerator.h2
-rw-r--r--Source/cmake.cxx5
7 files changed, 23 insertions, 19 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index dba4f46..bb818eb 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -76,7 +76,8 @@ cmGlobalGenerator::~cmGlobalGenerator()
}
}
-bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts)
+bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts,
+ cmMakefile* mf)
{
cmOStringStream e;
e <<
@@ -85,8 +86,7 @@ bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts)
"does not support toolset specification, but toolset\n"
" " << ts << "\n"
"was specified.";
- this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
- cmListFileBacktrace());
+ mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
@@ -448,6 +448,15 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
mf->ReadListFile(0,fpath.c_str());
}
+ // Tell the generator about the toolset, if any.
+ std::string toolset = mf->GetSafeDefinition("CMAKE_GENERATOR_TOOLSET");
+ if(!toolset.empty() &&
+ !this->SetGeneratorToolset(toolset, mf))
+ {
+ cmSystemTools::SetFatalErrorOccured();
+ return;
+ }
+
// **** Load the system specific initialization if not yet loaded
if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED"))
{
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 617e708..67bd378 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -63,7 +63,7 @@ public:
/** Set the generator-specific toolset name. Returns true if toolset
is supported and false otherwise. */
- virtual bool SetGeneratorToolset(std::string const& ts);
+ virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);
/**
* Create LocalGenerators and process the CMakeLists files. This does not
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index a252fa0..86d0de3 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -116,9 +116,11 @@ cmGlobalVisualStudio10Generator::MatchesGeneratorName(
//----------------------------------------------------------------------------
bool
-cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts)
+cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts,
+ cmMakefile* mf)
{
this->GeneratorToolset = ts;
+ this->AddVSPlatformToolsetDefinition(mf);
return true;
}
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 0360fa6..b4dcc7e 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -31,7 +31,7 @@ public:
virtual bool MatchesGeneratorName(const std::string& name) const;
- virtual bool SetGeneratorToolset(std::string const& ts);
+ virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);
virtual void GenerateBuildCommand(
std::vector<std::string>& makeCommand,
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 6c0eaea..87ccfbd 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -202,16 +202,19 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
}
//----------------------------------------------------------------------------
-bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts)
+bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts,
+ cmMakefile* mf)
{
if(this->XcodeVersion >= 30)
{
this->GeneratorToolset = ts;
+ mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET",
+ this->GeneratorToolset.c_str());
return true;
}
else
{
- return cmGlobalGenerator::SetGeneratorToolset(ts);
+ return cmGlobalGenerator::SetGeneratorToolset(ts, mf);
}
}
@@ -239,11 +242,6 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const&
}
}
mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
- if(!this->GeneratorToolset.empty())
- {
- mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET",
- this->GeneratorToolset.c_str());
- }
this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
const char* osxArch =
mf->GetDefinition("CMAKE_OSX_ARCHITECTURES");
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index ecbc3f9..ae23e3b 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -89,7 +89,7 @@ public:
i.e. "Can I build Debug and Release in the same tree?" */
virtual bool IsMultiConfig();
- virtual bool SetGeneratorToolset(std::string const& ts);
+ virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);
void AppendFlag(std::string& flags, std::string const& flag);
private:
cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget,
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 9906c4b..16dc724 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -1462,11 +1462,6 @@ int cmake::ActualConfigure()
"Name of generator toolset.",
cmCacheManager::INTERNAL);
}
- if(!this->GeneratorToolset.empty() &&
- !this->GlobalGenerator->SetGeneratorToolset(this->GeneratorToolset))
- {
- return -2;
- }
// reset any system configuration information, except for when we are
// InTryCompile. With TryCompile the system info is taken from the parent's