diff options
author | Brad King <brad.king@kitware.com> | 2008-02-11 18:35:39 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-02-11 18:35:39 (GMT) |
commit | ac0e58dcfbf17dec84b7bd848f6df0175f7d516b (patch) | |
tree | fd1cbb7b8fb4d6cec4fa467ea1e174b2b8535146 /Source/cmAddExecutableCommand.cxx | |
parent | 739a463539946323b09e4c22f5fdd38395add1e1 (diff) | |
download | CMake-ac0e58dcfbf17dec84b7bd848f6df0175f7d516b.zip CMake-ac0e58dcfbf17dec84b7bd848f6df0175f7d516b.tar.gz CMake-ac0e58dcfbf17dec84b7bd848f6df0175f7d516b.tar.bz2 |
ENH: Enforce global target name uniqueness.
- Error if imported target is involved in conflict
- Error for non-imported target conflict unless
CMAKE_BACKWARDS_COMPATIBILITY <= 2.4
- Include OUTPUT_NAME property in error message
- Update add_executable and add_library command documentation
Diffstat (limited to 'Source/cmAddExecutableCommand.cxx')
-rw-r--r-- | Source/cmAddExecutableCommand.cxx | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index cea12bc..7445069 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -82,12 +82,11 @@ bool cmAddExecutableCommand return false; } - // Check for an existing target with this name. - cmTarget* existing = this->Makefile->FindTargetToUse(exename.c_str()); + // Handle imported target creation. if(importTarget) { // Make sure the target does not already exist. - if(existing) + if(this->Makefile->FindTargetToUse(exename.c_str())) { cmOStringStream e; e << "cannot create imported target \"" << exename @@ -100,20 +99,13 @@ bool cmAddExecutableCommand this->Makefile->AddImportedTarget(exename.c_str(), cmTarget::EXECUTABLE); return true; } - else + + // Enforce name uniqueness. + std::string msg; + if(!this->Makefile->EnforceUniqueName(exename, msg)) { - // Make sure the target does not conflict with an imported target. - // This should really enforce global name uniqueness for targets - // built within the project too, but that may break compatiblity - // with projects in which it was accidentally working. - if(existing && existing->IsImported()) - { - cmOStringStream e; - e << "cannot create target \"" << exename - << "\" because an imported target with the same name already exists."; - this->SetError(e.str().c_str()); - return false; - } + this->SetError(msg.c_str()); + return false; } if (s == args.end()) |