mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-23 22:58:37 -05:00
Merge topic 'export-error-on-multuple-calls'
0cd20e8f62 export(): raise an error on multiple calls with same FILE
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4510
This commit is contained in:
@@ -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) {
|
||||
|
||||
+4
-1
@@ -305,7 +305,10 @@ class cmMakefile;
|
||||
17, 0, cmPolicies::WARN) \
|
||||
SELECT(POLICY, CMP0102, \
|
||||
"mark_as_advanced() does nothing if a cache entry does not exist.", \
|
||||
3, 17, 0, cmPolicies::WARN)
|
||||
3, 17, 0, cmPolicies::WARN) \
|
||||
SELECT(POLICY, CMP0103, \
|
||||
"multiple export() with same FILE without APPEND is not allowed.", \
|
||||
3, 18, 0, cmPolicies::WARN)
|
||||
|
||||
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
|
||||
#define CM_FOR_EACH_POLICY_ID(POLICY) \
|
||||
|
||||
Reference in New Issue
Block a user