mirror of
https://github.com/reactos/CMake.git
synced 2025-02-07 20:38:49 +00:00
export: Restore support for empty TARGETS list
Refactoring in commit f5acecaa6f (cmExportCommand: Port to cmArgumentParser, 2019-03-23, v3.15.0-rc1~270^2~3) broke the `export` command's support for specifying `TARGETS` with no entries. Fix it and add a test case. Fixes: #19415
This commit is contained in:
parent
5c7880956f
commit
2ba5c37b3f
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include "cm_static_string_view.hxx"
|
#include "cm_static_string_view.hxx"
|
||||||
#include "cmsys/RegularExpression.hxx"
|
#include "cmsys/RegularExpression.hxx"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -66,7 +68,9 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> unknownArgs;
|
std::vector<std::string> unknownArgs;
|
||||||
Arguments const arguments = parser.Parse(args, &unknownArgs);
|
std::vector<std::string> keywordsMissingValue;
|
||||||
|
Arguments const arguments =
|
||||||
|
parser.Parse(args, &unknownArgs, &keywordsMissingValue);
|
||||||
|
|
||||||
if (!unknownArgs.empty()) {
|
if (!unknownArgs.empty()) {
|
||||||
this->SetError("Unknown argument: \"" + unknownArgs.front() + "\".");
|
this->SetError("Unknown argument: \"" + unknownArgs.front() + "\".");
|
||||||
@ -128,7 +132,10 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ExportSet = it->second;
|
ExportSet = it->second;
|
||||||
} else if (!arguments.Targets.empty()) {
|
} else if (!arguments.Targets.empty() ||
|
||||||
|
std::find(keywordsMissingValue.begin(),
|
||||||
|
keywordsMissingValue.end(),
|
||||||
|
"TARGETS") != keywordsMissingValue.end()) {
|
||||||
for (std::string const& currentTarget : arguments.Targets) {
|
for (std::string const& currentTarget : arguments.Targets) {
|
||||||
if (this->Makefile->IsAlias(currentTarget)) {
|
if (this->Makefile->IsAlias(currentTarget)) {
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
|
1
Tests/RunCMake/export/Empty.cmake
Normal file
1
Tests/RunCMake/export/Empty.cmake
Normal file
@ -0,0 +1 @@
|
|||||||
|
export(TARGETS FILE targets.cmake)
|
@ -1,6 +1,7 @@
|
|||||||
include(RunCMake)
|
include(RunCMake)
|
||||||
|
|
||||||
run_cmake(CustomTarget)
|
run_cmake(CustomTarget)
|
||||||
|
run_cmake(Empty)
|
||||||
run_cmake(TargetNotFound)
|
run_cmake(TargetNotFound)
|
||||||
run_cmake(AppendExport)
|
run_cmake(AppendExport)
|
||||||
run_cmake(OldIface)
|
run_cmake(OldIface)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user