diff options
author | Brad King <brad.king@kitware.com> | 2008-08-06 21:48:53 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-08-06 21:48:53 (GMT) |
commit | d76b20bf3ae9b045fc3c17f8d5e33fccd997b175 (patch) | |
tree | 745768d27e4635a946234eec29cc72cce255d678 /Source/cmComputeTargetDepends.cxx | |
parent | 37a009b7f704e26e2a76485d74c3ee5612f208d7 (diff) | |
download | CMake-d76b20bf3ae9b045fc3c17f8d5e33fccd997b175.zip CMake-d76b20bf3ae9b045fc3c17f8d5e33fccd997b175.tar.gz CMake-d76b20bf3ae9b045fc3c17f8d5e33fccd997b175.tar.bz2 |
BUG: Avoid bogus dependency on executable targets
When an executable target within the project is named in
target_link_libraries for another target, but the executable does not
have the ENABLE_EXPORTS property set, then the executable cannot really
be linked. This is probably a case where the user intends to link to a
third-party library that happens to have the same name as an executable
target in the project (or else will get an error at build time). We
need to avoid making the other target depend on the executable target
incorrectly, since the executable may actually want to link to that
target and this is not a circular depenency.
Diffstat (limited to 'Source/cmComputeTargetDepends.cxx')
-rw-r--r-- | Source/cmComputeTargetDepends.cxx | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 19d99da..7a6e81f 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -214,7 +214,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // Don't emit the same library twice for this target. if(emitted.insert(lib->first).second) { - this->AddTargetDepend(depender_index, lib->first.c_str()); + this->AddTargetDepend(depender_index, lib->first.c_str(), true); } } @@ -226,14 +226,15 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // Don't emit the same utility twice for this target. if(emitted.insert(*util).second) { - this->AddTargetDepend(depender_index, util->c_str()); + this->AddTargetDepend(depender_index, util->c_str(), false); } } } //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddTargetDepend(int depender_index, - const char* dependee_name) + const char* dependee_name, + bool linking) { // Get the depender. cmTarget* depender = this->Targets[depender_index]; @@ -248,6 +249,16 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, dependee = this->GlobalGenerator->FindTarget(0, dependee_name); } + // Skip targets that will not really be linked. This is probably a + // name conflict between an external library and an executable + // within the project. + if(linking && dependee && + dependee->GetType() == cmTarget::EXECUTABLE && + !dependee->IsExecutableWithExports()) + { + dependee = 0; + } + // If not found then skip then the dependee. if(!dependee) { |