summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-02-08 18:38:56 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-02-08 18:38:56 (GMT)
commit7dab997771e4f496fd71a4e9c3abc26063c57c68 (patch)
treec591caee76cbcc3938e54823c2b06f30d6f698b0 /Source
parent2cd362d19114e4b8a85c3c5179734d12416f4d72 (diff)
parent56ca8d4e6365d67901e0cff7f2bd99f174537a97 (diff)
downloadCMake-7dab997771e4f496fd71a4e9c3abc26063c57c68.zip
CMake-7dab997771e4f496fd71a4e9c3abc26063c57c68.tar.gz
CMake-7dab997771e4f496fd71a4e9c3abc26063c57c68.tar.bz2
Merge topic 'generator-toolset'
56ca8d4 Tests: Add generator toolset support f36c665 Tests: Consolidate ctest --build-and-test generator options c0debb1 Merge branch 'master' into generator-toolset daae0d2 ExternalProject: Propagate the generator toolset e3841cf CTest: Add options to set generator toolset f980a80 Xcode: Implement generator toolset selection (#9831, #13802) 650c647 VS: Implement generator toolset selection (#10722, #13774) 4fd5342 CMake: Add -T option to choose a generator toolset 118c32f Merge branch 'xcode-duplicate-flags-13354' into generator-toolset cf8645e Tests: Run ctest custom commands with VERBATIM 5b2fba5 ExternalProject: Simplify CMake command line generation
Diffstat (limited to 'Source')
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx24
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.h1
-rw-r--r--Source/CTest/cmCTestConfigureCommand.cxx9
-rw-r--r--Source/cmDocumentVariables.cxx17
-rw-r--r--Source/cmGlobalGenerator.cxx14
-rw-r--r--Source/cmGlobalGenerator.h4
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx8
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h2
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx24
-rw-r--r--Source/cmGlobalXCodeGenerator.h2
-rw-r--r--Source/cmMakefile.cxx1
-rw-r--r--Source/cmake.cxx55
-rw-r--r--Source/cmake.h16
-rw-r--r--Source/ctest.cxx1
14 files changed, 174 insertions, 4 deletions
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 554efb5..4fa3c53 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -67,6 +67,12 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
generator += this->BuildGenerator;
args.push_back(generator);
}
+ if(this->BuildGeneratorToolset.size())
+ {
+ std::string toolset = "-T";
+ toolset += this->BuildGeneratorToolset;
+ args.push_back(toolset);
+ }
const char* config = 0;
if ( this->CTest->GetConfigType().size() > 0 )
@@ -229,10 +235,14 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
// should we cmake?
cmake cm;
cm.SetProgressCallback(CMakeProgressCallback, &cmakeOutString);
- cm.SetGlobalGenerator(cm.CreateGlobalGenerator(
- this->BuildGenerator.c_str()));
- if(!this->BuildNoCMake)
+ if(this->BuildNoCMake)
+ {
+ cm.SetGlobalGenerator(cm.CreateGlobalGenerator(
+ this->BuildGenerator.c_str()));
+ cm.SetGeneratorToolset(this->BuildGeneratorToolset);
+ }
+ else
{
// do the cmake step, no timeout here since it is not a sub process
if (this->RunCMake(outstring,out,cmakeOutString,cwd,&cm))
@@ -466,11 +476,17 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments(
idx++;
this->Timeout = atof(allArgs[idx].c_str());
}
- if(currentArg.find("--build-generator",0) == 0 && idx < allArgs.size() - 1)
+ if(currentArg == "--build-generator" && idx < allArgs.size() - 1)
{
idx++;
this->BuildGenerator = allArgs[idx];
}
+ if(currentArg == "--build-generator-toolset" &&
+ idx < allArgs.size() - 1)
+ {
+ idx++;
+ this->BuildGeneratorToolset = allArgs[idx];
+ }
if(currentArg.find("--build-project",0) == 0 && idx < allArgs.size() - 1)
{
idx++;
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h
index 9029600..ca50c64 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.h
+++ b/Source/CTest/cmCTestBuildAndTestHandler.h
@@ -57,6 +57,7 @@ protected:
cmStdString Output;
std::string BuildGenerator;
+ std::string BuildGeneratorToolset;
std::vector<std::string> BuildOptions;
bool BuildTwoConfig;
std::string BuildMakeProgram;
diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx
index 7a99ddf..d6d39a9 100644
--- a/Source/CTest/cmCTestConfigureCommand.cxx
+++ b/Source/CTest/cmCTestConfigureCommand.cxx
@@ -144,6 +144,15 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
cmakeConfigureCommand += cmakeGeneratorName;
cmakeConfigureCommand += "\"";
+ const char* cmakeGeneratorToolset =
+ this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_TOOLSET");
+ if(cmakeGeneratorToolset && *cmakeGeneratorToolset)
+ {
+ cmakeConfigureCommand += " \"-T";
+ cmakeConfigureCommand += cmakeGeneratorToolset;
+ cmakeConfigureCommand += "\"";
+ }
+
cmakeConfigureCommand += " \"";
cmakeConfigureCommand += source_dir;
cmakeConfigureCommand += "\"";
diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx
index 08b3ef1..9f7c0c1 100644
--- a/Source/cmDocumentVariables.cxx
+++ b/Source/cmDocumentVariables.cxx
@@ -255,6 +255,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
"CMAKE_EXTRA_GENERATOR (e.g. \"Eclipse CDT4\").",false,
"Variables that Provide Information");
cm->DefineProperty
+ ("CMAKE_GENERATOR_TOOLSET", cmProperty::VARIABLE,
+ "Native build system toolset name specified by user.",
+ "Some CMake generators support a toolset name to be given to the "
+ "native build system to choose a compiler. "
+ "If the user specifies a toolset name (e.g. via the cmake -T option) "
+ "the value will be available in this variable.",false,
+ "Variables that Provide Information");
+ cm->DefineProperty
("CMAKE_HOME_DIRECTORY", cmProperty::VARIABLE,
"Path to top of source tree.",
"This is the path to the top level of the source tree.",false,
@@ -295,6 +303,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
,false,
"Variables that Provide Information");
cm->DefineProperty
+ ("CMAKE_XCODE_PLATFORM_TOOLSET", cmProperty::VARIABLE,
+ "Xcode compiler selection.",
+ "Xcode supports selection of a compiler from one of the installed "
+ "toolsets. "
+ "CMake provides the name of the chosen toolset in this variable, "
+ "if any is explicitly selected (e.g. via the cmake -T option)."
+ ,false,
+ "Variables that Provide Information");
+ cm->DefineProperty
("CMAKE_MINOR_VERSION", cmProperty::VARIABLE,
"The Minor version of cmake (i.e. the 4 in X.4.X).",
"This specifies the minor version of the CMake"
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index f7eff21..ba29589 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -79,6 +79,20 @@ cmGlobalGenerator::~cmGlobalGenerator()
this->ClearGeneratorTargets();
}
+bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts)
+{
+ cmOStringStream e;
+ e <<
+ "Generator\n"
+ " " << this->GetName() << "\n"
+ "does not support toolset specification, but toolset\n"
+ " " << ts << "\n"
+ "was specified.";
+ this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
+ cmListFileBacktrace());
+ return false;
+}
+
void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
cmMakefile *mf,
bool optional)
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index bb805d9..f8275e8 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -49,6 +49,10 @@ public:
///! Get the name for this generator
virtual const char *GetName() const { return "Generic"; };
+ /** Set the generator-specific toolset name. Returns true if toolset
+ is supported and false otherwise. */
+ virtual bool SetGeneratorToolset(std::string const& ts);
+
/**
* Create LocalGenerators and process the CMakeLists files. This does not
* actually produce any makefiles, DSPs, etc.
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index d992036..cac72fc 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -80,6 +80,14 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
}
//----------------------------------------------------------------------------
+bool
+cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts)
+{
+ this->PlatformToolset = ts;
+ return true;
+}
+
+//----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf)
{
cmGlobalVisualStudio8Generator::AddPlatformDefinitions(mf);
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index b377a20..5926e0f 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -28,6 +28,8 @@ public:
const char* architectureId, const char* additionalPlatformDefinition);
static cmGlobalGeneratorFactory* NewFactory();
+ virtual bool SetGeneratorToolset(std::string const& ts);
+
virtual std::string
GenerateBuildCommand(const char* makeProgram,
const char *projectName,
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index abe60c6..9600771 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -201,6 +201,20 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
}
//----------------------------------------------------------------------------
+bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts)
+{
+ if(this->XcodeVersion >= 30)
+ {
+ this->PlatformToolset = ts;
+ return true;
+ }
+ else
+ {
+ return cmGlobalGenerator::SetGeneratorToolset(ts);
+ }
+}
+
+//----------------------------------------------------------------------------
void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const&
lang,
cmMakefile * mf, bool optional)
@@ -226,6 +240,11 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const&
mf->AddDefinition("CMAKE_GENERATOR_CC", "gcc");
mf->AddDefinition("CMAKE_GENERATOR_CXX", "g++");
mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
+ if(!this->PlatformToolset.empty())
+ {
+ mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET",
+ this->PlatformToolset.c_str());
+ }
this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
const char* osxArch =
mf->GetDefinition("CMAKE_OSX_ARCHITECTURES");
@@ -3163,6 +3182,11 @@ void cmGlobalXCodeGenerator
buildSettings->AddAttribute("MACOSX_DEPLOYMENT_TARGET",
this->CreateString(deploymentTarget));
}
+ if(!this->PlatformToolset.empty())
+ {
+ buildSettings->AddAttribute("GCC_VERSION",
+ this->CreateString(this->PlatformToolset.c_str()));
+ }
// Put this last so it can override existing settings
// Convert "CMAKE_XCODE_ATTRIBUTE_*" variables directly.
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index c98652f..131a6e6 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -83,6 +83,7 @@ public:
i.e. "Can I build Debug and Release in the same tree?" */
virtual bool IsMultiConfig();
+ virtual bool SetGeneratorToolset(std::string const& ts);
private:
cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget,
cmSourceGroup* sg);
@@ -236,6 +237,7 @@ private:
std::map<cmStdString, cmXCodeObject* > TargetGroup;
std::map<cmStdString, cmXCodeObject* > FileRefs;
std::vector<std::string> Architectures;
+ std::string PlatformToolset;
};
#endif
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index e7a1500..dbd0c36 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2990,6 +2990,7 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
cm.SetStartDirectory(srcdir);
cm.SetStartOutputDirectory(bindir);
cm.SetCMakeCommand(cmakeCommand.c_str());
+ cm.SetGeneratorToolset(this->GetCMakeInstance()->GetGeneratorToolset());
cm.LoadCache();
if(!gg->IsMultiConfig())
{
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 932c996..d57e981 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -659,6 +659,7 @@ void cmake::SetArgs(const std::vector<std::string>& args,
bool directoriesSetBefore)
{
bool directoriesSet = directoriesSetBefore;
+ bool haveToolset = false;
for(unsigned int i=1; i < args.size(); ++i)
{
std::string arg = args[i];
@@ -787,6 +788,27 @@ void cmake::SetArgs(const std::vector<std::string>& args,
"uninitialized variables.\n";
this->SetCheckSystemVars(true);
}
+ else if(arg.find("-T",0) == 0)
+ {
+ std::string value = arg.substr(2);
+ if(value.size() == 0)
+ {
+ ++i;
+ if(i >= args.size())
+ {
+ cmSystemTools::Error("No toolset specified for -T");
+ return;
+ }
+ value = args[i];
+ }
+ if(haveToolset)
+ {
+ cmSystemTools::Error("Multiple -T options not allowed");
+ return;
+ }
+ this->GeneratorToolset = value;
+ haveToolset = true;
+ }
else if(arg.find("-G",0) == 0)
{
std::string value = arg.substr(2);
@@ -2282,6 +2304,39 @@ int cmake::ActualConfigure()
cmCacheManager::INTERNAL);
}
+ if(const char* tsName =
+ this->CacheManager->GetCacheValue("CMAKE_GENERATOR_TOOLSET"))
+ {
+ if(this->GeneratorToolset.empty())
+ {
+ this->GeneratorToolset = tsName;
+ }
+ else if(this->GeneratorToolset != tsName)
+ {
+ std::string message = "Error: generator toolset: ";
+ message += this->GeneratorToolset;
+ message += "\nDoes not match the toolset used previously: ";
+ message += tsName;
+ message +=
+ "\nEither remove the CMakeCache.txt file or choose a different"
+ " binary directory.";
+ cmSystemTools::Error(message.c_str());
+ return -2;
+ }
+ }
+ else
+ {
+ this->CacheManager->AddCacheEntry("CMAKE_GENERATOR_TOOLSET",
+ this->GeneratorToolset.c_str(),
+ "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
// info to save time
diff --git a/Source/cmake.h b/Source/cmake.h
index f6fe0d6..63065a1 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -187,6 +187,14 @@ class cmake
///! Get the names of the current registered generators
void GetRegisteredGenerators(std::vector<std::string>& names);
+ ///! 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; }
+
///! get the cmCachemManager used by this invocation of cmake
cmCacheManager *GetCacheManager() { return this->CacheManager; }
@@ -418,6 +426,7 @@ protected:
std::string StartOutputDirectory;
bool SuppressDevWarnings;
bool DoSuppressDevWarnings;
+ std::string GeneratorToolset;
///! read in a cmake list file to initialize the cache
void ReadListFile(const std::vector<std::string>& args, const char *path);
@@ -528,6 +537,13 @@ private:
"A makefile generator is responsible for generating a particular build " \
"system. Possible generator names are specified in the Generators " \
"section."},\
+ {"-T <toolset-name>", "Specify toolset name if supported by generator.", \
+ "Some CMake generators support a toolset name to be given to the " \
+ "native build system to choose a compiler. " \
+ "This is supported only on specific generators:\n" \
+ " Visual Studio >= 10\n" \
+ " Xcode >= 3.0\n" \
+ "See native build system documentation for allowed toolset names."}, \
{"-Wno-dev", "Suppress developer warnings.",\
"Suppress warnings that are meant for the author"\
" of the CMakeLists.txt files."},\
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index 8de901a..3e63183 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -187,6 +187,7 @@ static const char * cmDocumentationOptions[][3] =
{"--build-two-config", "Run CMake twice", "" },
{"--build-exe-dir", "Specify the directory for the executable.", "" },
{"--build-generator", "Specify the generator to use.", "" },
+ {"--build-generator-toolset", "Specify the generator-specific toolset.",""},
{"--build-project", "Specify the name of the project to build.", "" },
{"--build-makeprogram", "Specify the make program to use.", "" },
{"--build-noclean", "Skip the make clean step.", "" },