diff options
author | Brad King <brad.king@kitware.com> | 2021-04-28 16:51:05 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-05-05 14:55:55 (GMT) |
commit | 8a4f536be664c0ef6d79c2bf7fd547355ae59c81 (patch) | |
tree | e0d93e27c6dcd6ff6ac114d6ee8d6837e976592b /Source | |
parent | 49c6d0f26199c252b493ed5f816dbcb2e9701112 (diff) | |
download | CMake-8a4f536be664c0ef6d79c2bf7fd547355ae59c81.zip CMake-8a4f536be664c0ef6d79c2bf7fd547355ae59c81.tar.gz CMake-8a4f536be664c0ef6d79c2bf7fd547355ae59c81.tar.bz2 |
NMake: Detect nmake version
Run `nmake -?` and extract the version from its output.
Use a timeout because Watcom tools come with a `nmake` tool
that always waits for user input on `-?`.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalNMakeMakefileGenerator.cxx | 34 | ||||
-rw-r--r-- | Source/cmGlobalNMakeMakefileGenerator.h | 3 |
2 files changed, 37 insertions, 0 deletions
diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index 36f583f..cbcd4b3 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -2,7 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGlobalNMakeMakefileGenerator.h" +#include "cmsys/RegularExpression.hxx" + #include "cmDocumentationEntry.h" +#include "cmDuration.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmState.h" @@ -34,6 +37,37 @@ void cmGlobalNMakeMakefileGenerator::EnableLanguage( this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } +bool cmGlobalNMakeMakefileGenerator::FindMakeProgram(cmMakefile* mf) +{ + if (!this->cmGlobalGenerator::FindMakeProgram(mf)) { + return false; + } + if (cmProp nmakeCommand = mf->GetDefinition("CMAKE_MAKE_PROGRAM")) { + std::vector<std::string> command; + command.emplace_back(*nmakeCommand); + command.emplace_back("-?"); + std::string out; + std::string err; + if (!cmSystemTools::RunSingleCommand(command, &out, &err, nullptr, nullptr, + cmSystemTools::OUTPUT_NONE, + cmDuration(30))) { + mf->IssueMessage(MessageType::FATAL_ERROR, + cmStrCat("Running\n '", cmJoin(command, "' '"), + "'\n" + "failed with:\n ", + err)); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + cmsys::RegularExpression regex( + "Program Maintenance Utility Version ([1-9][0-9.]+)"); + if (regex.find(err)) { + this->NMakeVersion = regex.match(1); + } + } + return true; +} + void cmGlobalNMakeMakefileGenerator::GetDocumentation( cmDocumentationEntry& entry) { diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index abe64ff..c23eef8 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -55,6 +55,9 @@ protected: void PrintBuildCommandAdvice(std::ostream& os, int jobs) const override; private: + std::string NMakeVersion; + bool FindMakeProgram(cmMakefile* mf) override; + void PrintCompilerAdvice(std::ostream& os, std::string const& lang, const char* envVar) const override; }; |