diff options
author | Brad King <brad.king@kitware.com> | 2016-01-28 15:12:26 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-01-28 15:33:26 (GMT) |
commit | d257d68138a00758910bbca3dd77dcfcc04e65cc (patch) | |
tree | 9c0eff84d7fc1268f7f57f656a3f6e7b835b78d2 /Source/cmMakefile.cxx | |
parent | 4d53e0a75e3ccddf14f556e88302573f14aa8830 (diff) | |
download | CMake-d257d68138a00758910bbca3dd77dcfcc04e65cc.zip CMake-d257d68138a00758910bbca3dd77dcfcc04e65cc.tar.gz CMake-d257d68138a00758910bbca3dd77dcfcc04e65cc.tar.bz2 |
add_custom_command: Clarify error when TARGET is out of scope (#15681)
The add_custom_command(TARGET) signature only works for targets defined
in the current directory. Clarify this in the error message when the
target exists but was defined elsewhere.
Inspired-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ba0d672..cba29eb 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -791,7 +791,24 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target, if(issueMessage) { - e << "The target name \"" << target << "\" is unknown in this context."; + if (cmTarget const* t = this->FindTargetToUse(target)) + { + if (t->IsImported()) + { + e << "TARGET '" << target + << "' is IMPORTED and does not build here."; + } + else + { + e << "TARGET '" << target + << "' was not created in this directory."; + } + } + else + { + e << "No TARGET '" << target + << "' has been created in this directory."; + } IssueMessage(messageType, e.str()); } |