diff options
35 files changed, 271 insertions, 11 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 609f35b..b918092 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -177,6 +177,11 @@ Id flags: ${testflags} set(id_type ${CMAKE_${lang}_COMPILER_XCODE_TYPE}) set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR}) get_filename_component(id_src "${src}" NAME) + if(CMAKE_XCODE_PLATFORM_TOOLSET) + set(id_toolset "GCC_VERSION = ${CMAKE_XCODE_PLATFORM_TOOLSET};") + else() + set(id_toolset "") + endif() if(NOT ${XCODE_VERSION} VERSION_LESS 3) set(v 3) set(ext xcodeproj) diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in index 41ca7db..d94a803 100644 --- a/Modules/CompilerId/Xcode-3.pbxproj.in +++ b/Modules/CompilerId/Xcode-3.pbxproj.in @@ -83,6 +83,7 @@ ONLY_ACTIVE_ARCH = YES; CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)"; SYMROOT = .; + @id_toolset@ }; name = Debug; }; diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index ed7fd7c..bf2892b 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -38,6 +38,7 @@ # [CONFIGURE_COMMAND cmd...] # Build tree configuration command # [CMAKE_COMMAND /.../cmake] # Specify alternative cmake executable # [CMAKE_GENERATOR gen] # Specify generator for native build +# [CMAKE_GENERATOR_TOOLSET t] # Generator-specific toolset name # [CMAKE_ARGS args...] # Arguments to CMake command line # [CMAKE_CACHE_ARGS args...] # Initial cache arguments, of the form -Dvar:string=on # #--Build step----------------- @@ -1588,16 +1589,27 @@ function(_ep_add_configure_command name) endif() get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR) + get_target_property(cmake_generator_toolset ${name} _EP_CMAKE_GENERATOR_TOOLSET) if(cmake_generator) - list(APPEND cmd "-G${cmake_generator}" "${source_dir}") + list(APPEND cmd "-G${cmake_generator}") + if(cmake_generator_toolset) + list(APPEND cmd "-T${cmake_generator_toolset}") + endif() else() if(CMAKE_EXTRA_GENERATOR) - list(APPEND cmd "-G${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}" - "${source_dir}") + list(APPEND cmd "-G${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}") else() - list(APPEND cmd "-G${CMAKE_GENERATOR}" "${source_dir}") + list(APPEND cmd "-G${CMAKE_GENERATOR}") + endif() + if(cmake_generator_toolset) + message(FATAL_ERROR "Option CMAKE_GENERATOR_TOOLSET not allowed without CMAKE_GENERATOR.") + endif() + if(CMAKE_GENERATOR_TOOLSET) + list(APPEND cmd "-T${CMAKE_GENERATOR_TOOLSET}") endif() endif() + + list(APPEND cmd "${source_dir}") endif() # If anything about the configure command changes, (command itself, cmake 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 d650777..5913914 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.", "" }, diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt index d6593e8..cb2aebd 100644 --- a/Tests/ExportImport/CMakeLists.txt +++ b/Tests/ExportImport/CMakeLists.txt @@ -43,7 +43,8 @@ add_custom_command( --build-generator ${CMAKE_GENERATOR} --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-options -C${ExportImport_BINARY_DIR}/InitialCache.cmake - ) + VERBATIM + ) add_custom_target(ExportTarget ALL DEPENDS ${ExportImport_BINARY_DIR}/ExportProject) add_dependencies(ExportTarget CleanupTarget) set_property( @@ -63,7 +64,8 @@ add_custom_command( --build-generator ${CMAKE_GENERATOR} --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-options -C${ExportImport_BINARY_DIR}/InitialCache.cmake - ) + VERBATIM + ) add_custom_target(ImportTarget ALL DEPENDS ${ExportImport_BINARY_DIR}/ImportProject) add_dependencies(ImportTarget ExportTarget) set_property( diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 6e78f42..fdfe525 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -205,7 +205,8 @@ if(TEST_MODULE_DEPENDS) -DCMAKE_Fortran_FLAGS_MINSIZEREL:STRING=${CMAKE_Fortran_FLAGS_MINSIZEREL} -DCMAKE_Fortran_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} ${External_BUILD_TYPE} - ) + VERBATIM + ) add_custom_target(ExternalTarget ALL DEPENDS ${testf_BINARY_DIR}/ExternalProject) # Test module output directory if available. diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index e55cf69..dd150a8 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -41,13 +41,19 @@ macro(add_RunCMake_test test) -DRunCMake_GENERATOR=${CMAKE_TEST_GENERATOR} -DRunCMake_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${test} -DRunCMake_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/${test} + ${${test}_ARGS} -P "${CMAKE_CURRENT_SOURCE_DIR}/${test}/RunCMakeTest.cmake" ) endmacro() +if(XCODE_VERSION AND "${XCODE_VERSION}" VERSION_LESS 3) + set(GeneratorToolset_ARGS -DXCODE_BELOW_3=1) +endif() + add_RunCMake_test(CMP0019) add_RunCMake_test(ExternalData) add_RunCMake_test(GeneratorExpression) +add_RunCMake_test(GeneratorToolset) add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) add_RunCMake_test(ObjectLibrary) diff --git a/Tests/RunCMake/GeneratorToolset/BadToolset-result.txt b/Tests/RunCMake/GeneratorToolset/BadToolset-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolset-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/BadToolset-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolset-stderr.txt new file mode 100644 index 0000000..bf1f190 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolset-stderr.txt @@ -0,0 +1,10 @@ +CMake Error: + Generator + + .* + + does not support toolset specification, but toolset + + Bad Toolset + + was specified.$ diff --git a/Tests/RunCMake/GeneratorToolset/BadToolset.cmake b/Tests/RunCMake/GeneratorToolset/BadToolset.cmake new file mode 100644 index 0000000..2fc38e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolset.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorToolset/CMakeLists.txt b/Tests/RunCMake/GeneratorToolset/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/GeneratorToolset/NoToolset-result.txt b/Tests/RunCMake/GeneratorToolset/NoToolset-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/NoToolset-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/NoToolset-stderr.txt b/Tests/RunCMake/GeneratorToolset/NoToolset-stderr.txt new file mode 100644 index 0000000..bc6f741 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/NoToolset-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at NoToolset.cmake:2 \(message\): + CMAKE_GENERATOR_TOOLSET is empty as expected. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorToolset/NoToolset.cmake b/Tests/RunCMake/GeneratorToolset/NoToolset.cmake new file mode 100644 index 0000000..f1f1ecd --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/NoToolset.cmake @@ -0,0 +1,7 @@ +if("x${CMAKE_GENERATOR_TOOLSET}" STREQUAL "x") + message(FATAL_ERROR "CMAKE_GENERATOR_TOOLSET is empty as expected.") +else() + message(FATAL_ERROR + "CMAKE_GENERATOR_TOOLSET is \"${CMAKE_GENERATOR_TOOLSET}\" " + "but should be empty!") +endif() diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake new file mode 100644 index 0000000..007280a --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake @@ -0,0 +1,17 @@ +include(RunCMake) + +run_cmake(NoToolset) + +if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[01]|Xcode" AND NOT XCODE_BELOW_3) + set(RunCMake_TEST_OPTIONS -T "Test Toolset") + run_cmake(TestToolset) + unset(RunCMake_TEST_OPTIONS) +else() + set(RunCMake_TEST_OPTIONS -T "Bad Toolset") + run_cmake(BadToolset) + unset(RunCMake_TEST_OPTIONS) +endif() + +set(RunCMake_TEST_OPTIONS -T "Toolset 1" "-TToolset 2") +run_cmake(TwoToolsets) +unset(RunCMake_TEST_OPTIONS) diff --git a/Tests/RunCMake/GeneratorToolset/TestToolset-result.txt b/Tests/RunCMake/GeneratorToolset/TestToolset-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolset-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/TestToolset-stderr.txt b/Tests/RunCMake/GeneratorToolset/TestToolset-stderr.txt new file mode 100644 index 0000000..d5726af --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolset-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at TestToolset.cmake:2 \(message\): + CMAKE_GENERATOR_TOOLSET is "Test Toolset" as expected. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorToolset/TestToolset.cmake b/Tests/RunCMake/GeneratorToolset/TestToolset.cmake new file mode 100644 index 0000000..6f83bef --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolset.cmake @@ -0,0 +1,7 @@ +if("x${CMAKE_GENERATOR_TOOLSET}" STREQUAL "xTest Toolset") + message(FATAL_ERROR "CMAKE_GENERATOR_TOOLSET is \"Test Toolset\" as expected.") +else() + message(FATAL_ERROR + "CMAKE_GENERATOR_TOOLSET is \"${CMAKE_GENERATOR_TOOLSET}\" " + "but should be \"Test Toolset\"!") +endif() diff --git a/Tests/RunCMake/GeneratorToolset/TwoToolsets-result.txt b/Tests/RunCMake/GeneratorToolset/TwoToolsets-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TwoToolsets-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/TwoToolsets-stderr.txt b/Tests/RunCMake/GeneratorToolset/TwoToolsets-stderr.txt new file mode 100644 index 0000000..9fa817f --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TwoToolsets-stderr.txt @@ -0,0 +1 @@ +CMake Error: Multiple -T options not allowed diff --git a/Tests/RunCMake/GeneratorToolset/TwoToolsets.cmake b/Tests/RunCMake/GeneratorToolset/TwoToolsets.cmake new file mode 100644 index 0000000..2fc38e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TwoToolsets.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index c3c161a..a43fee0 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -29,9 +29,13 @@ function(run_cmake test) set(RunCMake_TEST_BINARY_DIR "${top_bin}/${test}-build") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + if(NOT DEFINED RunCMake_TEST_OPTIONS) + set(RunCMake_TEST_OPTIONS "") + endif() execute_process( COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}" -G "${RunCMake_GENERATOR}" -DRunCMake_TEST=${test} + ${RunCMake_TEST_OPTIONS} WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" OUTPUT_VARIABLE actual_stdout ERROR_VARIABLE actual_stderr |