diff options
32 files changed, 378 insertions, 73 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c9fec35..40653ad 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150806) +set(CMake_VERSION_PATCH 20150811) #set(CMake_VERSION_RC 1) diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 6369e17..65599e0 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -1474,7 +1474,12 @@ int cmCTestCoverageHandler::HandleLCovCoverage( << std::endl, this->Quiet); std::vector<std::string> files; - this->FindLCovFiles(files); + if (!this->FindLCovFiles(files)) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error while finding LCov files.\n"); + return 0; + } std::vector<std::string>::iterator it; if (files.empty()) @@ -1745,18 +1750,28 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files) } //---------------------------------------------------------------------------- -void cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files) +bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files) { cmsys::Glob gl; gl.RecurseOff(); // No need of recurse if -prof_dir${BUILD_DIR} flag is // used while compiling. gl.RecurseThroughSymlinksOff(); std::string prevBinaryDir; - cmSystemTools::ChangeDirectory( - this->CTest->GetCTestConfiguration("BuildDirectory")); + std::string buildDir = this->CTest->GetCTestConfiguration("BuildDirectory"); + if (cmSystemTools::ChangeDirectory(buildDir)) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error changing directory to " << buildDir << std::endl); + return false; + } // Run profmerge to merge all *.dyn files into dpi files - cmSystemTools::RunSingleCommand("profmerge"); + if (!cmSystemTools::RunSingleCommand("profmerge")) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error while running profmerge.\n"); + return false; + } prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory().c_str(); @@ -1766,10 +1781,16 @@ void cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files) daGlob += "/*.dpi"; cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " looking for dpi files in: " << daGlob << std::endl, this->Quiet); - gl.FindFiles(daGlob); + if (!gl.FindFiles(daGlob)) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error while finding files matching " << daGlob << std::endl); + return false; + } files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end()); cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Now searching in: " << daGlob << std::endl, this->Quiet); + return true; } //---------------------------------------------------------------------- diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h index 2ca123a..7102d1e 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -75,7 +75,7 @@ private: //! Handle coverage using Intel's LCov int HandleLCovCoverage(cmCTestCoverageHandlerContainer* cont); - void FindLCovFiles(std::vector<std::string>& files); + bool FindLCovFiles(std::vector<std::string>& files); //! Handle coverage using xdebug php coverage int HandlePHPCoverage(cmCTestCoverageHandlerContainer* cont); diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 49f2515..03bc83a 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1600,6 +1600,13 @@ struct TargetFilesystemArtifactResultCreator<ArtifactPdbTag> cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { + if (target->IsImported()) + { + ::reportError(context, content->GetOriginalExpression(), + "TARGET_PDB_FILE not allowed for IMPORTED targets."); + return std::string(); + } + std::string language = target->GetLinkerLanguage(context->Config); std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index aed2c07..76bc426 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1248,6 +1248,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, UNORDERED_SET<std::string> languages; cmTarget::LinkImplementation const* impl = this->Target->GetLinkImplementation(config); + assert(impl); for(std::vector<std::string>::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) { diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index 67f9f2d..13a9afb 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -24,7 +24,7 @@ bool cmGetFilenameComponentCommand // Check and see if the value has been stored in the cache // already, if so use that value - if(args.size() == 4 && args[3] == "CACHE") + if(args.size() >= 4 && args[args.size() - 1] == "CACHE") { const char* cacheValue = this->Makefile->GetDefinition(args[0]); if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue)) @@ -111,7 +111,7 @@ bool cmGetFilenameComponentCommand return false; } - if(args.size() == 4 && args[3] == "CACHE") + if(args.size() >= 4 && args[args.size() - 1] == "CACHE") { if(!programArgs.empty() && !storeArgs.empty()) { diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 50e2cd9..35fe772 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2055,10 +2055,10 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmTarget const& target) const + cmGeneratorTarget* target) const { - if(target.GetType() == cmTarget::INTERFACE_LIBRARY - || target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(target->GetType() == cmTarget::INTERFACE_LIBRARY + || target->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This target is excluded from its directory. return true; @@ -2067,7 +2067,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, { // This target is included in its directory. Check whether the // directory is excluded. - return this->IsExcluded(root, target.GetMakefile()->GetLocalGenerator()); + return this->IsExcluded(root, target->GetLocalGenerator()); } } @@ -2128,15 +2128,16 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() { cmTarget const& target = t->second; + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // Consider the directory containing the target and all its // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, target); + for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); clg = clg->GetParent()) { // This local generator includes the target. std::set<cmGeneratorTarget const*>& targetSet = this->LocalGeneratorToTargetMap[clg]; - cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); targetSet.insert(gt); // Add dependencies of the included target. An excluded diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 3402fbc..c35cba2 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -374,6 +374,8 @@ protected: void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf); void SetLanguageEnabledMaps(const std::string& l, cmMakefile* mf); void FillExtensionToLanguageMap(const std::string& l, cmMakefile* mf); + virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang, + const char* envVar) const; virtual bool ComputeTargetDepends(); @@ -391,7 +393,7 @@ protected: void FillProjectMap(); void CheckLocalGenerators(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; - bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const; + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; void FillLocalGeneratorToTargetMap(); void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, @@ -462,8 +464,6 @@ private: virtual void ForceLinkerLanguages(); - virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang, - const char* envVar) const; void CheckCompilerIdCompatibility(cmMakefile* mf, std::string const& lang) const; diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx index 50e7053..3f33f91 100644 --- a/Source/cmGlobalJOMMakefileGenerator.cxx +++ b/Source/cmGlobalJOMMakefileGenerator.cxx @@ -36,18 +36,6 @@ void cmGlobalJOMMakefileGenerator // pick a default mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); - if(!(cmSystemTools::GetEnv("INCLUDE") && - cmSystemTools::GetEnv("LIB")) - ) - { - std::string message = "To use the JOM generator, cmake must be run " - "from a shell that can use the compiler cl from the command line. " - "This environment does not contain INCLUDE, LIB, or LIBPATH, and " - "these must be set for the cl compiler to work. "; - mf->IssueMessage(cmake::WARNING, - message); - } - this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } @@ -58,3 +46,19 @@ void cmGlobalJOMMakefileGenerator entry.Name = cmGlobalJOMMakefileGenerator::GetActualName(); entry.Brief = "Generates JOM makefiles."; } + +//---------------------------------------------------------------------------- +void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice(std::ostream& os, + std::string const& lang, + const char* envVar) const +{ + if(lang == "CXX" || lang == "C") + { + os << + "To use the JOM generator with Visual C++, cmake must be run from a " + "shell that can use the compiler cl from the command line. This " + "environment is unable to invoke the cl compiler. To fix this problem, " + "run cmake from the Visual Studio Command Prompt (vcvarsall.bat).\n"; + } + this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar); +} diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h index 2185b23..1869fed 100644 --- a/Source/cmGlobalJOMMakefileGenerator.h +++ b/Source/cmGlobalJOMMakefileGenerator.h @@ -42,6 +42,9 @@ public: */ virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *, bool optional); +private: + void PrintCompilerAdvice(std::ostream& os, std::string const& lang, + const char* envVar) const; }; #endif diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index 4219c34..7c570a6 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -36,18 +36,6 @@ void cmGlobalNMakeMakefileGenerator // pick a default mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); - if(!(cmSystemTools::GetEnv("INCLUDE") && - cmSystemTools::GetEnv("LIB")) - ) - { - std::string message = "To use the NMake generator, cmake must be run " - "from a shell that can use the compiler cl from the command line. " - "This environment does not contain INCLUDE, LIB, or LIBPATH, and " - "these must be set for the cl compiler to work. "; - mf->IssueMessage(cmake::WARNING, - message); - } - this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } @@ -58,3 +46,19 @@ void cmGlobalNMakeMakefileGenerator entry.Name = cmGlobalNMakeMakefileGenerator::GetActualName(); entry.Brief = "Generates NMake makefiles."; } + +//---------------------------------------------------------------------------- +void cmGlobalNMakeMakefileGenerator::PrintCompilerAdvice(std::ostream& os, + std::string const& lang, + const char* envVar) const +{ + if(lang == "CXX" || lang == "C") + { + os << + "To use the NMake generator with Visual C++, cmake must be run from a " + "shell that can use the compiler cl from the command line. This " + "environment is unable to invoke the cl compiler. To fix this problem, " + "run cmake from the Visual Studio Command Prompt (vcvarsall.bat).\n"; + } + this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar); +} diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index dd72c49..3c8375a 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -40,6 +40,9 @@ public: */ virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *, bool optional); +private: + void PrintCompilerAdvice(std::ostream& os, std::string const& lang, + const char* envVar) const; }; #endif diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 088f0e1..b92ad32 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -547,6 +547,18 @@ void cmGlobalNinjaGenerator // Source/cmake.cxx void cmGlobalNinjaGenerator::Generate() { + // Check minimum Ninja version. + if (cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, + CurrentNinjaVersion().c_str(), + RequiredNinjaVersion().c_str())) + { + std::ostringstream msg; + msg << "The detected version of Ninja (" << this->CurrentNinjaVersion(); + msg << ") is less than the version of Ninja required by CMake ("; + msg << this->RequiredNinjaVersion() << ")."; + this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, msg.str()); + return; + } this->OpenBuildFileStream(); this->OpenRulesFileStream(); @@ -1256,7 +1268,7 @@ std::string cmGlobalNinjaGenerator::ninjaCmd() const return "ninja"; } -std::string cmGlobalNinjaGenerator::ninjaVersion() const +std::string cmGlobalNinjaGenerator::CurrentNinjaVersion() const { std::string version; std::string command = ninjaCmd() + " --version"; @@ -1264,13 +1276,14 @@ std::string cmGlobalNinjaGenerator::ninjaVersion() const &version, 0, 0, 0, cmSystemTools::OUTPUT_NONE); - return version; + return cmSystemTools::TrimWhitespace(version); } bool cmGlobalNinjaGenerator::SupportsConsolePool() const { return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, - ninjaVersion().c_str(), "1.5") == false; + CurrentNinjaVersion().c_str(), + RequiredNinjaVersionForConsolePool().c_str()) == false; } void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 2a749c1..f103801 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -289,7 +289,7 @@ public: const std::vector<cmLocalGenerator*>& GetLocalGenerators() const { return LocalGenerators; } - bool IsExcluded(cmLocalGenerator* root, cmTarget& target) { + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) { return cmGlobalGenerator::IsExcluded(root, target); } int GetRuleCmdLength(const std::string& name) { @@ -299,8 +299,10 @@ public: virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; - std::string ninjaVersion() const; - + std::string CurrentNinjaVersion() const; + // Ninja generator uses 'deps' and 'msvc_deps_prefix' introduced in 1.3 + static std::string RequiredNinjaVersion() { return "1.3"; } + static std::string RequiredNinjaVersionForConsolePool() { return "1.5"; } bool SupportsConsolePool() const; protected: diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 69747a4..76d059ee 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -821,7 +821,7 @@ cmGlobalUnixMakefileGenerator3 localName, depends, commands, true); // add the all/all dependency - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); @@ -889,7 +889,7 @@ cmGlobalUnixMakefileGenerator3 "Pre-install relink rule for target.", localName, depends, commands, true); - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index b69fc65..c38a35a 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -112,17 +112,19 @@ bool cmGlobalVisualStudioGenerator::Compute() for(std::vector<cmLocalGenerator*>::iterator i = gen.begin(); i != gen.end(); ++i) { - cmTargets& targets = (*i)->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); + cmGeneratorTargetsType targets = + (*i)->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second.GetType() == cmTarget::GLOBAL_TARGET) + if (t->second->GetType() == cmTarget::GLOBAL_TARGET + || t->first->IsImported()) { continue; } if(!this->IsExcluded(gen[0], t->second)) { - allBuild->AddUtility(t->second.GetName()); + allBuild->AddUtility(t->second->GetName()); } } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 9889bd4..cfca418 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -90,7 +90,7 @@ void cmLocalNinjaGenerator::Generate() // Add the target to "all" if required. if (!this->GetGlobalNinjaGenerator()->IsExcluded( this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], - *t->second->Target)) + t->second)) this->GetGlobalNinjaGenerator()->AddDependencyToAll(t->second->Target); delete tg; } @@ -193,16 +193,14 @@ void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os) void cmLocalNinjaGenerator::WriteNinjaRequiredVersion(std::ostream& os) { // Default required version - // Ninja generator uses 'deps' and 'msvc_deps_prefix' introduced in 1.3 - std::string requiredVersion = "1.3"; + std::string requiredVersion = + this->GetGlobalNinjaGenerator()->RequiredNinjaVersion(); // Ninja generator uses the 'console' pool if available (>= 1.5) - std::string usedVersion = this->GetGlobalNinjaGenerator()->ninjaVersion(); - if(cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, - usedVersion.c_str(), - "1.5") == false) + if(this->GetGlobalNinjaGenerator()->SupportsConsolePool()) { - requiredVersion = "1.5"; + requiredVersion = + this->GetGlobalNinjaGenerator()->RequiredNinjaVersionForConsolePool(); } cmGlobalNinjaGenerator::WriteComment(os, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 27e5bce..1c4da00 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -114,10 +114,6 @@ public: bool GetIsSourceFileTryCompile() const; - ///! Get the current makefile generator. - cmLocalGenerator* GetLocalGenerator() const - { return this->LocalGenerator;} - /** * Help enforce global target name uniqueness. */ diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 71f47f3..7bee0ea 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1468,18 +1468,24 @@ bool cmcmd::RunCommand(const char* comment, std::string output; int retCode =0; // use rc command to create .res file - cmSystemTools::RunSingleCommand(command, - &output, &output, - &retCode, 0, cmSystemTools::OUTPUT_NONE); + bool res = cmSystemTools::RunSingleCommand(command, + &output, &output, + &retCode, 0, + cmSystemTools::OUTPUT_NONE); // always print the output of the command, unless // it is the dumb rc command banner, but if the command // returned an error code then print the output anyway as // the banner may be mixed with some other important information. if(output.find("Resource Compiler Version") == output.npos - || retCode !=0) + || !res || retCode) { std::cout << output; } + if (!res) + { + std::cout << comment << " failed to run." << std::endl; + return false; + } // if retCodeOut is requested then always return true // and set the retCodeOut to retCode if(retCodeOut) @@ -1593,7 +1599,10 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args, mtCommand.push_back(tempManifest); // now run mt.exe to create the final manifest file int mtRet =0; - cmcmd::RunCommand("MT", mtCommand, verbose, &mtRet); + if(!cmcmd::RunCommand("MT", mtCommand, verbose, &mtRet)) + { + return -1; + } // if mt returns 0, then the manifest was not changed and // we do not need to do another link step if(mtRet == 0) diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-JOM.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-JOM.txt new file mode 100644 index 0000000..b7db7eb --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-JOM.txt @@ -0,0 +1,17 @@ +CMake Error at BadCompilerC.cmake:2 \(enable_language\): + The CMAKE_C_COMPILER: + + no-C-compiler + + is not a full path and was not found in the PATH. + + To use the JOM generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to + the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-NMake.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-NMake.txt new file mode 100644 index 0000000..03c5933 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-NMake.txt @@ -0,0 +1,17 @@ +CMake Error at BadCompilerC.cmake:2 \(enable_language\): + The CMAKE_C_COMPILER: + + no-C-compiler + + is not a full path and was not found in the PATH. + + To use the NMake generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to + the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-JOM.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-JOM.txt new file mode 100644 index 0000000..4b42ea6 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-JOM.txt @@ -0,0 +1,17 @@ +CMake Error at BadCompilerCXX.cmake:2 \(enable_language\): + The CMAKE_CXX_COMPILER: + + no-CXX-compiler + + is not a full path and was not found in the PATH. + + To use the JOM generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path + to the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-NMake.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-NMake.txt new file mode 100644 index 0000000..1bfcdcc --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-NMake.txt @@ -0,0 +1,17 @@ +CMake Error at BadCompilerCXX.cmake:2 \(enable_language\): + The CMAKE_CXX_COMPILER: + + no-CXX-compiler + + is not a full path and was not found in the PATH. + + To use the NMake generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path + to the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-JOM.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-JOM.txt new file mode 100644 index 0000000..f25a267 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-JOM.txt @@ -0,0 +1,35 @@ +CMake Error at BadCompilerCandCXX.cmake:3 \(project\): + The CMAKE_C_COMPILER: + + no-C-compiler + + is not a full path and was not found in the PATH. + + To use the JOM generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to + the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at BadCompilerCandCXX.cmake:3 \(project\): + The CMAKE_CXX_COMPILER: + + no-CXX-compiler + + is not a full path and was not found in the PATH. + + To use the JOM generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path + to the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-NMake.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-NMake.txt new file mode 100644 index 0000000..ffcdce8 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-NMake.txt @@ -0,0 +1,35 @@ +CMake Error at BadCompilerCandCXX.cmake:3 \(project\): + The CMAKE_C_COMPILER: + + no-C-compiler + + is not a full path and was not found in the PATH. + + To use the NMake generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to + the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at BadCompilerCandCXX.cmake:3 \(project\): + The CMAKE_CXX_COMPILER: + + no-CXX-compiler + + is not a full path and was not found in the PATH. + + To use the NMake generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path + to the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake b/Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake index 8b84f39..19d149c 100644 --- a/Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake @@ -4,6 +4,20 @@ if("${RunCMake_GENERATOR}" MATCHES "Visual Studio|Xcode") run_cmake(NoCompilerC-IDE) run_cmake(NoCompilerCXX-IDE) run_cmake(NoCompilerCandCXX-IDE) +elseif(RunCMake_GENERATOR STREQUAL "NMake Makefiles") + set(RunCMake-stderr-file BadCompilerC-stderr-NMake.txt) + run_cmake(BadCompilerC) + set(RunCMake-stderr-file BadCompilerCXX-stderr-NMake.txt) + run_cmake(BadCompilerCXX) + set(RunCMake-stderr-file BadCompilerCandCXX-stderr-NMake.txt) + run_cmake(BadCompilerCandCXX) +elseif(RunCMake_GENERATOR STREQUAL "NMake Makefiles JOM") + set(RunCMake-stderr-file BadCompilerC-stderr-JOM.txt) + run_cmake(BadCompilerC) + set(RunCMake-stderr-file BadCompilerCXX-stderr-JOM.txt) + run_cmake(BadCompilerCXX) + set(RunCMake-stderr-file BadCompilerCandCXX-stderr-JOM.txt) + run_cmake(BadCompilerCandCXX) else() run_cmake(BadCompilerC) run_cmake(BadCompilerCXX) diff --git a/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-result.txt b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-stderr.txt b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-stderr.txt new file mode 100644 index 0000000..d915ecb --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at ImportedTarget-TARGET_PDB_FILE.cmake:2 \(add_custom_target\): + Error evaluating generator expression: + + \$<TARGET_PDB_FILE:empty> + + TARGET_PDB_FILE not allowed for IMPORTED targets. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE.cmake b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE.cmake new file mode 100644 index 0000000..c55c5d5 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE.cmake @@ -0,0 +1,2 @@ +add_library(empty UNKNOWN IMPORTED) +add_custom_target(custom COMMAND echo $<TARGET_PDB_FILE:empty>) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 1c8fab5..cba3941 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -26,6 +26,7 @@ run_cmake(COMPILE_LANGUAGE-add_library) run_cmake(COMPILE_LANGUAGE-add_test) run_cmake(COMPILE_LANGUAGE-unknown-lang) +run_cmake(ImportedTarget-TARGET_PDB_FILE) if(LINKER_SUPPORTS_PDB) run_cmake(NonValidTarget-TARGET_PDB_FILE) run_cmake(ValidTarget-TARGET_PDB_FILE) diff --git a/Tests/RunCMake/get_filename_component/CMakeLists.txt b/Tests/RunCMake/get_filename_component/CMakeLists.txt index 12cd3c7..74b3ff8 100644 --- a/Tests/RunCMake/get_filename_component/CMakeLists.txt +++ b/Tests/RunCMake/get_filename_component/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake index 9d7cf90..386109f 100644 --- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake +++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake @@ -1,9 +1,11 @@ +# Assertion macro macro(check desc actual expect) if(NOT "x${actual}" STREQUAL "x${expect}") message(SEND_ERROR "${desc}: got \"${actual}\", not \"${expect}\"") endif() endmacro() +# General test of all component types given an absolute path. set(filename "/path/to/filename.ext.in") set(expect_DIRECTORY "/path/to") set(expect_NAME "filename.ext.in") @@ -13,14 +15,19 @@ set(expect_PATH "/path/to") foreach(c DIRECTORY NAME EXT NAME_WE PATH) get_filename_component(actual_${c} "${filename}" ${c}) check("${c}" "${actual_${c}}" "${expect_${c}}") + list(APPEND non_cache_vars actual_${c}) endforeach() +# Test Windows paths with DIRECTORY component and an absolute Windows path. get_filename_component(test_slashes "c:\\path\\to\\filename.ext.in" DIRECTORY) check("DIRECTORY from backslashes" "${test_slashes}" "c:/path/to") +list(APPEND non_cache_vars test_slashes) get_filename_component(test_winroot "c:\\filename.ext.in" DIRECTORY) check("DIRECTORY in windows root" "${test_winroot}" "c:/") +list(APPEND non_cache_vars test_winroot) +# Test finding absolute paths. get_filename_component(test_absolute "/path/to/a/../filename.ext.in" ABSOLUTE) check("ABSOLUTE" "${test_absolute}" "/path/to/filename.ext.in") @@ -29,10 +36,80 @@ check("ABSOLUTE .. in root" "${test_absolute}" "/path/to/filename.ext.in") get_filename_component(test_absolute "c:/../path/to/filename.ext.in" ABSOLUTE) check("ABSOLUTE .. in windows root" "${test_absolute}" "c:/path/to/filename.ext.in") +list(APPEND non_cache_vars test_absolute) + +# Test the PROGRAM component type. +get_filename_component(test_program_name "/ arg1 arg2" PROGRAM) +check("PROGRAM with no args output" "${test_program_name}" "/") + +get_filename_component(test_program_name "/ arg1 arg2" PROGRAM + PROGRAM_ARGS test_program_args) +check("PROGRAM with args output: name" "${test_program_name}" "/") +check("PROGRAM with args output: args" "${test_program_args}" " arg1 arg2") + +list(APPEND non_cache_vars test_program_name) +list(APPEND non_cache_vars test_program_args) + +# Test CACHE parameter for most component types. get_filename_component(test_cache "/path/to/filename.ext.in" DIRECTORY CACHE) check("CACHE 1" "${test_cache}" "/path/to") +# Make sure that the existing CACHE entry from previous is honored: get_filename_component(test_cache "/path/to/other/filename.ext.in" DIRECTORY CACHE) check("CACHE 2" "${test_cache}" "/path/to") unset(test_cache CACHE) get_filename_component(test_cache "/path/to/other/filename.ext.in" DIRECTORY CACHE) check("CACHE 3" "${test_cache}" "/path/to/other") + +list(APPEND cache_vars test_cache) + +# Test the PROGRAM component type with CACHE specified. + +# 1. Make sure it makes a cache variable in the first place for basic usage: +get_filename_component(test_cache_program_name_1 "/ arg1 arg2" PROGRAM CACHE) +check("PROGRAM CACHE 1 with no args output" "${test_cache_program_name_1}" "/") +list(APPEND cache_vars test_cache_program_name_1) + +# 2. Set some existing cache variables & make sure the function returns them: +set(test_cache_program_name_2 DummyProgramName CACHE FILEPATH "") +get_filename_component(test_cache_program_name_2 "/ arg1 arg2" PROGRAM CACHE) +check("PROGRAM CACHE 2 with no args output" "${test_cache_program_name_2}" + "DummyProgramName") +list(APPEND cache_vars test_cache_program_name_2) + +# 3. Now test basic usage when PROGRAM_ARGS is used: +get_filename_component(test_cache_program_name_3 "/ arg1 arg2" PROGRAM + PROGRAM_ARGS test_cache_program_args_3 CACHE) +check("PROGRAM CACHE 3 name" "${test_cache_program_name_3}" "/") +check("PROGRAM CACHE 3 args" "${test_cache_program_args_3}" " arg1 arg2") +list(APPEND cache_vars test_cache_program_name_3) +list(APPEND cache_vars test_cache_program_args_3) + +# 4. Test that existing cache variables are returned when PROGRAM_ARGS is used: +set(test_cache_program_name_4 DummyPgm CACHE FILEPATH "") +set(test_cache_program_args_4 DummyArgs CACHE STRING "") +get_filename_component(test_cache_program_name_4 "/ arg1 arg2" PROGRAM + PROGRAM_ARGS test_cache_program_args_4 CACHE) +check("PROGRAM CACHE 4 name" "${test_cache_program_name_4}" "DummyPgm") +check("PROGRAM CACHE 4 args" "${test_cache_program_args_4}" "DummyArgs") +list(APPEND cache_vars test_cache_program_name_4) +list(APPEND cache_vars test_cache_program_name_4) + +# Test that ONLY the expected cache variables were created. +get_cmake_property(current_cache_vars CACHE_VARIABLES) +get_cmake_property(current_vars VARIABLES) + +foreach(thisVar ${cache_vars}) + if(NOT thisVar IN_LIST current_cache_vars) + message(SEND_ERROR "${thisVar} expected in cache but was not found.") + endif() +endforeach() + +foreach(thisVar ${non_cache_vars}) + if(thisVar IN_LIST current_cache_vars) + message(SEND_ERROR "${thisVar} unexpectedly found in cache.") + endif() + if(NOT thisVar IN_LIST current_vars) + # Catch likely typo when appending to non_cache_vars: + message(SEND_ERROR "${thisVar} not found in regular variable list.") + endif() +endforeach() |