summaryrefslogtreecommitdiffstats
path: root/Source/cmExportCommand.cxx
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2020-03-20 14:21:32 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2020-03-26 12:20:45 (GMT)
commit0cd20e8f62328b6e3ae750dc253473cf00e05adb (patch)
treeaafff71c6dbaab8a05a0ab84459117142b557b18 /Source/cmExportCommand.cxx
parent66e0b312c0985493adeeda63d1dc7815cc0fe364 (diff)
downloadCMake-0cd20e8f62328b6e3ae750dc253473cf00e05adb.zip
CMake-0cd20e8f62328b6e3ae750dc253473cf00e05adb.tar.gz
CMake-0cd20e8f62328b6e3ae750dc253473cf00e05adb.tar.bz2
export(): raise an error on multiple calls with same FILE
Fixes: 20472
Diffstat (limited to 'Source/cmExportCommand.cxx')
-rw-r--r--Source/cmExportCommand.cxx23
1 files changed, 23 insertions, 0 deletions
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index e49c174..f31759d 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -24,6 +24,7 @@
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
@@ -183,6 +184,28 @@ bool cmExportCommand(std::vector<std::string> const& args,
return false;
}
+ // if cmExportBuildFileGenerator is already defined for the file
+ // and APPEND is not specified, if CMP0103 is OLD ignore previous definition
+ // else raise an error
+ if (gg->GetExportedTargetsFile(fname) != nullptr) {
+ switch (mf.GetPolicyStatus(cmPolicies::CMP0103)) {
+ case cmPolicies::WARN:
+ mf.IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0103), '\n',
+ "export() command already specified for the file\n ",
+ arguments.Filename, "\nDid you miss 'APPEND' keyword?"));
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ break;
+ default:
+ status.SetError(cmStrCat("command already specified for the file\n ",
+ arguments.Filename,
+ "\nDid you miss 'APPEND' keyword?"));
+ return false;
+ }
+ }
+
// Setup export file generation.
std::unique_ptr<cmExportBuildFileGenerator> ebfg = nullptr;
if (android) {