diff options
author | Robert Maynard <rmaynard@nvidia.com> | 2021-05-12 13:44:39 (GMT) |
---|---|---|
committer | Robert Maynard <rmaynard@nvidia.com> | 2021-05-13 13:28:42 (GMT) |
commit | 5aa0dec6b011c74225f4af895922edd10db09607 (patch) | |
tree | f62e76730298284c05247c0ab985a90cf1eaf14f /Source/cmakemain.cxx | |
parent | 928cdb17c53f2fc5e57d658f297ec735ab8cb81d (diff) | |
download | CMake-5aa0dec6b011c74225f4af895922edd10db09607.zip CMake-5aa0dec6b011c74225f4af895922edd10db09607.tar.gz CMake-5aa0dec6b011c74225f4af895922edd10db09607.tar.bz2 |
cmake: `--build` and `--install` error out when encountering bad flags
Fixes #22186
Diffstat (limited to 'Source/cmakemain.cxx')
-rw-r--r-- | Source/cmakemain.cxx | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 88ba011..ad64818 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -532,11 +532,22 @@ int do_build(int ac, char const* const* av) for (; i < inputArgs.size() && !nativeOptionsPassed; ++i) { std::string const& arg = inputArgs[i]; + bool matched = false; + bool parsed = false; for (auto const& m : arguments) { - if (m.matches(arg) && m.parse(arg, i, inputArgs)) { + matched = m.matches(arg); + if (matched) { + parsed = m.parse(arg, i, inputArgs); break; } } + if (!(matched && parsed)) { + dir.clear(); + if (!matched) { + std::cerr << "Unknown argument " << arg << std::endl; + } + break; + } } if (nativeOptionsPassed) { @@ -806,11 +817,22 @@ int do_install(int ac, char const* const* av) for (decltype(inputArgs.size()) i = 0; i < inputArgs.size(); ++i) { std::string const& arg = inputArgs[i]; + bool matched = false; + bool parsed = false; for (auto const& m : arguments) { - if (m.matches(arg) && m.parse(arg, i, inputArgs)) { + matched = m.matches(arg); + if (matched) { + parsed = m.parse(arg, i, inputArgs); break; } } + if (!(matched && parsed)) { + dir.clear(); + if (!matched) { + std::cerr << "Unknown argument " << arg << std::endl; + } + break; + } } } |